PGASortPop(8)

PGASortPop8

Creates an (internal) array of indices according to one of three criteria.

Usage

void PGASortPop(ctx, pop)

PGAContext *ctx

int pop

Overview

If PGA_POPREPL_BEST is used (the default) the array is sorted from most fit to least fit. If PGA_POPREPL_RANDOM_REP is used the indices in the array are selected randomly with replacement. If PGA_POPREPL_RANDOM_NOREP is used the indices in the array are selected randomly without replacement. The function PGASetPopReplaceType() is used to specify which strategy is used. The indices of the sorted population members may then be accessed from the internal array via PGAGetSortedPopIndex(). This routine is typically used during population replacement.

Input parameters

ctx

- context variable

popindex

- symbolic constant of the population from which to create the srted array.

Output parameters

none

Location

pop.c

Examples

Example:
Copy the five best strings from the old population into the new
population.  The rest of the new population will be created by
recombination, and is not shown.
PGAContext *ctx;
int i,j;
:
PGASetPopReplaceType(ctx,PGA_POPREPL_BEST)
:
PGASortPop(ctx, PGA_OLDPOP);
for ( i=0; i < 5; i++) {
j = PGAGetSortedPopIndex(ctx, i);
PGACopyIndividual (ctx, j, PGA_OLDPOP, i, PGA_NEWPOP);
:

Releases

Unchanged in 4 releases since Debian 5.0 (Lenny).

  1. 5.0–8

From pgapack 1.1.1-3 in Debian 8 (Jessie). Parsed by carta from the page's man source.