0% found this document useful (0 votes)
105 views10 pages

Constraint Satisfaction Problems

The document discusses constraint satisfaction problems (CSPs). It defines a CSP as having a set of variables, domains of possible values for each variable, and constraints specifying allowed value combinations. CSPs can model problems like map coloring, where variables represent regions to color with constraints ensuring no adjacent regions share a color. Solving a CSP involves assigning values to variables while satisfying all constraints. Algorithms exploit CSP structure to prune large portions of the search space and efficiently find solutions.

Uploaded by

shikhar jain
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)
105 views10 pages

Constraint Satisfaction Problems

The document discusses constraint satisfaction problems (CSPs). It defines a CSP as having a set of variables, domains of possible values for each variable, and constraints specifying allowed value combinations. CSPs can model problems like map coloring, where variables represent regions to color with constraints ensuring no adjacent regions share a color. Solving a CSP involves assigning values to variables while satisfying all constraints. Algorithms exploit CSP structure to prune large portions of the search space and efficiently find solutions.

Uploaded by

shikhar jain
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/ 10

Constraint satisfaction

Problems
Constraint satisfaction Problems
• Till now we have seen that problems can be solved by searching in the
space of states
• We evaluate a state by defining a domain specific heuristic but each state is
atomic or indivisible
• CS strategy allows us to solve many problems more efficiently but we use a
factored representation for each state
• A state is defined by a set of variables and each of which has a value
• A problem is solved when each variable has a value such that it satisfies all
the constraints on the variable
• A problem described this way is called Constraint satisfaction Problem.
Constraint satisfaction Problems
• CSP algorithms take advantage of the structure of states
• The objective is to eliminate large portions of the search space all at
once by identifying variable/value combinations that violate the
constraints
Defining CSP
• A constraint satisfaction problem (or CSP) is defined by a set of variables, XI, X2,.
. . , Xn, and a set of constraints, C1, . . , Cn and a set of domains D1, D2…Dn.
• Each Domain Di consists of a set of allowable values{v1,v2…vn} for variable Xi
• Each Constraint Ci consists of a pair(scope, rel), where scope is a tuple of
variables which participate in the constraint and rel is a relation
• Relation defines the values that those variables can take on
• If the variables X1 and X2 both have domain{a,b}, then the constraint saying two
variables must have different values can be written as: <(X1,X2),[(a,b),(b,a)]> or
<(X1,X2),X1=! X2>
• Each step of solution of problem is defined by an assignment of values to some
or all of the variables.
• A solution to a CSP is a complete assignment that satisfies all the constraints.
Example: Graph Coloring problem
• Suppose we are looking at a map of Australia
• We are given the task of coloring each region either red, green or blue in
such a way that no two regions have the same color.
• we define the variables as : WA, NT, Q, NSW, V, SA, and T.
• The domain of each variable is: {red, green, blue).
• The constraints require neighboring regions to have distinct colors, so, the
allowable combinations for WA and NT are the pairs {(red, green), (red,
blue), (green, red), (green, blue), (blue, red), (blue, green)) .
• The constraint can also be represented as WA # NT
• There can be many possible solutions, such as: { WA= red, NT = green, Q =
red, NSW = green, V= red, SA= blue, T= red ).
Cont…
• A CSP can be formulated as an incremental standard search problem as
follows:
• Initial state: the empty assignment {), in which all variables are
unassigned.
• Successor function: a value can be assigned to any unassigned variable,
provided that it does not conflict with previously assigned variables.
• Goal test: the current assignment is complete.
• Path cost: a constant cost (e.g., 1) for every step.
• Every solution must be a complete assignment and therefore appears at
depth n if there are n variables.
• The search tree extends only to depth n and due to this depth first search
algorithms are popular for CSPs.
Cont..
• The simplest kind of CSP involves variables that are discrete and have finite
domains.
• Map-coloring problems and 8-queens problem are of this kind
• They can also be viewed as a finite-domain CSP.
• In 8-queens problem each queen is placed in columns 1, . . . ,8 and each row
variable has the domain {1,2,3,4,5,6,7,8).
• If the maximum domain size of any variable in a CSP is d, then the number of
possible complete assignments is O(d n )-that is, exponential in the number of
variables.
• Finite-domain CSPs include Boolean CSPs, whose variables can be either true or
false.
• Boolean CSPs include as special cases some NP-complete problems, such as 3SAT.
Cryptarithmetic puzzles
• One of the famous example of CSPs is cryptarithmetic puzzles.
• Each letter in a cryptarithmetic puzzle represents a different digit.
• TWO
• +TWO
• ------------------------------------------
• FOUR
• ----------------------------------------------- O +O = R +10.C10
• C10 + W +W = U + 10. C100
• C100 + T +T = O + 10. C1000
• C1000 = F

-
CSP formalism
• The simplest kind of CSP involves variables that have discrete, finite
domains
• Map coloring, job scheduling and 8 queen problems are of this kind
• A discrete domain can be infinite such as set of integers or strings
• With infinite domains like this, it is not possible to enumerate all
combinations of values.
• Mostly, constraints like T1+d1<=T2… are stated
• There are special solution algorithms for linear constraints on integer
variables(we do not discuss here) but no algo exists for nonlinear
constraints

You might also like