The goal of this task is to investigate the AIMA CSP Solver, make some improvements to it, apply it to a toy problem, and apply it to a practical problem of your own choosing. You'l need to run some comparative experiments, showing how the Solver works on different size problems, with and without your improvements, and submit a report on what you did and the experimental results.
See the CSP Setup Instructions for details on installing and testing the CSP Solver.
Do cryptarithmetic problems in the CSP Solver. Do SEND + MORE = MONEY but don't hard-code just that problem. At a minimum, you should be able to handle any 2-addend problem. Invent at least one more example, which should have at least one solution.
One tricky part is representing the constraints in this kind of problem as binary constraints, which is all the CSP Solver can handle. You need to create additional variables that combine the input variables, and form constraints with them. See your class notes and the newsgroup for discussions on this.
Puzzles are fine for testing and exploring, but in real life we need programs to solve real problems, like assigning resources to tasks, choosing parts for computers, and so on. Find a real world task that seems appropriate for CSP, represent one or two examples, and apply the CSP Solver to it.
The Solver is good code but it's very simple code. It's intended to have lots of room for improvement. As discussed in class, there appear to be two places where the CSP Solver may need improvement:
In both cases, any changes you make to the CSP code should be totally general and not assume any specific CSP problem.
Do not change
csp.lisp. Create a file with the code you need to
extend and redefine
csp.lisp. This will be the file you send in.
The CSP Solver checks all assigned variables against all assigned variables on every new assignment. In all the examples we've seen, we only need to check the most recently assigned variable against the assigned variables.
Change the CSP code to take a flag
check-all? that, if true (the
default), causes the current behavior to occur, but, if false, causes the Solver
to do the proposed new behavior.
As with the other flags for the CSP Solver, you should be able to give this flag:
The other place where you may need to change the CSP Solver code is to better support problems like cryptarithmetic that have n-ary constraints. As noted in Exercise 5.11, class discussion, and the newsgroup, n-ary constraints can be converted to binary constraints by introducing new intermediate variables that unite several variables. Such variables have domains that are the cross-product of the domains of the variables they unite. Odds are (but experimental evidence would be good here) that we don't want to randomly assign values to such variables and see if they work out. Instead, the CSP code should automatically assign and unassign these intermediate variables as the variables they unite are assigned.
Gather data on how the CSP Problem Solver runs for the different problems,
with different combinations of the flags and search functions, including the
check-all? flag. Draw some conclusions.
Note that the Solver code already gathers some statistics, and there's example
test-search.lisp that shows how to generate comparative
output. Use that and/or improve it.
Put your report in a Word document (or RTF file if you use something other than Word). Separate the document into clearly labeled sections based on the above, i.e., a section on how you changed the CSP Solver, a section on how you implemented the cryptarithmetic problem, a section on the experiments and results, and so on.
Create the following files:
name-task1.doc, where name is your last name.
Send the Zip file as an attachment in an email to
with the Subject line:
CS 348 Task 1.