cudd  3.0.0
The University of Colorado Decision Diagram Package
Functions
cuddReorder.c File Reference

Functions for dynamic variable reordering. More...

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

Functions

int Cudd_ReduceHeap (DdManager *table, Cudd_ReorderingType heuristic, int minsize)
 Main dynamic reordering routine. More...
 
int Cudd_ShuffleHeap (DdManager *table, int *permutation)
 Reorders variables according to given permutation. More...
 
DdNodecuddDynamicAllocNode (DdManager *table)
 Dynamically allocates a Node. More...
 
int cuddSifting (DdManager *table, int lower, int upper)
 Implementation of Rudell's sifting algorithm. More...
 
int cuddSwapping (DdManager *table, int lower, int upper, Cudd_ReorderingType heuristic)
 Reorders variables by a sequence of (non-adjacent) swaps. More...
 
int cuddNextHigh (DdManager *table, int x)
 Finds the next subtable with a larger index. More...
 
int cuddNextLow (DdManager *table, int x)
 Finds the next subtable with a smaller index. More...
 
int cuddSwapInPlace (DdManager *table, int x, int y)
 Swaps two adjacent variables. More...
 
int cuddBddAlignToZdd (DdManager *table)
 Reorders BDD variables according to the order of the ZDD variables. More...
 
static int ddUniqueCompare (void const *ptrX, void const *ptrY)
 Comparison function used by qsort. More...
 
static MoveddSwapAny (DdManager *table, int x, int y)
 Swaps any two variables. More...
 
static int ddSiftingAux (DdManager *table, int x, int xLow, int xHigh)
 Given xLow <= x <= xHigh moves x up and down between the boundaries. More...
 
static MoveddSiftingUp (DdManager *table, int y, int xLow)
 Sifts a variable up. More...
 
static MoveddSiftingDown (DdManager *table, int x, int xHigh)
 Sifts a variable down. More...
 
static int ddSiftingBackward (DdManager *table, int size, Move *moves)
 Given a set of moves, returns the DD heap to the position giving the minimum size. More...
 
static int ddReorderPreprocess (DdManager *table)
 Prepares the DD heap for dynamic reordering. More...
 
static int ddReorderPostprocess (DdManager *table)
 Cleans up at the end of reordering. More...
 
static int ddShuffle (DdManager *table, int *permutation)
 Reorders variables according to a given permutation. More...
 
static int ddSiftUp (DdManager *table, int x, int xLow)
 Moves one variable up. More...
 
static void bddFixTree (DdManager *table, MtrNode *treenode)
 Fixes the BDD variable group tree after a shuffle. More...
 
static int ddUpdateMtrTree (DdManager *table, MtrNode *treenode, int *perm, int *invperm)
 Updates the BDD variable group tree before a shuffle. More...
 
static int ddCheckPermuation (DdManager *table, MtrNode *treenode, int *perm, int *invperm)
 Checks the BDD variable group tree before a shuffle. More...
 

Detailed Description

Functions for dynamic variable reordering.

Author
Shipra Panda, Bernard Plessier, Fabio Somenzi

Function Documentation

◆ bddFixTree()

static void bddFixTree ( DdManager table,
MtrNode treenode 
)
static

Fixes the BDD 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 BDD variable group tree.

◆ Cudd_ReduceHeap()

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

Main dynamic reordering routine.

Calls one of the possible reordering procedures:

  • Swapping
  • Sifting
  • Symmetric Sifting
  • Group Sifting
  • Window Permutation
  • Simulated Annealing
  • Genetic Algorithm
  • Dynamic Programming (exact)

For sifting, symmetric sifting, group sifting, and window permutation it is possible to request reordering to convergence.

The core of all methods is the reordering procedure cuddSwapInPlace() which swaps two adjacent variables and is based on Rudell's paper.

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 diagrams and clears
the cache.
Parameters
tableDD manager
heuristicmethod used for reordering
minsizebound below which no reordering occurs

