Function PGARealEuclidianDistance

Function Documentation

double PGARealEuclidianDistance(PGAContext *ctx, int p1, int pop1, int p2, int pop2)

Compute genetic difference of two strings.

Description

This uses the Euclidian distance metric, the square-root of the sum of all squared differences of each allele. It can be used to override the default real genetic distance function (which uses a manhattan distance metric) using PGASetUserFunction() with the PGA_USERFUNCTION_GEN_DISTANCE setting.

Example

Override genetic distance function:

PGAContext *ctx;

...
assert (PGAGetDataType (ctx) == PGA_DATATYPE_REAL);
PGASetUserFunction
 (ctx, PGA_USERFUNCTION_GEN_DISTANCE, PGARealEuclidianDistance);

Parameters
  • ctx – context variable

  • p1 – first string index

  • pop1 – symbolic constant of the population the first string is in

  • p2 – second string index

  • pop2 – symbolic constant of the population the second string is in

Returns

Genetic euclidian distance of the two strings