Function PGACrossover
Defined in File cross.c
Function Documentation
-
void PGACrossover(PGAContext *ctx, int p1, int p2, int pop1, int c1, int c2, int pop2)
Perform crossover on two parent strings to create two child strings (via side-effect).
Description
The type of crossover performed is either the default or that specified by
PGASetCrossoverType()
.Example
Perform crossover on the two parent strings
mom
anddad
in populationPGA_OLDPOP
, and insert the child strings,child1
andchild1
, in populationPGA_NEWPOP
.PGAContext *ctx; int mom, dad, child1, child2; ... PGACrossover (ctx, mom, dad, PGA_OLDPOP, child1, child2, PGA_NEWPOP);
- Parameters:
ctx – the context variable
p1 – the first parent string
p2 – the second parent string
pop1 – symbolic constant of the population containing string p1 and p2
c1 – the first child string
c2 – the second child string
pop2 – symbolic constant of the population to contain string c1 and c2
- Returns:
c1 and c2 in pop2 are children of p1 and p2 in pop1. p1 and p2 are not modified.