Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraint Satisfaction and the Davis-Putnam-Logeman-Loveland Procedure Henry Kautz.

Similar presentations


Presentation on theme: "Constraint Satisfaction and the Davis-Putnam-Logeman-Loveland Procedure Henry Kautz."— Presentation transcript:

1 Constraint Satisfaction and the Davis-Putnam-Logeman-Loveland Procedure Henry Kautz

2 Guessing versus Reasoning A central feature of all search algorithms is making guesses –Which node to expand? –Which child to explore? We can reduce the amount of guesswork by doing more reasoning about the consequences of past decisions –Reasoning about past choices can prune away many future choices

3 Discrete Constraint Satisfaction Problem X is a set of variables x1, x2, …, xn D is a set of finite domains D1, D2, …, Dn C is a set of constraints C1, C2, …, Cm Each constraint restricts the joint values of a subset of the variables Example: 3-Coloring Xi = countries Di = { Red, Blue, Green} For each adjacent xi, xj there is a constraint Ck (xi,xj)  { (R,G), (R,B), (G,R), (G,B), (B,R), (B,G) }

4 Kinds of Problems Find a solution that satisfies all constraints Find all solutions Find a “tightest form” for each constraint (x1,x2)  { (R,G), (R,B), (G,R), (G,B), (B,R), (B,G) }  (x1,x2)  { (R,G), (R,B) } Find a solution that minimizes some additional objective function

5 Chinese Dinner Constraint Network Soup Total Cost < $30 Chicken Dish Vegetable RiceSeafood Pork Dish Appetizer Must be Hot&Sour No Peanuts No Peanuts Not Eggplant Not Both Spicy What is the arity of each constraint?

6 Solving CSP by Depth-First Search Interleave inference and guessing At each internal node: –Select unassigned variable –Select a value in domain –Backtracking: try another value At each node: –Propagate Constraints Where are the guesses?

7 4 Queens Q4  {1,2,3,4} Q3  {1,2,3,4} Q2  {1,2,3,4} Q1  {1,2,3,4} Q Q Q Q Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

8 Constraint Checking Q Q x Qx x Qx xx Qxx Q x x Qx Q x xQ Qxx Qx xx xQx Qxxx Takes 5 guesses to determine first guess was wrong

9 Forward Checking x x x Qxxx xx Qxx xxx Qxxx Qxx xx xx Qxxx Qxx xxx xQx Qxxx Takes 3 guesses to determine first guess was wrong When variable is set, immediately remove inconsistent values from domains of other variables

10 Arc Consistency Iterated forward checking Q Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

11 Arc Consistency Reduce domain of Q1 x x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

12 Arc Consistency Reduce domain of Q2 x x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

13 Arc Consistency Reduce domain of Q3 x x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

14 Arc Consistency Reduce domain of Q4 x x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

15 Arc Consistency Note that Q3=2 is determined by (Q2,Q3) xx x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43

16 Arc Consistency Propagating Q3=2 eliminates all rows in (Q3,Q4) xx x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43 violated constraint!

17 Arc Consistency First choice Q1=1 shown bad with no further guessing! xx x x Qxxx Q1Q2 13 14 24 31 41 42 Q1Q3 12 14 21 23 32 34 41 43 Q1Q4 12 13 21 23 24 31 32 34 42 43 1 2 3 4 4 3 2 1 Q2Q3 13 14 24 31 41 42 Q4 13 14 24 31 41 42 Q2Q4 12 14 21 23 32 34 41 43 violated constraint!

18 Huffman-Clowes Labeling ++ + + + + -

19 Waltz’s Filtering: Arc- Consistency Lines: variables Conjunctions: constraints Initially Di = {+,-, ,  ) Repeat until no changes: Choose edge (variable) Delete labels on edge not consistent with both endpoints

20 No labeling!

21 Path Consistency Path consistency (3-consistency): –Iterated check of every triple of variables K-consistency: N-consistency: backtrack-free search

22 Variable and Value Selection Select variable with smallest domain –Minimize branching factor –Most likely to propagate, reduce guessing –Most constrained variable heuristic Which values to try first? –Most likely value for solution –Forward checking reduces fewest constraints –Least constrained value heuristic

23 CSP Applications Scheduling –NASA: Shuttle repair, Hubble telescope scheduling,... –College basketball scheduling Configuration –#5ESS Switching System: >200 options, highly complex interactions –Reduced configuration time from 2 months  2 hours

