300 likes | 310 Views
Explore the impact of different encodings and maximality constraints on the performance of constraint satisfaction problems. The study compares various encoding methods using Choco 1.07 and ILOG Solver 5.0.
E N D
A Study of 0/1 Encodings Prosser & Selensky
A Study of 0/1 Encodings Prosser & Selensky
Paper in a nutshell You can encode a constraint satisfaction problem in a number of different, but logically equivalent ways. That is, each encoding explores the same search space, but they take different times. If you encode in a different constraint programming language you again get different relative performance for those encodings This is bad news
Presentation in a nutshell You can encode a constraint satisfaction problem (with n variables) as a problem of finding an independent set of size n That independent set is also maximal. Will the maximality constraint improve performance? Conclusion: maybe, maybe not. It depends on your toolkit!
A Hypergraph Encode CSP as independent set of size n 1 9 2 3 4 5 7 8 6
Independent set of a hypergraph G = (V,E) - a set I of vertices such that no edge in E is totally subsumed by I
An Independent Set Encode CSP as independent set of size n 1 1 9 9 2 2 3 3 4 4 5 5 7 7 8 8 6 6 You could add vertex 3 or vertex 8!
1 9 2 3 4 5 7 8 6 The Largest Independent Set Just so you know. There is only one for this graph
Represent a CSP with n variables as an independent set as follows • each vertex of the graph corresponds to an assignment of a value to a variable • if n variables each of domain size m, we have n.m vertices • there is an m-clique for each variable • therefore a variable can only take one value • constraints are explicitly represented as nogoods • a nogood is a hyper edge • select n vertices of the graph • corresponds to instantiation of all n variables
An Example X + Y + Z = 8 where X, Y and Z are in {2,3} Give me an independent set of size n We have n.m 0/1 vertices A hyper edge for each nogood An m-clique for each variable’s domain
Z3 X2 Z2 X3 Y2 Y3
Encode CSP as independent set of size n 1 9 2 3 4 5 7 8 6 • Constraints 3 and 4 can be implemented in two ways • sum of variables equals some value (r or k) • the number of occurrences of 1 equals some value (r or k) • Could this make a difference?
A Maximal Independent Set An independent set (as before), but we cannot add an element to the set without loss of the independence property. Note: the largest independent set is maximal … obviously
1 9 2 3 4 5 7 8 6 A Maximal Independent Set There are 11 maximal independent sets of size 6 Remember, there is one largest independent set, size 7
Encoding Maximality CP encoding 1 9 2 3 4 5 7 8 6 An example, vertex 2 That is, we state when a variable MUST be selected and when it MUST NOT be selected
CP encoding 1 9 2 3 4 5 7 8 6 Example, vertices 1,2, and 3
Actual Encoding of Maximality Example, vertice 3 • We have a sum • implement using sumVars or • implement using occurs We have the biconditional. This can be implemented in (at least) 3 ways Therefore 6 ways to implement maximality!
How it might go CSP Independent Set of Hypergraph Add redundant maximality constraint So? Solve
So, does maximality help? This IS exciting.
An experiment Does maximality help? • Encode independence using sumVars (rather than occurs) • Encode biconditional using ifOnlyIf • Given a hypergraph find an independent set of size k • using just independence constraint • using redundant maximality constraint • Carry out experiments using • Choco 1.07 • ILOG Solver 5.0 • Is run time reduced when we use maximality?
Choco 1.07 Run time in milliseconds Note: A’s largest indSet is size 14 B’s largest indSet is size 15 both encodings look for same thing Conclusion: Use maximality! About 3 times faster A & B are regular degree hypergraphs
Solver 5.0 Conclusion: Avoid maximality! About 8 times slower
Confused? • The paper has other confounding results such as • summation is faster than occurrence in Solver • occurrence is faster than summation in Choco • ((p & q) or (¬p & ¬q)) is fastest implementation of in Solver • ifOnlyIf is the fastest implementation of in Choco • maximality helps in Choco, and does not help in Solver
So? Why the differences, between Solver and Choco? Read the paper What does this mean? What lesson can I learn? Be paranoid