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

  Synopsis    [Generates the random sequences for the initial population.]

  Description [Generates the random sequences for the initial population.
  The sequences are permutations of the indices between lower and
  upper in the current order.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Generates the random sequences for the initial population.]

Description [Generates the random sequences for the initial population.
The sequences are permutations of the indices between lower and
upper in the current order.]




Function Synopsis [ Generates the random sequences for the initial population . ] Description [ Generates the random sequences for the initial population . The sequences are permutations of the indices between lower and upper in the current order . ]
static int
make_random(
  DdManager * table,
  int  lower)
{
    int i,j;            
    int *used;          
    int next;           
    used = ABC_ALLOC(int,numvars);
    if (used == NULL) {
        table->errorCode = CUDD_MEMORY_OUT;
        return(0);
    }
#if 0
#ifdef DD_STATS
    (void) fprintf(table->out,"Initial population before sifting\n");
    for (i = 0; i < 2; i++) {
        for (j = 0; j < numvars; j++) {
            (void) fprintf(table->out," %2d",STOREDD(i,j));
        }
        (void) fprintf(table->out,"\n");
    }
#endif
#endif
    for (i = 2; i < popsize; i++) {
        for (j = 0; j < numvars; j++) {
            used[j] = 0;
        }
        for (j = 0; j < numvars; j++) {
            do {
                next = rand_int(numvars-1);
            } while (used[next] != 0);
            used[next] = 1;
            STOREDD(i,j) = table->invperm[next+lower];
        }
#if 0
#ifdef DD_STATS
        for (j = 0; j < numvars; j++) {
            (void) fprintf(table->out," %2d",STOREDD(i,j));
        }
        (void) fprintf(table->out,"\n");
#endif
#endif
    }
    ABC_FREE(used);
    return(1);
}
static int make_random ( DdManager * table , int lower ) { int i , j ; int * used ; int next ; used = ABC_ALLOC ( int , numvars ) ; if ( used == NULL ) { table -> errorCode = CUDD_MEMORY_OUT ; return ( 0 ) ; } #if 0 #ifdef DD_STATS ( void ) fprintf ( table -> out , " \n " ) ; for ( i = 0 ; i < 2 ; i ++ ) { for ( j = 0 ; j < numvars ; j ++ ) { ( void ) fprintf ( table -> out , " " , STOREDD ( i , j ) ) ; } ( void ) fprintf ( table -> out , " \n " ) ; } #endif #endif for ( i = 2 ; i < popsize ; i ++ ) { for ( j = 0 ; j < numvars ; j ++ ) { used [ j ] = 0 ; } for ( j = 0 ; j < numvars ; j ++ ) { do { next = rand_int ( numvars - 1 ) ; } while ( used [ next ] != 0 ) ; used [ next ] = 1 ; STOREDD ( i , j ) = table -> invperm [ next + lower ] ; } #if 0 #ifdef DD_STATS for ( j = 0 ; j < numvars ; j ++ ) { ( void ) fprintf ( table -> out , " " , STOREDD ( i , j ) ) ; } ( void ) fprintf ( table -> out , " \n " ) ; #endif #endif } ABC_FREE ( used ) ; return ( 1 ) ; }
Function
Synopsis    [Generates the random sequences for the initial population.]
Function Synopsis [ Generates the random sequences for the initial population . ]
/* loop variables */ /* is a number already in a permutation */ /* next random number without repetitions */ /* Generate a permutation of {0...numvars-1} and use it to
        ** permute the variables in the layesr from lower to upper.
        */ /* Print the order just generated. */