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

  Synopsis [Builds a DD from a given order.]

  Description [Builds a DD from a given order.  This procedure also
  sifts the final order and inserts into the array the size in nodes
  of the result. Returns 1 if successful; 0 otherwise.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis [Builds a DD from a given order.]

Description [Builds a DD from a given order.  This procedure also
sifts the final order and inserts into the array the size in nodes
of the result. Returns 1 if successful; 0 otherwise.]




Function Synopsis [ Builds a DD from a given order . ] Description [ Builds a DD from a given order . This procedure also sifts the final order and inserts into the array the size in nodes of the result . Returns 1 if successful ; 0 otherwise . ]
static int
build_dd(
  DdManager * table,
  int  num ,
  int  lower,
  int  upper)
{
    int         i,j;            
    int         position;
    int         index;
    int         limit;          
    int         size;
    if (computed && st__lookup_int(computed,(char *)&STOREDD(num,0),&index)) {
        STOREDD(num,numvars) = STOREDD(index,numvars);
#ifdef DD_STATS
        (void) fprintf(table->out,"\nCache hit for index %d", index);
#endif
        return(1);
    }
    limit = 20 * STOREDD(0,numvars);
    for (j = 0; j < numvars; j++) {
        i = STOREDD(num,j);
        position = table->perm[i];
        result = sift_up(table,position,j+lower);
        if (!result) return(0);
        size = table->keys - table->isolated;
        if (size > limit) break;
    }
#ifdef DD_STATS
    (void) fprintf(table->out,"\n");
#endif
    result = cuddSifting(table,lower,upper);
    if (!result) return(0);
    for (j = 0; j < numvars; j++) {
        STOREDD(num,j) = table->invperm[lower+j];
    }
    STOREDD(num,numvars) = table->keys - table->isolated; 
    return(1);
}
static int build_dd ( DdManager * table , int num , int lower , int upper ) { int i , j ; int position ; int index ; int limit ; int size ; if ( computed && st__lookup_int ( computed , ( char * ) & STOREDD ( num , 0 ) , & index ) ) { STOREDD ( num , numvars ) = STOREDD ( index , numvars ) ; #ifdef DD_STATS ( void ) fprintf ( table -> out , " \n " , index ) ; #endif return ( 1 ) ; } limit = 20 * STOREDD ( 0 , numvars ) ; for ( j = 0 ; j < numvars ; j ++ ) { i = STOREDD ( num , j ) ; position = table -> perm [ i ] ; result = sift_up ( table , position , j + lower ) ; if ( ! result ) return ( 0 ) ; size = table -> keys - table -> isolated ; if ( size > limit ) break ; } #ifdef DD_STATS ( void ) fprintf ( table -> out , " \n " ) ; #endif result = cuddSifting ( table , lower , upper ) ; if ( ! result ) return ( 0 ) ; for ( j = 0 ; j < numvars ; j ++ ) { STOREDD ( num , j ) = table -> invperm [ lower + j ] ; } STOREDD ( num , numvars ) = table -> keys - table -> isolated ; return ( 1 ) ; }
Function
Synopsis [Builds a DD from a given order.]
Function Synopsis [ Builds a DD from a given order . ]
/* the index of the individual to be built */ /* loop vars */ /* how large the DD for this order can grow */ /* Check the computed table. If the order already exists, it
    ** suffices to copy the size from the existing entry.
    */ /* Stop if the DD grows 20 times larges than the reference size. */ /* Sift up the variables so as to build the desired permutation.
    ** First the variable that has to be on top is sifted to the top.
    ** Then the variable that has to occupy the secon position is sifted
    ** up to the second position, and so on.
    */ /* Sift the DD just built. */ /* Copy order and size to table. */ /* size of new DD */