Weighted Spanning Tree Constraint with Explanations CPAIOR 2016 - - PowerPoint PPT Presentation
Weighted Spanning Tree Constraint with Explanations CPAIOR 2016 - - PowerPoint PPT Presentation
Weighted Spanning Tree Constraint with Explanations CPAIOR 2016 Diego de U na, Graeme Gange, Peter Schachte and Peter J. Stuckey Presented by Peter J. Stuckey May 31, 2016 University of Melbourne CIS Department NICTA/Data61 Victoria
Table of Contents
- 1. Background
Spanning Trees in the Real World Variants of the Minimum Spanning Tree The WST constraint
- 2. Explaining Kruskal’s algorithm
Kruskal’s algorithm with mandatory and forbidden edges Example Propagation rule
- 3. Experimental Results
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 2
Background
Spanning Trees in the Real World
- Off-shore Wind Farm Planning (Klein et al., 2015):
Minimize the amount of cable needed to connect a network of turbines such that:
- The degree of each turbine is less than 4.
- The number of turbines on each branch connected to the main
transformer is less than 7.
- Cables between turbines don’t cross each other.
- Electrical and computer networks: there is a maximum
number of cables that can be connected to a single switch
(Wang et al., 1994).
- Data Compression uses the Spanning trees with bounds on
the diameter (Bookstein et al., 1991).
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 4
Variants of the Minimum Spanning Tree
Most variants of the Minimum Spanning Tree are NP-hard:
- Capacitated MST: where a root is chosen and each subtree
under the root has a maximum number of nodes (Papadimitriou
et al., 1984).
- Degree-constrained MST: minimum or maximum degree of
nodes (Narula et al., 1980).
- Constrained MST: two weights per edge (costs of building and
maintenance, for instance) with a bound on one and an
- bjective on the other (Ravi et al., 1996).
- Diameter-constrained MST: bound on the diameter of the
tree (Achuthan et al., 1992).
- ...
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 5
The WST constraint
Given:
- a graph G = (N, E)
- a weight function ws : E → N
- a set B containing a Boolean variable ce for each edge.
- an integer variable w
the constraint wst(N, E, ws, B, w) ensures that B describes a sub-tree T of G that spans all nodes in G and is of cost w. ce = true ⇔ e ∈ T
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 6
Previous work & Constribution
Brief literature review on the WST constraint:
- The MST constraint (Dooms et al., 2006): ensure a graph is an
MST.
- Cannot compromise cost for side constraints.
- The WST constraint (Dooms et al., 2007)(R´
egin, 2008): first
appearance of the constraint we study.
- No explanations
Contributions:
- Explanations for the lower bound of the WST constraint.
- Explanations for a propagation rule previously introduced.
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 7
Explaining Kruskal’s algorithm
Kruskal’s algorithm revisited
Kruskal’s algorithm main idea:
- Add cheapest edge until tree is formed.
- Use a priority queue to retrieve edges.
- Before adding an edge, ensure it does not form a cycle.
- Use Union-Find to test acyclicity.
Observations:
- When adding an edge e = (u, v), if u and v are already
connected, all edges between them are cheaper (or equal to) than e.
- If we skip an edge e = (u, v), a more expensive (or equal)
edge will be used to connect u and v.
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 9
Kruskal’s algorithm with mandatory and forbidden edges
It is easy to modify Kruskal’s algorithm to incorporate information about which edges MUST be in the tree and which edges CANNOT be in the tree.
Mandatory edges:
Pre-add mandatory edges as long as they don’t form cycles.
Forbidden edges:
Simply skip them. Some more expensive group of edges will con- nect the endnodes.
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 10
Explaining Kurskal’s algorithm
We need to explain failure when the cost of the cheapest possible Spanning Tree given the current decisions is above the limit w.
- 1. Run Kruskal’s algorithm while identifying:
- a subset of forbidden edges to add in the explanations,
- a substitute edge for each edge
- 2. Identify mandatory edges that could be substituted by cheaper
edges such that the total cost was below the limit.
Substitute edge
es is a substitute of e ∈ T iff replacing e with es in T yields a spanning tree.
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 11
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Initial graph
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 12
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Mandatory edges pre-added. Forbidden edges appear dotted in grey
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 13
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (h, a)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 14
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (e, i)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 15
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (f , g)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 16
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: cannot add edge (b, c)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 17
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ∅ a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: cannot add edge (b, c)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 18
Forbidden edge
We will have to connect b to c through some more expensive edges, thus we add it to the explanation: ¬c(b,c)
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (b, a)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 19
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: cannot add edge (g, e)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 20
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: cannot add edge (g, e)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 21
Substitute edge
Node g and e are already con- nected. Edge (g, e) could be used instead
- f (g, f ), (f , a), (a, d) or (d, e).
We say (g, e) substitutes those edges.
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (a, f )
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 22
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (c, a)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 23
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (a, d)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 24
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (d, e)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 25
Explaining Kurskal’s algorithm: Step 1 (Example)
Why is the cost of the spanning tree greater than 27 given the current decisions? Explanation = ¬c(b,c) a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 1: Following Kruskal’s algorithm: add edge (d, e)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 26
Total cost = 31 > 27
We must fail.
Explaining Kruskal’s algorithm: Step 2 (Example)
Processing the mandatory edges:
- For each mandatory edge that has a possible substitute,
pretend we substitute the edge (relax it).
- If the new cost is lower than the limit ⇒ explanation
- Else continue decreasing the cost
In our example:
- 31 − (f , a) + (g, e) = 31 − 4 + 3 = 30 > 27 ⇒ continue
- 30 − (a, d) + (g, e) = 30 − 5 + 3 = 28 > 27 ⇒ continue
- 28 − (d, e) + (g, e) = 28 − 10 + 3 = 21 < 27 ⇒ explanation
The final explanation is: ¬c(b,c) ∧ c(d,e) ⇒ w > 27
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 27
Explaining Kruskal’s algorithm (Example)
Final explanation: ¬c(b,c) ∧ c(d,e) ⇒ w > 27 a b c d e f g h i 4 10 5 3 1 4 2 3 2 2 100
- Fig. 2: Following Kruskal’s algorithm: add edge (d, e)
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 28
Summary of the algorithm
- 1. Pre-add mandatory edges
- 2. Add edges e = (u, v) as per Kruskal’s algorithm
- if u and v not yet connected and e is forbidden:
⇒ add ¬ce to the explanation
- if u and v connected:
2.1 update substitutes in the path connecting them 2.2 if some edge in the path is more expensive than e and e is forbidden ⇒ add ¬ce to the explanation
- 3. Relax mandatory edges e with their substitutes es until we get
to a cost lower than the limit:
- if cost − we + wes ≥ limit: cost ← cost − we + wes
- else add ce to the explanation
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 29
Explaining propagation
We have computed the cheapest Spanning Tree T given the current decisions of cost W ∗. Let e = (u, v) be a possible edge not in T. Its support is the most expensive edge in T in the path from u to v. If replacing the support of e with e in T yields a tree that is too expensive, e cannot be part of T (R´
egin, 2008).
Our explanations are also applicable to this!
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 30
Experimental Results
Diameter Constrained Spanning Trees
We compare
- NoProp: using a decomposition with explanation
- NoExpl: using a global propagator without explanation
- NaiveExpl: using a global propagator with naive
explanations
- Expl: using a global propagator with good explanations
- Choco3: using Choco3 and its WST propagator
- NRS: published results for CP Optimizer with WST
propagator
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 32
Diameter-Constrained MST
Instance NoProp NoExpl NaiveExpl Expl Choco3 NRS (IBM OPL) |N| |E| D Nodes Time Nodes Time Nodes Time Nodes Time Nodes Time Nodes Time 15 105 4 6825 0.45 784 0.23 448 0.2 447 0.19 6256 1.92 1044 0.08 15 105 5 35322 2.28 1921 0.39 1003 0.39 1001 0.38 301269 44.36 2850 0.22 15 105 6 133259 10.31 5997 0.63 2235 0.48 2101 0.45 160445 37.06 6960 0.28 15 105 7 258317 22.91 5873 0.54 2312 0.41 2221 0.41 2182510 300 8240 0.38 15 105 9 493166 39.80 6049 0.47 1968 0.21 1731 0.19 2623006 300 11743 0.47 15 105 10 550536 40.93 24259 1.95 2872 0.39 2831 0.29 898948 156.63 11830 0.41 20 190 4 192965 20.39 2651 1.86 1261 1.70 1266 1.69 200651 82.51 3143 0.20 20 190 5 1869837 186.76 9387 4.85 4452 4.56 4432 4.48 2064050 300 18283 1.06 20 190 6 2585912 300 49673 14.97 9018 4.55 8462 4.08 862115 300 35383 2.03 20 190 7 2661381 300 16690 4.67 4252 2.04 4288 1.97 1857850 300 19142 0.97 20 190 9 2433234 300 157236 34.43 6336 1.71 5972 1.60 1738525 300 119906 5.01 20 190 10 2628419 300 315618 52.61 9050 3.96 8645 3.56 1067170 300 151969 6.08 25 300 4 1898689 300 20202 58.53 6166 17.10 6217 17.1 592738 300 28842 1.48 25 300 5 2415919 300 86662 93.57 32787 80.62 26547 68.88 1553235 300 37608 2.83 25 300 6 2262702 300 402861 300 16150 17.66 15147 15.99 847691 300 534222 39.14 25 300 7 2045173 300 449104 210.13 76272 87.72 61098 63.68 1448142 300 812957 56.06 25 300 9 1929801 300 462886 300 21195 18.66 19724 17.43 1270399 300 2655810 114.14 25 300 10 1961836 300 620555 261.71 21453 11.86 21565 11.50 586552 300 1126130 55.47 20 50 4 14548 0.48 1219 0.05 558 0.05 558 0.05 4489 0.61 389 0.05 20 50 5 55748 2.58 307392 10.87 2258 0.26 2227 0.24 426762 40.91 3611 0.17 20 50 6 52217 2.34 68384 0.75 1574 0.10 1475 0.08 41892 5.28 2678 0.13 20 50 7 66676 3.45 25043 0.68 1381 0.12 1238 0.09 1389117 133 1975 0.14 20 50 9 274583 16.59 14016 0.33 1117 0.06 1261 0.06 3820792 300 13040 0.45 20 50 10 310688 18.93 410 0.01 564 0.03 564 0.02 329333 42.87 17937 0.64 40 100 4 3426079 300 45199 6.27 13766 4.41 13901 4.30 1180714 300 130480 5.44 40 100 5 3261615 300 9596291 300 36496 14.22 26970 9.69 3196955 300 161961 7.31 40 100 6 4836734 300 8161773 300 10708 2.59 5037 0.84 1851687 300 91022 4.72 40 100 7 4709441 300 5979528 300 38153 11.03 18504 4.49 2989047 300 778669 34.38 40 100 9 3646022 300 4468371 300 88837 25.12 36572 7.08 2873734 300 769161 40.16 Total 47017644 4868.2 31306034 2530.50 414642 312.21 302002 240.81 38365804 6245.15 7556985 379.84
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 33
Non-Crossing Minimal Spanning Trees
- 4 classes of Euclidean distance complete graphs
- C101, C201, R101, RC101 (Solomon benchmarks for VRP)
- Modify “lengths” of edges by random coefficient
- w[e] = coef * randomweight + (1-coef) * originalweight
- Compare results of NoExpl versus Expl
- reduction in nodes in search
- Results for time are correlated
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 34
Non-crossing edges MST on Euclidian Graphs
coef reduct 0.5 0.75 1.0
- 1.0
RC101 R101 C201 C101 0.2 0.4 0.6 0.8 1.0
(a) Instances with 25 nodes, 300 edges
coef reduct 0.5 0.75 1.0
- 1.0
RC101 R101 C201 C101 0.2 0.4 0.6 0.8 1.0
(b) Instances with 30 nodes, 435 edges
coef reduct 0.5 0.75 1.0
- 1.0
RC101 R101 C201 C101 0.2 0.4 0.6 0.8 1.0
(c) Instances with 35 nodes, 595 edges
coef reduct 0.5 0.75 1.0
- 1.0
RC101 R101 C201 C101 0.2 0.4 0.6 0.8 1.0
(d) Instances with 40 nodes, 780 edges
- Fig. 3: Reduction in nodes provided by explanations. The closer the reduction is to 1,
the more beneficial explanations were.
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 35
Conclusion
- Efficient algorithm for computing explanations for WST
propagations
- Does not produce minimal explanations
- Beneficial in constrained spanning tree problems
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 36
Thank you for your attention. Questions?
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 37
Why do we need to update the cost? (just in case)
a b c d e 10 12 4 5 6 7
- Fig. 4: Example of when updating the cost is absolutely necessary
Say limit is 25. This is feasible (MST is 4+5+6+7 = 22). If (a, b) and (b, c) are mandatory though, the best solution is 32.
- 32 - 10 + 5 = 27, 32 - 12 + 7 = 27 ⇒ empty explanation
- 32 - 10 + 5 = 27, 27 - 12 + 7 = 22 ⇒ c(b,c) ∈ explanation
Peter J. Stuckey WST Constraint with Explanations CPAIOR 2016 38