Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relaxation and Hybrid constraint processing Different relaxation techniques Some popular hybrid techniques.

Similar presentations


Presentation on theme: "Relaxation and Hybrid constraint processing Different relaxation techniques Some popular hybrid techniques."— Presentation transcript:

1 Relaxation and Hybrid constraint processing Different relaxation techniques Some popular hybrid techniques

2 Relaxation Node consistency Forward check Lookahead check AC1AC3Path-consistency

3 3 Running example  4 families A, B, C and D live next to each other in houses numbered 1, 2, 3 and 4.  D lives in a house with lower number than B,  B lives next to A in a house with higher number,  There is at least one house between B and C,  D does not live in the house with number 2,  C does not live in the house with number 4.  Which family lives in which house ?  The 4-houses puzzle:

4 4 Representation:  The variables: A, B, C and D  The domains: d A = d B = d C = d D = { 1, 2, 3, 4}  Constraints:  unary:  c(C) = C  4  c(D) = D  2  binary:  c(A,B) = B = A + 1  c(B,D) = D  B  c(B,C) = |B - C|  1  c(A,C) = A  C  c(A,D) = A  D  c(C,D) = C  D

5 5 Node-consistency:  Unary constraints are eliminated through domain- reductions:  Or: 1-consistency  (only 1 variable is involved)  c(C) = C  4  c(D) = D  2 d C = { 1, 2, 3} d D = { 1, 3, 4}

6 6 The constraint network: AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4}

7 Weak relaxation Forward Check Lookahead Check

8 8 Forward Check:  Assume we fix the value for 1 variable zi: zi = a  Forward Check(zi) =  activate each constraint c(zi, zj) or c(zj, zi) once to remove the inconsistent values for zi = a AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D {2} { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4}  Our example: assume A = 2 :

9 9 Forward check: weak consistency  Requires that 1 variable already obtained a value  suggests use in combination with backtracking AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D {2} { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4}  Does not produce a consistent state  not all relaxation is done

10 Look ahead check A stronger (weak) relaxation method

11 11 Look ahead Check:  Look Ahead Check =  activate each constraint c(zi, zj) exactly once to remove the inconsistent values from the domains Di and Dj.  Our example: AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3, 4}

12 12 Example continued: AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3}  The 3 other constraints:

13 13 Look ahead: final results: AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 1, 2, 3}  Still does not produce a consistent state  not all relaxation is done  Result may depend on the order in which constraints are dealt with.  Removing some values first may allow to find others inconsistent

14 Arc consistency techniques Techniques that reduce domains to a state that is consistent for each constraint (or arc). Also called: 2-consistency techniques

15 15 AC 1 (Mackworth) AC1: Repeat Look ahead check; Look ahead check; If some value was removed from If some value was removed from some domain then some domain then Deletion_occurred := true Until (not Deletion_occurred)  Forces Look ahead to reach a consistent state  by reactivating Look ahead until consistency Deletion_occurred := false ;

16 16 The example (1): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3, 4}  First pass (== Look ahead check): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 1, 2, 3}  Deletion_occurred := true

17 17 The example (2):  Second pass: AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 1, 2, 3}  Deletion_occurred := true AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 2, 3}

18 18 The example (3):  Third pass:  Deletion_occurred := false AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 2, 3}  Result: A (2 or 3), B (3 or 4), C (1 or 2), D (1 or 3)  Consistent, but NOT REALLY A SOLUTION !!

19 19 AC-3 (Mackworth) More efficient arc-consistency: AC3: Remove c(x,y) from QUEUE; Remove c(x,y) from QUEUE; End-While QUEUE := {all constraints in the problem} Remove all inconsistent values from domains Remove all inconsistent values from domains D x and D y with respect to c(x,y); D x and D y with respect to c(x,y); While not empty(QUEUE) DO If some value was removed from D x (or D y ) If some value was removed from D x (or D y ) then add all other constraints involving then add all other constraints involving x (or y) to QUEUE;

20 20 The example (1): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3, 4}  QUEUE = {c(A,B), c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}:  QUEUE = {c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}  To be added: c(A,C), c(A,D), c(B,C), c(B,D) All already in QUEUE !

21 21 The example (2): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3}  QUEUE = {c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}:  QUEUE = {c(B,C), c(B,D), c(C,D)}

22 22 The example (3): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3}  QUEUE = {c(B,C), c(B,D), c(C,D)}:  QUEUE = {c(B,D), c(C,D), c(A,B), c(A,C)}  To be added: c(A,B), c(A,C), c(B,D), c(C,D)

23 23 The example (4): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3, 4} { 1, 2, 3}  QUEUE = {c(B,D), c(C,D), c(A,B), c(A,C)}:  QUEUE = {c(C,D), c(A,B), c(A,C), c(A,D)}  To be added: c(A,D), c(C,D)

