cudd  3.0.0
The University of Colorado Decision Diagram Package
Macros | Functions
cuddZddReord.c File Reference

Procedures for dynamic variable ordering of ZDDs. More...

#include "util.h"
#include "mtrInt.h"
#include "cuddInt.h"
Include dependency graph for cuddZddReord.c:

Macros

#define DD_MAX_SUBTABLE_SPARSITY   8
 

Functions

int Cudd_zddReduceHeap (DdManager *table, Cudd_ReorderingType heuristic, int minsize)
 Main dynamic reordering routine for ZDDs. More...
 
int Cudd_zddShuffleHeap (DdManager *table, int *permutation)
 Reorders ZDD variables according to given permutation. More...
 
int cuddZddAlignToBdd (DdManager *table)
 Reorders ZDD variables according to the order of the BDD variables. More...
 
int cuddZddNextHigh (DdManager *table, int x)
 Finds the next subtable with a larger index. More...
 
int cuddZddNextLow (DdManager *table, int x)
 Finds the next subtable with a smaller index. More...
 
int cuddZddUniqueCompare (void const *ptr_x, void const *ptr_y)
 Comparison function used by qsort. More...
 
int cuddZddSwapInPlace (DdManager *table, int x, int y)
 Swaps two adjacent variables. More...
 
int cuddZddSwapping (DdManager *table, int lower, int upper, Cudd_ReorderingType heuristic)
 Reorders variables by a sequence of (non-adjacent) swaps. More...
 
int cuddZddSifting (DdManager *table, int lower, int upper)
 Implementation of Rudell's sifting algorithm. More...
 
static MovezddSwapAny (DdManager *table, int x, int y)
 Swaps any two variables. More...
 
static int cuddZddSiftingAux (DdManager *table, int x, int x_low, int x_high)
 Given xLow <= x <= xHigh moves x up and down between the boundaries. More...
 
static MovecuddZddSiftingUp (DdManager *table, int x, int x_low, int initial_size)
 Sifts a variable up. More...
 
static MovecuddZddSiftingDown (DdManager *table, int x, int x_high, int initial_size)
 Sifts a variable down. More...
 
static int cuddZddSiftingBackward (DdManager *table, Move *moves, int size)
 Given a set of moves, returns the ZDD heap to the position giving the minimum size. More...
 
static void zddReorderPreprocess (DdManager *table)
 Prepares the ZDD heap for dynamic reordering. More...
 
static int zddReorderPostprocess (DdManager *table)
 Shrinks almost empty ZDD subtables at the end of reordering to guarantee that they have a reasonable load factor. More...
 
static int zddShuffle (DdManager *table, int *permutation)
 Reorders ZDD variables according to a given permutation. More...
 
static int zddSiftUp (DdManager *table, int x, int xLow)
 Moves one ZDD variable up. More...
 
static void zddFixTree (DdManager *table, MtrNode *treenode)
 Fixes the ZDD variable group tree after a shuffle. More...
 

Detailed Description

Procedures for dynamic variable ordering of ZDDs.

Author
Hyong-Kyoon Shin, In-Ho Moon

Function Documentation

◆ Cudd_zddReduceHeap()

int Cudd_zddReduceHeap ( DdManager table,
Cudd_ReorderingType  heuristic,
int  minsize 
)

Main dynamic reordering routine for ZDDs.

Calls one of the possible reordering procedures:

  • Swapping
  • Sifting
  • Symmetric Sifting

For sifting and symmetric sifting it is possible to request reordering to convergence.

The core of all methods is the reordering procedure cuddZddSwapInPlace() which swaps two adjacent variables.

Returns
1 in case of success; 0 otherwise. In the case of symmetric sifting (with and without convergence) returns 1 plus the number of symmetric variables, in case of success.
Side effects Changes the variable order for all ZDDs and clears
the cache.
Parameters
tableDD manager
heuristicmethod used for reordering
minsizebound below which no reordering occurs

◆ Cudd_zddShuffleHeap()

int Cudd_zddShuffleHeap ( DdManager table,
int *  permutation 
)

Reorders ZDD variables according to given permutation.

The i-th entry of the permutation array contains the index of the variable that should be brought to the i-th level. The size of the array should be equal or greater to the number of variables currently in use.

Returns
1 in case of success; 0 otherwise.
Side effects Changes the ZDD variable order for all diagrams and clears
the cache.
See also
Cudd_zddReduceHeap
Parameters
tableDD manager
permutationrequired variable permutation

◆ cuddZddAlignToBdd()

int cuddZddAlignToBdd ( DdManager table)

Reorders ZDD variables according to the order of the BDD variables.

This function can be called at the end of BDD reordering to insure that the order of the ZDD variables is consistent with the order of the BDD variables. The number of ZDD variables must be a multiple of the number of BDD variables. Let M be the ratio of the two numbers. cuddZddAlignToBdd then considers the ZDD variables from M*i to (M+1)*i-1 as corresponding to BDD variable i. This function should be normally called from Cudd_ReduceHeap, which clears the cache.

Returns
1 in case of success; 0 otherwise.
Side effects Changes the ZDD variable order for all diagrams and performs
garbage collection of the ZDD unique table.
See also
Cudd_zddShuffleHeap Cudd_ReduceHeap
Parameters
tableDD manager

