Bite 3.5.2 · Modelling Challenges

How to model the n-queens problem using binary linear optimization

Modelling maximum non-attacking queens on a chessboard

Image by Arturo Añez · Unsplash

Chess is one of the oldest and most celebrated board games in history, with origins dating back over a thousand years. Traditionally played on an $8 \times 8$ board, chess involves strategy, tactics, and deep thinking, as each piece moves according to specific rules. Beyond the game itself, the chessboard and its pieces have inspired a variety of logic puzzles and mathematical challenges.

One of the most famous of these is the eight queens problem, which asks how to place eight queens on a standard chessboard so that no two queens threaten each other—meaning that no two queens share the same row, column, or diagonal. This puzzle has fascinated mathematicians and enthusiasts alike, as it combines combinatorial reasoning with spatial visualization.

The problem can also be generalized to place the maximum number of queens on a board of different dimensions, $m \times n$, creating a family of logic challenges with increasing complexity.

Do you dare to solve it logically for a standard chessboard $8 \times 8$ before taking on the model?


This problem can be formulated as a binary optimization model. Do you dare to try it?

Keep following the series

← Previous · 3.5.1Sudoku Modelling Challenges Next · 3.5.3 →Einstein's Riddle

How to cite

Cite this post

Martín-Campo, F. Javier (2025). How to model the n-queens problem using binary linear optimization. https://www.fjmartincampo.com/blog/2025/queens/

As a BibTeX entry:

@misc{martín-campo2025how-to-model-the-n-queens-problem-using-binary-linear-optimization,
  title   = {How to model the n-queens problem using binary linear optimization},
  author  = {Martín-Campo, F. Javier},
  year    = {2025},
  month   = {dec},
  url     = {https://www.fjmartincampo.com/blog/2025/queens/}
}

This post is published under a CC BY-NC-SA 4.0 license.