ZDD For Combination Problems
ZDD For Combination Problems
in Combinatorial Problems
Shin-ichi Minato
NTT LSI Laboratories
3-1, Morinosato Wakamiya, Atsugi-shi
Kanagawa Pref., 243-01, JAPAN
272
equivalent sharing
x3
&
*
01 x3
0 X2 o 10 ‘:*OX3 ‘
xl x2 x2
1
1° 0:@~ ;.1
~. xl 0/ “.$) x1
““0:,,1”01 ,.$ ..
0 1 ;. :, ,.. ,,.
(a) BDDs (b) Binary Tree Graph (a) Node Elimination (b) Node Sharing
Fig. 1: Binary Decision Diagram (BDD) Fig. 2: Reduction Rules on BDDs
{001,010} { Oocjl, oolo ]
f(a, b,c)=a+b
a
bcco 01 11 10 ~f(a, b,c, d)=a+b
00011 1T
{ bcoo 01 11 10
11 1 1 1 ad x3 ()
dFi!i
P@ 2 000011
1
I x2
010011 o,
f(a, b)=a+b
111111
xl xl
j’ La ~ ]Bl
101111
‘*
o 1
Fig. 3: Shared BDD (SBDD) Fig. 4: Suppression of Irrelevant Variables Fig. 5: BDDs for Combination Sets
● After generating BDDs, the equivalence of two func- Combination sets can describe solutions to combinw
tions can be checked in a constant time. torial problems. We can solve combinatorial problems
by manipulating combination sets. The representation
● Logic operations can be carried out within a time that and manipulation of combination sets are important tech-
is almost proportional to the size of graphs. niques for many applications.
We can represent a combination set with a Boolean
The size of BDDs largely depends on the order of the input function by using n input variables for each bit of the vec-
variables. We can find a good order in many cases using tor. The output value of the function expresses whether
heuristic methods[9][10]. each combination specified by the input variables are in-
The BDD package cannot exhibit its power if the graph cluded in the set or not. Such Boolean functions are called
size is too large to be held in the memory. It is im- characten”stic functions. The operations of sets, such as
portant how the graph is shrunk by the reduction rules. union, intersection and difference, can be executed by logic
One recent paper[l 1] shows that for generaJ (or random) operations on characteristic functions.
Boolean functions, node sharing makes a much more sig- Using BDDs for characteristic functions, we can manip-
nificant contribution to storage saving than node elimina- ulate combination sets efficiently. In such BDDs, the paths
tion. However, we consider that the node elimination is from the starting node to the l-terminal node, which we
also important for practicrd functions. For example, as in call l-paths, represent possible combinations in the set.
Fig. 4, the form of a BDD does not depend on the num- Because of the effect of node sharing, BDDs represent
ber of input variables as long as the expressions of the combination sets with a huge number of elements com-
functions are the same. Using BDDs, the irrelevant vari- pactly. In many practical cases, the size of graphs be-
ables are suppressed automatically and we do not have to comes much less than the number of elements. BDDs can
consider them. This property is significant because some- be generated and manipulated within a time that is ahnost
times we manipulate a function which depends on only a proportional to the size of graphs, while previous set rep-
few variables among hundreds. This suppression comes resentations, such as arrays and sequential lists, require a
from the node elimination of BDDs. time proportional to the number of elements.
Set manipulation using BDDs is very efficient, however,
2.2 Combination Sets
there is one inconvenience in that the form of BDDs de-
pends on the number of input variables, as shown in Fig. 5.
A combination on n objects can be represented by an Therefore we have to fix the number of input variables
n bit binary vector, (z~z~_l . . . Zzxl)j where each bit, before generating BDDs. This inconvenience comes from
z~ E {1, O}, expresses whether the corresponding object is the difference in the model on default variables. In com-
included in the combination or not. A set of combinations bination sets, default variables are regarded as zero when
can be represented by a set of the n bit binary vectors. the characteristic function is true? since the irrelevant ob-
We call such sets combination sets. Combination sets can jects never appear in any combmation. Unfortunately,
be regarded aa subsets of the power set on n objects. such variables can not be suppressed in the BDD repre-
273
sentation. We have to generate many useless nodes for “both OK” in Boolean functions. We can choose one of
irrelevant objects when we manipulate very sparse combi- the two types of BDDs according to the feature of appli-
nations. Node elimination does not work well in reducing cations,
the graphs in such cases.
In the following section, we describe a method that
solves the above problem by using BDDs based on new 4 Manipulation of O-Sup-BDDs
reduction rules.
4.1 Basic Operations
3 Zero-Suppressed BDDs In original BDDs, we first generate BDDs with only one
input variable for each input, and then we construct more
We propose the following reduction rules for BDDs to rep- complex BDDs by applying basic logic operations, such as
resent combination sets efficiently. AND, OR and EXOR. O-Sup-BDDs are also constructed
from the trivial graphs by applying basic operations, but
1. Eliminate W the nodes whose l-edge points to the the kinds of operations are not the same as with original
O-terminal node, Then connect the edge to the other BDDs since O-SUP-BDDS are adapted for combination set
subgraph directly, as shown in Fig. 6. manipulation.
2. Share all equivalent sub-graphs the same as for orig- We arranged the line up of basic operations for O-Sup-
inal BDDs.- BDDs w follows:
Notice that, contrary to the situation with original BDDs, Emptyo returns #. (empty set)
we do not eliminate the nodes whose two edges point to Baseo returns {0}.
the same node, This reduction rule is asymmetric for the Subsetl(P, var) returns the subset of P such as war = 1.
two edges, as we do not eliminate the nodes whose O-edge SubsetO(P, var) returns the subset of P such as war= 0.
points to a terminal nodes. Change(P, war) returns P when var is inverted.
We call BDDs based on the above rules Zero-Suppressed
Union(P, Q) returns (P u Q)
BDDs (0-Sup-BDDs). If the number and the order of in-
Intsec(P, Q) returns (P n Q)
put variables are fixed? a O-SUP-BDD represents a Boolean
function uniquely. Th~ property is clear because a binary Diff(P, Q) returns (P – Q)
tree as in Fig, l(b) can be reconstructed from a O-Sup- Count(P) returns lP\. (number of elements)
BDD by applying the reduction rule reversely.
In Fig. 91 we show the examples of O-Sup-BDDs gen-
Fig. 7 shows O-Sup-BDDs representing the combination
sets which are the same ones shown in Fig. 5, One fea- erated with the above operations. Emptyo returns the
ture of O-Sup-BDDs is that the form does not depend on O-terminal node, and Bsseo is the l-terminal node. Any
the number of input variables as long as the combination one combination can be generated with Bsseo operation
sets are the same, We do not have to fix the number of followed by Changeo operations for all the variables which
input variables before generating graphs. O-Sup-BDDs au- appear in the combination. Using Intseco operation, we
tomatically suppress the variables for objects which never can check whether a combination is contained in a set or
appear in any combination. It is very efficient when we not.
manipulate very sparse combinations. In O-Sup-BDDs, we do not have NOT operation, which
For evaluating efficiency of O-SUP-BDDS, we conducted is an essential operation in original BDDs. This is rea-
a statistical experiment. We generated a set of one hun- sonable since the complement set ~ cannot be computed
dred combinations each of which selects k out of 100 ob- if the universal set U is not defined. Using the difference
jects randomly. We then compared the size of both the operation, ~ can be computed as U – P,
O-Sup-BDDs and original BDDs representing these ran-
dom combinations. The result for variation in k is shown
4.2 Algorithms
in Fig. 8. This result shows that O-Sup-BDDs are much
more compact thaa original BDDs especially when k is We show here that the above operations for O-SUP-BDDS
small. Namely, O-SUP-BDDS are remarkably effective for can be executed recursively like original BDDs.
representing sets of sparse combinations. The effect weak- First, to describe the algorithms simply, we define
ens for large k; however, we can use complement combi- the procedure Getnode(top, P., PI), which generates (or
nations to make k small. For example, the combination copies) a node for a variable top and two subgraphs P., PI.
selecting 90 out of 100 objects is equivalent to selecting In the procedure, we use a hash table, called uniq-table,
the remaining 10 out of 100. to keep each node unique. Node elimination and sharing
Another advantage of O-Sup-BDDs is that the number are managed only by Getnodeo.
of l-paths in the graph is exactly equal to the number
of elements in the combination set. In original BDDs, Getnode (top, Po, PI) {
the node elimination breaks this property. Therefore, we if (PI == ~) return PO; /* node elimination */
believe that O-Sup-BDDs are more suitable than original P = search a node with (top, Po, PI ) in uniq-table;
BDDs to represent combination sets. if (P exist) return P; /* node sharing */
On the other hand, it would be better to use original P = generate a node with (top, PO, PI );
BDDs when representing ordinary Boolean functions, as append P to the uniq-table;
shown in Fig, 4. The difference is in the models on default return P;
variables; that is, “fixed to zero” in combination sets, and }
274
f(b
Original BDD
~“: x2 x2
0.
.; ‘..,1
, o: ..!
,..
0
0 10 20 30 40 50 60 70 80 90 100
Number of 1’s in a combination
~~~,,~~d ~
Fig. 8: Experimental Result
275
Table 1: Experimental Result for Irredundant Cube Set Remesentation
Name - In out Net #Cube #Literal #ZBDD Time(s) #BDD Time
c432 36 7 203 84235 969028 14407 83.2 41869 111.8
( a=b~c~
C499 41 32 275 348219564 6462057445 195356 2400.1 (>lM) -
ab +~={101000, 000001}
C880 60 26 464 114299 1986014 18108 78.7 69446 119.3
c1908 33 25 938 56323472 1647240617 233775 385.6 (>lM) -
al C5315 178 123 2608 137336131 742606419 41662 886.4 (>lM) -
oL
Ob
Fig.
H
0
T1
4.3 Using of Attributed Edges sets of cubes each of which is a combination of positive or
negative literals for input variables.
In original BDDs, we can reduce the execution time and
memory requirement by using attn”buted edges[9] to indi- Coudert and Madre proposed a representation of cube
cate cert tin logic operations such as inverting. Also O- sets using BDDs named Mets-products[7]. Met a-products
Sup-BDDs may have a kind of attributed edges, but the are BDD representations for characteristic functions of
operation should be different from original BDDs. cube sets. In their method, two variables are used for each
Here we present an attributed edge for O-Sup-BDDs. input and these decide the existence of the literal and its
This attributed edge, named O-element edge, indicates sign. The y also presented further reduced graphs, named
that the pointing sub-graph has a l-path which consists Implicii Prime Sets (IPS)[12], to represent prime cube sets
of O-edges only. In other word, a O-element edge means efficiently. However, IPS can represent only pn”me cube
that the combina~ion set includes the element of O. We sets aud they do not give canonical expressions for general
use the notation P to express the O-element edge pointing cube sets.
P.
As with other attributed edges, we have to place a cou- Using O-Sup-BDDs, we can represent any cube set sim-
ple of constraints on the location of O-element edges to ply, efficiently and uniquely. As shown in Fig. 11, a cube
keep the uniqueness of the graphs. They are: set can be seen as a combination set by using two variables
for the literals z~ and ~. Both z~ and ~ never appear
● Use the O-terminal only, since {O} can be written as
in the same cube; that is, at least one of them should be
d O. The O’s are conveniently suppressed in O-SUP-BDDS.
The cube set manipulation can be composed of basic op-
● Do not use O-element edges at the O-edge on each
erat ions on O-Sup-BDDs. The number of cubes equals the
node.
number of l-paths in the graph. The total number of lit-
If necessary, O-element edges can be carried over, as shown erals can be counted in a time proportional to the size of
in Fig. 10. The constraint rules can be implemented in the the graph.
Getnodeo.
O-element edges accelerate operations on O-Sup-BDDs. We conducted an experiment to evaluate this method.
For example, the result of Union(P, {0}) depends only on We generated prime and irredundant cube sets for the
whether P includes the element of O or not. In such a case, functions of large-scale combinational circuits using the
we can get the result in a constant time using O-element ISOP algorithm presented at SASIMI’92[13]. We repre-
edges, otherwise we have to repeat the expansion until P sented the results of the cube sets in O-SUP-BDDS and in
becomes a terminal node. original BDDs to compare the size of graphs and the ex-
ecution time. In Table 1, In, Out and Net show the size
of the circuits. #Cube and #Literal show the cube sets
5 Applications obtained. #ZBDD is the size of O-SUP-BDDS representing
the cube sets, and #BDD is when using original BDDs.
In this section, we show that O-Sup-BDDs can be readily
applied to practical problems. As mentioned in forego- The experimental results show that O-Sup-BDDs enable
ing sections, O-Sup-BDDs are suitable for manipulation of us to generate yery large prime-irredundant cube sets con-
combination sets, especially when the combinations are taining billions of literals. Noteworthy is c5315, where
sparse. only 5.5 literals appear in a cube on average, while the
function has 178 inputs (i. e., 356 literals). In such a case
5.1 Cube Set Representation where the combinations are very sparse, O-Sup-BDDs are
dramatically effective. When we manipulate cube sets U5
In many logic design systems, cube sets (also called cov- ing intermediate variables to represent multi-level logics,
ers, PLAs, sum-of-products forms or two-level logics) are the cube sets are more sparse, and O-Sup-BDDs will be
employed to represent Boolean functions. Cube sets are more effective,
276
5.2 For Combinatorial Problems O-SUP-BDDS appear to display some interesting proper-
ties. So far, we ha;e only eval-uated them statistic-~y. ‘Our
The methods of solving combinatorial problems are im- future work includes a theoretical analysis of O-SUP-BDDS
portant in developing VLSI CAD systems. The solutions and developing good practical applications for them.
of a combinatorial problem can be represented in a com-
bination set. There are many practical applications which
require good representation of combination sets. Acknowledgment
One example is representing sets of paths in networks
The author wish to acknowledge the interesting discus-
for timing analysis. We can express a path as a combina-
sions with Olivier Coudert and Fabio Somenzi.
tion of variables each of which represents a net, as shown
in Fig. 12. A set of paths can be represented as a combi-
nation set. Since a path consists of a comparatively small References
number of nets in the network, the combinations are usu-
ally sparse and effectively represented using O-Sup-BDDs. [1] S. B. Akers: “BinarY Decision Diagrams”, IEEE
Representation of fault sets in logic circuits is another Trans. Comput., pp. 509-516, 1978 -
[2] R. E. Bryant: “Graph-Based Algorithms for Boolean
good application. We can express any combination of
Function Manipulation”, IEEE ‘Ihns. Comput.,
faults using variables that represent faults, as presented in
pp. 677-691, 1986
[5]. If we represent double or triple faults using this data [3] M. Fujita, H. Fojisawa and n. Kawato: “Evaluation
structure, the combinations will be very sparse, therefore and Improvement of Boolean Comparison Method
we expect that O-Sup-BDDs would be effective. This rep- Based on Binary Decision Diagrams”, Proc. IEEE
resentation method may be also utilized for test pattern lCCAD’88, p. 2-5, 1988
compact ion and fault diagnosis. [4] R. K. Gae x e, M. R. Mercer, K. M. Bulter and
We expect that O-Sup-BDDs will be useful not only “CATAPULT: .Concurrent. Automati
!?&&gRA 7: rowing Parrdlehzatlon and Using Lmute J
in logic design systems but also in layout or high-level
Topology”, Proc. ACM/IEEE 25th DAC, pp. 597-
CAD systems, because in these systems there are many
600, 1988
instances where the manipulation of sparse combinations
[5] N. Takahashi, n. Ishiura and S. Yajirna: “Fault Sim-
is required.
ulation for Multiple Faults Using Shsred BDD Rep-
Furthermore, O-Sup-BDDs can be used to solve gen- resentation of Fault Sets”, Proc. IEEE ICCAD’90,
eral combinatorial problems. Lin and Somenzi proposed a pp. 550-553 1991
method of solving binite covering problems using BDDs[8]. [6] J. R. Burc~, E, M. Clarke, K. L. McMillan and
Using this method as a basis, we can efficiently compute D. L. Dill: “Sequential Circuit Verification Using
the minimum-cost solution by generating a BDD which Symbolic Model Checking”, Proc. ACM/IEEE 27th
represents the constraint function of the problem. This DAC, p .46-51, 1990
method can also be used if we use O-Sup-BDDs instead of [7] O. Cou cl’ert and J. C. Madre: “Implicit and Incremen-
original BDDs. tal Computation of Primes and Essential Implicant
Primes of Boolesn Functions”, Proc. ACM/IEEE
O-SUP-BDDS are effective when the solutions are rep-
29th DAC, pp. 36-39, 1992
resented in sparse combinations. For example, in the N-
[8] Bill Lin and Fabio Somenzi: “Minimization of Sym-
Queen problem, there are only n queens on a chessboard bolic Relations”, Proc. IEEE ICCAD’90, pp. 88-91,
matrix with n2 points. If we use variables for each point, (1990).
solutions are obviously expressed in a sparse combina- [9] S. Minato, N. Ishiura and S. Yajima: Shared Binary
tion. Similarly in the traveling salesman problem, there Decision Diagram with Attributed Edges for Efficient
are n(n – 1)/2 paths connecting n points with each other, Boolean Function Manipulation, ACM/IEEE Proc.
and we take only n paths to travel to all the points. 27th DAC, pp. 52-57, 1990
Compact representation is the key to solving problems. [10] M. Fujita, Y. Matsunaga and T. Kakuda: On Vari-
We consider that many useful algorithms, such as the able Ordering of Binary Decision Diagrams for the
dynamic programming and divide-and-conquer method, Application of Multi-level Logic Synthesis, Proc. the
could be efficiently composed of operations on O-sup- European Conference on Design Automation, pp.50-
54, 1991
BDDs.
[11] H.-T. Liaw and C.-S. Lin: “On the OBDD-
Representation of General Boolean Functions” IEEE
Trans. Comput., pp. 661-664, 1992
6 Conclusion [12] 0. Coudert and J. C. Madre: “A New Implicit Graph
Based Prime and EssentisJ Prime Computation Tech-
We have proposed O-Sup-BDDs, which are BDDs based nique”, Proc. International Symposium on Logic Syn-
on a new reduction rule, and presented their manipula- thesis and Microprocessor Architecture (ISKIT’92,
tion algorithms and applications. O-Sup-BDDs can repre- Jsap~~a~~. 125-131, 1992.
sent a combination set uniquely and more compactly than [13] : ‘Fast Generation of Irredundant Sum-
original BDDs. The effect of O-Sup-BDDs is remarkable of-Products Forms from Binary Decision Diagrams’,
Proceedings of the Synthesis and Simulation Meeting
especially when manipulating sparse combinations. We
and International Interchange (SASIMI’92, Japan),
expect that there are many applications which require the
1992, pp. 6473
manipulation of such combination sets.
277