abc/src/bdd/extrab/extraBddImage.c
/**Function*************************************************************

  Synopsis    [Computes the best variable.]

  Description [The variables is the best if the sum of squares of the
  BDD sizes of the partitions, in which it participates, is the minimum.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Computes the best variable.]

Description [The variables is the best if the sum of squares of the
BDD sizes of the partitions, in which it participates, is the minimum.]




Function Synopsis [ Computes the best variable . ] Description [ The variables is the best if the sum of squares of the BDD sizes of the partitions in which it participates is the minimum . ]
int Extra_FindBestVariable( DdManager * dd,
    int nNodes, Extra_ImageNode_t ** pNodes, 
    int nVars,  Extra_ImageVar_t ** pVars )
{
    DdNode * bTemp;
    int iVarBest, v;
    double CostBest, CostCur;
    CostBest = 100000000000000.0;
    iVarBest = -1;
    for ( v = 0; v < nVars; v++ )
        if ( pVars[v] )
        {
            CostCur = 0;
            for ( bTemp = pVars[v]->bParts; bTemp != b1; bTemp = cuddT(bTemp) )
                CostCur += pNodes[bTemp->index]->pPart->nNodes * 
                           pNodes[bTemp->index]->pPart->nNodes;
            if ( CostBest > CostCur )
            {
                CostBest = CostCur;
                iVarBest = v;
            }
        }
    return iVarBest;
}
int Extra_FindBestVariable ( DdManager * dd , int nNodes , Extra_ImageNode_t * * pNodes , int nVars , Extra_ImageVar_t * * pVars ) { DdNode * bTemp ; int iVarBest , v ; double CostBest , CostCur ; CostBest = 100000000000000.0 ; iVarBest = -1 ; for ( v = 0 ; v < nVars ; v ++ ) if ( pVars [ v ] ) { CostCur = 0 ; for ( bTemp = pVars [ v ] -> bParts ; bTemp != b1 ; bTemp = cuddT ( bTemp ) ) CostCur += pNodes [ bTemp -> index ] -> pPart -> nNodes * pNodes [ bTemp -> index ] -> pPart -> nNodes ; if ( CostBest > CostCur ) { CostBest = CostCur ; iVarBest = v ; } } return iVarBest ; }
Function
Synopsis    [Computes the best variable.]
Function Synopsis [ Computes the best variable . ]