Sudoku using POCS and Sparsity
5 stars based on
This tour was written by Yue M. The idea of encoding the Sudoku rule using a higer dimensional lifting, linear constraints and binary constraint is explained in:. This tour elaborarates on these two ideas. You need to download the following files: You should create a text file named for instance bintprog matlab 2010.
Then, simply run exec 'numericaltour. The basic idea is to use a higher dimensional space of size n,n,n to represent a Sudoku matrix of size n,n. In this space, the arrays are bintprog matlab 2010 to have binary entries. The resulting matrix has binary entries and has size n,n,n. Decoding from binary format. One use a min to be able to recover even if the matrix X is not binary because of computation errors.
For X to be a valid encoded matrix, it should be binary and satifies that each X i,j,: In a Sudoku valid matrix xeach column, row and sub-square of x should contains all the values in A Sudoku game asks to fill the missing entries of a partial Sudoku matrix x1 to obtain a full Sudoku matrix x. Unfortunately, solving a linear system under binary constraints is difficult, in fact solving a general integer program is known to be NP-hard.
It means that such a method is very slow to solve Sudoku for large n. One can use branch-and-bounbs methods to solve the binary bintprog matlab 2010 program, but this might be slow. One can use for instance the command bintprog of Matlab optimization toolboxwith an arbitrary objective function since one wants to solve a feasability problem, no objective is needed. But unfortunately it has an infinite number of bintprog matlab 2010 and the set of solutions is not bounded.
Plot the histogrtam of the entries of Xproj. As you can see, they are not binary, meaning that the binary constraint is violated. It is thus not a solution to the Sudoku problem. And iteratively project on each bintprog matlab 2010. This corresponds to the POCS algorithm to find a feasible point into the non empty intersection of convex sets.
As you can see, the resulting bintprog matlab 2010 is nearly, up to convergence errors of the POCS a binary one, meaning that it bintprog matlab 2010 actually the unique solution to the Sudoku problem. Unfortunately, this is not always the case. For more difficult grids, P might not be reduced to a singleton. What is your conclusion? A classical method to approximate the solution to the minimum L0 norm problem it to replace it by a minimum L1 norm solution, which can be computed with polynomial time algorithms.
The L1 norm of a projected vector is usually larger. They work if and only if the polytope is reduced to a single point. Nevertheless, one can compute the solution with minimum L1 norm which corresponds to the Basis pursuit problem. This problem is equivalent to a bintprog matlab 2010 program, and can be solved using standard interior points method other algorithms, such as Douglas-Rachford could be used as well. This leads to non-convex problems, and one can compute a not necessarily globally optimal local minimum.
An algorithm to find a local minimum of the energy is the reweighted L1 minimization, described in:. Boyd, Enhancing sparsity by reweighted l1 minimizationJ. The weighted L1 minimization can be recasted as a traditional L1 minimization using a change of variables. Track the evolution of the number of invalidated constraints as the algorithm iterates.
While reweighting L1 works for reasonnably complicated Sudoku, it might fail bintprog matlab 2010 very difficult one. Contents Installing toolboxes and setting up the path.