Title: Constraint Satisfaction
1(No Transcript)
2(baby) Bio
- I am Patrick Prosser
- I am a senior lecturer at Glasgow
- I teach AF2 CP4
- I am a member of
- the algorithms group
- the apes (distributed, not disbanded)
- I am a Glaswegian
This is all that I am allowed to tell you
310 years of conflict-directed backjumping
4CI 9(4)Hybrid Algorithms for the Constraint
Satisfaction Problem
Patrick Prosser
- Still using that old greasy stuff?
- Who cares?
- So?
5(No Transcript)
6Plan of the talk
- Whats a csp?
- The simplest algorithm (BT) and its behaviour
- Some improvements (BJ, GBJ)
- A better way (CBJ)
- Improvements to CBJ
- Strange things about CBJ
- k-inconsistencies
- the bridge and the long jump
- value ordering and insolubility
- So, what about CBJ?
- some say its good
- some say its a waste of time
- whos using it
- whos not using
- Wheres it going
- QBF?
7Whats a csp?
ltV,D,Cgt
- a set of variables
- each with a domain of values
- a collection of constraints (Im going to assume
binary) - assign each variable a value from its domain to
satisfy the constraint
8Example of a csp
B
A
E
C
D
H
F
G
3 colour me!
9Example of a csp
B
A
E
C
D
H
F
G
10Example of a csp
Variables and Instantiation Order Checking back
Va Vb Vc Vd Ve Vf Vg Vh
1 red 2 blue 3 green
11Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
12Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
13Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
14Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
15Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
16Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
17Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
18Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
19Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
20Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
21Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
22Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
23Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
24Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
25Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
Why did it do that? That was dumb!
1 red 2 blue 3 green
26Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
27Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
28Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
29Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
30Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
31Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
32Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
33Example of a csp
Variables and Instantiation Order Checking back
B
A
Va Vb Vc Vd Ve Vf Vg Vh
E
C
D
H
F
G
1 red 2 blue 3 green
34That was good old fashioned chronological
backtracking
- instantiate a variable
- check current against past variables to see if
okay - current? past? Future?
- If not okay try another value
- If no values left go back to previous variable
35Example of a csp
What would have happened if we had the E
intermediate variables? i.e. it falls back on E4,
then E3, towards E?
B
A
E
C
D
E1
H
E2
F
G
E3
1 red 2 blue 3 green
E4
36Its all just depth first search, right?
37BT Thrashes!
past variable vh
past
conflict with vh
current variable vi
future
future variable vj
38BT
Assume that when we instantiate the current
variable vi we check against all past variables
from v1 to vi-1 to check if consistent
consistent false for x in domaini while
not(consistent) // find a consistent
value begin consistent true vi x
for h in (1 .. i-1) while consistent //
check backwards begin consistent
(check(vi,vh) end if not(consistent)
then delete(x,domaini) end
// did we find a
good value?
39John Gaschnigs BJ
Make a small modification to BT. Remember the
last variable we check against
consistent false maxChecki 0 for x in
domaini while not(consistent) // find a
consistent value begin consistent true
vi x for h in (1 .. i-1) while consistent
// check backwards begin consistent
(check(vi,vh) maxCheck
max(h,maxChecki) end if not(consistent)
then delete(x,domaini) end
// did we find a
good value?
If the loop terminates with consistent false then
jump back to vh, where h lastChecki This
is then the deepest variable we failed against
40John Gaschnigs BJ
consistent false maxChecki 0 for x in
domaini while not(consistent) // find a
consistent value begin consistent true
vi x for h in (1 .. i-1) while consistent
// check backwards begin consistent
(check(vi,vh) maxCheck
max(h,maxChecki) end if not(consistent)
then delete(x,domaini) end
// did we find a
good value?
If the loop terminates with consistent true
... lastChecki i-1 we then step back!
BJ jumps then steps back. It can only jump after
it has moved forwards!
41BJ reduces thrashing
maxChecki
0 1 2 3 4
1
2
3
4
5
4
6
Jump back to v4 then step back
42Rina Dechters GBJ
Graph-based backjumping, exploits topology of
constraint graph
If there are no values remaining for vi Jump
back to vh, where vh is the deepest variable
connected to vi in the constraint graph
If there are no values remaining for vh Jump
back to vg, where vg is the deepest variable
connected to vh or vi in the constraint graph
If there are no values remaining for vg Jump
back to vf, where vf is the deepest variable
connected to vg or vh or vi in the
constraint graph
What happens if constraint graph is a clique?
43We want something that can jump and jump
again, something that takes into consideration
what caused a dead-end, not something that just
looks at the topology of the constraint graph
Combine BJ and GBJ
44CBJ
Remember your conflicts, and when you have used
them forget them.
- When we instantiate vi x and
- check(vi,vh) and
- it fails
- vi is in conflict with vh
- add h to the set confSeti
confSeti is then the set of past variables that
conflict with values in the domain of vi
45CBJ
Conflict-directed backjumping, exploits failures
within the search process
If there are no values remaining for vi Jump
back to vh, where vh is the deepest variable
in conflict with vi The hope re-instantiate
vh will allow us to find a good value for vi
If there are no values remaining for vh Jump
back to vg, where vg is the deepest variable
in conflict with vi or vh The hope
re-instantiate vg will allow us to find a good
value for vi or a good value for
vh that will be good for vi
If there are no values remaining for vg Jump
back to vf, where vf is the deepest variable
in conflict with vi or vh or vg The hope
re-instantiate vf will allow us to find a good
value for vi or a good value for
vh that will be good for vi or a
good value for vg that will be good for vh
and vi
What happens if constraint graph is dense,
tight, or highly consistent?
46CBJ
consistent false confSeti 0 for x in
domaini while not(consistent) // find a
consistent value begin consistent true
vi x for h in (1 .. i-1) while consistent
// check backwards begin consistent
(check(vi,vh) if not(consistent) then
confSeti confSeti ? h end if
not(consistent) then delete(x,domaini) end
47CBJ
When jumping back from vi to vh update
conflict sets
confSeth confSeth ? confSeti \
h confSeti 0
That is, when we jump back from vh jump back to
a variable that is in conflict with vh or with
vi Throw away everything you new on
vi Reset all variables from vh1 to vi
(i.e. domain and confSet)
48CBJ
1
2
conflict set
3
4
2,0
5
4,1,0
6
49CBJ
1
2
conflict set
3
4
2,1,0
5
6
50CBJ (reduce thrashing)
1
2
3
4
2,1,0
5
6
Jump back to deepest past variable in confSet
(call it h) and then combine confSeti with
confSeth
- History
- Konkrat and V Beek,
- Gent and Underwood
51Forward Checking
1
2
3
NOTE arrows go forward!
4
5
6
7
8
9
521
2
3
4
5
Forward Checking Can Thrash
6
7
8
9
53Check Forwards, Jump Back!
1
2
- There are no values in cd6 compatible with v9
- get more values into cd9 (undo v1?) OR
- get more values into cd6 (undo v4)
- and if that doesnt work?
- undo v3 so cd4 gets value compatible with
- cd6 that is then compatible with cd9
3
4
5
6
7
8
9
54CBJ Variants
BM-CBJ, FC-CBJ, MAC-CBJ
55CBJ DkC
If we jump from vi to vh and confSeti
0,h then remove value(vh) from
domain(h) value(vh) is 2-inconsistent wrt vi
If we jump from vh to vg and confSeth
0,g then remove value(vg) from
domain(g) value(vg) is 3-inconsistent wrt vi
and vh
If we jump from vg to vf and confSetg
0,f then remove value(vf) from
domain(f) value(vf) is 4-inconsistent wrt vi
and vh and vg
What happens if the problem is highly
consistent? See JAIR 14 2001, Xinguang Chen
Peter van Beek
56CBJ ATMS
If we jump from vi to vg and confSeth ? 0
.. g-1 then do NOT reset domain(h) and
do NOT reset confSet(h)
Consider the past variables as assumptions and
confSeti as an explanation
Down side, we have more work to do. This is a
kind of learning (what kind?)
57CBJ DB
confSetx,i gives the past variable in conflict
with vi x
Finer grained on jumping back we can deduce
better what values to return to domains
Down side, we have more work to do. This is an
algorithm between CBJ and DB
58The bridge and the long jump
Funny things about cbj
59Funny things about cbj
Value ordering on insoluble problems can have an
effect
Problem V1 to V7, each with domain A,B
nogoods (1A,7A),(3A,7B),(5A,7B),(6A,7A),(6
A,7B),(6B,7A),(6B,7B)
Var Val confSet V1 A V2 A V3 A V4
A V5 A V6 A V7 A/B 1,3
Var Val confSet V1 A V2 A V3 B V4
A V5 A V6 A V7 A/B 1,5
Var Val confSet V1 A V2 A V3 B V4
A V5 B V6 A V7 A/B 6
Var Val confSet V1 A V2 A V3 B V4
A V5 B V6 B V7 A/B 6
Finally V6 has no values and cbj jumps to V0
60Funny things about cbj
Value ordering on insoluble problems can have an
effect
Problem V1 to V7, each with domain A,B
nogoods (1A,7A),(3A,7B),(5A,7B),(6A,7A),(6
A,7B),(6B,7A),(6B,7B)
We now order domains and choose B then A!
Var Val confSet V1 B V2 B V3 B V4
B V5 B V6 B V7 A/B 6
Var Val confSet V1 B V2 B V3 B V4
B V5 B V6 A V7 A/B 6
Finally V6 has no values and cbj jumps to V0
Value ordering made a difference to an insoluble
problem!
61Conflicting claims
Smith Grant IJCAI95 CBJ helps minimise
occurrence of EHPs random problems as evidence
Bessier Regin CP96 CBJ is nothing but an
overhead random problems as evidence
Chen van Beek JAIR 2001 CBJ is a tiny
overhead When it makes a difference it is a
HUGE difference random real problems as
evidence
62New CBJ
I believe all state of the art sat solvers are
using cbj (or have rediscovered cbj but dont
know it)
CBJ for QSAT see recent AIJ conflict and
solution directed!
63Who is not using cbj?
Constraint programming! We dont jump and we
dont learn
64Is speed everything?
No How about explanations and retraction?
65Why is cbj not in CP?
Need to propagate laterally (see MAC-CBJ tech
report) but this is no big deal
Need to get explanations out of constraints! Not
just writing a good constraint propagator but a
good constraint explainer!
Maybe there is not yet the demand for retraction
and explanation (but I dont believe that)
66So?
- Paper rejected from IJCAI91 (written in 1990)
- I was a Lisp programmer at the time (it shows)
- I think the experiments were very good (so
there!) - Nice study of influence of topological parameter
on search cost. - In conclusion I forgot to say CBJ was new why?
- I like BMJ, it is cool (I was smart for 1 day)
- I think CBJ is pretty (natural, discovered, not
invented) - I like FC-CBJ (I can understand it)
- I identify work to be done (researchers love
that (why?)) - and I make errors re-dvos (researchers love
that (why?)) - I put my results in perspective (trash them )
- I got encouragement (Nadel) and help (Ole and
Peter) - I got a whole load of background (Rina)
- But it hurt why did it take 3 years to get
somebody to read it? - It is still alive! We are not done yet.
67(No Transcript)