670 likes | 766 Views
(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. 10 years of conflict-directed backjumping.
E N D
(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
Patrick Prosser CI 9(4)Hybrid Algorithms for the Constraint Satisfaction Problem • Still using that old greasy stuff? • Who cares? • So?
Plan of the talk • What’s 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 it’s a waste of time • who’s using it • who’s not using • Where’s it going • QBF?
What’s a csp? <V,D,C> • a set of variables • each with a domain of values • a collection of constraints (I’m going to assume binary) • assign each variable a value from its domain to satisfy the constraint
Example of a csp A B E C D H F G 3 colour me!
Example of a csp A B E C D H F G
A B E C D H F G Example of a csp Variables and Instantiation Order Checking back Va Vb Vc Vd Ve Vf Vg Vh 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B 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
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
Example of a csp Variables and Instantiation Order Checking back A B Va Vb Vc Vd Ve Vf Vg Vh E C D H F G 1 = red 2 = blue 3 = green
That 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
Example 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? A B E C D E1 H E2 F G E3 1 = red 2 = blue 3 = green E4
BT Thrashes! past variable v[h] past conflict with v[h] current variable v[i] future future variable v[j]
BT Assume that when we instantiate the current variable v[i] we check against all past variables from v[1] to v[i-1] to check if consistent consistent := false for x in domain[i] while not(consistent) // find a consistent value begin consistent := true v[i] := x for h in (1 .. i-1) while consistent // check backwards begin consistent := (check(v[i],v[h]) end if not(consistent) then delete(x,domain[i]) end // did we find a good value?
John Gaschnig’s BJ Make a small modification to BT. Remember the last variable we check against consistent := false maxCheck[i] := 0 for x in domain[i] while not(consistent) // find a consistent value begin consistent := true v[i] := x for h in (1 .. i-1) while consistent // check backwards begin consistent := (check(v[i],v[h]) maxCheck := max(h,maxCheck[i]) end if not(consistent) then delete(x,domain[i]) end // did we find a good value? If the loop terminates with consistent false then jump back to v[h], where h := lastCheck[i] This is then the deepest variable we failed against
John Gaschnig’s BJ consistent := false maxCheck[i] := 0 for x in domain[i] while not(consistent) // find a consistent value begin consistent := true v[i] := x for h in (1 .. i-1) while consistent // check backwards begin consistent := (check(v[i],v[h]) maxCheck := max(h,maxCheck[i]) end if not(consistent) then delete(x,domain[i]) end // did we find a good value? If the loop terminates with consistent true ... lastCheck[i] = i-1 we then step back! BJ jumps then steps back. It can only jump after it has moved forwards!
BJ reduces thrashing maxCheck[i] 0 1 2 3 4 1 2 3 4 5 4 6 Jump back to v[4] then step back
Rina Dechter’s GBJ Graph-based backjumping, exploits topology of constraint graph If there are no values remaining for v[i] Jump back to v[h], where v[h] is the deepest variable connected to v[i] in the constraint graph If there are no values remaining for v[h] Jump back to v[g], where v[g] is the deepest variable connected to v[h] or v[i] in the constraint graph If there are no values remaining for v[g] Jump back to v[f], where v[f] is the deepest variable connected to v[g] or v[h] or v[i] in the constraint graph What happens if constraint graph is a clique?
We 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
CBJ Remember your conflicts, and when you have used them forget them. • When we instantiate v[i] := x and • check(v[i],v[h]) and • it fails • v[i] is in conflict with v[h] • add h to the set confSet[i] confSet[i] is then the set of past variables that conflict with values in the domain of v[i]
CBJ Conflict-directed backjumping, exploits failures within the search process If there are no values remaining for v[i] Jump back to v[h], where v[h] is the deepest variable in conflict with v[i] The hope: re-instantiate v[h] will allow us to find a good value for v[i] If there are no values remaining for v[h] Jump back to v[g], where v[g] is the deepest variable in conflict with v[i] or v[h] The hope: re-instantiate v[g] will allow us to find a good value for v[i] or a good value for v[h] that will be good for v[i] If there are no values remaining for v[g] Jump back to v[f], where v[f] is the deepest variable in conflict with v[i] or v[h] or v[g] The hope: re-instantiate v[f] will allow us to find a good value for v[i] or a good value for v[h] that will be good for v[i] or a good value for v[g] that will be good for v[h] and v[i] What happens if: constraint graph is dense, tight, or highly consistent?
CBJ consistent := false confSet[i] := {0} for x in domain[i] while not(consistent) // find a consistent value begin consistent := true v[i] := x for h in (1 .. i-1) while consistent // check backwards begin consistent := (check(v[i],v[h]) if not(consistent) then confSet[i] := confSet[i] {h} end if not(consistent) then delete(x,domain[i]) end
CBJ When jumping back from v[i] to v[h] update conflict sets confSet[h] := confSet[h] confSet[i] \ {h} confSet[i] := {0} That is, when we jump back from v[h] jump back to a variable that is in conflict with v[h] or with v[i] Throw away everything you new on v[i] Reset all variables from v[h+1] to v[i] (i.e. domain and confSet)
CBJ 1 2 conflict set 3 4 {2,0} 5 {4,1,0} 6
CBJ 1 2 conflict set 3 4 {2,1,0} 5 6
CBJ (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 confSet[i] with confSet[h] • History: • Konkrat and V Beek, • Gent and Underwood