abc/src/bdd/cudd/cuddAPI.c
/**Function********************************************************************

  Synopsis    [Adds multiplicity groups to a ZDD variable group tree.]

  Description [Adds multiplicity groups to a ZDD variable group tree.
  Returns 1 if successful; 0 otherwise. This function creates the groups
  for set of ZDD variables (whose cardinality is given by parameter
  multiplicity) that are created for each BDD variable in
  Cudd_zddVarsFromBddVars. The crux of the matter is to determine the index
  each new group. (The index of the first variable in the group.)
  We first build all the groups for the children of a node, and then deal
  with the ZDD variables that are directly attached to the node. The problem
  for these is that the tree itself does not provide information on their
  position inside the group. While we deal with the children of the node,
  therefore, we keep track of all the positions they occupy. The remaining
  positions in the tree can be freely used. Also, we keep track of all the
  variables placed in the children. All the remaining variables are directly
  attached to the group. We can then place any pair of variables not yet
  grouped in any pair of available positions in the node.]

  SideEffects [Changes the variable group tree.]

  SeeAlso     [Cudd_zddVarsFromBddVars]

******************************************************************************/
Function
Synopsis    [Adds multiplicity groups to a ZDD variable group tree.]

Description [Adds multiplicity groups to a ZDD variable group tree.
Returns 1 if successful; 0 otherwise. This function creates the groups
for set of ZDD variables (whose cardinality is given by parameter
multiplicity) that are created for each BDD variable in
Cudd_zddVarsFromBddVars. The crux of the matter is to determine the index
each new group. (The index of the first variable in the group.)
We first build all the groups for the children of a node, and then deal
with the ZDD variables that are directly attached to the node. The problem
for these is that the tree itself does not provide information on their
position inside the group. While we deal with the children of the node,
therefore, we keep track of all the positions they occupy. The remaining
positions in the tree can be freely used. Also, we keep track of all the
variables placed in the children. All the remaining variables are directly
attached to the group. We can then place any pair of variables not yet
grouped in any pair of available positions in the node.]

SideEffects [Changes the variable group tree.]


Function Synopsis [ Adds multiplicity groups to a ZDD variable group tree . ] Description [ Adds multiplicity groups to a ZDD variable group tree . Returns 1 if successful ; 0 otherwise . This function creates the groups for set of ZDD variables ( whose cardinality is given by parameter multiplicity ) that are created for each BDD variable in Cudd_zddVarsFromBddVars . The crux of the matter is to determine the index each new group . ( The index of the first variable in the group . ) We first build all the groups for the children of a node and then deal with the ZDD variables that are directly attached to the node . The problem for these is that the tree itself does not provide information on their position inside the group . While we deal with the children of the node therefore we keep track of all the positions they occupy . The remaining positions in the tree can be freely used . Also we keep track of all the variables placed in the children . All the remaining variables are directly attached to the group . We can then place any pair of variables not yet grouped in any pair of available positions in the node . ] SideEffects [ Changes the variable group tree . ]
static int
addMultiplicityGroups(
  DdManager *dd ,
  MtrNode *treenode ,
  int multiplicity ,
  char *vmask ,
  char *lmask )
{
    int startV, stopV, startL;
    int i, j;
    MtrNode *auxnode = treenode;
    while (auxnode != NULL) {
        if (auxnode->child != NULL) {
            addMultiplicityGroups(dd,auxnode->child,multiplicity,vmask,lmask);
        }
        startV = dd->permZ[auxnode->index] / multiplicity;
        startL = auxnode->low / multiplicity;
        stopV = startV + auxnode->size / multiplicity;
        for (i = startV, j = startL; i < stopV; i++) {
            if (vmask[i] == 0) {
                MtrNode *node;
                while (lmask[j] == 1) j++;
                node = Mtr_MakeGroup(auxnode, j * multiplicity, multiplicity,
                                     MTR_FIXED);
                if (node == NULL) {
                    return(0);
                }
                node->index = dd->invpermZ[i * multiplicity];
                vmask[i] = 1;
                lmask[j] = 1;
            }
        }
        auxnode = auxnode->younger;
    }
    return(1);
}
static int addMultiplicityGroups ( DdManager * dd , MtrNode * treenode , int multiplicity , char * vmask , char * lmask ) { int startV , stopV , startL ; int i , j ; MtrNode * auxnode = treenode ; while ( auxnode != NULL ) { if ( auxnode -> child != NULL ) { addMultiplicityGroups ( dd , auxnode -> child , multiplicity , vmask , lmask ) ; } startV = dd -> permZ [ auxnode -> index ] / multiplicity ; startL = auxnode -> low / multiplicity ; stopV = startV + auxnode -> size / multiplicity ; for ( i = startV , j = startL ; i < stopV ; i ++ ) { if ( vmask [ i ] == 0 ) { MtrNode * node ; while ( lmask [ j ] == 1 ) j ++ ; node = Mtr_MakeGroup ( auxnode , j * multiplicity , multiplicity , MTR_FIXED ) ; if ( node == NULL ) { return ( 0 ) ; } node -> index = dd -> invpermZ [ i * multiplicity ] ; vmask [ i ] = 1 ; lmask [ j ] = 1 ; } } auxnode = auxnode -> younger ; } return ( 1 ) ; }
Function
Synopsis    [Adds multiplicity groups to a ZDD variable group tree.]
Function Synopsis [ Adds multiplicity groups to a ZDD variable group tree . ]
/* manager */ /* current tree node */ /* how many ZDD vars per BDD var */ /* variable pairs for which a group has been already built */ /* levels for which a group has already been built*/ /* Build remaining groups. */ /* Walk down vmask starting at startV and build missing groups. */