0% found this document useful (0 votes)
27 views

Name: R.Viswaesvaran - Class: 11a - Sns Academy

CSPs involve variables with domains of possible values and constraints on value combinations. Backtracking search assigns one variable per node but heuristics like most-constrained variable selection and forward checking help prune the search tree. Constraint propagation methods like arc consistency further reduce the search space by enforcing consistency between unassigned variables.

Uploaded by

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

Name: R.Viswaesvaran - Class: 11a - Sns Academy

CSPs involve variables with domains of possible values and constraints on value combinations. Backtracking search assigns one variable per node but heuristics like most-constrained variable selection and forward checking help prune the search tree. Constraint propagation methods like arc consistency further reduce the search space by enforcing consistency between unassigned variables.

Uploaded by

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

CONSTRAINT SATISFACTION

PROBLEM
• Name: R.Viswaesvaran
• Class: 11a
• SNS ACADEMY

1
Formal Definition of CSP
• A constraint satisfaction problem (CSP) is
a triple (V, D, C) where
– V is a set of variables X1, ... , Xn.
– D is the union of a set of domain sets D1,...,Dn,
where Di is the domain of possible values for
variable Xi.
– C is a set of constraints on the values of the
variables, which can be pairwise (simplest and
most common) or k at a time.
2
CSPs vs. Standard Search Problems

• Standard search problem:


– state is a "black box“ – any data structure that supports
successor function, heuristic function, and goal test
• CSP:
– state is defined by variables Xi with values from domain Di
– goal test is a set of constraints specifying allowable
combinations of values for subsets of variables




– 3
Constraint graph
• Binary CSP: each constraint relates two variables
• Constraint graph: nodes are variables, arcs are
constraints

4
Varieties of constraints
• Unary constraints involve a single variable,
– e.g., SA ≠ green

• Binary constraints involve pairs of variables,


– e.g., value(SA) ≠ value(WA)

• Higher-order constraints involve 3 or more


variables,
– e.g., cryptarithmetic column constraints


5

Real-world CSPs
• Assignment problems
– e.g., who teaches what class
• Timetabling problems
– e.g., which class is offered when and where?
• Transportation scheduling
• Factory scheduling




• 6
The Consistent Labeling Problem

• Let P = (V,D,C) be a constraint satisfaction problem.

• An assignment is a partial function f : V -> D that assigns


a value (from the appropriate domain) to each variable

• A consistent assignment or consistent labeling is an


assignment f that satisfies all the constraints.

• A complete consistent labeling is a consistent labeling


in which every variable has a value.

7
Standard Search Formulation

• state: (partial) assignment


• initial state: the empty assignment { }
• successor function: assign a value to an unassigned variable
that does not conflict with current assignment
 fail if no legal assignments
• goal test: the current assignment is complete
(and is a consistent labeling)

1. This is the same for all CSPs regardless of application.

2. Every solution appears at depth n with n variables


 we can use depth-first search.

3. Path is irrelevant, so we can also use complete-state formulation.


– 8
What Kinds of Algorithms are used for CSP?

• Backtracking Tree Search

• Tree Search with Forward Checking

• Tree Search with Discrete Relaxation (arc consistency,


k-consistency)

• Many other variants

• Local Search using Complete State Formulation

9
Backtracking Tree Search

• Variable assignments are commutative}, i.e.,


[ WA = red then NT = green ] same as [ NT = green then WA = red ]

• Only need to consider assignments to a single variable at each node.

• Depth-first search for CSPs with single-variable assignments is called


backtracking search.

• Backtracking search is the basic uninformed algorithm for CSPs.

• Can solve n-queens for n ≈ 25.



10
Improving Backtracking Efficiency
• General-purpose methods can give huge
gains in speed:
– Which variable should be assigned next?
– In what order should its values be tried?
– Can we detect inevitable failure early?



• 11
Most Constrained Variable
• Most constrained variable:
choose the variable with the fewest legal values

• a.k.a. minimum remaining values (MRV)


heuristic


12
Most Constraining Variable
• Tie-breaker among most constrained
variables
• Most constraining variable:
– choose the variable with the most constraints
on remaining variables

13
Least Constraining Value
• Given a variable, choose the least
constraining value:
– the one that rules out the fewest values in the
remaining variables
• Combining these heuristics makes 1000
queens feasible

• 14
Forward Checking
Forward checking is based on the idea that
once variable ui is assigned a value v,
then certain future variable-value pairs (uj,v’)
become impossible.

ui,v)

uj,v’ uj,v’

15
Book’s Forward Checking Example
• Idea:
– Keep track of remaining legal values for unassigned variables
– Terminate search when any variable has no legal values

16
Forward Checking
• Idea:
– Keep track of remaining legal values for unassigned variables
– Terminate search when any variable has no legal values

17
Constraint Propagation
• Forward checking propagates information from assigned
to unassigned variables, but doesn't provide early
detection for all failures:

• NT and SA cannot both be blue!



• 18
Arc Consistency
• Simplest form of propagation makes each arc consistent
• X Y is consistent iff
for every value x of X there is some allowed value y of Y


19
Comparison of Methods

• Backtracking tree search is a blind search.

• Forward checking checks constraints between the


current variable and all future ones.

• Arc consistency then checks constraints between


all pairs of future (unassigned) variables.

20
Local Search for CSPs
• Hill-climbing, simulated annealing typically work with
"complete" states, i.e., all variables assigned

• To apply to CSPs:
– allow states with unsatisfied constraints
– operators reassign variable values

• Variable selection: randomly select any conflicted


variable



– 21
Summary
• CSPs are a special kind of problem:
– states defined by values of a fixed set of variables
– goal test defined by constraints on variable values

• Backtracking = depth-first search with one variable assigned per


node

• Variable ordering and value selection heuristics help significantly

• Forward checking prevents assignments that guarantee later failure

• Constraint propagation (e.g., arc consistency) does additional work


to constrain values and detect inconsistencies

• Iterative min-conflicts is often effective in practice




22

You might also like