ARI711S Homework: CSP
1 Course Scheduling
You are in charge of scheduling for computer science classes that meet Mondays, Wednesdays and Fridays. There
are 5 classes that meet on these days and 3 professors who will be teaching these classes. You are constrained by
the fact that each professor can only teach one class at a time.
The classes are:
1. Class 1 - Intro to Programming: meets from 8:00-9:00am
2. Class 2 - Intro to Artificial Intelligence: meets from 8:30-9:30am
3. Class 3 - Natural Language Processing: meets from 9:00-10:00am
4. Class 4 - Computer Vision: meets from 9:00-10:00am
5. Class 5 - Machine Learning: meets from 10:30-11:30am The professors are:
1. Professor A, who is qualified to teach Classes 1, 2, and 5.
2. Professor B, who is qualified to teach Classes 3, 4, and 5.
3. Professor C, who is qualified to teach Classes 1, 3, and 4.
1. Formulate this problem as a CSP problem in which there is one variable per class, stating the domains, and
constraints. Constraints should be specified formally and precisely, but may be implicit rather than explicit.
2. Draw the constraint graph associated with your CSP.
3. Your CSP should look nearly tree-structured. Briefly explain (one sentence or less) why we might prefer to
solve tree-structured CSPs.
1
2 CSPs: Trapped Pacman
Pacman is trapped! He is surrounded by mysterious corridors, each of which leads to either a pit (P), a ghost (G),
or an exit (E). In order to escape, he needs to figure out which corridors, if any, lead to an exit and freedom, rather
than the certain doom of a pit or a ghost.
The one sign of what lies behind the corridors is the wind: a pit produces a strong breeze (S) and an exit produces
a weak breeze (W), while a ghost doesn’t produce any breeze at all. Unfortunately, Pacman cannot measure the
strength of the breeze at a specific corridor. Instead, he can stand between two adjacent corridors and feel the max
of the two breezes. For example, if he stands between a pit and an exit he will sense a strong (S) breeze, while if he
stands between an exit and a ghost, he will sense a weak (W) breeze. The measurements for all intersections are
shown in the figure below.
Also, while the total number of exits might be zero, one, or more, Pacman knows that two neighbouring squares
will not both be exits.
1
s s
6 2
S W
5 3
S w
4
Pacman models this problem using variables Xi for each corridor i and domains P, G, and E.
1. State the binary and/or unary constraints for this CSP (either implicitly or explicitly).
2. Cross out the values from the domains of the variables that will be deleted in enforcing arc consistency.
X1 P G E
X2 P G E
X3 P G E
X4 P G E
X5 P G E
X6 P G E
2
3. According to MRV, which variable or variables could the solver assign first?
4. Assume that Pacman knows that X6 = G. List all the solutions of this CSP or write none if no solutions exist.
1
n 2
5. The CSP described above has a circular structure with 6 variables. Now consider a CSP forming a circular
structure that has n variables (n > 2), as shown below. Also assume that the domain of each variable has
cardinality d. Explain precisely how to solve this general class of circle-structured CSPs efficiently (i.e. in time
linear in the number of variables), using methods covered in class. Your answer should be at most two
sentences.
6. If standard backtracking search were run on a circle-structured graph, enforcing arc consistency at every
step, what, if anything, can be said about the worst-case backtracking behaviour (e.g. number of times the
search could backtrack)?