Alan Mishchenko University of California, Berkeley

Slides:



Advertisements
Similar presentations
Symbol Table.
Advertisements

A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
Introduction to Computer Science 2 Lecture 7: Extended binary trees
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
A Compressed Breadth-First Search for Satisfiability DoRon B. Motter and Igor L. Markov University of Michigan, Ann Arbor.
CUTE: A Concolic Unit Testing Engine for C Technical Report Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Good Programming Practices for Building Less Memory-Intensive EDA Applications Alan Mishchenko University of California, Berkeley.
Graphs. Made up of vertices and arcs Digraph (directed graph) –All arcs have arrows that give direction –You can only traverse the graph in the direction.
Developing a Simple ZDD Package Alan Mishchenko University of California, Berkeley.
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
7. Runtime Environments Zhang Zhizheng
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
1 Alan Mishchenko Research Update June-September 2008.
State Representation of State Space Searching Alan Tam Siu Lung
1 Computing Abstractions by integrating BDDs and SMT Solvers Alessandro Cimatti Fondazione Bruno Kessler, Trento, Italy Joint work with R. Cavada, A. Franzen,
Enhancing Model Checking Engines for Multi-Output Problem Solving Alan Mishchenko Robert Brayton Berkeley Verification and Synthesis Research Center Department.
 Problem Analysis  Coding  Debugging  Testing.
