Function PGARank

Function Documentation

int PGARank(PGAContext *ctx, int p, int *order, int n)

Return the rank of a string in a population.

Description

This is a value between 1,…,N (the population size). The most fit string has rank 1, the least fit string has rank N.

Example

Determine the rank of string p.

PGAContext *ctx;
int i, popsize, rank;
int popsize = PGAGetPopsize (ctx)
int order [popsize];

...
PGAEvalSort (ctx, pop, order);
rank = PGARank (ctx, p, order, popsize)

Parameters
  • ctx – context variable

  • p – the index of the string whose rank is desired

  • order – an array containing a unique rank for each string

  • n – the size of the array order

Returns

The rank of string p