◆ cuddZddNextHigh()

int cuddZddNextHigh ( DdManager table,
int  x 
)

Finds the next subtable with a larger index.

Returns
the index.
Side effects None

◆ cuddZddNextLow()

int cuddZddNextLow ( DdManager table,
int  x 
)

Finds the next subtable with a smaller index.

Returns
the index.
Side effects None

◆ cuddZddSifting()

int cuddZddSifting ( DdManager table,
int  lower,
int  upper 
)

Implementation of Rudell's sifting algorithm.

Assumes that no dead nodes are present.

  1. Order all the variables according to the number of entries in each unique table.
  2. Sift the variable up and down, remembering each time the total size of the DD heap.
  3. Select the best permutation.
  4. Repeat 3 and 4 for all variables.
Returns
1 if successful; 0 otherwise.
Side effects None

◆ cuddZddSiftingAux()

static int cuddZddSiftingAux ( DdManager table,
int  x,
int  x_low,
int  x_high 
)
static

Given xLow <= x <= xHigh moves x up and down between the boundaries.

Finds the best position and does the required changes.

Returns
1 if successful; 0 otherwise.
Side effects None

◆ cuddZddSiftingBackward()

static int cuddZddSiftingBackward ( DdManager table,
Move moves,
int  size 
)
static

Given a set of moves, returns the ZDD heap to the position giving the minimum size.

In case of ties, returns to the closest position giving the minimum size.

Returns
1 in case of success; 0 otherwise.
Side effects None

◆ cuddZddSiftingDown()

static Move* cuddZddSiftingDown ( DdManager table,
int  x,
int  x_high,
int  initial_size 
)
static

Sifts a variable down.

Moves x down until either it reaches the bound (x_high) or the size of the ZDD heap increases too much.

Returns
the set of moves in case of success; NULL if memory is full.
Side effects None

◆ cuddZddSiftingUp()

static Move* cuddZddSiftingUp ( DdManager table,
int  x,
int  x_low,
int  initial_size 
)
static

Sifts a variable up.

Moves y up until either it reaches the bound (x_low) or the size of the ZDD heap increases too much.

Returns
the set of moves in case of success; NULL if memory is full.
Side effects None

◆ cuddZddSwapInPlace()

int cuddZddSwapInPlace ( DdManager table,
int  x,
int  y 
)

Swaps two adjacent variables.

It assumes that no dead nodes are present on entry to this procedure. The procedure then guarantees that no dead nodes will be present when it terminates. cuddZddSwapInPlace assumes that x < y.

Returns
the number of keys in the table if successful; 0 otherwise.
Side effects None

◆ cuddZddSwapping()

int cuddZddSwapping ( DdManager table,
int  lower,
int  upper,
Cudd_ReorderingType  heuristic 
)

Reorders variables by a sequence of (non-adjacent) swaps.

Implementation of Plessier's algorithm that reorders variables by a sequence of (non-adjacent) swaps.

  1. Select two variables (RANDOM or HEURISTIC).
  2. Permute these variables.
  3. If the nodes have decreased accept the permutation.
  4. Otherwise reconstruct the original heap.
  5. Loop.
Returns
1 in case of success; 0 otherwise.
Side effects None

◆ cuddZddUniqueCompare()

int cuddZddUniqueCompare ( void const *  ptr_x,
void const *  ptr_y 
)

Comparison function used by qsort.

Comparison function used by qsort to order the variables according to the number of keys in the subtables.

Returns
the difference in number of keys between the two variables being compared.
Side effects None

◆ zddFixTree()

static void zddFixTree ( DdManager table,
MtrNode treenode 
)
static

Fixes the ZDD variable group tree after a shuffle.

Assumes that the order of the variables in a terminal node has not been changed.

Side effects Changes the ZDD variable group tree.

◆ zddReorderPostprocess()

static int zddReorderPostprocess ( DdManager table)
static

Shrinks almost empty ZDD subtables at the end of reordering to guarantee that they have a reasonable load factor.

However, if there many nodes are being reclaimed, then no resizing occurs.

Returns
1 in case of success; 0 otherwise.
Side effects None

◆ zddReorderPreprocess()

static void zddReorderPreprocess ( DdManager table)
static

Prepares the ZDD heap for dynamic reordering.

Does garbage collection, to guarantee that there are no dead nodes; and clears the cache, which is invalidated by dynamic reordering.

Side effects None

◆ zddShuffle()

static int zddShuffle ( DdManager table,
int *  permutation 
)
static

Reorders ZDD variables according to a given permutation.

The i-th permutation array contains the index of the variable that should be brought to the i-th level. zddShuffle assumes that no dead nodes are present. The reordering is achieved by a series of upward sifts.

Returns
1 if successful; 0 otherwise.
Side effects None

◆ zddSiftUp()

static int zddSiftUp ( DdManager table,
int  x,
int  xLow 
)
static

Moves one ZDD variable up.

Takes a ZDD variable from position x and sifts it up to position xLow; xLow should be less than or equal to x.

Returns
1 if successful; 0 otherwise
Side effects None

◆ zddSwapAny()

static Move* zddSwapAny ( DdManager table,
int  x,
int  y 
)
static

Swaps any two variables.

Returns
the set of moves.
Side effects None