Due Tuesday, May 11 at 11:59 PM via e-mail to BOTH vrastogi at u.northwestern.edu and ddowney at eecs.northwestern.edu. Use EECS 348 Homework 4 as the e-mail subject line. PDF format required. LATE ASSIGNMENTS WILL NOT BE GRADED.

Assignment

Write a constraint satisfaction problem solver to solve sudoku puzzles of varying size (see the link for the rules if you're unfamiliar with the puzzles). At least backtracking (BT) and forward checking (FC) must be implemented; other heuristics should be implemented based on the number of students in the team (see note below). The goal is to get a performance comparison of various CSP strategies.

The input to the solver is a Sudoku board, and the output should be a complete solution, along with the number of consistency checks utilized. We've supplied specific input puzzles you'll use for this assignment (thanks to Stef Schoenmackers at Univ. of Washington for these). They have the following format:

<board_size> - (board size will be 4, 9, 16, or 25)
<num_initial_values> - (The number of set cells in the initial state)
<row1>	<col1>	<value1> - value of the cell at row1, col1
<row2>	<col2>	<value2> - value of the cell at row2, col2
<row3>	<col3>	<value3> - value of the cell at row3, col3
... for a total of num_initial_values lines
Each row, col, and value is in the range [1, board_size]. This Example corresponds to the board:
 2  
   2
 34 
4   

When testing your code, it will help to try some easy test boards, which you can find here. For further testing you may use these boards. Note that for the larger problems, without powerful heuristics your program will not terminate in a reasonable amount of time -- you should choose an upper bound to the number of consistency checks you make so that the program terminates in, say, 10 minutes.

Note: This assignment can be done in the same groups as for Homework 2 and 3. Each team member must however implement a different heuristic (e.g., arc consistency, min conflicts) on her own. Each student must also turn in her own homework write-up along with the code and should understand all key pieces of the code.

Turn in the following:
  1. Code
    1. (3 points) Your code
    2. (1 point) Describe who within your group performed which piece of the design/programming effort.
  2. Write-up
    1. (5x1 points) Briefly explain the representation of each of the following in 1-2 sentences each: the board, variables, constraints, the constraint graph and the states.
    2. (1 points) How do you implement forward checking?
    3. (3 points) Make a table comparing the performance of the heuristics (in terms of number of consistency checks) for these test problems: 4x4 9x9 16x16 25x25
    4. The table should have the following format (numbers are random)
      ProblemBacktrackingForward Checking<other methods>
      4x41234567...
      9x9234567890...
      16x16789K12K...
      25x25(> 1M)234K...
    5. (2 points) Comment on your results in about 100 words: what trends do you see, in terms of scalability across the various heuristics? Are these as expected?
If your program does not work, you may still discuss your methodology and what went wrong, and any possible ways to fix this. Considerable credit can still be earned even if the program doesn't work, provided the writeup is of sufficient quality.