# A Study of 0/1 Encodings Prosser & Selensky A Study of 0/1 Encodings Prosser & Selensky.

## Presentation on theme: "A Study of 0/1 Encodings Prosser & Selensky A Study of 0/1 Encodings Prosser & Selensky."— Presentation transcript:

A Study of 0/1 Encodings Prosser & Selensky

A Study of 0/1 Encodings Prosser & Selensky

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 Paper 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! Presentation in a nutshell

1 2 3 4 5 7 9 8 6 A HypergraphEncode CSP as independent set of size n

Independent set of a hypergraph G = (V,E) - a set I of vertices such that no edge in E is totally subsumed by I

1 2 3 4 5 7 9 8 6 1 2 3 4 5 7 9 8 6 An Independent Set You could add vertex 3 or vertex 8! Encode CSP as independent set of size n

1 2 3 4 5 7 9 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

X + Y + Z = 8 where X, Y and Z are in {2,3} An Example We have n.m 0/1 vertices A hyper edge for each nogood An m-clique for each variables domain Give me an independent set of size n

X2X2 X3X3 Y2Y2 Y3Y3 Z2Z2 Z3Z3

1 2 3 4 5 7 9 8 6 Encode CSP as independent set of size n 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 2 3 4 5 7 9 8 6 A Maximal Independent Set There are 11 maximal independent sets of size 6 Remember, there is one largest independent set, size 7

CP encoding 1 2 3 4 5 7 9 8 6 Encoding Maximality That is, we state when a variable MUST be selected and when it MUST NOT be selected An example, vertex 2

CP encoding 1 2 3 4 5 7 9 8 6 Example, vertices 1,2, and 3

More Generally

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!

CSP Independent Set of Hypergraph Add redundant maximality constraint Solve How it might go So?

So, does maximality help? This IS exciting.

An experiment 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? Does maximality help?

Choco 1.07 Conclusion: Use maximality! Run time in milliseconds Note: As largest indSet is size 14 Bs largest indSet is size 15 both encodings look for same thing About 3 times faster A & B are regular degree hypergraphs

Solver 5.0 Conclusion: Avoid maximality! About 8 times slower

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 Confused?

So? Why the differences, between Solver and Choco? Read the paper What does this mean? What lesson can I learn? Be paranoid

… and maximality is interesting!

Any questions?

Download ppt "A Study of 0/1 Encodings Prosser & Selensky A Study of 0/1 Encodings Prosser & Selensky."

Similar presentations