24 24 The example (5): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 1, 2, 3}  QUEUE = {c(C,D), c(A,B), c(A,C), c(A,D)}:  QUEUE = {c(A,C), c(A,D)}  To be added: c(A,C), c(A,D)

25 25 The example (6): AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 3, 4} { 1, 2}{ 1, 3} { 2, 3}  QUEUE = {c(A,C), c(A,D)}:  QUEUE = empty STOP !

26 26 Comparison:  Same result: full arc-consistency:  A = {2,3}, B = {3,4}, C= {1,2}, D = {1,3}  Efficiency:  AC1:  3 times 6 checks = 18  AC3:  9 constraint checks

27 27K-consistency:  1-consistency (node-consistency):  unary constraints (on 1 variable) are consistent  2-consistency (arc-consistency):  binary constraints (on 2 variables) are consistent  3-consistency:  all constraints involving 3 variables are consistent AB DC B = A + 1 A  C D  BD  B A  D |B - C|  1 C  D { 1, 2, 3, 4} { 1, 2, 3}{ 1, 3, 4} { 1, 2, 3, 4}  A value remains in the domain if there are consistent values in the domains of the 2 other variables (for all connecting constraints) Example:

28 28 Practicality of k-consistency:  Checking k-consistency for k  2 is very hard to do efficiently !!  Example: 4-consistency for the 4-houses puzzle is equivalent to finding solutions to the original problem.

29 Hybrid constraint processing Combine the power of exhaustive (backtrack) search with (relaxation) pruning

30 Forward checking Backtracking combined with Forward Check

31 31 Forward checking: Forward Checking: Execute Standard Backtracking After each assignment of a After each assignment of a value to a variable zi DO value to a variable zi DO Forward Check(zi) BUT

32 32 1A Forward checking at work B2 AB CD{1}{1,2,3,4}{1,2,3} {1,3,4} B=A+1 ADADADAD ACACACAC AB CD{1}{2}{2,3} {3,4} |B-C|  1 D BD BD BD B fail AB CD{2}{1,2,3,4}{1,2,3} {1,3,4} B=A+1 ADADADAD ACACACAC 2 B3 AB CD{2}{3}{1,3} {1,3,4} D BD BD BD B C1 AB C D{4}{3}{1}{1} CDCDCDCD fail AB CD{3}{1,2,3,4}{1,2,3} {1,3,4} B=A+1 ADADADAD ACACACAC 3 B4 AB CD{3}{4}{1,2} {1,4} D BD BD BD B AB C D{3}{4}{1}{1} CDCDCDCD AB C D{3}{4}{2}{1} CDCDCDCD 1C 2failsuccess

33 Lookahead checking Backtracking combined with Look ahead check

34 34 Lookahead checking: Execute Standard Backtracking Look Ahead Check BUT Look Ahead Check ; Lookahead Checking: After each assignment of a After each assignment of a value to some variable DO value to some variable DO

35 35 Lookahead checking at work AB C D{1,2,3,4}{1,2,3,4}{1,2,3}{1,3,4} B=A+1 ADADADAD ACACACAC D BD BD BD B |B-C|  1 CDCDCDCD AB CD{1}{3,4}{1,2} {1,3} B=A+1 fail AB C D{2}{3,4}{1,2}{1,3} B=A+1 ADADADAD ACACACAC D BD BD BD B CDCDCDCD fail AB C D{3}{3,4}{1,2}{1,3} B=A+1 ADADADAD ACACACAC D BD BD BD B CDCDCDCD AB C D{3}{4}{2}{1} D BD BD BD B CDCDCDCD AB C D{3}{4}{2}{1} CDCDCDCD 1A 2 3 B4 C2 success

36 36 Which is best?  Forward checking:  does less consistency checking  has more branching  closer to backtracking  Lookahead checking:  spends more work on consistency  tries less alternative values  Usually: forward checking is best trade-off  For VERY strongly constrainted problems:  Lookahead checking is needed to prune more

37 37 Applications:  All combinatorial search problems  Scheduling problems:  Ex.: reschedule the trains when some railway problem has occurred  Rostering problems:  Ex.: compute work-shifts, given various expertise constraints and personal preferences  Production planning:  Ex.: schedule the optimal workfloor traversal  Loading problems:  Ex.: optimize truck-space given various types of loads

38 38 Alternative techniques  Linear programming  numerical techniques for solving systems of linear equations (and inequalities) + optimization problems  Ex.: simplex algorithm  Works VERY well for ‘linear’ constraints 4*X - 3*Y  Z + 2 X 3 - 3*Y  Z 2 + 2 YES ! NO !  Works, but not VERY well, for discrete problems  In such cases: Constraint Processing is a better option  Also: for constraint problems on non-numerical data !


Download ppt "Relaxation and Hybrid constraint processing Different relaxation techniques Some popular hybrid techniques."

Similar presentations


Ads by Google