The document compares two algorithms for solving Sudoku puzzles: a genetic algorithm (GA) and a constraint propagation-search algorithm. It tests both algorithms on 30 random Sudoku puzzles. The constraint propagation-search algorithm solved all puzzles in an average of 0.01 seconds, while the GA took an average of 3.94 seconds to solve each puzzle, demonstrating that the constraint propagation-search algorithm is much more efficient for solving Sudoku puzzles.
2. 1. WHAT IS SUDOKU
2. OBJECTIVE OF SUDOKU
3. CONSTRAINT PROPAGATION
4. SEARCH ALGORITHM
5. GENETIC ALGORITHM (GA)
6. ANALYSIS
7. COMPARE RESULTS
8. CONCLUSION AND THE FUTURE
9. REFERENCES
3. Sudoku requires no calculation or arithmetic skills.
It can be played by children and adults and the rules are simple to learn.
It is essentially a game of placing numbers in squares, using very simple
rules of logic and deduction.
5. The number of different possible combinations of 9 by 9 Sudoku grids
is N=6670903752021072936960 which is approximately 6.671×1021
2 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
123456789 123456789 123456789 123456789 123456789 6 2 123456789 123456789
123456789 123456789 1 123456789 123456789 123456789 123456789 7 123456789
123456789 123456789 6 123456789 123456789 8 123456789 123456789 123456789
3 123456789 123456789 123456789 9 123456789 123456789 123456789 7
123456789 123456789 123456789 6 123456789 123456789 4 123456789 123456789
123456789 4 123456789 123456789 123456789 123456789 8 123456789 123456789
123456789 123456789 5 2 123456789 123456789 123456789 123456789 123456789
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 3
1. OBJECTIVE OF SUDOKU
6. onstraint
Propagation
• As soon as we know the initial values,
we can eliminate impossible values
from other squares.
• While we assign initial values for each
square, we also eliminate it from the
peers.
• This process is called constraint
propagation.
not 3
not 3
not 3
not 3
not 3
not 3
not 3 not 3 not 3
not 3
3 not 3 not 3 not 3 not 3 not 3 not 3 not 3
not 3 not 3 not 3
8. First make sure we haven’t already found a solution or a
contradiction, and if not
Choose one unfilled square and consider all its possible values.
Choose the square with the minimum number of possible
values.
One at a time, try assigning the square each value, and
searching from the resulting position.
That’s done.
9. GA encode a potential solution to a specific problem on a
Simple chromosome like data structure and
Apply recombination operators to these structures
GA Architecture
Selection: Survival of each individual depends on its fitness.
Crossover: Mating and recombining portions of good individuals.
Mutation: Random modifications.
11. The performance of this algorithm is tested by:
I have experimented with 30 random index puzzles.
I use the results as in [2] done with 2 datasets; 50 easy-level and 50 hard-level
Sudoku puzzles, each of them Peter says was solved in less than a fifth of a second.
Peter also test puzzle from Arto Inkala and solve them in 0.01 seconds.
Peter generated a million random puzzles and fill them at least 17 squares with at
least 8 different digits, but still Peter random puzzles are not guaranteed to have
one unique solution.
Puzzles that appear in books and newspapers always have one unique solution. The
average time to solve a random puzzle is 0.01 seconds.
12. The performance of this algorithm is tested by:
I tested 30 random index puzzles.
The solving of all these 30 Sudoku puzzle took 118.2 seconds in average 3.94
seconds for solving one Sudoku.
Also I use the results as in [3] start by testing five Sudoku puzzles taken from
the newspaper Helsingin Sanomat.
The solving of all these 27 [3] Sudoku puzzles took in average 4.11 seconds for
solving one Sudoku.
13. Index of Puzzle
Time taken to solve Sudoku problems using different algorithms
GA Constraint Propagation – Search
1 0.7 0.01
2 1.21 0.01
3 2.12 0.01
4 0.9 0.01
5 1.32 0.01
… … …
23 4.5 0.01
24 5.4 0.01
25 7.62 0.02
26 6.3 0.01
27 11.9 0.01
28 11.8 0.01
29 9.5 0.01
30 11.01 0.01
• GA is tested with 30 random index
puzzles, and the average is 3.94 seconds
for solving one Sudoku.
• Constraint Propagation-Search is tested
with 30 random index puzzles and the
average time to solve is 0.01 seconds.
14. 0
2
4
6
8
10
12
14
5 10 15 20 25 30
Time(s)
Puzzle Index
GA Average Time
0
0.005
0.01
0.015
0.02
0.025
0 5 10 15 20 25 30
Time(s)
Puzzle Index
Constraint Propagation - Search Average Time
16. Time performance of Constraint Propagation-Search is average 0.01s
Time performance of GA is average 3.94s
So the Constraint Propagation-Search is much better than the GA
In the future there is still work to do:
1. Find the unique solution,
2. Calculate the minimum basic number for a unique solution
3. Find solution for each puzzle using Constraint Propagation-Search
17. [1]Russell Stuart and Peter Norvig. Artificial Intelligence: A Modern Approach. New Jersey: Prentice
Hall, 2003.
[2]http://norvig.com/sudoku.html
[3] Mantere, T., Koljonen, J.: Solving, Rating and Generating Sudoku Puzzles with GA. 2007 IEEE
Congress on Evolutionary Computation-CEC2007, Singapore, pp. 1382–1389 (2007)
[4] Mantere, T., Koljonen, J.: Solving and analyzing Sudokus with cultural algorithms. 2008 IEEE
Congress on Evolutionary Computation-CEC2008, Hong Kong, China, (2008)
[5] Moraglio, A., Togelius, J., Lucas, S.: Product geometric crossover for the sudoku puzzle. In 2006 IEEE
Congress on Evolutionary Computation (CEC2006), Vancouver, BC, Canada, July 16-21 (2006) 470-476.
(GA)
[6] Bertram Felgenhauer, Frazer Jarvis, Mathematics of sudoku I, Mathematical Spectrum, Vol. 39,
No. 1, Pp. 15–22, 2006
[7] J.-P. Delahaye, "The Science Behind Sudoku", Scientific American, vol. 294, no. 6, pp. 80-87, Jun 2006.