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

  Synopsis    [Tree sifting algorithm for ZDDs.]

  Description [Tree sifting algorithm for ZDDs. Assumes that a tree
  representing a group hierarchy is passed as a parameter. It then
  reorders each group in postorder fashion by calling
  zddTreeSiftingAux.  Assumes that no dead nodes are present.  Returns
  1 if successful; 0 otherwise.]

  SideEffects [None]

******************************************************************************/
Function
Synopsis    [Tree sifting algorithm for ZDDs.]

Description [Tree sifting algorithm for ZDDs. Assumes that a tree
representing a group hierarchy is passed as a parameter. It then
reorders each group in postorder fashion by calling
zddTreeSiftingAux.  Assumes that no dead nodes are present.  Returns
1 if successful; 0 otherwise.]


Function Synopsis [ Tree sifting algorithm for ZDDs . ] Description [ Tree sifting algorithm for ZDDs . Assumes that a tree representing a group hierarchy is passed as a parameter . It then reorders each group in postorder fashion by calling zddTreeSiftingAux . Assumes that no dead nodes are present . Returns 1 if successful ; 0 otherwise . ]
int
cuddZddTreeSifting(
  DdManager * table ,
  Cudd_ReorderingType method )
{
    int i;
    int nvars;
    int result;
    int tempTree;
    tempTree = table->treeZ == NULL;
    if (tempTree) {
        table->treeZ = Mtr_InitGroupTree(0,table->sizeZ);
        table->treeZ->index = table->invpermZ[0];
    }
    nvars = table->sizeZ;
#ifdef DD_DEBUG
    if (pr > 0 && !tempTree)
        (void) fprintf(table->out,"cuddZddTreeSifting:");
    Mtr_PrintGroups(table->treeZ,pr <= 0);
#endif
#if 0
    if (table->tree && table->treeZ) {
        (void) fprintf(table->out,"\n");
        Mtr_PrintGroups(table->tree, 0);
        cuddPrintVarGroups(table,table->tree,0,0);
        for (i = 0; i < table->size; i++) {
            (void) fprintf(table->out,"%s%d",
                           (i == 0) ? "" : ",", table->invperm[i]);
        }
        (void) fprintf(table->out,"\n");
        for (i = 0; i < table->size; i++) {
            (void) fprintf(table->out,"%s%d",
                           (i == 0) ? "" : ",", table->perm[i]);
        }
        (void) fprintf(table->out,"\n\n");
        Mtr_PrintGroups(table->treeZ,0);
        cuddPrintVarGroups(table,table->treeZ,1,0);
        for (i = 0; i < table->sizeZ; i++) {
            (void) fprintf(table->out,"%s%d",
                           (i == 0) ? "" : ",", table->invpermZ[i]);
        }
        (void) fprintf(table->out,"\n");
        for (i = 0; i < table->sizeZ; i++) {
            (void) fprintf(table->out,"%s%d",
                           (i == 0) ? "" : ",", table->permZ[i]);
        }
        (void) fprintf(table->out,"\n");
    }
#endif
#ifdef DD_STATS
    extsymmcalls = 0;
    extsymm = 0;
    secdiffcalls = 0;
    secdiff = 0;
    secdiffmisfire = 0;
    (void) fprintf(table->out,"\n");
    if (!tempTree)
        (void) fprintf(table->out,"#:IM_NODES  %8d: group tree nodes\n",
                       zddCountInternalMtrNodes(table,table->treeZ));
#endif
    for (i = 0; i < nvars; i++)
        table->subtableZ[i].next = i;
    result = zddTreeSiftingAux(table, table->treeZ, method);
#ifdef DD_STATS         
    if (!tempTree && method == CUDD_REORDER_GROUP_SIFT &&
        (table->groupcheck == CUDD_GROUP_CHECK7 ||
         table->groupcheck == CUDD_GROUP_CHECK5)) {
        (void) fprintf(table->out,"\nextsymmcalls = %d\n",extsymmcalls);
        (void) fprintf(table->out,"extsymm = %d",extsymm);
    }
    if (!tempTree && method == CUDD_REORDER_GROUP_SIFT &&
        table->groupcheck == CUDD_GROUP_CHECK7) {
        (void) fprintf(table->out,"\nsecdiffcalls = %d\n",secdiffcalls);
        (void) fprintf(table->out,"secdiff = %d\n",secdiff);
        (void) fprintf(table->out,"secdiffmisfire = %d",secdiffmisfire);
    }
#endif
    if (tempTree)
        Cudd_FreeZddTree(table);
    return(result);
}
int cuddZddTreeSifting ( DdManager * table , Cudd_ReorderingType method ) { int i ; int nvars ; int result ; int tempTree ; tempTree = table -> treeZ == NULL ; if ( tempTree ) { table -> treeZ = Mtr_InitGroupTree ( 0 , table -> sizeZ ) ; table -> treeZ -> index = table -> invpermZ [ 0 ] ; } nvars = table -> sizeZ ; #ifdef DD_DEBUG if ( pr > 0 && ! tempTree ) ( void ) fprintf ( table -> out , " " ) ; Mtr_PrintGroups ( table -> treeZ , pr <= 0 ) ; #endif #if 0 if ( table -> tree && table -> treeZ ) { ( void ) fprintf ( table -> out , " \n " ) ; Mtr_PrintGroups ( table -> tree , 0 ) ; cuddPrintVarGroups ( table , table -> tree , 0 , 0 ) ; for ( i = 0 ; i < table -> size ; i ++ ) { ( void ) fprintf ( table -> out , " " , ( i == 0 ) ? " " : " " , table -> invperm [ i ] ) ; } ( void ) fprintf ( table -> out , " \n " ) ; for ( i = 0 ; i < table -> size ; i ++ ) { ( void ) fprintf ( table -> out , " " , ( i == 0 ) ? " " : " " , table -> perm [ i ] ) ; } ( void ) fprintf ( table -> out , " \n \n " ) ; Mtr_PrintGroups ( table -> treeZ , 0 ) ; cuddPrintVarGroups ( table , table -> treeZ , 1 , 0 ) ; for ( i = 0 ; i < table -> sizeZ ; i ++ ) { ( void ) fprintf ( table -> out , " " , ( i == 0 ) ? " " : " " , table -> invpermZ [ i ] ) ; } ( void ) fprintf ( table -> out , " \n " ) ; for ( i = 0 ; i < table -> sizeZ ; i ++ ) { ( void ) fprintf ( table -> out , " " , ( i == 0 ) ? " " : " " , table -> permZ [ i ] ) ; } ( void ) fprintf ( table -> out , " \n " ) ; } #endif #ifdef DD_STATS extsymmcalls = 0 ; extsymm = 0 ; secdiffcalls = 0 ; secdiff = 0 ; secdiffmisfire = 0 ; ( void ) fprintf ( table -> out , " \n " ) ; if ( ! tempTree ) ( void ) fprintf ( table -> out , " \n " , zddCountInternalMtrNodes ( table , table -> treeZ ) ) ; #endif for ( i = 0 ; i < nvars ; i ++ ) table -> subtableZ [ i ] . next = i ; result = zddTreeSiftingAux ( table , table -> treeZ , method ) ; #ifdef DD_STATS if ( ! tempTree && method == CUDD_REORDER_GROUP_SIFT && ( table -> groupcheck == CUDD_GROUP_CHECK7 || table -> groupcheck == CUDD_GROUP_CHECK5 ) ) { ( void ) fprintf ( table -> out , " \n \n " , extsymmcalls ) ; ( void ) fprintf ( table -> out , " " , extsymm ) ; } if ( ! tempTree && method == CUDD_REORDER_GROUP_SIFT && table -> groupcheck == CUDD_GROUP_CHECK7 ) { ( void ) fprintf ( table -> out , " \n \n " , secdiffcalls ) ; ( void ) fprintf ( table -> out , " \n " , secdiff ) ; ( void ) fprintf ( table -> out , " " , secdiffmisfire ) ; } #endif if ( tempTree ) Cudd_FreeZddTree ( table ) ; return ( result ) ; }
Function
Synopsis    [Tree sifting algorithm for ZDDs.]
Function Synopsis [ Tree sifting algorithm for ZDDs . ]
/* DD table */ /* reordering method for the groups of leaves */ /* If no tree is provided we create a temporary one in which all
    ** variables are in a single group. After reordering this tree is
    ** destroyed.
    */ /* Debugging code. */ /* End of debugging code. */ /* Initialize the group of each subtable to itself. Initially
    ** there are no groups. Groups are created according to the tree
    ** structure in postorder fashion.
    */ /* Reorder. */ /* print stats */