Chasing First Queens by Integer Programming

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10848)


The n-queens puzzle is a well-known combinatorial problem that requires to place n queens on an \(n\times n\) chessboard so that no two queens can attack each other. Since the 19th century, this problem was studied by many mathematicians and computer scientists. While finding any solution to the n-queens puzzle is rather straightforward, it is very challenging to find the lexicographically first (or smallest) feasible solution. Solutions for this type are known in the literature for \(n\le 55\), while for some larger chessboards only partial solutions are known. The present paper was motivated by the question of whether Integer Linear Programming (ILP) can be used to compute solutions for some open instances. We describe alternative ILP-based solution approaches, and show that they are indeed able to compute (sometimes in unexpectedly-short computing times) many new lexicographically optimal solutions for n ranging from 56 to 115.


n-Queens problem Mixed-integer programming Lexicographic simplex 



This research was partially supported by MiUR, Italy, through project PRIN2015 “Nonlinear and Combinatorial Aspects of Complex Networks”. We thank Donald E. Knuth for having pointed out the problem to us, and for inspiring discussions on the role of Integer Linear Programming in solving combinatorial problems arising in digital tomography.


  1. 1.
    Achterberg, T.: Constraint integer programming. Ph.D. thesis, Technische Universität Berlin (2007)Google Scholar
  2. 2.
    Andreello, G., Caprara, A., Fischetti, M.: Embedding \(\{\)0, 1/2\(\}\)-cuts in a branch-and-cut framework: a computational study. INFORMS J. Comput. 19(2), 229–238 (2007)MathSciNetCrossRefGoogle Scholar
  3. 3.
    Balas, E., Fischetti, M., Zanette, A.: On the enumerative nature of Gomory’s dual cutting plane method. Math. Program. 125, 325–351 (2010)MathSciNetCrossRefGoogle Scholar
  4. 4.
    Bell, J., Stevens, B.: A survey of known results and research areas for n-Queens. Discret. Math. 309(1), 1–31 (2009)MathSciNetCrossRefGoogle Scholar
  5. 5.
    Bezzel, M.: Proposal of 8-Queens problem. Berl. Schachzeitung 3, 363 (1848)Google Scholar
  6. 6.
    Caprara, A., Fischetti, M.: \(\{0,\frac{1}{2}\}\)-Chvátal-Gomory cuts. Math. Program. 74, 221–235 (1996)zbMATHGoogle Scholar
  7. 7.
    Caprara, A., Fischetti, M.: Odd cut-sets, odd cycles, and 0–1/2 Chvatal-Gomory cuts. Ricerca Operativa 26, 51–80 (1996)Google Scholar
  8. 8.
    Foulds, L.R., Johnston, D.G.: An application of graph theory and integer programming: chessboard non-attacking puzzles. Math. Mag. 57, 95–104 (1984)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Gecode Team. Gecode: Generic constraint development environment (2017).
  10. 10.
    Gent, I.P., Jefferson, C., Nightingale, P.: Complexity of n-Queens completion. J. Artif. Intell. Res. 59, 815–848 (2017)MathSciNetzbMATHGoogle Scholar
  11. 11.
    Gomory, R.E.: Outline of an algorithm for integer solutions to linear programs. Bull. Am. Math. Soc. 64, 275–278 (1958)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Gomory, R.E.: An algorithm for the mixed integer problem. Technical report RM-2597, The RAND Cooperation (1960)Google Scholar
  13. 13.
    Grötschel, M., Lovász, L., Schrijver, A.: Geometric Algorithms and Combinatorial Optimization. Springer, Heidelberg (1988). Scholar
  14. 14.
    Hsiang, J., Frank Hsu, D., Shieh, Y.-P.: On the hardness of counting problems of complete mappings. Discret. Math. 277(1–3), 87–100 (2004)MathSciNetCrossRefGoogle Scholar
  15. 15.
    IBM. ILOG CPLEX 12.7 User’s Manual (2017)Google Scholar
  16. 16.
    Knuth, D.E.: Private communication, November 2017Google Scholar
  17. 17.
    Lionnet, F.J.E.: Question 963. Nouvelles Annales de Mathématiques 8, 560 (1869)Google Scholar
  18. 18.
    Régin, J.-C.: A filtering algorithm for constraints of difference in CSPs. In: Artificial Intelligence, vol. 1, pp. 362–367 (1994)Google Scholar
  19. 19.
    Schubert, W.: Wolfram Schubert’s N-Queens page. Accessed Dec 2017
  20. 20.
    Sloane, N.J.A.: The on-line encyclopedia of integer sequences (2017)Google Scholar
  21. 21.
    van Hoeve, W.F.: The alldifferent constraint: a survey. CoRR (2001)Google Scholar
  22. 22.
    Zanette, A., Fischetti, M., Balas, E.: Lexicography and degeneracy: can a pure cutting plane algorithm work? Math. Program. 130, 153–176 (2011)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  1. 1.Department of Information Engineering (DEI)University of PadovaPaduaItaly

Personalised recommendations