Pond processes - Griffith Research Online - Griffith University
Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton...
-
Upload
kathryn-montgomery -
Category
Documents
-
view
212 -
download
0
Transcript of Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton...
![Page 1: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/1.jpg)
Principles of Intelligent SystemsConstraint Satisfaction + Local Search
Written by Dr John ThorntonSchool of IT, Griffith University Gold Coast
![Page 2: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/2.jpg)
Outline
The Constraint Satisfaction Paradigm Variables, Domains and Constraints Example Problem Domains Constraint Satisfaction Algorithms
Local Search Algorithms Summary
![Page 3: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/3.jpg)
The 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
![Page 4: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/4.jpg)
Variables, 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
![Page 5: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/5.jpg)
Problem Domains
N-Queens Satisfiability Problems Binary Constraint Satisfaction Nurse Rostering University Timetabling
![Page 6: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/6.jpg)
Local Search Algorithms
Getting ‘stuck’ Variable and Constraint-based Search Random Walk Tabu Search
NOVELTY and RNOVELTY Constraint Weighting
![Page 7: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/7.jpg)
Satisfiability 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
![Page 8: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/8.jpg)
Predicate 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
![Page 9: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/9.jpg)
Binary 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
![Page 10: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/10.jpg)
Nurse Scheduling
![Page 11: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/11.jpg)
Binary Constraint Representation
0 1 0 0 1
1 1 1 0 1
1 0 0 1 0
0 0 1 1 0
Variable 1
Variable 2
0 1 2 3 4
0
1
2
3
![Page 12: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/12.jpg)
Random Walk Local Search
if randomly generated probability < p: Take best cost local move
else: Take randomly selected local move
![Page 13: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/13.jpg)
Tabu Search
if cost(best local move) < 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
![Page 14: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/14.jpg)
The Eight Queens Problem
Variable
Constraint
Domain
![Page 15: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/15.jpg)
Constraint Satisfaction Algorithms
Backtracking Algorithm 8-Queens Example 8-Queens Performance
Local Search Algorithm 8-Queens Example 8-Queens Performance
![Page 16: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/16.jpg)
Summary
Constraint Satisfaction practical knowledge representation allows general purpose approaches
Algorithms Backtracking Local Search
![Page 17: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/17.jpg)
Backtracking Algorithm
V = list of all variables vi (i = 1 to n)U = emptyTryVariable()
select next vi from V and move to Ufor each domain value di of vi
if di satisfies all constraints with UValue(vi) = di if(V is empty) SaveSolution()else TryVariable()
move vi from U back to V
![Page 18: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/18.jpg)
Basic Local Search Algorithm
assign a domain value di to each variable vi
while no solution and not stuck and not timed outbestCost ; bestList ;for each variable vi | Cost(Value(vi)) > 0
for each domain value di of vi
if Cost(di) < bestCost bestCost Cost(di); bestList di;
else if Cost(di) = bestCost bestList bestList di
Take a randomly selected move from bestList
![Page 19: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/19.jpg)
Backtracking Performance
0
1000
2000
3000
4000
5000
0 4 8 12 16 20 24 28 32
Number of Queens
Tim
e in
sec
onds
![Page 20: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/20.jpg)
Local Search Performance
0
500
1000
1500
2000
2500
0 5000 10000 15000 20000
Number of Queens
Tim
e in
sec
onds
![Page 21: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/21.jpg)
Local Search Diagram
![Page 22: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/22.jpg)
Eight Queens using Backtracking
Try Queen 1Try Queen 2Try Queen 3Try Queen 4Try Queen 5
Stuck!
Undo move
for Queen 5Try next value
for Queen 5
Still Stuck
Undo move
for Queen 5
no move left
Backtrack and
undo last move
for Queen 4
Try next value
for Queen 4
Try Queen 5Try Queen 6Try Queen 7
Stuck AgainUndo move
for Queen 7
and so on...
![Page 23: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/23.jpg)
Place 8 Queens
randomly on
the board
Eight Queens using Local Search
Pick a Queen:
Calculate cost
of each move3 1 054 111
Take least cost
move then try
another Queen
0 4 4 41 1 1 1
4 3 41 1 1 1 31
3 3 3 21 1 1 12
3 4 41 1 1 1 32
2 2 3 42 2 2 12
3 2 32 1 1 2 31
2 0 4 21 2 2 31
2 3 22 1 3 2 31
2 3 3 21 2 2 21
2 3 2 32 2 1 31
2 2 32 1 3 2 11
3 2 23 3 3 3 01
Answer Found
![Page 24: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/24.jpg)
Variable/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
![Page 25: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/25.jpg)
NOVELTY
select best and second best cost moves that improve a violated constraint
if best cost move not most recent or p >= random value select best cost move
else select second best cost move
![Page 26: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/26.jpg)
RNOVELTY
Same as NOVELTY except when best cost move is also most recent, then :
if second best cost - best cost <= c or p < random value select second best cost move
else select best cost move
![Page 27: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/27.jpg)
Constraint 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
![Page 28: Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.](https://reader036.fdocuments.us/reader036/viewer/2022070413/5697bf9a1a28abf838c92779/html5/thumbnails/28.jpg)
Constraint Weighting Example
Graph Colouring
a green
b green
c red
d green
cab = 2w
cac = 0 ccd = 0
cbd = w
cbc = 0 a green
b red
c red
d green
cab = 0
cac = 0 ccd = 0
cbd = 0
cbc = wa green
b green
c red
d red
cab = w
cac = 0 ccd = w
cbd = 0
cbc = 0
(a) Local minimum, cost 2w (b) After Weighting, cost 3w (c) Final solution, cost w