CSC 143 P 1 CSC 143 Recursion [Chapter 5]. CSC 143 P 2 Recursion  A recursive definition is one which is defined in terms of itself  Example:  Compound.
23/07/2016CSE1303 Part B lecture notes 1 Introduction to computer systems Lecture B01 Lecture notes section B01.
Implementing Subprograms
COSC160: Data Structures: Lists and Queues
Power Optimization Toolbox for Logic Synthesis and Mapping
Review: Two Programming Paradigms
Lists in Lisp and Scheme
Delay Optimization using SOP Balancing
Programming Fundamentals
Improving Runtime and Memory Requirements in EDA Applications
Faster Logic Manipulation for Large Designs
Enhancing PDR/IC3 with Localization Abstraction
Specialized Applications of Decision Diagrams Alan Mishchenko
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
11/10/2018.
Simple Circuit-Based SAT Solver
Chain Reduction for Binary and Zero-Suppressed Decision Diagrams
Versatile SAT-based Remapping for Standard Cells
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Program Slicing Baishakhi Ray University of Virginia
Standard-Cell Mapping Revisited
Introduction to Formal Verification
Fast Computation of Symmetries in Boolean Functions Alan Mishchenko
SAT-Based Area Recovery in Technology Mapping
The Metacircular Evaluator
Alan Mishchenko University of California, Berkeley
Canonical Computation without Canonical Data Structure
SAT-Based Optimization with Don’t-Cares Revisited
Canonical Computation Without Canonical Data Structure
CS212D: Data Structures Week 5-6 Linked List.
SAT-based Methods for Scalable Synthesis and Verification
Alan Mishchenko UC Berkeley (With many thanks to Donald Knuth,
Alan Mishchenko UC Berkeley (With many thanks to Donald Knuth for
Advanced Implementation of Tables
Integrating an AIG Package, Simulator, and SAT Solver
Canonical Computation without Canonical Data Structure
How to use hash tables to solve olympiad problems
Lists.
Data Structures & Algorithms
Recording Synthesis History for Sequential Verification
Delay Optimization using SOP Balancing
Course Overview PART I: overview material PART II: inside a compiler
Lecture No.02 Data Structures Dr. Sohail Aslam
Developing a Program.
CUTE: A Concolic Unit Testing Engine for C
Canonical Computation without Canonical Data Structure
Software Design Lecture : 39.
SAT-based Methods: Logic Synthesis and Technology Mapping
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
Introduction to Computer Science
Improving Runtime and Memory Requirements in EDA Applications
Presentation transcript:

Alan Mishchenko University of California, Berkeley Enumerating Reachable States of 2x2x2 Rubik's Cube Using Implicit and Explicit Methods Alan Mishchenko University of California, Berkeley

Outline Understanding decision diagrams Designing a minimalistic ZDD package Enumerating states of a Rubik’s Cube Implicit enumeration using ZDD Explicit enumeration using bitmaps Experiment Summary

Decision Diagrams DDs are a useful data-structure They are canonical and easy to use in computations In many cases (but not always), can be easily built Several flavors of DDs are available In this presentation, we focus on ZDDs, which are a good way to manipulate sparse sets A set is sparse if it contains relatively few elements out of the set of all possible elements For example, English alphabet has 26 characters but an average word is only 5 characters Various practical applications of ZDD are known We will focus on state enumeration

Minimalistic ZDD Package ZDDs are maintained in a software package Building a new package is a good exercise One idea is to make it as simple as possible For this, we need to isolate what is most useful A new simple ZDD package was developed This presentation is illustrated by actual C code The code can be found at https://github.com/berkeley-abc/abc/blob/master/src/misc/extra/extraUtilPerm.c

Building a DD Package Define data structures Pay special attention to memory management Write a procedure for creating a new node Develop neede traversal procedures Debug and clean up the code Develop and test application code based on the new package

Basic Data Structures typedef struct Abc_ZddObj_ Abc_ZddObj; // ZDD node struct Abc_ZddObj_ { unsigned Var : 31; unsigned Mark : 1; unsigned True; unsigned False; }; typedef struct Abc_ZddEnt_ Abc_ZddEnt; // cache entry struct Abc_ZddEnt_ int Arg0; int Arg1; int Arg2; int Res;

ZDD Manager typedef struct Abc_ZddMan_ Abc_ZddMan; struct Abc_ZddMan_ { // ZDD package parameters int nVars; // the number of variables int nObjs; // the number of nodes used int nObjsAlloc; // the number of nodes allocated // ZDD node representation Abc_ZddObj * pObjs; // node table int * pUnique; // unique table (chained hash table) int * pNexts; // next entry in the chain unsigned nUniqueMask;// unique table mask // computed table representation Abc_ZddEnt * pCache; // computed table unsigned nCacheMask; // computed table mask };

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->pUnique + (Abc_ZddHash(Var, True, False) & p->nUniqueMask); for ( ; *q; q = p->pNexts + *q ) if ( p->pObjs[*q].Var == Var && p->pObjs[*q].True == True && p->pObjs[*q].False == False ) return *q; assert( p->nObjs < p->nObjsAlloc ); *q = p->nObjs++; p->pObjs[*q].Var = Var; p->pObjs[*q].True = True; p->pObjs[*q].False = False; }

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

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 > b ) return Abc_ZddUnion( p, b, a ); if ( (r = Abc_ZddCacheLookup(p, a, b, ABC_ZDD_OPER_UNION)) >= 0 ) return r; A = Abc_ZddNode( p, a ); B = Abc_ZddNode( p, b ); if ( A->Var < B->Var ) r0 = Abc_ZddUnion( p, A->False, b ), r1 = A->True; else if ( A->Var > B->Var ) r0 = Abc_ZddUnion( p, a, B->False ), r1 = B->True; else r0 = Abc_ZddUnion( p, A->False, B->False ), r1 = Abc_ZddUnion( p, A->True, B->True ); r = Abc_ZddUniqueCreate( p, Abc_MinInt(A->Var, B->Var), r1, r0 ); return Abc_ZddCacheInsert( p, a, b, ABC_ZDD_OPER_UNION, r ); }

Case Study: Permutations 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. SAT’11, pp. 90-104 One of the applications cited in the paper, is enumeration of reachable states of a simplified Rubik’s cube Traditional cube is 3x3x3 and has 4.3*10^19 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 Minato’s ZDD-based implementation takes 207 sec to enumerate states of the simplified cube on a 2.4 GHz Core2Duo PC

Cube’s State Enconding

Cube’s Transition Relation

Experiment from Minato’s Paper