◆ Cudd_ShuffleHeap()

int Cudd_ShuffleHeap ( DdManager table,
int *  permutation 
)

Reorders 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 variable order for all diagrams and clears
the cache.
See also
Cudd_ReduceHeap
Parameters
tableDD manager
permutationrequired variable permutation

◆ cuddBddAlignToZdd()

int cuddBddAlignToZdd ( DdManager table)

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

This function can be called at the end of ZDD reordering to insure that the order of the BDD variables is consistent with the order of the ZDD 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. cuddBddAlignToZdd 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_zddReduceHeap, which clears the cache.

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

◆ cuddDynamicAllocNode()

DdNode* cuddDynamicAllocNode ( DdManager table)

Dynamically allocates a Node.

This procedure is similar to cuddAllocNode in Cudd_Table.c, but it does not attempt garbage collection, because during reordering there are no dead nodes.

Returns
a pointer to a new node if successful; NULL is memory is full.
Side effects None
See also
cuddAllocNode

◆ cuddNextHigh()

int cuddNextHigh ( DdManager table,
int  x 
)

Finds the next subtable with a larger index.

Returns
the index.
Side effects None
See also
cuddNextLow

◆ cuddNextLow()

int cuddNextLow ( DdManager table,
int  x 
)

Finds the next subtable with a smaller index.

Returns
the index.
Side effects None
See also
cuddNextHigh

◆ cuddSifting()

int cuddSifting ( 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

◆ cuddSwapInPlace()

int cuddSwapInPlace ( 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. cuddSwapInPlace assumes that x < y.

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

◆ cuddSwapping()

int cuddSwapping ( 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

◆ ddCheckPermuation()

static int ddCheckPermuation ( DdManager table,
MtrNode treenode,
int *  perm,
int *  invperm 
)
static

Checks the BDD variable group tree before a shuffle.

Returns
1 if successful; 0 otherwise.
Side effects Changes the BDD variable group tree.

◆ ddReorderPostprocess()

static int ddReorderPostprocess ( DdManager table)
static

Cleans up at the end of reordering.

Side effects None

◆ ddReorderPreprocess()

static int ddReorderPreprocess ( DdManager table)
static

Prepares the DD heap for dynamic reordering.

Does garbage collection, to guarantee that there are no dead nodes; clears the cache, which is invalidated by dynamic reordering; initializes the number of isolated projection functions; and initializes the interaction matrix.

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

◆ ddShuffle()

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

Reorders 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. ddShuffle assumes that no dead nodes are present and that the interaction matrix is properly initialized. The reordering is achieved by a series of upward sifts.

Returns
1 if successful; 0 otherwise.
Side effects None

◆ ddSiftingAux()

static int ddSiftingAux ( DdManager table,
int  x,
int  xLow,
int  xHigh 
)
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

◆ ddSiftingBackward()

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

Given a set of moves, returns the DD 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

◆ ddSiftingDown()

static Move* ddSiftingDown ( DdManager table,
int  x,
int  xHigh 
)
static

Sifts a variable down.

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

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

◆ ddSiftingUp()

static Move* ddSiftingUp ( DdManager table,
int  y,
int  xLow 
)
static

Sifts a variable up.

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

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

◆ ddSiftUp()

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

Moves one variable up.

Takes a 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

◆ ddSwapAny()

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

Swaps any two variables.

Returns
the set of moves.
Side effects None

◆ ddUniqueCompare()

static int ddUniqueCompare ( void const *  ptrX,
void const *  ptrY 
)
static

Comparison function used by qsort.

Used 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

◆ ddUpdateMtrTree()

static int ddUpdateMtrTree ( DdManager table,
MtrNode treenode,
int *  perm,
int *  invperm 
)
static

Updates the BDD variable group tree before a shuffle.

Returns
1 if successful; 0 otherwise.
Side effects Changes the BDD variable group tree.