Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraint Satisfaction CSE 473 University of Washington.

Similar presentations


Presentation on theme: "Constraint Satisfaction CSE 473 University of Washington."— Presentation transcript:

1 Constraint Satisfaction CSE 473 University of Washington

2 © Daniel S. Weld 2 Logistics PS PS 1 due in a week Reading Today + Monday: Ch 5 (esp 5.1 and 5.2) 4/14 (Wed) Ch 6 (esp 6.1 - 6.4) 4/16 (Fri) Ch 7

3 © Daniel S. Weld 3 473 Topics Agency Problem Spaces SearchKnowledge Representation Blind Informed (Heuristics) Constraint Satisfaction (Factored) Adversarial

4 © Daniel S. Weld 4 Today: Constraint Satisfaction Problems Definition Factoring state spaces Backtracking policies Variable-ordering heuristics Preprocessing algorithms

5 © Daniel S. Weld 5 Constraint Satisfaction Kind of search in which States are factored into sets of variables Search = assigning values to these variables Structure of space is encoded with constraints Backtracking-style algorithms work E.g. DFS for SAT (i.e. DPLL) But other techniques add speed Propagation Variable ordering Preprocessing

6 © Daniel S. Weld 6 Chinese Food as Search? States? Operators? Start state? Goal states? Partially specified meals Add, remove, change dishes Null meal Meal meeting certain conditions (rating?)

7 © Daniel S. Weld 7 Factoring States Rather than state = meal Model state’s (independent) parts, e.g. Suppose every meal for n people Has n dishes plus soup Soup = Meal 1 = Meal 2 = … Meal n = Or… physical state = X coordinate = Y coordinate =

8 © Daniel S. Weld 8 Chinese Constraint Network Soup Total Cost < $30 Chicken Dish Vegetable RiceSeafood Pork Dish Appetizer Must be Hot&Sour No Peanuts No Peanuts Not Chow Mein Not Both Spicy

9 © Daniel S. Weld 9 CSPs in the Real World Scheduling space shuttle repair Airport gate assignments Transportation Planning Supply-chain management Computer configuration Diagnosis UI optimization Etc...

10 © Daniel S. Weld 10 Binary Constraint Network Set of n variables: x 1 … x n Value domains for each variable: D 1 … D n Set of binary constraints (also “relations”) R ij  D i  D j Specifies which values pair (x i x j ) are consistent V for each country Each domain = 4 colors R ij enforces 

11 © Daniel S. Weld 11 Binary Constraint Network Partial assignment of values = tuple of pairs {...(x, a)…} means variable x gets value a... Tuple=consistent if all constraints satisfied Tuple=full solution if consistent + has all vars Tuple {(x i, a i ) … (x j, a j )} = consistent w/ a set of vars {x m … x n } iff  a m … a n such that {(x i, a i )…(x j, a j ), (x m, a m )…(x n, a n )} } = consistent

12 © Daniel S. Weld 12 Cryptarithmetic SEND + MORE ------ MONEY State Space Set of states Operators [and costs] Start state Goal states Variables? Domains (variable values)? Constraints?

13 © Daniel S. Weld 13 Classroom Scheduling Variables? Domains (possible values for variables)? Constraints?

14 © Daniel S. Weld 14 N Queens As a CSP?

15 © Daniel S. Weld 15 N Queens Variables = board columns Domain values = rows R ij = {(a i, a j ) : (a i  a j )  (|i-j|  |a i -a j |) e.g. R 12 = {(1,3), (1,4), (2,4), (3,1), (4,1), (4,2)} Q Q Q {(x 1, 2), (x 2, 4), (x 3, 1)} consistent with (x 4 ) Shorthand: “{2, 4, 1} consistent with x 4 ”

16 © Daniel S. Weld 16 CSP as a search problem? What are states? (nodes in graph) What are the operators? (arcs between nodes) Initial state? Goal test? Q Q Q

17 © Daniel S. Weld 17 Chronological Backtracking (BT) (e.g., depth first search) Q Q Q Q Q Q Q Q Q Q Q 1 2 3 4 5 6 Consistency check performed in the order in which vars were instantiated If c-check fails, try next value of current var If no more values, backtrack to most recent var

18 © Daniel S. Weld 18 Backjumping (BJ) Similar to BT, but more efficient when no consistent instantiation can be found for the current var Instead of backtracking to most recent var… BJ reverts to deepest var which was c-checked against the current var BJ Discovers (2, 5, 3, 6) inconsistent with x 6 No sense trying other values of x 5 Q Q Q Q Q

19 © Daniel S. Weld 19 5 Conflict-Directed Backjumping (CBJ) More sophisticated backjumping behavior Each variable has conflict set CS Set of vars that failed c-checks w/ current val Update this set on every failed c-check When no more values to try for x i Backtrack to deepest var, x d, in CS(x i ) And updateCS(x d ):=CS(x d )  CS(x i )-{x d } CBJ Discovers (2, 5, 3) inconsistent with {x 5, x 6 } Q Q Q Q Q 1 1 3 2 3 3 3 2 1 2 3 4 5 6 x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 CS(x 5 ) 1,2,3 CS(x 6 ) 1, 2,3,5

20 © Daniel S. Weld 20 BT vs. BJ vs. CBJ {

21 © Daniel S. Weld 21 Forward Checking (FC) Perform Consistency Check Forward Whenever a var is assigned a value Prune inconsistent values from As-yet unvisited variables Backtrack if domain of any var ever collapses Q Q Q Q Q FC only visits consistent nodes but not all such nodes skips (2, 5, 3, 4) which CBJ visits But FC can’t detect that (2, 5, 3) inconsistent with {x 5, x 6 }


Download ppt "Constraint Satisfaction CSE 473 University of Washington."

Similar presentations


Ads by Google