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

  Synopsis    [Updates entry for a subset.]

  Description [Updates entry for a subset. Finds the subset, if it exists.
  If the new order for the subset has lower cost, or if the subset did not
  exist, it stores the new order and cost. Returns the number of subsets
  currently in the table.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Updates entry for a subset.]

Description [Updates entry for a subset. Finds the subset, if it exists.
If the new order for the subset has lower cost, or if the subset did not
exist, it stores the new order and cost. Returns the number of subsets
currently in the table.]




Function Synopsis [ Updates entry for a subset . ] Description [ Updates entry for a subset . Finds the subset if it exists . If the new order for the subset has lower cost or if the subset did not exist it stores the new order and cost . Returns the number of subsets currently in the table . ]
static int
updateEntry(
  DdManager * table,
  DdHalfWord * order,
  int  level,
  int  cost,
  DdHalfWord ** orders,
  int * costs,
  int  subsets,
  char * mask,
  int  lower,
  int  upper)
{
    int i, j;
    int size = upper - lower + 1;
    for (i = lower; i <= upper; i++)
        mask[table->invperm[i]] = 0;
    for (i = level; i < size; i++)
        mask[order[i]] = 1;
    for (i = 0; i < subsets; i++) {
        DdHalfWord *subset = orders[i];
        for (j = level; j < size; j++) {
            if (mask[subset[j]] == 0)
                break;
        }
        if (j == size)          
            break;
    }
    if (i == subsets || cost < costs[i]) {              
        for (j = 0; j < size; j++)
            orders[i][j] = order[j];
        costs[i] = cost;
        subsets += (i == subsets);
    }
    return(subsets);
}
static int updateEntry ( DdManager * table , DdHalfWord * order , int level , int cost , DdHalfWord * * orders , int * costs , int subsets , char * mask , int lower , int upper ) { int i , j ; int size = upper - lower + 1 ; for ( i = lower ; i <= upper ; i ++ ) mask [ table -> invperm [ i ] ] = 0 ; for ( i = level ; i < size ; i ++ ) mask [ order [ i ] ] = 1 ; for ( i = 0 ; i < subsets ; i ++ ) { DdHalfWord * subset = orders [ i ] ; for ( j = level ; j < size ; j ++ ) { if ( mask [ subset [ j ] ] == 0 ) break ; } if ( j == size ) break ; } if ( i == subsets || cost < costs [ i ] ) { for ( j = 0 ; j < size ; j ++ ) orders [ i ] [ j ] = order [ j ] ; costs [ i ] = cost ; subsets += ( i == subsets ) ; } return ( subsets ) ; }
Function
Synopsis    [Updates entry for a subset.]
Function Synopsis [ Updates entry for a subset . ]
/* Build a mask that says what variables are in this subset. */ /* Check each subset until a match is found or all subsets are examined. */ /* no mismatches: success */ /* add or replace */