PGADuplicate3
Determines if a specified string is a duplicate of one already in an existing population
Part of PGADuplicate(8).
Usage
int PGADuplicate(ctx,
p,
pop1,
pop2,
n)
PGAContext *ctx
int p
int pop1
int pop2
int n
Input 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
- n
-
- the number of strings in pop2 to compare string p against
- n
-
-1)
Output parameters
- none
Location
duplcate.c
Examples
0,...,n-1 in population pop2. Otherwise returns PGA_FALSE
Example:
Change any string in PGA_NEWPOP that is an exact copy of a string
in PGA_OLDPOP.
PGAContext *ctx;
int b, n;
:
n = PGAGetPopsize(ctx);
for (b=0; b<n; b++)
if (PGADuplicate(ctx, b, PGA_NEWPOP, PGA_OLDPOP, n))
PGAChange(ctx, b, PGA_NEWPOP);
Check if the best string in population PGA_OLDPOP is a duplicate of any
of the strings in the first half of population PGA_NEWPOP.
PGAContext *ctx;
int b, n;
:
b = PGAGetBestIndex(ctx, PGA_OLDPOP);
n = PGAGetPopsize(ctx) / 2;
if (PGADuplicate(ctx, b, PGA_OLDPOP, PGA_NEWPOP, n))
printf("A duplicate!0);
Releases
8 releases since Debian 1.1 (Buzz); the text changed 1 time.