24 (Barry and Humblet 93, Cheung et al. 90, Green 92, Kumar et al. 99) CONFLICT FREE LATIN ROUTER Input ports Output ports 3 1 2 4 Input PortOutput Port 1 2 4 3 Router Design Dynamic wavelength router design: –each channel cannot be repeated in the same input port (row constraints); –each channel cannot be repeated in the same output port (column constraints);

25 SAT as a CSP Domain of all variables is {0, 1} Clauses are constraints – specify illegal combinations of values (A v B v ~C) rules out (A=0,B=0,C=1) ABC 100 101 110 111 010 011 000

26 Basic Backtrack Search for SAT Solve( F ): return Search(F, { }); Search( F, assigned ): if vars(F)=vars(assigned) then if evaluate(F, assigned) then return assigned; else return FALSE; choose unassigned variable x; returnSearch(F, assigned U {x=0}) || Search(F, assigned U {x=1}); end;

27 Propagating Constraints Suppose formula contains (A v B v ~C) and we set A=0. What is the resulting constraint on the remaining variables B and C? (B v ~C) Suppose instead we set A=1. What is the resulting constraint on B and C? No constraint

28 Empty Clauses and Formulas Suppose a clause in F is shortened until it become empty. What does this mean about F and the partial assignment? F cannot be satisfied by any way of completing the assignment; must backtrack Suppose all the clauses in F disappear. What does this mean? F is satisfied by any completion of the partial assignment

29 Arc Consistency for SAT Suppose a clause in F is shortened to contain a single literal, such as (A) What should you do? Immediately add the literal to assigned, and repeat constraint propagation Arc consistency for SAT is called unit propagation

30 DPLL DPLL( F, assigned ): while F has a unit clause (c) do assigned = assigned U {c}; shorten clauses containing ~c; delete clauses containing c; end if F is empty then return assigned; if F contains an empty clause then return FALSE; choose an unassigned literal c; // variable and initial value returnSearch(F U { (c) }, assigned) || Search(F U { (~c) }, assigned); end;

31 I.e., ((not x_1) or x_7) ((not x_1) or x_6) etc. What is BIG? x_1, x_2, x_3, etc. our Boolean variables (set to True or False) Set x_1 to False ?? Consider a real world Boolean Satisfiability (SAT) problem

32 I.e., (x_177 or x_169 or x_161 or x_153 … x_33 or x_25 or x_17 or x_9 or x_1 or (not x_185)) clauses / constraints are getting more interesting… 10 pages later: … Note x_1 …

33 4000 pages later: …

34 Finally, 15,000 pages later: Current SAT solvers solve this instance in approx. 1 minute! Search space of truth assignments: HOW?

35 Progress in SAT Solvers Source: Marques Silva 2002

36 Questions How? –Clause learning Why? –Phase transition phenomena –Small backdoors

37 How: Clause Learning Idea: backtrack search can repeatedly reach an empty clause (backtrack point) for the same reason A BB CC  Example: Propagation from B=0 and C=0 leads to empty clause

38 How: Clause Learning If reason was remembered, then could avoid having to rediscover it A BB CD  Example: Propagation from B=0 and C=0 leads to empty clause I had better set C=1 immediately!

39 How: Clause Learning The reason can be remembered by adding a new learned clause to the formula A BB CD  learn (~B V ~C) Example: Propagation from B=0 and C=0 leads to empty clause Set C=1 by unit propagation

40 How: Clause Learning Savings can be huge A B B C  Example: Setting B=0 is the root cause of reaching an empty clause DE  C  DE 

41 How: Clause Learning Savings can be huge A B C C  Example: Setting B=0 is the root cause of reaching an empty clause DE  Have learned unit clause (B)

42 Determining Reasons The reason for a backtrack can be found by (incrementally) constructing a conflict graph of the implications between assumed or derived literals (unit clauses) Analyzing the graph yields learned clauses

43 43 Conflict Graphs Decision scheme (p  q   b) 1-UIP scheme t pp qq b a x1x1 x2x2 x3x3 y yy false tt Known Clauses (p  q  a) (  a   b   t) (t   x 1 ) (t   x 2 ) (t   x 3 ) (x 1  x 2  x 3  y) (x 2   y) Current decisions p  false q  false b  true

44 Scaling Up Clause Learning Clause learning greatly enhances the power of unit propagation Tradeoff: memory needed for the learned clauses, time needed to check if they cause propagations Clever data structures enable modern SAT solvers to manage millions of learned clauses efficiently


Download ppt "Constraint Satisfaction and the Davis-Putnam-Logeman-Loveland Procedure Henry Kautz."

Similar presentations


Ads by Google