abc/src/misc/extra/extraZddTrunc.c
/**Function********************************************************************

  Synopsis    [Compute the set of subsets whose probability is more than ProbLimit.]

  Description [The resulting array has the following form:  The first integer entry 
  is the number of resulting subsets.  The following integer entries in the array
  contain as many subsets. Each subset is an array of integers followed by -1. 
  See how subsets are printed in the included test procedure below.]

  SideEffects []

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Compute the set of subsets whose probability is more than ProbLimit.]

Description [The resulting array has the following form:  The first integer entry
is the number of resulting subsets.  The following integer entries in the array
contain as many subsets. Each subset is an array of integers followed by -1.
See how subsets are printed in the included test procedure below.]




Function Synopsis [ Compute the set of subsets whose probability is more than ProbLimit . ] Description [ The resulting array has the following form : The first integer entry is the number of resulting subsets . The following integer entries in the array contain as many subsets . Each subset is an array of integers followed by - 1 . See how subsets are printed in the included test procedure below . ]
void Extra_zddTruncate_rec(
  DdManager * dd, 
  DdNode * zFunc,       
  double * pVarProbs,    
  double ProbLimit,      
  double ProbThis,       
  Vec_Int_t * vSubset,  
  Vec_Int_t * vResult ) 
{
    if ( ProbThis < ProbLimit )
        return;
    if ( zFunc == Cudd_ReadZero(dd) ) 
        return;
    if ( zFunc == Cudd_ReadOne(dd) ) 
    {
        Vec_IntAddToEntry( vResult, 0, 1 );
        Vec_IntAppend( vResult, vSubset );
        Vec_IntPush( vResult, -1 );
        return;
    }
    Extra_zddTruncate_rec( dd, cuddE(zFunc), pVarProbs, ProbLimit, ProbThis, vSubset, vResult );
    Vec_IntPush( vSubset, Cudd_NodeReadIndex(zFunc) );
    Extra_zddTruncate_rec( dd, cuddT(zFunc), pVarProbs, ProbLimit, ProbThis * pVarProbs[Cudd_NodeReadIndex(zFunc)], vSubset, vResult );
    Vec_IntPop( vSubset );
}
void Extra_zddTruncate_rec ( DdManager * dd , DdNode * zFunc , double * pVarProbs , double ProbLimit , double ProbThis , Vec_Int_t * vSubset , Vec_Int_t * vResult ) { if ( ProbThis < ProbLimit ) return ; if ( zFunc == Cudd_ReadZero ( dd ) ) return ; if ( zFunc == Cudd_ReadOne ( dd ) ) { Vec_IntAddToEntry ( vResult , 0 , 1 ) ; Vec_IntAppend ( vResult , vSubset ) ; Vec_IntPush ( vResult , -1 ) ; return ; } Extra_zddTruncate_rec ( dd , cuddE ( zFunc ) , pVarProbs , ProbLimit , ProbThis , vSubset , vResult ) ; Vec_IntPush ( vSubset , Cudd_NodeReadIndex ( zFunc ) ) ; Extra_zddTruncate_rec ( dd , cuddT ( zFunc ) , pVarProbs , ProbLimit , ProbThis * pVarProbs [ Cudd_NodeReadIndex ( zFunc ) ] , vSubset , vResult ) ; Vec_IntPop ( vSubset ) ; }
Function
Synopsis    [Compute the set of subsets whose probability is more than ProbLimit.]
Function Synopsis [ Compute the set of subsets whose probability is more than ProbLimit . ]
// zFunc is the ZDD to be truncated // pVarProbs is probabilities of each variable (should have at least dd->sizeZ entries) // ProbLimit is the limit on the probabilities (only those more than this will be collected) // current path probability // current subset under construction // resulting subsets to be returned to the user // quit if probability of the path is less then the limit // quit if there is no subsets // quit and save a new subset if there is one // call recursively for the set without the given variable // call recursively for the set with the given variable