7

I was reading through the following notes regarding solving a 9x9 Sudoku via a binary integer program

https://vanderbei.princeton.edu/tex/talks/INFORMS_19/Sudoku.pdf

The formulation is straightforward but on slide 10 the author claims that if the problem has a unique integer solution then that implies the linear relaxation has the same solution and therefore the binary constraints on the variables is unnecessary.

It's really not clear to me why this would be so. Wouldn't this contradict the fact that Sudoku is known to be NP-complete?

enter image description here

Edit:

The following Sudoku has a unique solution. You can verify that by solving it by logical deduction alone.

4  7     |     3     |  6  2   
9  3     |  2     6  |  7  4   
6  2  8  |  5  7  4  |  1  9  3
-------------------------------
2  1  3  |  8  4  5  |  9  7  6
   4  9  |  3  6  7  |     1  2
7     6  |        2  |  3     4
-------------------------------
1  6  7  |  4     3  |  2     9
3     4  |  7  2     |     6  1
      2  |  6     1  |  4  3  7

I adapted the PuLP sudoku example code and the LP relaxation solves with the unique integral solution. However, I introduced auxiliary variable and constraints and changed objective function to make non integral solutions more attractive, and it found a solution where 42 of the variables had a value of 1/2.

So this counts as a counter-example that a unique BIP solution gives rise to a unique LP solution.

Ram
  • 137
  • 4
  • No, its the other way around. It means that in this specific case, the sudoku is no longer NP-hard. – Kuifje Oct 06 '22 at 10:06
  • @Kuifje Are you sure it is referring to this specific case? The last sentence on the slide is "Hence, it is always possible to solve sudoku problems as linear optimization problems" - that seems like a very general statement. – Ram Oct 06 '22 at 10:14
  • 3
    I have found Provan (2009) where they say that if the solution of the Sudoku can be found via pigeon-hole rules (i.e. enough non-empty cells are given), then the relaxation solution is integer (Theorem 2). In general, it is NP-complete by reduction to graph colouring or set covering. The claim on unique integer solutions in this talk sounds wrong (otherwise all MIPs with unique integer solutions would be easy peasy). – David Torres Oct 11 '22 at 11:15
  • Great find @David, thanks for sharing! – Ram Oct 14 '22 at 03:48

1 Answers1

2

The creators of the Sudoku puzzles ensure players that there is a unique solution to the puzzle. Hence, the system of integer linear equalities over Boolean variables described in Vanderbei's slides has one and only one solution. This is what Vanderbei calls the "unique integer solution" in slide 10.

EDIT: THE FOLLOWING ARGUMENT IS FALSE BECAUSE THE RANK OF THE MATRIX IS NOT (NECESSARILY) FULL. SORRY FOR THIS WRONG PATH. SEE THE DISCUSSION IN THE COMMENT. Now, consider a relaxation of this system of equalities over the reals. This is what Vanderbei calls "linear relaxation" in slide 10. The unique integer solution discussed above remains a solution to this relaxed system. A system of linear equalities over the reals has no solution, one solution, or an infinite number of solutions (for a proof of this claim, or at least an intuition, please check a linear algebra course on the web). Consequently, the linear relaxation has one solution which is the integer one.

In the case where the initial assertion becomes false - "the creators of the Sudoku puzzles ensure players that there is a unique solution to the puzzle" - then the property above does not hold anymore.

Then, to answer your question, the best is to cite David Eppstein, a renowned computational complexity theorist, who blogged a lot about the complexity of the Sudoku puzzle in the past:

"In the meantime, when one says Sudoku is NP-complete, one should keep in mind that this refers only to an unusual type of Sudoku puzzle in which there might be multiple solutions."

To conclude, may we recall that any KxK Sodoku puzzle with K a fixed parameter in input, that is, with K a constant, is solvable in constant time.

