Gurobi Modeling Examples

Explore our modeling examples for the Gurobi Python API

3D Tic-Tac-Toe

This model solves the problem of arranging X’s and 0’s on a three-dimensional Tic-Tac-Toe board so as to minimize the number of completed lines or diagonals. It demonstrates the use of mixed integer programming to capture simple logical constraints.

This is example 17 from the fifth edition of Model Building in Mathematical Programming, by H. Paul Williams on pages 272 and 327-328.

This modeling example is at the beginning level. We assume that you have some familiarity with Python and the Gurobi Python API, but you can hopefully pick up any missing concepts from the example.

View the notebook

Google Colab Link


For details on licensing or on running the notebooks, see the overview on Modeling Examples

© Gurobi Optimization, LLC