Developing a Simple ZDD Package - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Developing a Simple ZDD Package

Description:

Developing a Simple ZDD Package Alan Mishchenko University of California, Berkeley – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 17
Provided by: Alan204
Category:

less

Transcript and Presenter's Notes

Title: Developing a Simple ZDD Package


1
Developing a Simple ZDD Package
  • Alan Mishchenko
  • University of California, Berkeley

2
Outline
  • Decision diagrams
  • ZDD package
  • Experiment
  • Summary

3
Decision Diagrams
  • DDs are a useful data-structure
  • It is a good exercise to build a new DD package
  • This presentation is based on real code without
    any simplification
  • The code can be found at https//bitbucket.org/ala
    nmi/abc/src/4dc7e5aa7805931d35ba1c310f90f5baed74d8
    59/src/misc/extra/extraUtilPerm.c

4
Building a DD Package
  • Define data structures
  • Consider memory management
  • Write a procedure for creating a new node
  • Develop traversal procedures
  • Debug and clean up the code
  • Develop and test application code based on the
    new package

5
Basic Data Structures
  • typedef struct Abc_ZddObj_ Abc_ZddObj
  • struct Abc_ZddObj_
  • unsigned Var 31
  • unsigned Mark 1
  • unsigned True
  • unsigned False
  • typedef struct Abc_ZddEnt_ Abc_ZddEnt
  • struct Abc_ZddEnt_
  • int Arg0
  • int Arg1
  • int Arg2
  • int Res

6
ZDD Manager
  • typedef struct Abc_ZddMan_ Abc_ZddMan
  • struct Abc_ZddMan_
  • int nVars
  • int nObjs
  • int nObjsAlloc
  • int nPermSize
  • unsigned nUniqueMask
  • unsigned nCacheMask
  • int pUnique
  • int pNexts
  • Abc_ZddEnt pCache
  • Abc_ZddObj pObjs
  • int nCacheLookups
  • int nCacheMisses
  • word nMemory
  • int pV2TI
  • int pV2TJ
  • int pT2V

7
Creating New Node
  • static inline unsigned Abc_ZddHash( int Arg0, int
    Arg1, int Arg2 )
  • return 12582917 Arg0 4256249 Arg1
    741457 Arg2
  • static inline int Abc_ZddUniqueCreate(
  • Abc_ZddMan p, int Var, int True, int False
    )
  • if ( True 0 )
  • return False
  • else
  • int q p-gtpUnique (Abc_ZddHash(Var,
    True, False) p-gtnUniqueMask)
  • for ( q q p-gtpNexts q )
  • if ( p-gtpObjsq.Var Var
  • p-gtpObjsq.True True
  • p-gtpObjsq.False False )
  • return q
  • assert( p-gtnObjs lt p-gtnObjsAlloc )
  • q p-gtnObjs
  • p-gtpObjsq.Var Var

8
Traversal Procedures
  • Set operations
  • Union, difference, intersection
  • Product operations
  • Dot-product, cross-product
  • Counting operations
  • Count the number of nodes and paths
  • Permutation operations
  • Transposition, permutation product

9
ZDD Union
  • int Abc_ZddUnion( Abc_ZddMan p, int a, int b )
  • Abc_ZddObj A, B
  • int r0, r1, r
  • if ( a 0 ) return b
  • if ( b 0 ) return a
  • if ( a b ) return a
  • if ( a gt b ) return Abc_ZddUnion( p, b, a )
  • if ( (r Abc_ZddCacheLookup(p, a, b,
    ABC_ZDD_OPER_UNION)) gt 0 )
  • return r
  • A Abc_ZddNode( p, a )
  • B Abc_ZddNode( p, b )
  • if ( A-gtVar lt B-gtVar )
  • r0 Abc_ZddUnion( p, A-gtFalse, b ),
  • r1 A-gtTrue
  • else if ( A-gtVar gt B-gtVar )
  • r0 Abc_ZddUnion( p, a, B-gtFalse ),
  • r1 B-gtTrue
  • else

