Plans for Maximagenerators related to Sudokulike problems.
More...
Go to the source code of this file.
Detailed Description
Plans for Maximagenerators related to Sudokulike problems.
 Todo:
 Relations to other modules
 Todo:
 Implement the four mixed cases for the direct translation
 Todo:
 Further improve implementation
 Todo:
 Random Sudoku problems

For the creation of random Sudokuproblems the easiest approach seems to fix the number f of fixed fields, and then choose f random fields from the N^2 fields, and for each chosen field choose a random value from {1,...,N}. In other words, using the natural notion of (nonboolean) literals a random problem is just given by a random partial assignment with a fixed number of f variables.

Such random Sudokuproblems should also undergo a phase transition (for fixed p and appropriate f) ?!

Creation of the partial assignment (with nonboolean variables) simply as a random clause by the OKgenerator.

For the analysis one can filter out partial assignments which are not r_kconsistent (so r_0consistency just means that the partial assignment does not (directly) falsify a clause); no consistency check then would be "1consistency".

To speed up the creation, filtering out of r_kinconsistent partial assignments can be done already during the creation (without disturbing the probability distribution).

However, even r_1reduction for boxdimension 2 takes a long time in Maxima (90 s). Thus this filtering cannot be done in Maxima, but we need C++ components.

It seems however, that the most basic version should already exclude trivial inconsistencies:

Thus best is likely to start with the list of all possible pairs [field, value].

A random element is chosen, and this field together with the fields with the same value in the same line is removed.

This process is repeated.

This yields a different random process (fields with many values have a higher probability for being chosen), but this process is also natural.
 Todo:
 Enumerating all solutions

Likely this should go to a submodule of module CombinatorialMatrices/Lisp/LatinSquares.

Apparently for boxdimension 2 we have 288 solutions; this should be computed and made available.

There are 576 many latin squares of order 4; given that they are derived from just 4 reduced latin squares of order 4, it should be easy to make them available, and then to filter out the sudokus amongst them.
 Todo:
 Sampling of all solutions

Likely this should go to a submodule of module CombinatorialMatrices/Lisp/LatinSquares.

A solution is just a total assignment (fulfilling the Sudokuconstraints.

See Satisfiability/Enumeration/plans/general.hpp.

A natural approach seems to be to create random instances, remove the unsatisfiable ones, and pick a solution.

Just picking the first solution might lead to a bias?

So we could try to pick the second, third, ... solution.

Perfectly, we would enumerate all solutions and pick one at random. But this is likely infeasible in most cases.

But sampling the solution space of a problem instance might be more feasible.

Of course, one could apply this approach just to the problem given by the empty partial assignment, and obtain in this way all solutions.

However it might be worthwhile to first restrict the solution space.

Another approach just uses "random selfreduction":

Start with the empty partial assignment.

Create the list of all pairs (empty field)/values.

Remove the obviously unsatisfiable extensions by one such pair.

Choose a random pair from the list, and check whether this extension is still satisfiable; if not, remove from the list, and choose another pair (as long as the list is not empty, there must exist a satisfiable extension).

Repeat until a full solution is obtained.

The question is whether this process yields perfect sampling of all solutions? One should check this for boxdimension 2.

This process is similar to the second process above for creating random Sudoku problems, only that above no satisfiabilitycheque is performed.
 Todo:
 Sampling of minimally uniquely satisfiable problems

Here the task is to sample (count, enumerate etc.) all Sudoku problems which are minimally uniquely satisfiable (they are uniquely satisfiable, and removing any assignment creates further solutions).

So "minimal" here is related to the partial assignment (and not to the problem instance).

See http://magictour.free.fr/suexco.txt, where the generator "suexg" is described (also copied into this directory).

Regarding *minimum* uniquely satisfiable problems, that is, where the partial assignment has minimum size, the conjecture is that this size is 17; all known nonisomorphic cases are made available by Gordon Royle at http://units.maths.uwa.edu.au/~gordon/sudokumin.php .

The natural approach is to create a random solution (see "Sampling of
all solutions" above), which is trivially uniquely satisfiable and then randomly remove assignments (i.e., literals) which can be removed without creating further solutions, until we obtain a minimally uniquely satisfiable problem.

DONE (see minUNISAT in Satisfiability/Lisp/Generators/plans/PlantedSolutions.hpp) We should create a general procedure, which starts with some unique solution phi (could be a partial assignment in general), and then picks variables by some heuristics and removes them from phi.

Using the boolean literals, in general we get a "fractured Sudoku
instance", where fields have forbidden values.

But if we use just a positive partial assignment, which only states the occupied fields (not the other forbidden values, which follow by UCP), then actually we get standard Sudoku problems, and don't need to use negatively monosigned literals.

For Sudoku it should be most natural to start with some given total solution (represented by a partial assignment containing only positive literals).

Interesting questions here are what heuristics to use for removing a variable (if there are several choices), and whether the solution we start with makes a difference.

The first objective could be to use the OKsolver2002, and to first maximise the number of nodes in the tree, second the number of 2reductions.

There should be instances which are not completely decided by 2reduction; but we can also try maximise the number of 2reductions for those instances decided by 2reduction (where the OKsolver2002 only needs one node).

For specification purposes the Maxima functions are fine (of course), but they will be too slow, so that later a little C++ program is needed.

Is the discussion and implementation of a Sudoku generator at http://skasblog.blogspot.com/2007/07/endofsudokuroad.html relevant for us?

To me (OK) this looks rather amateurish; and, of course, completely ignored is the main perspective for us, that of generalised Sudoku as an NPcomplete problem.

In those discussions the "hardness" of a problem always plays a role; I think a good way to measure it is the least k such that r_k yields the solution (this only works for unique solutions; otherwise generalised reductions have to be used).
 Todo:
 Sudoku generator for the Minion constraint solver

This should be placed into a module for constraint satisfaction.

What is the meaning of "generator" here? Is this just a fileformat, or, more meaningfully, do we first create a constraintsatisfactionproblem, using a suitable Maximarepresentation of "constraints", and then output this in Minionformat?

Parameters: n (box size), N = n^2, M = N^2

Cells variables : {x_1,...,x_M}. dom(x_i) = {1,...,N} for i = 1...M. x_i = j means j is assigned to cell i.

Boxes are represented by vectors v_i (i = 1..N) of cell variables.

The Sudoku then consists of a single N x N matrix of cell variables.

Implementation:

Row constraints: for i = 1..N

Column constraints: for i = 1..N

Box constraints: for i = 1..N

Syntax: (what syntax?? the filecontent?)
sudoku_minion_format(boxsize, filename)
Definition in file Sudoku.hpp.