A generalpurpose toolkit for combinatorial problems Torsten M ü tze Based on D Knuth The Art of Computer Programming Vol 4 Binary Decision Diagrams BDDs ID: 912373
Download Presentation The PPT/PDF document "Binary Decision Diagrams" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Binary Decision DiagramsA general-purpose toolkit for combinatorial problems Torsten Mütze[Based on D. Knuth, The Art of Computer Programming, Vol. 4]
Slide2Binary Decision Diagrams (BDDs)Data structure to represent a Boolean functionD. Knuth 2008: “One of the only really fundamental data structures that came out in the last 25 years.”Very powerful general-purpose toolkit forall fundamental combinatorial problems:countingrandom samplingcomputing minimum/
maximum weight
independent sets
matchingsspanning treesHamilton paths/cycles
colorings
…
Slide3Binary Decision Diagrams (BDDs) - Definition
Data structure to represent a Boolean
function
i
i
R2
R1
i
1
2
2
3
3
3
3
┴
┬
┴
┬
┴
┬
┴
┬
1
2
2
3
┴
┬
Directed
acyclic graph
1
2
2
3
┴
┬
3
must be
ordered
…
…and
reduced
!
i
i
Slide4Virtues of BDDsEvaluate for any in stepsFind lexicographically smallest
with in stepsCount solutions to
Count solutions to with forGenerate uniformly random solutionto
Solve over all with
Efficient algorithms
to construct,
combine and modify BDDs
Encode class of
combinatorial objects as solutions to a
boolean
function
Build BDD for
independent sets
matchings
spanning trees
Hamilton paths/cycles
colorings
…
Count all…
Compute the generating function of all…
Sample uniformly at random…
Compute
maximum/minimum weight…
Dynamic programming
on the BDD
Running time polynomial in and
number of
nodes
of the BDD of
small
→
efficient algorithm,
often number of solutions
Recipe for
combinatorialists
Slide5Count solutions to
Bottom-up
dynamic program
Decorate BDD
nodes with
counts ‘=‘ #paths from
node to
Example
Count all independent sets of
┴
┬
1
1
0
→ result
1
2
3
4
5
6
0
1
2
1
3
1
2
3
5
3
5
8
5
13
5
18
i
i+1
i+1
i
j
k
┬
1
2
3
5
6
4
1
2
3
5
6
4
Slide6Count solutions to with
for
Bottom-up
dynamic program
Decorate BDD nodes
with
count vectors
Example
Compute the generating function
of all independent sets of
┴
┬
1
(1,0,…,0)
(0,0,…,0)
→ result vector
1
2
3
4
5
6
(
0,0,0,0,0,0,0)
(
1,0,0,0,0,0,0)
i
i+1
i+1
i
j
k
weighted sum
with binomial coefficients
(
1,6,9,2,0,0,0)
Slide7Generate uniformly random solutions to Count solutions bottom-up
Generate random solution top-downby setting the ‘s one after the otherwith the corresponding
probabilitiesExampleSample a uniformly randomindependent set of
Example
1
2
3
4
5
6
0
1
2
1
1
2
3
3
5
3
5
8
5
13
5
18
1
2
3
5
6
4
#
ind.sets
=
792.070.839.848.372.253.127
Solve overall with
Bottom-up
dynamic program
Decorate BDD nodes
with
current
maximum
Example
Compute a maximum weight independent set of the USA graph,
vertex weights = postal codes
┴
┬
1
0
→ result
i
j
k
i
i+1
i+1
sums of skipped
positive weights
#
ind.sets
= 211.954.906
etc.
maximum weight =
492
(
2
optimal solutions)
Slide9Building BDDs
┴
┬
┴
┬
┴
┬
┴
┬
┴
┬
Atomic BDDs as
building blocks
Operations
on BDDs
i
┴
┬
Single
variable
BDDs
BDDs for symmetric functions
iff
n
n
n
n
n
1
2
2
3
3
3
+reduce
0
1
┴
┴
┴
┬
┴
┴
┴
┴
┴
┬
┬
┬
┬
┴
┴
┬
┬
┬
Slide10Building graph BDDs
Independent sets of a graph on verticesSimilar: Colorings of a
graphMatchings of a graph on edges
Somewhat more complicated:
Connected
spanning
subgraphs
Spanning
trees
Hamilton
paths
/
cycles
forbid adjacent vertices
enforce degree <=2
enforce m-1 edges
enforce degree = 2
enforce degree <= 2
Slide11Example: USA graphBDD size
CountIndependent setsB(IND) = 428
211.954.9064-colorings
B(4COL) = 25579
25.623.183.458.304
Matchings
B
(MAT) = 3376
105.349.480.877.850
Connected
spanning
subgraphs
B
(CONN) =
43109
393.352.428.583.002.517.479.225.491.456
Spanning
trees
188.245.384.298.803.435.554.555
Hamilton
pathsB(HAMPATHS) = 23385
26.652.195Hamilton cyclesB(HAMCYCLES) = 1
0
via
g.f.
┴
Slide12Size of BDDs
ordering: 1,2,3,4,5,6,7,8B(f)=10
ordering: 1,3,5,7,2,4,6,8B(f)=32
Construction of BDDs for a
fixed
variable
ordering
Different
ordering
→ different BDDs, with
possibly
very
different
size
Example
Theorem
[Bollig, Wegener ‘96
]
Computing
an optimal variable
ordering
is NP-hard.
Slide13Size of BDDsFew interactions between variables → small BDD
Theorem [McMillan ‘92]If can be computed by such a network, then .
Exampleindependent set BDD of 4x4 grid
B(f)=240
B(f)=92
B(f)=80
2
1
3
6
4
5
7
8
9
10
11
12
13
14
15
16
2
1
3
6
4
5
7
8
9
10
11
12
13
15
16
14
2
1
3
6
4
5
7
8
9
10
11
12
13
14
15
16
Slide14Thank you!Questions?