a study of 0/1 encodings prosser & selensky a study of 0/1 encodings prosser & selensky
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 ofdifferent, but logically equivalent ways. That is, each encodingexplores the same search space, but they take different times.
If you encode in a different constraint programming languageyou 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
)}9,8,7,3(),6,4(),5,4,2(),3,2,1{(
}9,8,7,6,5,4,3,2,1{
E
V
A Hypergraph
Encode 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}9,7,5,4,1{S
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
}9,8,7,6,5,2,1{S
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
20
...
30
31
20
21
2
3
3
2
2
ZZ
XX
XX
XX
XX
We have n.m 0/1 vertices
)},,(),,,(),,,(),,,(),,,{( 333223232322222 ZYXZYXZYXZYXZYXnogoods
A hyper edge for each nogood
)},(),,(),,{( 323232 ZZYYXXcliques
An m-clique for each variable’s domain
Give me an independent set of size n
9333
8233
8323
7223
8332
7232
7322
6222ZYX
X2
X3
Y2Y3
Z2
Z3
1
2 3
4 5 7
9
8
6
Vv
ev
k size ofset t independen 4.
e hyperedge ofarity isr ce,independen v 3.
selectednot ex vert0 2.
selectedex vert1 1.
kv
r
iV
iVth
i
thi
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 anelement 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
}8,7,6,5,3,2{S
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
)2()2(1
)2()2(0
54312
54312
VVVVV
VVVVV
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
on so and ...
)3()2(1
)3()2(0
)2()2(1
)2()2(0
21
20
987213
987213
54312
54312
321
321
VVVVVV
VVVVVV
VVVVV
VVVVV
VVV
VVV Example, vertices 1,2, and 3
More Generally
]1)([0
]1)([1
maximality ensure :Vertices
)()(
)()(
iji
iji
VeverticesVj
Vedgesei
VeverticesVj
Vedgesei
VearityV
VearityV
))((
ceindependen ensure :Edges
)(
earityVEeeverticesV
VV
i
i
kV
set of size :Graph
Actual Encoding of Maximality
)3()2(1 987213 VVVVVV
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
)()( (3)
)()( (2)
(1)
pqqp
qpqp
qp
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
2590705018
44801696017
140803628016
102015
1840722018
55301642017
132103519016
184507035015
4029014
B
A
misisk
Conclusion: Use maximality!
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
About 3 times faster
A & B are regular degree hypergraphs
Solver 5.0
60912518
148421817
345342216
626215
64112518
151621817
346940616
678178115
7812514
B
A
misisk
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?