Experiment: ZDD-Based Enumeration UC Berkeley, ABC 1.01 (compiled May 14 2014 04:30:19) abc 01> cubeenum -z Enumerating states of 2x2x2 cube. Iter 0 -> 1 Nodes = 0 Used = 2 Time = 0.02 sec Iter 1 -> 10 Nodes = 63 Used = 577 Time = 0.25 sec Iter 2 -> 64 Nodes = 443 Used = 4349 Time = 0.57 sec Iter 3 -> 385 Nodes = 2018 Used = 26654 Time = 0.59 sec Iter 4 -> 2232 Nodes = 7451 Used = 119442 Time = 0.60 sec Iter 5 -> 12224 Nodes = 25178 Used = 490038 Time = 0.67 sec Iter 6 -> 62360 Nodes = 83955 Used = 1919750 Time = 0.91 sec Iter 7 -> 289896 Nodes = 290863 Used = 7182932 Time = 1.88 sec Iter 8 -> 1159968 Nodes = 614845 Used = 25301123 Time = 5.38 sec Iter 9 -> 3047716 Nodes = 585664 Used = 66228369 Time = 13.71 sec Iter 10 -> 3671516 Nodes = 19430 Used = 102292452 Time = 22.73 sec Iter 11 -> 3674160 Nodes = 511 Used = 103545878 Time = 23.08 sec Iter 12 -> 3674160 Nodes = 511 Used = 103566266 Time = 23.08 sec ZDD stats: Var = 276 Obj = 103566266 Alloc = 134217728 Hit = 63996630 Miss = 141768893 Mem = 4608.00 MB (on Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz)

Explicit Enumeration Use bitmap to remember visited states (depending on state-encoding, takes 50MB-4GB) and an array to remember states to be explored Mark the initial state, add it to the states to be explored Take one state to be explored, perform 9 transitions and check if they are visited; if not, add them to the states to be explored Stop when there is no states to be explored The code can found at https://github.com/berkeley-abc/abc/blob/master/src/misc/extra/extraUtilCube.c

Experiment: Explicit Enumeration UC Berkeley, ABC 1.01 (compiled May 14 2014 04:30:19) abc 01> cubeenum Enumerating states of 2x2x2 cube. Iter 0 -> 1 Time = 0.00 sec Iter 1 -> 10 Time = 0.00 sec Iter 2 -> 64 Time = 0.02 sec Iter 3 -> 385 Time = 0.09 sec Iter 4 -> 2232 Time = 0.25 sec Iter 5 -> 12224 Time = 0.34 sec Iter 6 -> 62360 Time = 0.35 sec Iter 7 -> 289896 Time = 0.39 sec Iter 8 -> 1159968 Time = 0.59 sec Iter 9 -> 3047716 Time = 1.23 sec Iter 10 -> 3671516 Time = 2.58 sec Iter 11 -> 3674160 Time = 3.04 sec Iter 12 -> 3674160 Time = 3.05 sec (on Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz) Memory Usage reported by command top: 1578 MB

Conclusion Discussed the basics of decision diagrams Proposed a minimalistic ZDD package Considered ZDD-based manipulation of sets of permutations and applied to Rubik’s cube Compared performance of ZDD-based enumeration with the explicit implementation Open question: when and under what conditions ZDD-based implemetaiton is faster?

Abstract The talk discusses the design of a minimalistic ZDD package using actual C code for illustration. The ZDD package was developed and applied to enumerate reachable states of the simplified (2x2x2) Rubik's cube, as described in Minato's Pi-DD paper (ISAAC 20014). The results of this paper were reproduced and independently verified to be correct. The talk also discusses an explicit enumeration method, which does not use decision diagrams. The runtime of the explicit method is faster than the ZDD-based one. An open question remains: in what applications or under what conditions, a ZDD-based implementation is faster than an explicit implementation. Speaker's bio and CV can be found here: https://people.eecs.berkeley.edu/~alanmi/speaker_bio.txt https://people.eecs.berkeley.edu/~alanmi/Alan_Mishchenko_CV.pdf