© j. christopher beck 20081 lecture 15: cp search
TRANSCRIPT
© J. Christopher Beck 2008 1
Lecture 15: CP Search
© J. Christopher Beck 2008 2
Outline Quick CP Review Standard CP Search Scheduling Specific Branching
Heuristics
© J. Christopher Beck 2008 3
Readings
P Ch 5.5, D.2, D.3
© J. Christopher Beck 2008 4
Generic CP Algorithm
AssertCommitment
Propagators
Start
SuccessSolution?
MakeHeuristicDecision
BacktrackTechnique
Failure
Nothing toretract?
Dead-end?
© J. Christopher Beck 2008 5
Constraint Satisfaction Problem (CSP)
Given: V, a set of variables {v0, v1, …, vn} D, a set of domains {D0, D1, …, Dn} C, a set of constraints {c0, c1, …, cm}
Each constraint, ci, has a scope ci(v0, v2, v4, v117, …), the variables that it constrains
From Lecture 13
© J. Christopher Beck 2008 6
Idea #1: Partitioning
Add constraint to the original problem to form a partition: P1, P2, P3, … Partitions are easier to solve Partitions, sub-partitions, sub-sub-
partitions Solution is the best one from all
the partitions
From Lecture 11
© J. Christopher Beck 2008 7
Standard CP Search
Tree Search a, b, c є {0, 1}
a = 0 a = 1
b = 0 b = 1
c = 0 c = 1 c = 0 c = 1 c = 0 c = 1c = 0 c = 1
b = 0 b = 1
Branch
In CSP there is no optimization function!(think of the Crystal Maze)
© J. Christopher Beck 2008 8
Standard CP Search
Branch-and-Infer at each node, run constraint propagation
For Constraint Optimization Problems: Branch-Infer-&-Bound
Partition/Inference/Relax (see Lecture 11) Often bound calculation is “hidden” in
constraint propagation
© J. Christopher Beck 2008 9
Basic MIP B&B
Q.push(root)
while Q is not empty
n = Q.pop()
solve LP(n)
if better than incumbent
if integral
update incumbent
else
v = choose branching variable
Q.push(children(n,v))
Priority queue(node selection)
Relaxation
Branching variableselection
From Lecture 12
© J. Christopher Beck 2008 10
Basic CP BI&B
CPSearch(Problem P)
if propagate(P) == dead-end
return dead-end
if not all variables are assigned
V = choose variable in P
x = choose value for V
if CPSearch(P + V=x) == solution
return solution
else return CPSearch(P + V≠x)
return solution
depth-firstsearch
variable orderingheuristic
value orderingheuristic
© J. Christopher Beck 2008 11
MIP vs CP Search
Conceptually (almost) the same thing
Nice exam question: How do node selection & branch
selection correspond to DFS, variable ordering, and value ordering?
© J. Christopher Beck 2008 12
CP Heuristics for Scheduling
It is common to make a decision (branch) about the sequence of a pair of activities. What pair? Which sequence should be tried first?
How do these map into variable and value ordering heuristics?
© J. Christopher Beck 2008 13
Slack
slack(Ai,Aj) = lftj – esti – pi – pj
A2 20
35 100
A1 15
12050
slack(A1,A2) = 100 – 50 – 15 – 20 = 15
slack(A2,A1) = 120 – 35 – 15 – 20 = 50
If you post AiAj, howmuch time is left between
the end of Aj and lftj?
© J. Christopher Beck 2008 14
MinSlack Heuristic
Find operation pair with smallest slack Post the opposite sequence Example
slack(A B) = 50, slack(B A) = 25 slack(A C) = 150, slack(C A) = 5 slack(B C) = 15, slack(C B) = 50
Pick A,C and post A C
Note: The text is wrong here!
© J. Christopher Beck 2008 15
Branch on Sequence
A1 A2 A2 A1
…A4 A1
…
© J. Christopher Beck 2008 16
CBA & Slack Find all CBA inferences Find first heuristic decision
based on slack
A3 20
40
50
A1 10
10
50A2 5
A4 5
20
30 50
0
© J. Christopher Beck 2008 17
Generic CP Algorithm
AssertCommitment
Propagators
Start
SuccessSolution?
MakeHeuristicDecision
BacktrackTechnique
Failure
Nothing toretract?
Dead-end?
© J. Christopher Beck 2008 18
CP on JSP
Run CP on our JSP problem Use
CBA, EF Exclusion Min Slack Heuristic
Jobs Processing times
0 J0R0[15] J0R1[50] J0R2[60]
1 J1R1[50] J1R0[50] J1R2[15]
2 J2R0[30] J2R1[15] J2R2[20]