/**Function******************************************************************** Synopsis [Reorders ZDD variables according to given permutation.] Description [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.] SideEffects [Changes the ZDD variable order for all diagrams and clears the cache.] SeeAlso [Cudd_zddReduceHeap] ******************************************************************************/ int Cudd_zddShuffleHeap( DdManager * table /* DD manager */, int * permutation /* required variable permutation */) { int result; /* NuSMV: begin add */ abort(); /* NOT USED BY NUSMV */ /* NuSMV: begin end */ /* NuSMV: add begin */ #if 0 /* NuSMV: add end */ empty = table->zero; /* NuSMV: add begin */ #endif empty = DD_FALSE(table); /* NuSMV: add end */ zddReorderPreprocess(table); result = zddShuffle(table,permutation); if (!zddReorderPostprocess(table)) return(0); return(result); } /* end of Cudd_zddShuffleHeap */
/** @brief Reorders %ZDD variables according to given permutation. @details 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. @return 1 in case of success; 0 otherwise. @sideeffect Changes the %ZDD variable order for all diagrams and clears the cache. @see Cudd_zddReduceHeap */ int Cudd_zddShuffleHeap( DdManager * table /**< DD manager */, int * permutation /**< required variable permutation */) { int result; zddReorderPreprocess(table); result = zddShuffle(table,permutation); if (!zddReorderPostprocess(table)) return(0); return(result); } /* end of Cudd_zddShuffleHeap */
/**Function******************************************************************** Synopsis [Main dynamic reordering routine for ZDDs.] Description [Main dynamic reordering routine for ZDDs. Calls one of the possible reordering procedures: <ul> <li>Swapping <li>Sifting <li>Symmetric Sifting </ul> For sifting and symmetric sifting it is possible to request reordering to convergence.<p> 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.] SideEffects [Changes the variable order for all ZDDs and clears the cache.] ******************************************************************************/ int Cudd_zddReduceHeap( DdManager * table /* DD manager */, Cudd_ReorderingType heuristic /* method used for reordering */, int minsize /* bound below which no reordering occurs */) { DdHook *hook; int result; unsigned int nextDyn; #ifdef DD_STATS unsigned int initialSize; unsigned int finalSize; #endif long localTime; /* Don't reorder if there are too many dead nodes. */ if (table->keysZ - table->deadZ < (unsigned) minsize) return(1); if (heuristic == CUDD_REORDER_SAME) { heuristic = table->autoMethodZ; } if (heuristic == CUDD_REORDER_NONE) { return(1); } /* This call to Cudd_zddReduceHeap does initiate reordering. Therefore ** we count it. */ table->reorderings++; empty = table->zero; localTime = util_cpu_time(); /* Run the hook functions. */ hook = table->preReorderingHook; while (hook != NULL) { int res = (hook->f)(table, "ZDD", (void *)heuristic); if (res == 0) return(0); hook = hook->next; } /* Clear the cache and collect garbage. */ zddReorderPreprocess(table); zddTotalNumberSwapping = 0; #ifdef DD_STATS initialSize = table->keysZ; switch(heuristic) { case CUDD_REORDER_RANDOM: case CUDD_REORDER_RANDOM_PIVOT: (void) fprintf(table->out,"#:I_RANDOM "); break; case CUDD_REORDER_SIFT: case CUDD_REORDER_SIFT_CONVERGE: case CUDD_REORDER_SYMM_SIFT: case CUDD_REORDER_SYMM_SIFT_CONV: (void) fprintf(table->out,"#:I_SIFTING "); break; case CUDD_REORDER_LINEAR: case CUDD_REORDER_LINEAR_CONVERGE: (void) fprintf(table->out,"#:I_LINSIFT "); break; default: (void) fprintf(table->err,"Unsupported ZDD reordering method\n"); return(0); } (void) fprintf(table->out,"%8d: initial size",initialSize); #endif result = cuddZddTreeSifting(table,heuristic); #ifdef DD_STATS (void) fprintf(table->out,"\n"); finalSize = table->keysZ; (void) fprintf(table->out,"#:F_REORDER %8d: final size\n",finalSize); (void) fprintf(table->out,"#:T_REORDER %8g: total time (sec)\n", ((double)(util_cpu_time() - localTime)/1000.0)); (void) fprintf(table->out,"#:N_REORDER %8d: total swaps\n", zddTotalNumberSwapping); #endif if (result == 0) return(0); if (!zddReorderPostprocess(table)) return(0); if (table->realignZ) { if (!cuddBddAlignToZdd(table)) return(0); } nextDyn = table->keysZ * DD_DYN_RATIO; if (table->reorderings < 20 || nextDyn > table->nextDyn) table->nextDyn = nextDyn; else table->nextDyn += 20; table->reordered = 1; /* Run hook functions. */ hook = table->postReorderingHook; while (hook != NULL) { int res = (hook->f)(table, "ZDD", (void *)localTime); if (res == 0) return(0); hook = hook->next; } /* Update cumulative reordering time. */ table->reordTime += util_cpu_time() - localTime; return(result); } /* end of Cudd_zddReduceHeap */