Hexaly
  • 2,976
  • 1
  • 11
  • 17
  • 2
    Thanks @LocalSolver. I'm still missing whatever is needed to make the conclusion that "Consequently, the linear relaxation has one solution". Why could it not be the case that we have one integer solution and infinite number of non-integer solutions to the linear relaxation? The simple BIP with two variables and a single constraint 2x_1 + x_2 = 2 has a single integer solution (1,0) but the linear relaxation has an infinite amount of solutions right? – Ram Oct 06 '22 at 22:30
  • In the case you mention here, your system has 2 variables but 1 equality. Then it can have an infinity of solutions over the reals. More generally, if your system has N variables and M equalities with M < N, then you will have an infinite number of solutions. If the system has N variables and M equalities with M >= N and no linearly dependent equalities, which is the case here (check the AMPL output: 198 variables, 212 constraints on page 9), then there is one or no solution. – Hexaly Oct 07 '22 at 20:40
  • I probably misunderstand this argument. If M>=N then the rank can at most be N. So there must be linear dependent constraints, right? Of course, LP solvers typically work with N+M variables. – Erwin Kalvelagen Oct 08 '22 at 16:51
  • You're right @ErwinKalvelagen. The argument is fallacious. Intuitively, I feel the rank to be full because, according to the principle of the game, one can reduce the matrix using simple propagation techniques. Sorry for this. But our exchange leads to interesting thoughts and experiments. Below are the ones. – Hexaly Oct 09 '22 at 21:05
  • Consider the original system, without applying any reduction techniques using the integrity of variables. The system is underdetermined, thus there is an infinity of real solutions. Now, consider the corresponding LP in normal form. Seems that when the Sodoku puzzle has only one solution, there is only one basic feasible solution to this LP, which is thus the integral one. Consequently, the simplex finds it. Here is a related paper: https://ieeexplore.ieee.org/document/5247059 Open question: it is true? If not, would be nice to see some basic feasible solutions that aren't integral.
  • – Hexaly Oct 09 '22 at 21:50
  • Modern MILP solvers apply sophisticated constraint propagation techniques before the computation of the root node LP. By using a modern MILP solver, you will observe that it eliminates almost all - if not all - the columns and rows of the system before the computation of the LP relaxation. So we need to be precise when we talk about the "linear relaxation". The LP after any good constraint propagation is trivially integral.
  • – Hexaly Oct 09 '22 at 22:20
  • 1
    Thanks again! I have updated the original question to include an example which has a non-integral solution to the linear relaxation. – Ram Oct 10 '22 at 09:16
  • Thank you @Ram for your feedback and additional information. Very interesting. This is Frédéric from LocalSolver. Started to work on analyzing in-depth the structure of the LP yesterday but had little time to advance on this recreational topic, unfortunately :-) You did what I wanted to do in the end: building a counter-example. Great job. – Hexaly Oct 10 '22 at 17:27
  • But I am concerned by your sentence "However, I introduced auxiliary variable and constraints and changed objective function to make non integral solutions more attractive". If you change the structure of the LP and find a counterexample, this doesn't mean necessarily that the property doesn't hold for the original LP. It was my point about being clear about what is "the LP" to analyze here. – Hexaly Oct 10 '22 at 17:31
  • If you start reducing the LP, this is not the original LP anymore. In the same way, if you add variables and change constraints, this is not the original LP anymore. Even if I well understand that the optimal solutions of your transformed LP remain optimal solutions of the original LP. – Hexaly Oct 10 '22 at 17:33
  • What you proved here is that Vanderbei is wrong. Which is already a good point :-) Some fractional optimal solutions to the LP exist. Now, the simplex can have the property to output integer solutions only. For example, all these fractional solutions may not be "basic feasible", and not "extreme" from a geometric point of view. Do you see my point? Anyway, exhibiting a fractional solution as a counterexample is a nice step forward. Thanks for providing the info. I can sleep better now :-) – Hexaly Oct 10 '22 at 17:43
  • Would I be right in thinking, if infinite solutions exist to the linear relaxation, then there must be at least two basic feasible solutions, and we know that at most one is integral (due to the unique sudoku solution) and therefore the existence of a fractional basic feasible solution is guaranteed (even if it is not the one I identified)? – Ram Oct 10 '22 at 23:28
  • Your demonstration approach is interesting but be careful. You cannot deduce that the property is always true because you have exhibited an instance for which it is true. Maybe for some Sodoku puzzles there exists only one solution to the LP which is the integral one. At this stage, we don't know. We know that for one puzzle - the one you exhibited - there exists a fractional optimal solution to the LP in addition to the integer one. – Hexaly Oct 11 '22 at 20:33
  • But you're right in some sense. According to me, at this point, we can claim the following. If the LP matrix hasn't a full rank, then an infinite number of optimal solutions exist to the LP relaxation: 1 integer (the one corresponding to the unique solution to the puzzle) and all the other ones fractional. If you can prove that any Sodoku puzzle, whatever its structure, leads to an LP whose matrix has not a full rank, then you will have proved the above property. But if you want to get my feeling about this, I would say I am not sure :-) – Hexaly Oct 11 '22 at 20:45
  • Check the very interesting comment and finding by @David Torres above. It seems that some Sudoku puzzles (the ones that can be solved completely using the pigeon-hole rule, according to J. Scott Provan) have the property to have only one integer solution to the LP. If true (to be checked :-), this disproves the conjecture. It also explains why in many cases, the LP relaxation is integral. In particular why Vanderbei found an integral one in his example, despite the use of LOQO which is an interior-point method and thus would tend to provide fractional solutions if any. – Hexaly Oct 11 '22 at 21:06