# CS 1571: Homework 4

## Search and Constraints (Chapters 4-5)

Assigned: October 2, 2008

Due: October 14, 2008 (NOTE: due to the fall break on Monday, there is no Tuesday class that day - hardcopies must be in my mailbox (on the 5th floor) by when class would have met)

#### 1. Hill Climbing Search, Constraint Representation (50 pts)

(a) Suppose you are in an initial state where you have a stack of alphabet blocks, where B is the bottom black, A is the top block, and the full order of the blocks from bottom to top is B, C, D, E, F, G, H, A. The goal state is to have an alphabetized stack, such that A is the bottom block and H is on the top (e.g., the full order is A, B, C, D, E, F, G, H). To get from one state to another, you can move a block off the top of a stack to either the table, or to the top of another stack.

Let heuristic function H1 count +N for every block that sits on a correct stack of N things, and count -N for every block that sits on an incorrect stack of N things. The goal state has the value +28, and the initial state has the value -28.

Let heuristic function H2 count +1 for every block that sits on the correct thing, and count -1 for every block that sits on an incorrect thing. The goal state has the value +8, and the inital state has the value +4.

Assume you are doing Hill Climbing Search. Explain which heuristic is better. HINT: You should only have to expand a few nodes to answer this question.

(b) Pitt's Cucina serves dinner Wednesday through Sunday. The restaurant is closed on Monday and Tuesday. Five entrees - veal parmesan, grilled swordfish, pan seared salmon, pork loin, and chicken parmesan are served as the special each week according to the following restrictions:

- Something must be served every day
- Grilled swordfish is never served on Friday.
- Pork loin cannot be served the day after veal parmesan
- Pan seared salmon and veal parmesan must be served on the weekend.
- Chicken parmesan is always served within two days of grilled swordfish.

  Specify the problem of determining which meals can be served on which day as a CSP.

  #### 2. Constraint Satisfaction Problems (50 pts)

  Federal Express needs to deliver five packages a,b,c,d, and e at one of four times, 1,2,3, or 4. Let A represent the time at which a is delivered, B represent the time at which b is delivered, etc. The initial possible values for each delivery is the set {1, 2, 3, 4}. The following constraints need to be met:

  (B ≠ 3) ^ (C ≠ 2) ^ (A ≠ B) ^ (B ≠ C) ^ (C < D) ^ (A = D)^ (E < A) ^ (E < B) ^ (E < C) ^ (E < D) ^ (B ≠ D)

  (a) Apply backtracking search to the problem. Draw the search tree, labeling the nodes with current variable assignments and the order in which the nodes are visited. Consider the variables in the order A,B,C,D,E and the values in the order 1,2,3,4. Stop after 10 nodes have been added to the tree.

  (b) Give an example where the use of each of the following would have been beneficial:

- Most constrained variable
- Most constraining variable
- Least constraining value

  (c) Apply forward-checking search to the problem. Use the order mentioned in part (a). Fill in the table with the appropriate values:

  Current assignment being considered | Domain A | Domain B | Domain C | Domain D | Domain E

  (d) Is there an example where the use of arc consistency would have been beneficial?