cudd  3.0.0
The University of Colorado Decision Diagram Package
Data Structures | Macros | Typedefs | Functions
cuddApprox.c File Reference

Procedures to approximate a given BDD. More...

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

Data Structures

struct  NodeData
 Data structure to store the information on each node. More...
 
struct  ApproxInfo
 Main bookkeeping data structure for approximation algorithms. More...
 
struct  GlobalQueueItem
 Item of the queue used in the levelized traversal of the BDD. More...
 
struct  LocalQueueItem
 Type of the item of the local queue. More...
 

Macros

#define DBL_MAX_EXP   1024
 
#define NOTHING   0
 
#define REPLACE_T   1
 
#define REPLACE_E   2
 
#define REPLACE_N   3
 
#define REPLACE_TT   4
 
#define REPLACE_TE   5
 
#define DONT_CARE   0
 
#define CARE   1
 
#define TOTAL_CARE   2
 
#define CARE_ERROR   3
 

Typedefs

typedef struct NodeData NodeData
 Data structure to store the information on each node. More...
 
typedef struct ApproxInfo ApproxInfo
 Main bookkeeping data structure for approximation algorithms.
 
typedef struct GlobalQueueItem GlobalQueueItem
 Item of the queue used in the levelized traversal of the BDD.
 
typedef struct LocalQueueItem LocalQueueItem
 Type of the item of the local queue.
 

Functions

