WORHP Kata of July 2023: Queens puzzle ⌚ 2023-07-01A kata (in the context of programming) is a small training unit to practise coding. In this series of WORHP Katas we present standard problems of optimization which you can use to get familiar with optimization (and our optimization software WORHP).
Kata: The queens puzzle is the problem of placing queens on an chessboard.
As an NLP, this could be formulated as follows:
- The optimization variables are the entries of a matrix
, where for
- means, there is a queen on position on the checkboard, and
- means, there is no queen on that position.
- The first set of constraints has to make sure, that in each column and in each row
- the sum of the entries is 1,
- (at least) one of the entries is 1.
- The second set of constraints has to make sure, that in each diagonal and subdiagonal
- the sum of the entries is not larger than 1.
A solution will be provided with the next WORHP Kata.
Solution of last WORHP Kata: The common approximations of the partial derivatives simplify on the given grid with spacing 1: