Base class for Sudoku puzzles. More...
Public Types | |
| enum | { MODEL_INT , MODEL_SET , MODEL_MIXED } |
| Model variants. More... | |
| enum | { BRANCH_NONE , BRANCH_SIZE , BRANCH_SIZE_DEGREE , BRANCH_SIZE_AFC , BRANCH_AFC } |
Public Member Functions | |
| Sudoku (const InstanceOptions &opt) | |
| Constructor. | |
| Sudoku (Sudoku &s) | |
| Constructor for cloning s. | |
| Sudoku (const InstanceOptions &opt) | |
| Constructor. | |
| Sudoku (Sudoku &s) | |
| Constructor for cloning s. | |
| virtual Space * | copy (void) |
| Perform copying during cloning. | |
| virtual void | print (std::ostream &os) const |
| Print solution. | |
| Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > > | |
| ScriptBase (const Options &opt) | |
| Constructor. | |
| ScriptBase (ScriptBase &e) | |
| Constructor used for cloning. | |
| virtual void | compare (const Space &home, std::ostream &os) const |
| Compare with s. | |
| Public Member Functions inherited from Gecode::Driver::IgnoreStepOption< BaseSpace > | |
| IgnoreStepOption (const Options &) | |
| Constructor. | |
| IgnoreStepOption (BaseSpace &e) | |
| Constructor used for cloning. | |
Protected Attributes | |
| int | nn |
| The side of the grid. | |
| int | bw |
| The width of a box. | |
| int | bh |
| The height of a box. | |
| IntSharedArray | givens |
| Given values in row-major order (0 for blank). | |
| IntVarArray | x |
| Values for the fields. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| int | main (int argc, char *argv[]) |
| Main-function. | |
Sudoku specifications | |
Each specification gives the initial positions that are filled in, with blank squares represented as zeroes. | |
| const char * | examples [] |
| The specifications. | |
| const unsigned int | n_examples = sizeof(examples)/sizeof(char*) |
| The number of instances. | |
| const char * | instance_spec |
| Reader spec for sudoku files. | |
| int | example_size (const char *s) |
| The size of an instance. | |
| int | sudokuField (const char *s, int n, int i, int j) |
| Return value at position (i,j) in the example s of size n. | |
| void | print_value (std::ostream &os, int v) |
| Print value v of a field, with the symbols of the scaled sudoku corpus. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > > | |
| static std::ostream & | select_ostream (const char *sn, std::ofstream &ofs) |
| Choose output stream according to sn. | |
| static void | run (const Options &opt, Script *s=nullptr) |
Detailed Description
Base class for Sudoku puzzles.
Example: Solving Sudoku puzzles using integer constraints
The instance is either the number of a built-in instance or a file in the format of the scaled sudoku corpus: a line such as # size=6 box=3x2, then the rows of the grid with . for blank cells and the symbols 1-9, A-Z, and 0 for the values 1 to 36.
Definition at line 65 of file sudoku-advanced.cpp.
Member Enumeration Documentation
◆ anonymous enum
| anonymous enum |
Model variants.
| Enumerator | |
|---|---|
| MODEL_INT | Use integer constraints. |
| MODEL_SET | Use set constraints. |
| MODEL_MIXED | Use both integer and set constraints. |
Definition at line 78 of file sudoku-advanced.cpp.
◆ anonymous enum
| anonymous enum |
| Enumerator | |
|---|---|
| BRANCH_NONE | Use lexicographic ordering. |
| BRANCH_SIZE | Use minimum size. |
| BRANCH_SIZE_DEGREE | Use minimum size over degree. |
| BRANCH_SIZE_AFC | Use minimum size over afc. |
| BRANCH_AFC | Use maximum afc. |
Definition at line 85 of file sudoku-advanced.cpp.
Constructor & Destructor Documentation
◆ Sudoku() [1/4]
|
inline |
Constructor.
Definition at line 94 of file sudoku-advanced.cpp.
◆ Sudoku() [2/4]
|
inline |
Constructor for cloning s.
Definition at line 102 of file sudoku-advanced.cpp.
◆ Sudoku() [3/4]
|
inline |
Constructor.
Definition at line 71 of file sudoku.cpp.
◆ Sudoku() [4/4]
|
inline |
Constructor for cloning s.
Definition at line 100 of file sudoku.cpp.
Member Function Documentation
◆ copy()
|
inlinevirtual |
Perform copying during cloning.
Reimplemented in SudokuInt, SudokuMixed, and SudokuSet.
Definition at line 106 of file sudoku.cpp.
◆ print()
|
inlinevirtual |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > >.
Reimplemented in SudokuInt, SudokuMixed, and SudokuSet.
Definition at line 112 of file sudoku.cpp.
Friends And Related Symbol Documentation
◆ examples
|
The specifications.
Definition at line 54 of file sudoku-instances.hh.
◆ n_examples
|
The number of instances.
Definition at line 1849 of file sudoku-instances.hh.
◆ instance_spec
|
Reader spec for sudoku files.
The format of the scaled sudoku corpus: a line such as # size=6 box=3x2, then the rows of the grid with . for blank cells and the symbols 1-9, A-Z, and 0 for the values 1 to 36. A file may contain several puzzles, one after the other; select one with -param instance=K. See Instance::Spec for the spec language.
Definition at line 1890 of file sudoku-instances.hh.
◆ main()
|
Main-function.
Definition at line 423 of file sudoku-advanced.cpp.
◆ example_size()
|
The size of an instance.
Definition at line 1852 of file sudoku-instances.hh.
◆ sudokuField()
|
Return value at position (i,j) in the example s of size n.
Definition at line 1860 of file sudoku-instances.hh.
◆ print_value()
|
Print value v of a field, with the symbols of the scaled sudoku corpus.
Definition at line 1946 of file sudoku-instances.hh.
Member Data Documentation
◆ nn
|
protected |
The side of the grid.
Definition at line 68 of file sudoku-advanced.cpp.
◆ bw
|
protected |
The width of a box.
Definition at line 70 of file sudoku-advanced.cpp.
◆ bh
|
protected |
The height of a box.
Definition at line 72 of file sudoku-advanced.cpp.
◆ givens
|
protected |
Given values in row-major order (0 for blank).
Definition at line 74 of file sudoku-advanced.cpp.
◆ x
|
protected |
Values for the fields.
Definition at line 67 of file sudoku.cpp.
The documentation for this class was generated from the following files:
- examples/sudoku-advanced.cpp
- examples/sudoku-instances.hh
- examples/sudoku.cpp
