Exemple #1
0
static keyvalue_table_ptr cudd_count(shadow_mgr mgr, set_ptr roots) {
    word_t wk, wv;
    keyvalue_table_ptr result = word_keyvalue_new();
    set_iterstart(roots);
    while (set_iternext(roots, &wk)) {
	ref_t r = (ref_t) wk;
	DdNode *n = get_ddnode(mgr, r);
	bool zdd = is_zdd(mgr, r);
#if USE_APA
	int digits;
	DdApaNumber num = Cudd_ApaCountMinterm(mgr->bdd_manager, n, mgr->nvars,
					       &digits);
	wv = apa2word(num, digits);
	FREE(num);
#else
	double fv = 0.0;
	if (zdd) {
	    fv = Cudd_zddCountMinterm(mgr->bdd_manager, n, mgr->nzvars);
	} else {
	    fv = Cudd_CountMinterm(mgr->bdd_manager, n, mgr->nvars);
	}
	wv = (word_t) fv;
#endif
	keyvalue_insert(result, wk, wv);
    }
    return result;
}
Exemple #2
0
/**Function********************************************************************

  Synopsis [Prints to the standard output a ZDD and its statistics.]

  Description [Prints to the standard output a DD and its statistics.
  The statistics include the number of nodes and the number of minterms.
  (The number of minterms is also the number of combinations in the set.)
  The statistics are printed if pr > 0.  Specifically:
  <ul>
  <li> pr = 0 : prints nothing
  <li> pr = 1 : prints counts of nodes and minterms
  <li> pr = 2 : prints counts + disjoint sum of products
  <li> pr = 3 : prints counts + list of nodes
  <li> pr &gt; 3 : prints counts + disjoint sum of products + list of nodes
  </ul>
  Returns 1 if successful; 0 otherwise.
  ]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
int
Cudd_zddPrintDebug(
  DdManager * zdd,
  DdNode * f,
  int  n,
  int  pr)
{
    DdNode	*empty = DD_ZERO(zdd);
    int		nodes;
    double	minterms;
    int		retval = 1;

    if (f == empty && pr > 0) {
	(void) fprintf(zdd->out,": is the empty ZDD\n");
	(void) fflush(zdd->out);
	return(1);
    }

    if (pr > 0) {
	nodes = Cudd_zddDagSize(f);
	if (nodes == CUDD_OUT_OF_MEM) retval = 0;
	minterms = Cudd_zddCountMinterm(zdd, f, n);
	if (minterms == (double)CUDD_OUT_OF_MEM) retval = 0;
	(void) fprintf(zdd->out,": %d nodes %g minterms\n",
		       nodes, minterms);
	if (pr > 2)
	    if (!cuddZddP(zdd, f)) retval = 0;
	if (pr == 2 || pr > 3) {
	    if (!Cudd_zddPrintMinterm(zdd, f)) retval = 0;
	    (void) fprintf(zdd->out,"\n");
	}
	(void) fflush(zdd->out);
    }
    return(retval);

} /* end of Cudd_zddPrintDebug */