relaxation and hybrid constraint processing
Post on 05-Feb-2016
45 Views
Preview:
DESCRIPTION
TRANSCRIPT
Relaxation Relaxation and and
Hybrid constraint processingHybrid constraint processing
Different relaxation techniquesDifferent relaxation techniquesSome popular hybrid techniquesSome popular hybrid techniques
RelaxationRelaxation
Node consistencyNode consistencyForward checkForward check
Lookahead checkLookahead checkAC1AC1AC3AC3
Path-consistencyPath-consistency
3
Running exampleRunning example
4 families 4 families AA, , BB, , CC and and DD live next to each other in live next to each other in houses numbered houses numbered 11, , 22, , 33 and and 44.. DD lives in a house lives in a house with lower numberwith lower number than than BB,, BB lives lives next tonext to AA in a house in a house with higher numberwith higher number,, There is There is at least one house betweenat least one house between BB andand CC,, DD does not livedoes not live in the house with number in the house with number 22,, CC does not livedoes not live in the house with number in the house with number 44..
Which family lives in which house ?Which family lives in which house ?
The 4-houses puzzle:The 4-houses puzzle:
4
Representation:Representation: The variables: The variables: AA, , BB, , CC and and DD The domains: dThe domains: dAA = d = dBB = d = dCC = d = dDD = { = { 11, , 22, , 33, , 44}} Constraints:Constraints:
unary:unary: c(c(CC) =) = CC 4 4 c(c(DD) =) = DD 22 binary:binary:
c(c(AA,,BB) =) = BB == A A + 1+ 1 c(c(BB,,DD) =) = DD BB c(c(BB,,CC) = |) = |BB -- CC| | 1 1
c(c(AA,,CC) =) = A A C C c(c(AA,,DD) = ) = A A DD c(c(CC,,DD) = ) = C C DD
5
Node-consistency:Node-consistency:
Unary constraints are eliminated through Unary constraints are eliminated through domain- reductions:domain- reductions:
Or: 1-consistencyOr: 1-consistency (only 1 variable is involved)(only 1 variable is involved)
c(c(CC) =) = CC 4 4
c(c(DD) =) = DD 22
ddCC = { = { 11, , 22, , 33}}
ddDD = { = { 11, , 33,, 4 4}}
6
The constraint network:The constraint network:
AA BB
DDCC
B = A + 1
A C D B
A D
|B - C| 1
C D
{ 1, 2, 3, 4} { 1, 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
Weak relaxationWeak relaxation
Forward CheckForward CheckLookahead CheckLookahead Check
8
Forward Check:Forward Check: Assume we fix the value for 1 variable Assume we fix the value for 1 variable zizi: : zizi = = aa Forward Check(Forward Check(zizi) = ) =
activate each constraint c(activate each constraint c(zizi, , zjzj) or c() or c(zjzj, , zizi) once ) once to remove the inconsistent values for to remove the inconsistent values for zizi = = aa
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{2} { 1, 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
Our exampleOur example: assume : assume AA = = 22 : :
9
Forward check: Forward check: weak consistencyweak consistency
Requires that 1 variable already obtained a valueRequires that 1 variable already obtained a value suggests use in combination with backtracking suggests use in combination with backtracking
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{2} { 1, 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
Does not produce a Does not produce a consistent stateconsistent state not all relaxation is donenot all relaxation is done
Look ahead checkLook ahead check
A stronger (weak) relaxation methodA stronger (weak) relaxation method
11
Look ahead Check:Look ahead Check: Look Ahead Check = Look Ahead Check =
activate each constraint c(activate each constraint c(zizi, , zjzj) exactly ) exactly once to remove the inconsistent values from once to remove the inconsistent values from the domains the domains DiDi and and DjDj..
Our exampleOur example::
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 1, 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
{ 1, 2, 3, 4}
12
Example continued:Example continued:
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
{ 1, 2, 3}
The 3 other constraintsThe 3 other constraints::
13
Look ahead: final results:Look ahead: final results:
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 1, 2, 3}
Still does not produce a Still does not produce a consistent stateconsistent state not all relaxation is donenot all relaxation is done
Result may depend on the order in which constraints are dealt with. Result may depend on the order in which constraints are dealt with. Removing some values first may allow to find Removing some values first may allow to find others others
inconsistentinconsistent
Arc consistency techniquesArc consistency techniques
Techniques that reduce domains to a state Techniques that reduce domains to a state that is consistent for each constraint (or that is consistent for each constraint (or
arc).arc).Also calledAlso called: 2-consistency techniques: 2-consistency techniques
15
AC 1 (Mackworth)AC 1 (Mackworth)AC1:AC1:
RepeatRepeat
Look ahead checkLook ahead check;; IfIf some value was removed from some value was removed from some domain some domain thenthen
Deletion_occurredDeletion_occurred := true:= trueUntilUntil (not(not Deletion_occurredDeletion_occurred))
Forces Look ahead to reach a Forces Look ahead to reach a consistent stateconsistent state by reactivating Look ahead until consistencyby reactivating Look ahead until consistency
Deletion_occurredDeletion_occurred := false ;:= false ;
16
The example (1):The example (1):
AA BB
DDCC
B = A + 1
A C D BA 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):First pass (== Look ahead check):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 1, 2, 3}
Deletion_occurredDeletion_occurred := true:= true
17
The example (2):The example (2): Second pass:Second pass:
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 1, 2, 3}
Deletion_occurredDeletion_occurred := true:= true
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 2, 3}
18
The example (3):The example (3): Third pass:Third pass:
Deletion_occurredDeletion_occurred := false:= false
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 2, 3}
ResultResult: : AA ( (2 or 32 or 3) , ) , BB ( (3 or 43 or 4), ), CC ( (1 or 21 or 2), ), DD ( (1 or 31 or 3)) Consistent, but NOT REALLY A SOLUTION !!Consistent, but NOT REALLY A SOLUTION !!
19
AC-3 (Mackworth)AC-3 (Mackworth)More efficient arc-consistency:More efficient arc-consistency:
AC3:AC3:
Remove Remove c(c(xx,,yy)) from from QUEUEQUEUE;;
End-WhileEnd-While
QUEUEQUEUE := {all constraints in the problem}:= {all constraints in the problem}
Remove all inconsistent values from domainsRemove all inconsistent values from domains DDxx and and DDyy with respect to with respect to c(c(xx,,yy));;
WhileWhile not empty(not empty(QUEUEQUEUE) ) DODO
IfIf some value was removed from some value was removed from DDxx (or (or DDyy)) thenthen add all add all otherother constraints involving constraints involving
xx (or (or yy) to ) to QUEUEQUEUE;;
20
The example (1):The example (1):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 1, 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
{ 1, 2, 3, 4}
QUEUEQUEUE = {c(A,B), c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}: = {c(A,B), c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}:
QUEUEQUEUE = {c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)} = {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)To be added: c(A,C), c(A,D), c(B,C), c(B,D)
All already inAll already in QUEUEQUEUE ! !
21
The example (2):The example (2):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
{ 1, 2, 3}
QUEUEQUEUE = {c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}: = {c(A,C), c(A,D), c(B,C), c(B,D), c(C,D)}:
QUEUEQUEUE = {c(B,C), c(B,D), c(C,D)} = {c(B,C), c(B,D), c(C,D)}
22
The example (3):The example (3):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
{ 1, 2, 3}
QUEUEQUEUE = {c(B,C), c(B,D), c(C,D)}: = {c(B,C), c(B,D), c(C,D)}:
QUEUEQUEUE = {c(B,D), c(C,D), = {c(B,D), c(C,D), c(A,B), c(A,C)c(A,B), c(A,C)}}
To be added: c(A,B), c(A,C), c(B,D), c(C,D)To be added: c(A,B), c(A,C), c(B,D), c(C,D)
23
The example (4):The example (4):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3, 4}
{ 1, 2, 3}
QUEUEQUEUE = {c(B,D), c(C,D), c(A,B), c(A,C)}: = {c(B,D), c(C,D), c(A,B), c(A,C)}:
QUEUEQUEUE = {c(C,D), c(A,B), c(A,C) = {c(C,D), c(A,B), c(A,C), c(A,D), c(A,D)}}
To be added: c(A,D), c(C,D)To be added: c(A,D), c(C,D)
24
The example (5):The example (5):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 1, 2, 3}
QUEUEQUEUE = {c(C,D), c(A,B), c(A,C), c(A,D)}: = {c(C,D), c(A,B), c(A,C), c(A,D)}:
QUEUEQUEUE = {c(A,C), c(A,D)} = {c(A,C), c(A,D)}
To be added: c(A,C), c(A,D)To be added: c(A,C), c(A,D)
25
The example (6):The example (6):
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 3, 4}
{ 1, 2} { 1, 3}
{ 2, 3}
QUEUEQUEUE = {c(A,C), c(A,D)}: = {c(A,C), c(A,D)}:
QUEUEQUEUE = empty = empty
STOP !STOP !
26
Comparison:Comparison: Same result: full arc-consistency:Same result: full arc-consistency:
A = {2,3}, B = {3,4}, C= {1,2}, D = {1,3} A = {2,3}, B = {3,4}, C= {1,2}, D = {1,3}
Efficiency:Efficiency: AC1: AC1:
3 times 6 checks = 3 times 6 checks = 1818 AC3:AC3:
99 constraint checks constraint checks
27
K-consistency:K-consistency: 1-consistency1-consistency (node-consistency): (node-consistency):
unary constraints (on 1 variable) are consistentunary constraints (on 1 variable) are consistent 2-consistency2-consistency (arc-consistency): (arc-consistency):
binary constraints (on 2 variables) are consistentbinary constraints (on 2 variables) are consistent 3-consistency3-consistency::
all constraints involving 3 variables are consistentall constraints involving 3 variables are consistent
AA BB
DDCC
B = A + 1
A C D BA D
|B - C| 1
C D
{ 1, 2, 3, 4}
{ 1, 2, 3} { 1, 3, 4}
{ 1, 2, 3, 4}
A value A value remainsremains in the domain if there are consistent in the domain if there are consistent values in the domains of the 2 other variables (for all values in the domains of the 2 other variables (for all connecting constraints)connecting constraints)
Example:Example:
28
Practicality of k-consistency:Practicality of k-consistency: CheckingChecking k-consistency for k k-consistency for k 2 is very hard to 2 is very hard to
do efficiently !!do efficiently !!
Example:Example: 4-consistency for the 4-houses puzzle 4-consistency for the 4-houses puzzle is equivalent to finding solutions to the original is equivalent to finding solutions to the original problem.problem.
Hybrid constraint processingHybrid constraint processing
Combine the power ofCombine the power ofexhaustive (backtrack) searchexhaustive (backtrack) search
with (relaxation) pruningwith (relaxation) pruning
Forward checkingForward checking
Backtracking combined Backtracking combined with Forward Checkwith Forward Check
31
Forward checking:Forward checking:
Forward Checking:Forward Checking:ExecuteExecute Standard BacktrackingStandard Backtracking
AfterAfter each assignment of a each assignment of a value to a variable value to a variable zizi DODOForward Check(Forward Check(zizi))
BUTBUT
32
11 AAForward checking at workForward checking at work
BB22
AA BBCC DD
{1}{1} {1,2,3,4}{1,2,3,4}
{1,2,3}{1,2,3} {1,3,4}{1,3,4}
B=A+1B=A+1AADDAACC
AA BBCC DD
{1}{1} {2}{2}
{2,3}{2,3} {3,4}{3,4}
|B-C||B-C|11DD B B
failfail
AA BBCC DD
{2}{2} {1,2,3,4}{1,2,3,4}
{1,2,3}{1,2,3} {1,3,4}{1,3,4}
B=A+1B=A+1AADDAACC
22
BB33
AA BBCC DD
{2}{2} {3}{3}
{1,3}{1,3} {1,3,4}{1,3,4}
|B-C||B-C|11DD B B
CC11AA BBCC DD
{4}{4} {3}{3}
{1}{1} {1}{1}CCDD
failfail
AA BBCC DD
{3}{3} {1,2,3,4}{1,2,3,4}
{1,2,3}{1,2,3} {1,3,4}{1,3,4}
B=A+1B=A+1AADDAACC
33
BB44
AA BBCC DD
{3}{3} {4}{4}
{1,2}{1,2} {1,4}{1,4}
|B-C||B-C|11DD B B
AA BBCC DD
{3}{3} {4}{4}
{1}{1} {1}{1}CCDD
AA BBCC DD
{3}{3} {4}{4}
{2}{2} {1}{1}CCDD
11 CC 22
failfail successsuccess
Lookahead checkingLookahead checking
Backtracking combined Backtracking combined with Look ahead checkwith Look ahead check
34
Lookahead checking:Lookahead checking:
ExecuteExecute Standard BacktrackingStandard Backtracking
Look Ahead CheckLook Ahead Check
BUTBUT
Look Ahead Check Look Ahead Check ;;Lookahead Checking:Lookahead Checking:
AfterAfter each assignment of a each assignment of a value to some variable value to some variable DODO
35
Lookahead checking at workLookahead checking at work
AA BB
CC DD
{1,2,3,4}{1,2,3,4} {1,2,3,4}{1,2,3,4}
{1,2,3}{1,2,3} {1,3,4}{1,3,4}
B=A+1B=A+1AADDAACC DD B B|B-C||B-C|11
CCDD
AA BBCC DD
{1}{1} {3,4}{3,4}
{1,2}{1,2} {1,3}{1,3}
B=A+1B=A+1
failfail
AA BB
CC DD
{2}{2} {3,4}{3,4}
{1,2}{1,2} {1,3}{1,3}
B=A+1B=A+1AADDAACC DD B B|B-C||B-C|11
CCDD
failfail
AA BB
CC DD
{3}{3} {3,4}{3,4}
{1,2}{1,2} {1,3}{1,3}
B=A+1B=A+1AADDAACC DD B B|B-C||B-C|11
CCDD
AA BB
CC DD
{3}{3} {4}{4}
{2}{2} {1}{1}DD B B
|B-C||B-C|11
CCDD
AA BB
CC DD
{3}{3} {4}{4}
{2}{2} {1}{1}CCDD
11 AA
22
33
BB 44
CC 22
successsuccess
36
Which is best?Which is best? Forward checking:Forward checking:
does less consistency checkingdoes less consistency checking has more branchinghas more branching
closer to backtrackingcloser to backtracking
Lookahead checking:Lookahead checking: spends more work on consistencyspends more work on consistency tries less alternative valuestries less alternative values
Usually: forward checking is best trade-offUsually: forward checking is best trade-off For VERY strongly constrainted problems:For VERY strongly constrainted problems:
Lookahead checking is needed to prune moreLookahead checking is needed to prune more
37
Applications:Applications: All combinatorial search problemsAll combinatorial search problems Scheduling problems:Scheduling problems:
Ex.:Ex.: reschedule the trains when some railway reschedule the trains when some railway problem has occurredproblem has occurred
Rostering problems:Rostering problems: Ex.:Ex.: compute work-shifts, given various compute work-shifts, given various expertise constraints and personal preferencesexpertise constraints and personal preferences
Production planning:Production planning: Ex.:Ex.: schedule the optimal workfloor traversal schedule the optimal workfloor traversal
Loading problems:Loading problems: Ex.:Ex.: optimize truck-space given various types of optimize truck-space given various types of loadsloads
38
Alternative techniquesAlternative techniques Linear programmingLinear programming
numerical techniques for solving systems of linear equations (and inequalities) + optimization problemsnumerical techniques for solving systems of linear equations (and inequalities) + optimization problems Ex.:Ex.: simplex algorithm simplex algorithm
Works VERY well for ‘linear’ constraints Works VERY well for ‘linear’ constraints 4*X - 3*Y 4*X - 3*Y Z + 2 Z + 2XX33 - 3*Y - 3*Y Z Z22 + 2 + 2
YES !YES !
NO !NO !
Works, but not VERY well, for discrete problems Works, but not VERY well, for discrete problems In such cases:In such cases: Constraint Processing is a better option Constraint Processing is a better option Also: for constraint problems on Also: for constraint problems on non-numerical datanon-numerical data ! !
top related