Function PGASetRealInitFraction
Defined in File real.c
Function Documentation
-
void PGASetRealInitFraction(PGAContext *ctx, double *median, double *frac)
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. With this routine the user specifies a median value and a fraction of the median for each allele.
Example
Set the initialization routines to select a value for each real-valued gene
i
uniformly randomly from the interval \([i-v,i+v]\), where \(v = i/2\). Assumes all strings are the same length.PGAContext *ctx; double *median, *frac; int i, stringlen; ... stringlen = PGAGetStringLength (ctx); median = malloc (stringlen * sizeof(double)); frac = malloc (stringlen * sizeof(double)); for (i=0; i<stringlen; i++) { median [i] = (double) i; frac [i] = 0.5; } PGASetRealInitPercent (ctx, median, frac);
- Parameters:
ctx – context variable
median – an array containing the mean value of the interval
frac – an array containing the fraction of median to add and subtract to/from the median to define the interval
- Returns:
None