This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS221 Lecture notes #4 Constraint satisfaction problems (CSP) In the previous set of notes, we discussed the application of local search algorithms to problems such TSP, 8queens and SAT. In those problems, we were interested in finding a solution, but we didn’t care how we get to a good state. Greedy hillclimbing search is an effective algorithm for these problems, but for a subset of them, we will be able to devise more efficient search algorithms, ones that rely on our making explicit more of the structure in the problem. Recall that by incorporating a heuristic function, we converted uniform cost search into a much better algorithm, A ∗ . The heuristic function was a way to convey information about the problem to the algorithm, so that A ∗ could reason about what nodes it could skip expanding, and still guaran tee finding an optimal solution. That reasoning process was an example of inference . In today’s lecture, we’ll describe a formalism that makes more of the structure of certain search problems explicit to the search algorithm, so that it can reason more “deeply” into the problem and perform deeper inference regarding the space of solutions. Specifically, we will describe constraint satisfaction problems (CSP) , where the goal is to find assignments to a set of variables, so that the assignments satisfy a certain set of constraints. The CSP problem specification will allow us to do inference to prune off huge portions of the search space which would have been explored by simpler algorithms such as blind search. In some cases, it will also help us to choose the most promising areas of the state space to explore first. 1 2 (a) (b) Figure 1: (a) A map which we want to color using only three colors, with no two adjacent countries sharing the same color. (b) A portion of the search tree if we attempt to solve the problem using naive depthfirst search. Note that the search continues down the left hand side even though the color constraint is already violated after just two steps. 1 Problem Definition First, a motivating example. Consider the problem of coloring the map in Figure 1 with no more than three colors, such that no two adjacent countries share the same color. How might we solve this problem naively using depth first search? We define a variable C i for each region, which can take values in the set { red, green, blue } . The states will be partial assignments of values (colors) to the variables. The operator takes the next uncolored region, and colors it. The goal test takes a full assignment of colors to all of the countries and checks if all pairs of adjacent countries have different colors. What happens when we apply naive depth first search (DFS) using this formalism? Part of the search tree is shown in Figure 1. The algorithm first proceeds down the lefthand side of the search tree, assuming the first operator is to color the next country red. Therefore, it immediately colors countries 1 and 2 red. This seems silly to us, because we know there can’tcountries 1 and 2 red....
View
Full
Document
This note was uploaded on 10/30/2009 for the course CS 221 at Stanford.
 '09
 KOLLER,NG
 Algorithms

Click to edit the document details