Function PGADuplicate

Function Documentation

int PGADuplicate(PGAContext *ctx, int p, int pop1, int pop2)

Determine if a specified string is a duplicate of one already in an existing population.

Description

Return PGA_TRUE if PGAGetNoDuplicatesFlag() returns PGA_TRUE and string p in population pop1 is a duplicate of at least one strings already inserted into population pop2, otherwise return PGA_FALSE.

Example

Check the current to-be-inserted string if it is a copy of any of the strings in PGA_NEWPOP. Note that the check relies on all individuals in PGA_NEWPOP to also be inserted into the duplicate hash, see PGAHashIndividual().

PGAContext *ctx;
int p;

...
while (PGADuplicate (ctx, p, PGA_NEWNEW, PGA_NEWPOP)) {
    PGAChange (ctx, p, PGA_NEWPOP);
}

Parameters
  • ctx – context variable

  • p – string index

  • pop1 – symbolic constant of the population containing string p

  • pop2 – symbolic constant of the (possibly partial) population containing strings to compare string p against

Returns

Return true if duplicate