Unit 2.1
Unit 2.1
Constraint
Satisfaction
Problems
Introduction
• We have seen the 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.
• In this method we are going to use a factored representation for
each state: a set of variables, each of which has a value.
• 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.
4
Example problem: Map coloring
Example problem: Map coloring
• 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 } .
• There are many possible solutions to this problem, such as
• {WA=red ,NT =green,Q=red ,NSW =green, V =red ,SA=blue, T =red }.
• It can be visualized as a constraint graph.
• The nodes of the graph correspond to variables of the problem, and
a link connects any two variables that participate in a constraint.
Cryptarithmetic Puzzles
• A constraint involving an arbitrary number of variables is called a
global constraint.
• One of the most common global constraints is Alldiff , which says
that all of the variables involved in the constraint must have
different values.
• Each letter in a cryptarithmetic puzzle represents a different digit.
• This can be represented as the global constraint
Alldiff (F, T,U,W,R,O).
• These constraints can be represented in a constraint hypergraph.
• A hypergraph consists of ordinary nodes
• (the circles) and hypernodes (the squares), which represent n-ary
constraints.
Cryptarithmetic Puzzles
The addition constraints on the four columns of the puzzle
can be written as the following n-ary constraints:
e.g. We can delete SA from the graph by fixing a value for SA and deleting
from the domains of other variables any values that are inconsistent with
the value chosen for SA.
The Structure of Problem
• The general algorithm:
• Choose a subset S of the CSP’s variables such that the constraint
graph becomes a tree after removal of S. S is called a cycle cutset.
• For each possible assignment to the variables in S that satisfies all
constraints on S,
• (a) remove from the domain of the remaining variables any values
that are inconsistent with the assignment for S, and
• (b) If the remaining CSP has a solution, return it together with the
assignment for S.
• Time complexity: O(dc·(n-c)d2), c is the size of the cycle cut set.
• Cutset conditioning: The overall algorithmic approach of efficient
approximation algorithms to find the smallest cycle cutset.
The Structure of Problem
• 2. Based on collapsing nodes together
• Tree decomposition: construct a tree decomposition of the constraint
graph into a set of connected subproblems, each subproblem is solved
independently, and the resulting solutions are then combined.
The Structure of Problem
• A tree decomposition must satisfy three requirements:
Every variable in the original problem appears in at least one of
the subproblems.
If two variables are connected by a constraint in the original
problem, they must appear together (along with the constraint) in
at least one of the subproblems.
If a variable appears in two subproblems in the tree, it must
appear in every subproblem along the path connecting those
those subproblems.
The Structure of Problem
• Each subproblem can be solved independently.
• If any one has no solution, the entire problem has no solution.
• If all the subproblems can be solved, then a global solution can be
constructed as follows. First, each subproblem can be viewed as a
mega-variable whose domain is the set of all solutions for the
subproblem.
• A given constraint graph declares many tree decompositions; in
choosing a decomposition, the aim is to make the subproblems as
small as possible.
• The tree width of a tree decomposition of a graph is one less than
the size of the largest subproblems.
• The tree width of the graph itself is the minimum tree width
among all its tree decompositions.
• Time complexity: O(ndw+1), w is the tree width of the graph.