0% found this document useful (0 votes)
10 views20 pages

AI Unit 2 CSP

The document explains Constraint Satisfaction Problems (CSP), which consist of variables, domains, and constraints, allowing for efficient problem-solving by eliminating portions of the search space. It describes how a CSP is defined and solved, emphasizing the need for consistent and complete assignments. An example of map coloring is provided to illustrate the application of CSP, where regions must be colored such that no neighboring regions share the same color.

Uploaded by

Aisha Sarkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views20 pages

AI Unit 2 CSP

The document explains Constraint Satisfaction Problems (CSP), which consist of variables, domains, and constraints, allowing for efficient problem-solving by eliminating portions of the search space. It describes how a CSP is defined and solved, emphasizing the need for consistent and complete assignments. An example of map coloring is provided to illustrate the application of CSP, where regions must be colored such that no neighboring regions share the same color.

Uploaded by

Aisha Sarkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

COSTRAINT

SATISFACTION
PROBLEMS
COSTRAINT SATISFACTION PROBLEMS
Previous Search Problems:

• problems can be solved by searching in a space of states. These states can be evaluated by domain-specific
heuristics and tested to see whether they are goal states

• From the point of view of the search algorithm, however, each state is atomic, or indivisible—a black box with
no internal structure

CSP:

• CSP describes a way to solve a wide variety of problems more efficiently. We use a factored representation
for each state: a set of variables, each of which has a value

• Here, a problem is solved when each variable has a value that satisfies all the constraints on the variable

• A problem described this way is called a constraint satisfaction problem, or CSP.

• CSP search algorithms take advantage of the structure of states and use general-purpose rather than problem-
specific heuristics to enable the solution of complex problems.

• The main idea is to eliminate large portions of the search space all at once by identifying variable/value
combinations that violate the constraints
DEFINING CONSTRAINT SATISFACTION PROBLEMS
A constraint satisfaction problem consists of three components, X, D, and C:

• X is a set of variables, {X1,... , Xn}, with values from Domain D

• D is a set of domains, {D1,... , Dn}. Each domain Di consists of a set of allowable values, {v1,... , vk} for
variable Xi

• C is a set of constraints that specify allowable combinations of values.

• A relation can be represented as an explicit list of all tuples of values that satisfy the constraint, or as an
abstract relation that supports two operations: testing if a tuple is a member of the relation and enumerating
the members of the relation.
SOLUTION
• To solve a CSP, we need to define a state space and the notion of a solution.

• Each state in a CSP is defined by an assignment of values to some or all of the


variables, {Xi = vi, Xj = vj,.. .}

• An assignment that does not violate any constraints is called a consistent or legal
assignment.

• A complete assignment is one in which every variable is assigned. A partial


assignment is one that assigns values to only some of the variables.

• a solution to a CSP is a consistent, complete


assignment.
P
Example problem: Map coloring
• We are looking at a map of Australia showing each of its states and territories

• We are given the task of coloring each region either red, green, or blue in such a way that no neighboring
regions have the same color.

• To formulate this as a CSP, we define the variables to be the regions


X = {WA, NT , Q, NSW , V, SA,T }

• The domain of each variable is the set Di = {red , green , blue}.

• The constraints require neighboring regions to have distinct colors. Since there are nine places where regions
border, there are nine constraints:
C = {SA ≠ WA, SA ≠ NT , SA ≠ Q, SA ≠ NSW , SA ≠ V, WA ≠ NT , NT ≠ Q, Q ≠ NSW , NSW ≠ V }
Solution (cont.)

• Here we are using abbreviations; SA ≠ WA is a shortcut for ((SA, WA), SA ≠ WA), where SA ≠ WA can be
fully enumerated in turn as {(red , green), (red , blue), (green , red ), (green , blue), (blue, red ), (blue,
green)}

• There are many possible solutions to this problem, such as {WA = red , NT = green ,Q = red , NSW =
green ,V = red , SA = blue, T = red }
CSP EXAMPLE 2

You might also like