0% found this document useful (0 votes)
13 views14 pages

Lecture 22 CSP

Uploaded by

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

Lecture 22 CSP

Uploaded by

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

ITEC4119-Artificial Intelligence

Lecture 22
Constraint satisfaction problem
Muhammad Umar Farooq
Constraint satisfaction problem
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.
Summary of Previous lectures
• Problem solving
• Problem solving by search
– Uninformed search methods
– Informed search methods
– Local search methods
• Adversarial search
– Min max algorithm
– Alpha beta pruning
Note: for every new topic we are trying to solve our
problem in less time or more intelligent way
Constraint satisfaction problem
• A constraint satisfaction problem consists of
three components, X,D, and C:
• X is a set of variables, {X1, . . . ,Xn}.
• D is a set of domains, {D1, . . . ,Dn}, one for
each variable.
• C is a set of constraints that specify allowable
combinations of values.
Constraint satisfaction problem
• Each domain Di consists of a set of allowable
values, {v1, . . . , vk} for variable Xi.
– Values are finite and discrete
• Constraint Ci consists of a pair <scope, rel>
– where scope is a tuple of variables that participate
in the constraint
– rel is a relation that defines the values that those
variables can take on
Constraint satisfaction problem
• For example, if X1 and X2 both have the
domain {A,B}, then the constraint saying the
two variables must have different values can
be written as < (X1,X2), [(A,B), (B,A)]> or as
<(X1,X2),X1≠X2>.
• A relation can be represented as an explicit list
of all tuples of values that satisfy the
constraint,
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 } .
Map coloring
• 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)} .
Map coloring Solution
• There are many possible solutions to this
problem, such as
– {WA=red, NT =green, Q=red, NSW =green, V =red
,SA=blue, T =red }.
• We have chosen {SA=blue} none of the five
neighboring variables can take on the value
blue.
Map coloring Solution
Advantage of CSP
• CSP solvers can be faster than state-space
searchers because the CSP solver can quickly
eliminate large swatches of the search space
• Without taking advantage of constraint
propagation, a search procedure would have to
consider 35 =243 assignments for the five
neighboring variables;
• with constraint propagation we never have to
consider blue as a value, so we have only 25 =32
assignments to look at, a reduction of 87%.
Thank you

Any question ?

You might also like