DdNodeCudd_UnderApprox (DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
 Extracts a dense subset from a BDD with Shiple's underapproximation method. More...
 
DdNodeCudd_OverApprox (DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
 Extracts a dense superset from a BDD with Shiple's underapproximation method. More...
 
DdNodeCudd_RemapUnderApprox (DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
 Extracts a dense subset from a BDD with the remapping underapproximation method. More...
 
DdNodeCudd_RemapOverApprox (DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
 Extracts a dense superset from a BDD with the remapping underapproximation method. More...
 
DdNodeCudd_BiasedUnderApprox (DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
 Extracts a dense subset from a BDD with the biased underapproximation method. More...
 
DdNodeCudd_BiasedOverApprox (DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
 Extracts a dense superset from a BDD with the biased underapproximation method. More...
 
DdNodecuddUnderApprox (DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
 Applies Tom Shiple's underappoximation algorithm. More...
 
DdNodecuddRemapUnderApprox (DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
 Applies the remapping underappoximation algorithm. More...
 
DdNodecuddBiasedUnderApprox (DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
 Applies the biased remapping underappoximation algorithm. More...
 
static void updateParity (DdNode *node, ApproxInfo *info, int newparity)
 Recursively update the parity of the paths reaching a node. More...
 
static NodeDatagatherInfoAux (DdNode *node, ApproxInfo *info, int parity)
 Recursively counts minterms and computes reference counts of each node in the BDD. More...
 
static ApproxInfogatherInfo (DdManager *dd, DdNode *node, int numVars, int parity)
 Gathers information about each node. More...
 
static int computeSavings (DdManager *dd, DdNode *f, DdNode *skip, ApproxInfo *info, DdLevelQueue *queue)
 Counts the nodes that would be eliminated if a given node were replaced by zero. More...
 
static int updateRefs (DdManager *dd, DdNode *f, DdNode *skip, ApproxInfo *info, DdLevelQueue *queue)
 Update function reference counts to account for replacement. More...
 
static int UAmarkNodes (DdManager *dd, DdNode *f, ApproxInfo *info, int threshold, int safe, double quality)
 Marks nodes for replacement by zero. More...
 
static DdNodeUAbuildSubset (DdManager *dd, DdNode *node, ApproxInfo *info)
 Builds the subset BDD. More...
 
static int RAmarkNodes (DdManager *dd, DdNode *f, ApproxInfo *info, int threshold, double quality)
 Marks nodes for remapping. More...
 
static int BAmarkNodes (DdManager *dd, DdNode *f, ApproxInfo *info, int threshold, double quality1, double quality0)
 Marks nodes for remapping. More...
 
static DdNodeRAbuildSubset (DdManager *dd, DdNode *node, ApproxInfo *info)
 Builds the subset BDD for cuddRemapUnderApprox. More...
 
static int BAapplyBias (DdManager *dd, DdNode *f, DdNode *b, ApproxInfo *info, DdHashTable *cache)
 Finds don't care nodes by traversing f and b in parallel. More...
 

Detailed Description

Procedures to approximate a given BDD.

See also
cuddSubsetHB.c cuddSubsetSP.c cuddGenCof.c
Author
Fabio Somenzi

Typedef Documentation

◆ NodeData

typedef struct NodeData NodeData

Data structure to store the information on each node.

It keeps the number of minterms of the function rooted at this node in terms of the number of variables specified by the user; the number of minterms of the complement; the impact of the number of minterms of this function on the number of minterms of the root function; the reference count of the node from within the root function; the flag that says whether the node intersects the care set; the flag that says whether the node should be replaced and how; the results of subsetting in both phases.

Function Documentation

◆ BAapplyBias()

static int BAapplyBias ( DdManager dd,
DdNode f,
DdNode b,
ApproxInfo info,
DdHashTable cache 
)
static

Finds don't care nodes by traversing f and b in parallel.

Returns
the care status of the visited f node if successful; CARE_ERROR otherwise.
Side effects None
See also
cuddBiasedUnderApprox

◆ BAmarkNodes()

static int BAmarkNodes ( DdManager dd,
DdNode f,
ApproxInfo info,
int  threshold,
double  quality1,
double  quality0 
)
static

Marks nodes for remapping.

Returns
1 if successful; 0 otherwise.
Side effects None
See also
cuddBiasedUnderApprox
Parameters
ddmanager
ffunction to be analyzed
infoinfo on BDD
thresholdwhen to stop approximating
quality1minimum improvement for accepted changes when b=1
quality0minimum improvement for accepted changes when b=0

◆ computeSavings()

static int computeSavings ( DdManager dd,
DdNode f,
DdNode skip,
ApproxInfo info,
DdLevelQueue queue 
)
static

Counts the nodes that would be eliminated if a given node were replaced by zero.

This procedure uses a queue passed by the caller for efficiency: since the queue is left empty at the endof the search, it can be reused as is by the next search.

Returns
the count (always striclty positive) if successful; 0 otherwise.
Side effects None
See also
UAmarkNodes RAmarkNodes BAmarkNodes

◆ Cudd_BiasedOverApprox()

DdNode* Cudd_BiasedOverApprox ( DdManager dd,
DdNode f,
DdNode b,
int  numVars,
int  threshold,
double  quality1,
double  quality0 
)

Extracts a dense superset from a BDD with the biased underapproximation method.

The procedure is identical to the underapproximation procedure except for the fact that it works on the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.

Returns
a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory.
Side effects None
See also
Cudd_SupersetHeavyBranch Cudd_SupersetShortPaths Cudd_RemapOverApprox Cudd_BiasedUnderApprox Cudd_ReadSize
Parameters
ddmanager
ffunction to be superset
bbias function
numVarsnumber of variables in the support of f
thresholdwhen to stop approximation
quality1minimum improvement for accepted changes when b=1
quality0minimum improvement for accepted changes when b=0

◆ Cudd_BiasedUnderApprox()

DdNode* Cudd_BiasedUnderApprox ( DdManager dd,
DdNode f,
DdNode b,
int  numVars,
int  threshold,
double  quality1,
double  quality0 
)

Extracts a dense subset from a BDD with the biased underapproximation method.

This procedure uses a biased remapping technique and density as the cost function. The bias is a function. This procedure tries to approximate where the bias is 0 and preserve the given function where the bias is 1. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will cause overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.

Returns
a pointer to the BDD of the subset if successful. NULL if the procedure runs out of memory.
Side effects None
See also
Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_UnderApprox Cudd_RemapUnderApprox Cudd_ReadSize
Parameters
ddmanager
ffunction to be subset
bbias function
numVarsnumber of variables in the support of f
thresholdwhen to stop approximation
quality1minimum improvement for accepted changes when b=1
quality0minimum improvement for accepted changes when b=0

◆ Cudd_OverApprox()

DdNode* Cudd_OverApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  safe,
double  quality 
)

Extracts a dense superset from a BDD with Shiple's underapproximation method.

The procedure is identical to the underapproximation procedure except for the fact that it works on the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.

Returns
a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory.
Side effects None
See also
Cudd_SupersetHeavyBranch Cudd_SupersetShortPaths Cudd_ReadSize
Parameters
ddmanager
ffunction to be superset
numVarsnumber of variables in the support of f
thresholdwhen to stop approximation
safeenforce safe approximation
qualityminimum improvement for accepted changes

◆ Cudd_RemapOverApprox()

DdNode* Cudd_RemapOverApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
double  quality 
)

Extracts a dense superset from a BDD with the remapping underapproximation method.

The procedure is identical to the underapproximation procedure except for the fact that it works on the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.

Returns
a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory.
Side effects None
See also
Cudd_SupersetHeavyBranch Cudd_SupersetShortPaths Cudd_ReadSize
Parameters
ddmanager
ffunction to be superset
numVarsnumber of variables in the support of f
thresholdwhen to stop approximation
qualityminimum improvement for accepted changes

◆ Cudd_RemapUnderApprox()

DdNode* Cudd_RemapUnderApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
double  quality 
)

Extracts a dense subset from a BDD with the remapping underapproximation method.

This procedure uses a remapping technique and density as the cost function. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will cause overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.

Returns
a pointer to the BDD of the subset if successful. NULL if the procedure runs out of memory.
Side effects None
See also
Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_UnderApprox Cudd_ReadSize
Parameters
ddmanager
ffunction to be subset
numVarsnumber of variables in the support of f
thresholdwhen to stop approximation
qualityminimum improvement for accepted changes

◆ Cudd_UnderApprox()

DdNode* Cudd_UnderApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  safe,
double  quality 
)

Extracts a dense subset from a BDD with Shiple's underapproximation method.

This procedure uses a variant of Tom Shiple's underapproximation method. The main difference from the original method is that density is used as cost function. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will cause overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.

Returns
a pointer to the BDD of the subset if successful; NULL if the procedure runs out of memory.
Side effects None
See also
Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_ReadSize
Parameters
ddmanager
ffunction to be subset
numVarsnumber of variables in the support of f
thresholdwhen to stop approximation
safeenforce safe approximation
qualityminimum improvement for accepted changes

◆ cuddBiasedUnderApprox()

DdNode* cuddBiasedUnderApprox ( DdManager dd,
DdNode f,
DdNode b,
int  numVars,
int  threshold,
double  quality1,
double  quality0 
)

Applies the biased remapping underappoximation algorithm.

Proceeds in three phases:

  • collect information on each node in the BDD; this is done via DFS.
  • traverse the BDD in top-down fashion and compute for each node whether remapping increases density.
  • traverse the BDD via DFS and actually perform the elimination.
Returns
the approximated BDD if successful; NULL otherwise.
Side effects None
See also
Cudd_BiasedUnderApprox

< readable true

Parameters
ddDD manager
fcurrent DD
bbias function
numVarsmaximum number of variables
thresholdthreshold under which approximation stops
quality1minimum improvement for accepted changes when b=1
quality0minimum improvement for accepted changes when b=0

◆ cuddRemapUnderApprox()

DdNode* cuddRemapUnderApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
double  quality 
)

Applies the remapping underappoximation algorithm.

Proceeds in three phases:

  • collect information on each node in the BDD; this is done via DFS.
  • traverse the BDD in top-down fashion and compute for each node whether remapping increases density.
  • traverse the BDD via DFS and actually perform the elimination.
Returns
the approximated BDD if successful; NULL otherwise.
Side effects None
See also
Cudd_RemapUnderApprox

< readable true

Parameters
ddDD manager
fcurrent DD
numVarsmaximum number of variables
thresholdthreshold under which approximation stops
qualityminimum improvement for accepted changes

◆ cuddUnderApprox()

DdNode* cuddUnderApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  safe,
double  quality 
)

Applies Tom Shiple's underappoximation algorithm.

Proceeds in three phases:

  • collect information on each node in the BDD; this is done via DFS.
  • traverse the BDD in top-down fashion and compute for each node whether its elimination increases density.
  • traverse the BDD via DFS and actually perform the elimination.
Returns
the approximated BDD if successful; NULL otherwise.
Side effects None
See also
Cudd_UnderApprox
Parameters
ddDD manager
fcurrent DD
numVarsmaximum number of variables
thresholdthreshold under which approximation stops
safeenforce safe approximation
qualityminimum improvement for accepted changes

◆ gatherInfo()

static ApproxInfo* gatherInfo ( DdManager dd,
DdNode node,
int  numVars,
int  parity 
)
static

Gathers information about each node.

Counts minterms and computes reference counts of each node in the BDD. The minterm count is separately computed for the node and its complement. This is to avoid cancellation errors.

Returns
a pointer to the data structure holding the information gathered if successful; NULL otherwise.
Side effects None
See also
cuddUnderApprox gatherInfoAux

◆ gatherInfoAux()

static NodeData* gatherInfoAux ( DdNode node,
ApproxInfo info,
int  parity 
)
static

Recursively counts minterms and computes reference counts of each node in the BDD.

Similar to the cuddCountMintermAux which recursively counts the number of minterms for the dag rooted at each node in terms of the total number of variables (max). It assumes that the node pointer passed to it is regular and it maintains the invariant.

Side effects None
See also
gatherInfo
Parameters
nodefunction to analyze
infoinfo on BDD
paritygather parity information

◆ RAbuildSubset()

static DdNode* RAbuildSubset ( DdManager dd,
DdNode node,
ApproxInfo info 
)
static

Builds the subset BDD for cuddRemapUnderApprox.

Based on the info table, performs remapping or replacement at selected nodes.

Returns
a pointer to the result if successful; NULL otherwise.
Side effects None
See also
cuddRemapUnderApprox
Parameters
ddDD manager
nodecurrent node
infonode info

◆ RAmarkNodes()

static int RAmarkNodes ( DdManager dd,
DdNode f,
ApproxInfo info,
int  threshold,
double  quality 
)
static

Marks nodes for remapping.

Returns
1 if successful; 0 otherwise.
Side effects None
See also
cuddRemapUnderApprox
Parameters
ddmanager
ffunction to be analyzed
infoinfo on BDD
thresholdwhen to stop approximating
qualityminimum improvement for accepted changes

◆ UAbuildSubset()

static DdNode* UAbuildSubset ( DdManager dd,
DdNode node,
ApproxInfo info 
)
static

Builds the subset BDD.

Based on the info table, replaces selected nodes by zero.

Returns
a pointer to the result if successful; NULL otherwise.
Side effects None
See also
cuddUnderApprox

< readable true

Parameters
ddDD manager
nodecurrent node
infonode info

◆ UAmarkNodes()

static int UAmarkNodes ( DdManager dd,
DdNode f,
ApproxInfo info,
int  threshold,
int  safe,
double  quality 
)
static

Marks nodes for replacement by zero.

Returns
1 if successful; 0 otherwise.
Side effects None
See also
cuddUnderApprox

< readable true

Parameters
ddmanager
ffunction to be analyzed
infoinfo on BDD
thresholdwhen to stop approximating
safeenforce safe approximation
qualityminimum improvement for accepted changes

◆ updateParity()

static void updateParity ( DdNode node,
ApproxInfo info,
int  newparity 
)
static

Recursively update the parity of the paths reaching a node.

Assumes that node is regular and propagates the invariant.

Side effects None
See also
gatherInfoAux
Parameters
nodefunction to analyze
infoinfo on BDD
newparitynew parity for node

◆ updateRefs()

static int updateRefs ( DdManager dd,
DdNode f,
DdNode skip,
ApproxInfo info,
DdLevelQueue queue 
)
static

Update function reference counts to account for replacement.

Returns
the number of nodes saved if successful; 0 otherwise.
Side effects None
See also
UAmarkNodes RAmarkNodes BAmarkNodes