10
Experiment
  • Shin-ichi Minato proposed PiDDs, a ZDD-based
    data-structure to represent and manipulate
    permutations
  • Shin-ichi Minato, "PiDD A new decision diagram
    for efficient problem solving in permutation
    space, Proc. SAT11, pp. 90-104
  • One of the applications cited in the paper, is
    enumeration of reachable states of a simplified
    Rubiks cube
  • Traditional cube is 3x3x3 and has 4.31019
    states
  • http//en.wikipedia.org/wiki/Rubiks_Cube
  • Simplified cube is 2x2x2 and has only 3,674,160
    states
  • http//en.wikipedia.org/wiki/Pocket_cube
  • Minatos ZDD-based implementation takes 207 sec
    to enumerate states of the simplified cube on a
    2.4 GHz Core2Duo PC

11
Cubes State Enconding
12
Cubes Transition Relation
13
Experiment from Minatos Paper
14
Experiment ZDD-Based Enumeration
  • UC Berkeley, ABC 1.01 (compiled May 14 2014
    043019)
  • abc 01gt cubeenum -z
  • Enumerating states of 2x2x2 cube.
  • Iter 0 -gt 1 Nodes 0 Used
    2 Time 0.00 sec
  • Iter 1 -gt 10 Nodes 63 Used
    577 Time 0.00 sec
  • Iter 2 -gt 64 Nodes 443 Used
    4349 Time 0.03 sec
  • Iter 3 -gt 385 Nodes 2018 Used
    26654 Time 0.12 sec
  • Iter 4 -gt 2232 Nodes 7451 Used
    119442 Time 0.43 sec
  • Iter 5 -gt 12224 Nodes 25178 Used
    490038 Time 1.07 sec
  • Iter 6 -gt 62360 Nodes 83955 Used
    1919750 Time 1.77 sec
  • Iter 7 -gt 289896 Nodes 290863 Used
    7182932 Time 3.16 sec
  • Iter 8 -gt 1159968 Nodes 614845 Used
    25301123 Time 8.18 sec
  • Iter 9 -gt 3047716 Nodes 585664 Used
    66228369 Time 20.72 sec
  • Iter 10 -gt 3671516 Nodes 19430 Used
    102292452 Time 34.28 sec
  • Iter 11 -gt 3674160 Nodes 511 Used
    103545878 Time 34.80 sec
  • Iter 12 -gt 3674160 Nodes 511 Used
    103566266 Time 34.81 sec
  • ZDD stats Var 276 Obj 103566266 Alloc
    134217728
  • Hit 63996630 Miss 141768893 Mem
    4608.00 MB

15
Experiment Explicit Enumeration
  • UC Berkeley, ABC 1.01 (compiled May 14 2014
    043019)
  • abc 01gt cubeenum
  • Enumerating states of 2x2x2 cube.
  • Iter 0 -gt 1 Time 0.00 sec
  • Iter 1 -gt 10 Time 0.00 sec
  • Iter 2 -gt 64 Time 0.00 sec
  • Iter 3 -gt 385 Time 0.00 sec
  • Iter 4 -gt 2232 Time 0.01 sec
  • Iter 5 -gt 12224 Time 0.03 sec
  • Iter 6 -gt 62360 Time 0.09 sec
  • Iter 7 -gt 289896 Time 0.18 sec
  • Iter 8 -gt 1159968 Time 0.36 sec
  • Iter 9 -gt 3047716 Time 1.02 sec
  • Iter 10 -gt 3671516 Time 2.44 sec
  • Iter 11 -gt 3674160 Time 2.93 sec
  • Iter 12 -gt 3674160 Time 2.93 sec

16
Conclusion
  • Discussed basics of decision diagrams
  • Proposed a simple ZDD package
  • Analyzed performance of ZDDs vs explicit method
    for a state enumeration problem
Write a Comment
User Comments (0)
About PowerShow.com