Title: Constraint Satisfaction: An Overview
1Principles of Intelligent SystemsConstraint
Satisfaction Local Search
Written by Dr John ThorntonSchool of IT,
Griffith University Gold Coast
2Outline
- The Constraint Satisfaction Paradigm
- Variables, Domains and Constraints
- Example Problem Domains
- Constraint Satisfaction Algorithms
- Local Search Algorithms
- Summary
3The Constraint Satisfaction Paradigm
- Knowledge represented by constraints
- What is allowed or disallowed.
- Transforms broad range of problems into a
computable form - Standard representation means general purpose
algorithms can be used - solvers know how to solve problems
- issue becomes how to model a problem
4Variables, Domains and Constraints
- A Constraint Satisfaction Problem (CSP) is
- a set of variables each with
- a set of domain of values, and
- a set of constraints that define which
combinations of variable values are allowed - the task is to find a domain value for each
variable such that all constraints are
simultaneously satisfied
5Problem Domains
- N-Queens
- Satisfiability Problems
- Binary Constraint Satisfaction
- Nurse Rostering
- University Timetabling
6Local Search Algorithms
- Getting stuck
- Variable and Constraint-based Search
- Random Walk
- Tabu Search
- NOVELTY and RNOVELTY
- Constraint Weighting
7Satisfiability Problems
- Conjunctive Normal Form Example
- ?x Ú ?y Ú ?z Ù x Ú y Ú ?z Ù ?x Ú y Ù ?y Ú
z - To Solve
- All clauses evaluate true
- e.g. x false, y true, z true
- As a CSP
- Each clause is a constraint, each literal is a
variable with a true, false domain
8Predicate to Conjunctive Form
- Predicate ?(X) (dog (X) ? animal (X))
- Clause (? dog(X) Ú animal(X))
- Clause is false only if ? dog(X) is false and
animal(X) is false, i.e. if X is a dog and X is
not an animal - in other words if X is a dog then
X is an animal
9Binary Constraint Satisfaction
- Two variable constraint representation
- Non-binary to binary transformation
- Phase transition
- p2crit 1 - m-2/p1(n - 1)
- where p1 constraint density
- p2 constraint tightness
- m uniform domain size
- n number of variables
-
10Nurse Scheduling
11Binary Constraint Representation
Variable 1
0 1 2 3 4
0
1
Variable 2
2
3
12Random Walk Local Search
- if randomly generated probability lt p
- Take best cost local move
- else
- Take randomly selected local move
13Tabu Search
- if cost(best local move) lt best cost yet
- Take best local move
- else
- Take best cost local move from the set of domain
values that have not been used in the last n moves
14The Eight Queens Problem
Domain
Variable
Constraint
15Constraint Satisfaction Algorithms
- Backtracking
- Algorithm
- 8-Queens Example
- 8-Queens Performance
- Local Search
- Algorithm
- 8-Queens Example
- 8-Queens Performance
16Summary
- Constraint Satisfaction
- practical knowledge representation
- allows general purpose approaches
- Algorithms
- Backtracking
- Local Search
17Backtracking Algorithm
V list of all variables vi (i 1 to n) U
empty TryVariable() select next vi from V and
move to U for each domain value di of vi if di
satisfies all constraints with U Value(vi)
di if(V is empty) SaveSolution() else
TryVariable() move vi from U back to V
18Basic Local Search Algorithm
assign a domain value di to each variable
vi while no solution and not stuck and not timed
out bestCost ? ? bestList ? ? for each
variable vi Cost(Value(vi)) gt 0 for each
domain value di of vi if Cost(di) lt bestCost
bestCost ? Cost(di) bestList ? di
else if Cost(di) bestCost bestList ?
bestList ? di Take a randomly selected move from
bestList
19Backtracking Performance
20Local Search Performance
21Local Search Diagram
22Eight Queens using Backtracking
23Eight Queens using Local Search
24Variable/Constraint-based Search
- Variable-based search
- Randomly select variable in constraint violation
- Try all domain values for that variable
- Constraint-based search
- Randomly select a violated constraint
- Try all domain values for all variables in the
constraint that improve the constraint
25NOVELTY
- select best and second best cost moves that
improve a violated constraint - if best cost move not most recent or p gt random
value - select best cost move
- else
- select second best cost move
26RNOVELTY
- Same as NOVELTY except when best cost move is
also most recent, then - if second best cost - best cost lt c or p lt
random value - select second best cost move
- else
- select best cost move
27Constraint Weighting
- Add weight to all constraints violated at a local
minimum graph colouring example - Use these weights to calculate cost of subsequent
moves - Adding weights changes shape of cost surface
fills in the minimum
28Constraint Weighting Example
(a) Local minimum, cost 2w (b) After
Weighting, cost 3w (c) Final solution,
cost w