CS 4804 Homework #2

Date Assigned: September 7, 2006
Date Due: September 18, 2006, in class, before class starts
  1. (10 points) Problem 5.3 from your textbook.

  2. (10 points) Problem 5.4 from your textbook.

  3. (10 points) Problem 5.5 from your textbook.

  4. (20 points) Problem 5.11 from your textbook.

  5. (50 points) In this exercise, you are going to code up a Sudoku solver that uses constraint satisfaction techniques.

    First, carefully define the variables, domains, and constraints of this problem. Keep in mind there are numerous formulations and there is no single answer. We are only looking to see if you have captured the Sudoko puzzle in your formulation, not if you got the formulation we have in mind.

    Next, you will implement four programs that will perform varying degrees of search and constraint propagation (i.e., simplification of domains):

    • The first program you will implement is a mere backtracking search (i.e., depth-first search). Keep in mind that the algorithm was covered way back in Chapter 3 and is also reviewed in Section 5.2.

    • The second program conducts what is called "forward checking". We did not cover this in class but it is a minor variant of maintaining arc-consistency. Here, after we take a step down the search tree (e.g., by placing a tile in a specific position), we "flush" out to find all variables that get constrained as a result of this step, and reduce the domains of these variables. We backtrack when a domain gets empty. Therefore, forward chdcking is performed only with respect to the current step.

      Another way of saying this is we can perform arc-consistency on only those edges (Vi, Vj) where Vi is the just set variable.

    • The third program maintains arc-consistency, meaning it performs a full lookahead. It extends constraint propagation to even the variables that have not been assigned. For instance, after you have set variables V1, V2, V3, and V4, maintaining arc-consistency might simplify the domain of position V7 because for some values of this position, there is no possible value for variable V8. Use the AC-3 algorithm (Fig. 5.7) for implementing this (and perhaps the previous) approach. Once again, you backtrack when a domain becomes empty. The algorithm in 5.7 has to be implemented carefully, in order to ensure that the effect of removing values from a domain is properly "propagated" to neighboring values.

    • The final program uses the AllDiff constraint checker. Again, we haven't covered this in class but read up "Handling special constraints" in Section 5.2 to see what this is about.

    Notice that all programs except the first perform constraint propagation at each step of search - it is the level of constraint propagation that is different.

    Using a range of problems from easiest to most difficult, explore how the four programs fare. Which of them runs fastest? Time each carefully, taking care to distinguish the time spent in constraint propagation from that spent in search - i.e., "thinking" versus "doing". Make interesting observations about the search times, the effectiveness of the different strategies, and the range of problems that each strategy can solve.

    For full credit, give us an URL where your code can be checked (and downloaded, if necessary), write up a summary of how you represented the states, operators, the specific manner in which you did your experiments, and graphs/tables depicting the numbers you measured. Give English statements summarizing the conclusions and lessons learned.


Return Home