Lecture 15: CP Search © J. Christopher Beck 2008 1 Outline Quick CP Review Standard CP Search Scheduling Specific Branching Heuristics © J. Christopher Beck 2008 2 Readings P Ch 5.5, D.2, D.3 © J. Christopher Beck 2008 3 Generic CP Algorithm Start Solution? Propagators Success Dead-end? Backtrack Technique Nothing to retract? Failure © J. Christopher Beck 2008 Make Heuristic Decision Assert Commitment 4 Constraint Satisfaction Problem (CSP) From Lecture 13 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 © J. Christopher Beck 2008 5 From Lecture 11 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-subpartitions Solution is the best one from all the partitions © J. Christopher Beck 2008 6 Standard CP Search Tree Search a, b, c є {0, 1} a=0 b=0 c=0 c=1 © J. Christopher Beck 2008 Branch a=1 b=1 c=0 b=0 c=1 c=0 c=1 b=1 c=0 c=1 In CSP there is no optimization function! (think of the Crystal Maze) 7 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 8 From Lecture 12 Basic MIP B&B Priority queue (node selection) Q.push(root) while Q is not empty Relaxation n = Q.pop() solve LP(n) if better than incumbent if integral Branching variable update incumbent selection else v = choose branching variable Q.push(children(n,v)) © J. Christopher Beck 2008 9 Basic CP BI&B CPSearch(Problem P) if propagate(P) == dead-end return dead-end if not all variables are assigned value ordering V = choose variable in P variable ordering heuristic heuristic x = choose value for V if CPSearch(P + V=x) == solution depth-first return solution search else return CPSearch(P + V≠x) return solution © J. Christopher Beck 2008 10 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 11 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 12 If you post AiAj, how much time is left between the end of Aj and lftj? Slack slack(Ai,Aj) = lftj – esti – pi – pj A1 15 A2 20 35 50 100 120 slack(A1,A2) = 100 – 50 – 15 – 20 = 15 slack(A2,A1) = 120 – 35 – 15 – 20 = 50 © J. Christopher Beck 2008 13 Note: The text is wrong here! 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 © J. Christopher Beck 2008 14 Branch on Sequence A1 A2 A4 A1 A2 A1 … … © J. Christopher Beck 2008 15 CBA & Slack Find all CBA inferences Find first heuristic decision based on slack A1 10 20 50 A2 5 30 A3 20 50 0 A4 5 10 © J. Christopher Beck 2008 50 40 16 Generic CP Algorithm Start Solution? Propagators Success Dead-end? Backtrack Technique Nothing to retract? Failure © J. Christopher Beck 2008 Make Heuristic Decision Assert Commitment 17 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] © J. Christopher Beck 2008 18