Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis1 Using Constraint Processing to Model, Solve, and Support Interactive Solving of.

Similar presentations


Presentation on theme: "Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis1 Using Constraint Processing to Model, Solve, and Support Interactive Solving of."— Presentation transcript:

1 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis1 Using Constraint Processing to Model, Solve, and Support Interactive Solving of Sudoku Puzzles Christopher G. Reeson Constraint Systems Laboratory Department of Computer Science & Engineering University of Nebraska-Lincoln Research supported by a UCARE grant

2 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis2 Goals How to use CP techniques on Sudoku puzzles? –Study & compare the effectiveness of various constraint propagation algorithms How can we use CP to interactively support and guide human players? Is Sudoku useful to illustrate and teach CP? … How to deconstruct Sudoku solving to –Demystify the puzzle –Prevent students from losing time playing it

3 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis3 Outline Background information: the game, CSPs Our contributions –Algorithms –Conjectures –Interface: interactive solver Conclusions and future research Live demonstration

4 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis4 The game Number place Main properties –NP-complete [Yato 03] –Well-formed Sudoku: has 1 solution [Simonis 05] –Minimal Sudoku In a 9x9 Sudoku: smallest known number of givens is 17 [Royle] –Symmetrical puzzles Many axes of symmetry Position of the givens, not their values Often makes the puzzle non-minimal –Level of difficulties Varied ranking systems exist Mimimality and difficulty not related #15 on Royle’s web site

5 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis5 Constraint Satisfaction Problem (CSP) V3V3 {d} {a, b, d}{a, b, c} {c, d, e, f} V4V4 V2V2 V1V1 Given P = (V, D, C) –V: set of variables –D: set of their domains –C: set of constraints (relations) restricting the acceptable combination of values for variables –Solution is a consistent assignment of values to variables Query: find 1 solution, all solutions, etc.

6 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis6 Sudoku as a CSP (9x9 puzzles) Variables are the cells Domains are sets {1,…,9} Two models –Binary constraints: 810 all-different binary constraint between variables –Non-binary constraints: 27 all-different 9-ary constraints

7 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis7 Solving Sudoku as a CSP Search –Builds solutions by enumerating consistent combinations Constraint propagation –Removes values that do not appear in a solution –Example, arc-consistency:

8 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis8 Search Backtrack search –Systematically enumerate solutions by instantiating one variable after another –Backtracks when a constraint is broken –Is sound and complete (guaranteed to find solution if one exists) Look-ahead –Cleans up domain of ‘future’ variables, during search, given current instantiations Forward Checking (FC): weak form of arc-consistency Maintaining Arc-Consistency (MAC): arc-consistency

9 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis9 Forward Checking (FC) Forward Checking on the binary model

10 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis10 Maintaining Arc-Consistency (MAC) Arc Consistency on the binary model

11 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis11 Generalized Arc-Consistency (GAC) Operates on the non- binary model Subsumes AC Can be done in polynomial time for all-different constraints [Régin 94]

12 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis12 Consistency Algorithms - SAC Shaving Arc-Consistency –Binary –Stronger than Arc- Consistency Michael Mepham Extreme #26

13 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis13 Consistency Algorithms - SGAC Shaving Generalized Arc-Consistency –Non-binary –Subsumes SAC Michael Mepham Extreme #26

14 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis14 Consistency relationships Sets denote the values removed by propagation

15 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis15 R(1,2)C Takes two constraints and Removes any value that does not appear in a solution to both constraints

16 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis16 Consistency R(1,2)C

17 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis17 Conjecture 1: R(1,2)C  SGAC R(1,2)C is at least as strong as SGAC Is SGAC at least as strong as R(1,2)C? We proved R(1,2)C  SGAC when the 2 relations overlap over one variable

18 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis18 Conjecture 2: SGAC solves.. … every: –Well-formed –9x9 Sudoku? Proof still open, but empirical evidence is strong Warning –Sudoku is NP-Complete –SGAC is polynomial –When a 9x9 Sudoku has multiple solutions, SGAC does not solve it Proof may exploit the fact that all non-binary constraints are 1-tight

19 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis19 Interactive interface Loading instances Buttons for propagation –On individual constraints –For consistency algorithms: AC, GAC, SAC, SGAC –For interactive look-ahead Finding solutions Hint panel Highlighting error Manual domain filtering Manual assignments Do/Undo buttons supporting every functionality

20 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis20 Buttons for constraint propagation Buttons allow users to run –AC –GAC Over each –Column –Row –Block

21 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis21 Finding solutions Find the number of solutions at any point in the game –Creates a copy of the CSP displayed on the board –Runs consistency algorithms to speed up search –Runs exhaustive search to find all solutions Found Sudokus that are not well-formed on the web and in… the LA Times

22 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis22 Hint panel Two types of hints: Singleton & Vital Eight Levels (6 implemented) –FC, AC, Single GAC, GAC, Single SAC, SAC, Single SGAC, SGAC Highlight a cell with a hint –Option to move to the next hint –Display the number of hints Preliminary tests show that this new strategy can teach people to play Sudoku effectively and… get them quickly bored with the game

23 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis23 Web-based implementation XML files Solver Constructor

24 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis24 The way humans play ‘Cross-hash,’ sweep through lines, columns, and blocks Pencil in possible positions of values Generally, look for patterns, some intricate, and give them funny names: –Naked single, locked pairs, swordfish, medusa, etc. ‘Identified’ dozens of strategies –Many fall under a unique constraint propagation technique But humans do not seem to be able to carry simple inference (i.e., propagation) in a systematic way for more than a few steps

25 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis25 Impact Inspired a PhD student @ USC –to use propagation to infer the applicable constraints for automatically modeling various types of Sudoku puzzles Collaborating with an MS student @ USC on Constructor –Inputting, storing instances –Generalization to other Sudoku variations

26 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis26 Conclusions: CP solving Propagation is useful for –effectively guide humans & train them in Sudoku solving SAC (often), SGAC (always) can solve any well-formed Sudoku, also noticed by Simonis Sudoku good illustration of the power of SAC and SGAC –otherwise thought to be more expensive than effective No need for extra CP modeling as Simonis did: –Use the simple constraint model on row, columns, blocks –Stick to general purpose propagation algorithms But… Who wants to play Sudoku any more when they know that SGAC can do it?

27 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis27 Finally Future work: –Use the interface to generate Sudoku puzzles –Investigate theoretically the relationship between Sudoku size And the consistency level necessary for solving it Live demonstration

28 Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis28 Thank you for your attention I would be glad to answer your questions


Download ppt "Constraint Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis1 Using Constraint Processing to Model, Solve, and Support Interactive Solving of."

Similar presentations


Ads by Google