Function PGASetRealInitRange

Function Documentation

void PGASetRealInitRange(PGAContext *ctx, const double *min, const double *max)

Set the upper and lower bounds for randomly initializing real-valued genes.

Description

For each gene these bounds define an interval from which the initial allele value is selected uniformly randomly. The user specifies two arrays containing lower and upper bound for each gene to define the interval. This is the default strategy for initializing real-valued strings. The default interval is \([0,1.0]\) for each gene.

Example

Set the initialization routines to select a value for each real-valued gene \(i\) uniformly randomly from the interval \([-10.,i]\) Assumes all strings are of the same length.

PGAContext *ctx;
double *low, *high;
int i, stringlen;

...
stringlen = PGAGetStringLength (ctx);
low  = malloc (stringlen * sizeof(double));
high = malloc (stringlen * sizeof(double));
for (i=0; i<stringlen; i++) {
   low  [i] = -10.0;
   high [i] = i;
}
PGASetRealInitRange (ctx, low, high);

Parameters
  • ctx – context variable

  • min – array containing the lower bound of the interval for each gene

  • max – array containing the upper bound of the interval for each gene

Returns

None