# CS2710 / ISSP 2160: Homework 2

## Problem-Solving (Chapters 3-6)

Assigned: September 22, 2010

Due: October 6, 2010

#### 1. Formulating Search Problems (10 pts)

Russell and Norvig 3.9 (a). Instead of the solution we discussed in class, represent states using a 6-tuple.

#### 2. Blind Search (10 pts)

Russell and Norvig 3.15 (a)

What is the full search space size? If you had to choose, would you pick breadth-first or depth-first search as a method for exploring a larger portion of this state space? Explain your answer.

Russell and Norvig 3.15 (b) (6 pts)

#### 3. Greedy Search (10 pts)

Consider a graph with nodes A, B, C, D, E, F, G, and S. The start state is S and the goal state is G. The edges in the graph are as follows: (A,B,4), (A,D,5), (A,S,2), (B,C,4), (B,E,6), (B,F,3), (C,G,1), (D,E,3), (D,S,3), (E,F,4), (F,G,5). (The notation (A,B,4) means that there is an edge between nodes A and B, and that the cost of traveling that edge is 4.)

Nodes should be expanded alphabetically if two or more nodes have the same evaluation cost. Use the following table for the heuristic function:
 n S A B C D E F G h(n) 10 7 3 1 5 4 2 0

Use Greedy Best First search to
i. List the nodes in the order they would be generated.
ii. List the nodes that lie along the final correct path to the goal.
iii. What is the cost of the solution? Is it optimal? Explain.

#### 4. A* Search (10 pts)

Russell and Norvig 3.23

#### 5. Heuristics (10 pts)

Consider a sliding block puzzle with the following initial configuration:
|B|B|B|W|W|W|E|
There are 3 black tiles (B), three white tiles (W), and an empty cell (E).

The puzzle has the following moves:

• A tile may move to an adjacent empty cell with a cost of 1.
• A tile may hop over at most two other tiles into an empty cell with a cost equal to the number of tiles hopped over.
• The goal of the puzzle is to have all of the white tiles to the left of all the black tiles (without regard to the position of the blank cell). There are many possible ideas for a heuristic. One could be #white tiles to right of leftmost black tile.

(a) Is the given heuristic admissable? Why or why not?

(b) Using the given heuristic, show the first set of generated nodes (from the initial configuration) produced by the A* algorithm.

#### 6. Hill Climbing Search (10 pts)

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.

You only need to expand through the first two sets of possible moves, compute the heuristic values, and use this information in your answer.

#### 7. Adversarial Search (10 pts)

Russell and Norvig, 5.9 b-e

#### 8. Adversarial Search with chance (10 pts)

Russell and Norvig, 5.16 a-c

#### 9. Constraint Representation (10 pts)

Russell and Norvig 6.2 a-c

#### 10. Constraint Satisfaction (10 pts)

Consider the following CSP. Let {A,B,C,D} be a set of variables. The domain of each variable is {1,2,3}. The constraints are: A=D, A ≠ B, C < D, and C < B.

We will solve this CSP using backtracking search and arc consistency. Run arc consistency (AC-3) as a preprocessor and after each variable assignment. When there is ambiguity as to which variable to assign next, assign a value to the variable that comes first lexicographically. Furthermore, when the next value to assign to a variable is ambiguous, break ties by assigning the earliest value first.

(a) What are the remaining domains after enforcing arc consistency on the initial CSP with no assignments?

(b) What are the remaining domains after assigning A = 2 and re-enforcing arc consistency?

(c) State a solution to the CSP.

(d) True / False: With arc consistency, we will never have to backtrack while solving a CSP.