Title: Constraint Satisfaction
1Constraint Satisfaction
R N Chapter 5
2Constraint Satisfaction Early Use
From http//www-2.cs.cmu.edu/awm/731/constraint07
-2x2.pdf
3The Waltz Algorithm
4More on Waltz Algorithm
The constraints come from the fact that a line
must have the same label at both ends.
5Crossword Puzzles
6Latin Squares
Using only the numbers 1, 2, 3, and 4, arrange
four sets of these numbers into a four-by-four
array so that no column or row contains the same
two numbers. The result is known as a Latin
square. Here are two examples of Latin squares of
order 4
1 2 3 4 2 1 4 3 3 4 1 2 4 3 2 1
1 2 3 4 3 4 1 2 4 3 2 1 2 1 4 3
http//www.sciencenews.org/20000506/mathtrek.asp
7Satisfiability
(P ? Q ? ?S) ? (A ? ? Q ? B) ? (P ? ? B ? ?C)
? (? A ? B ? C) ? (Q ? ?A ? ?C) Example
applications
8Real Examples
Scheduling What else?
9Algorithms for CSPs
- Branching
- State space usually incremental formulation
- Straight line
- State space usually complete-state formulation
10Cryptarithmetic
SEND MORE MONEY
PEAS description
- State space when formulated as a CSP variables,
domain, constraints - Incremental state space formulation
- Complete state formulation
11Cryptarithmetic
SEND MORE MONEY
Representing the constraints As formulas As a
graph Using special constraints Alldiff
12Cryptarithmetic Best First Search
SEND MORE MONEY
M 1
M 2
M 2
13Cryptarithmetic Best First Search
SEND MORE MONEY
M 1
M 2
M 2
M 1 S 2 O 3
14Cryptarithmetic Branching Algorithms
- Backtracking
- Minimum remaining values
- Degree heuristic
- Least-constraining value
SEND MORE MONEY
M 1
M 2
M 2
15Cryptarithmetic Constraint Propagation
Forward checking After assigning a value to a
variable X, look at all the variables connected
to X and prune inconsistent values. Constraint
propagation using arc consistency The
tradeoff how much time to spend propagating vs.
searching.
SEND MORE MONEY
16Backtracking Chronological vs. Dependency
Directed
17Straight-Line Algorithms Min-Conflicts
function Min-Conflicts(csp, max_steps) returns a
solution or failure inputs csp, a constraint
satisfaction problem max_steps, the number of
steps allowed before giving up current ? an
initial assignment for csp for i 1 to
max_steps do if current is a solution for csp
then return current var ? a randomly chosen,
conflicted variable from Variablescsp value
? the value v for var that minimizes
Conflicts(var, v, current, csp) set var
value in current return failure
18Do Straight-Line Algorithms Work?
Does Min-Conflicts work?
From http//www.cs.mu.oz.au/303/slides/week03ah.p
df
19Do Straight-Line Algorithms Work?
20Another Win of Straight Line Algorithms
They can be used to perturb a solution that
ceases to be correct Most scheduling problems