PGADone(8)

NAME
PGACopyIndividual - copies string p1 in population pop1 to position p2 in population pop2

INPUT PARAMETERS
ctx - context variable
p1  - string to copy
pop1
    - symbolic constant of population containing string p1
p2  - string to copy p1 to
pop2
    - symbolic constant of population containing string p2

OUTPUT PARAMETERS
none

SYNOPSIS
#include "pgapack.h"
int  PGADone(ctx)
PGAContext *ctx

LOCATION
pga.c

EXAMPLE
Example:
PGAContext *ctx;
int i,j;
:
PGACopyIndividual(ctx, i, PGA_OLDPOP, j, PGA_NEWPOP);
****************************************************************************I*/
void PGACopyIndividual( PGAContext *ctx, int p1, int pop1, int p2, int pop2)
{
PGAIndividual *source, *dest;
PGADebugPrint( ctx, PGADEBUG_ENTERED, "PGACopyIndividual", "Entered",
PGA_VOID, NULL );
source = PGAGetIndividual ( ctx, p1, pop1 );
dest   = PGAGetIndividual ( ctx, p2, pop2 );
dest->evalfunc     = source->evalfunc;
dest->fitness      = source->fitness;
dest->evaluptodate = source->evaluptodate;
(*ctx->ops.CopyString)(ctx, p1, pop1, p2, pop2);
PGADebugPrint( ctx, PGADEBUG_EXIT, "PGACopyIndividual", "Exit",
PGA_VOID, NULL );
return;
}
/*U****************************************************************************
PGAUpdateGeneration - updates internal data structures for the next
genetic algorityhm iteration
Category: Generation
Inputs:
ctx  - context variable
Outputs:
Reinitializes several internal arrays
Example:
PGAContext *ctx;
:
PGAUpdateGeneration(ctx);
****************************************************************************I*/
void PGAUpdateGeneration ( PGAContext *ctx )
{
PGAIndividual *temp;
int i;
PGADebugPrint( ctx, PGADEBUG_ENTERED, "PGAUpdateGeneration", "Entered",
PGA_VOID, NULL );
PGADebugPrint( ctx, PGADEBUG_PRINTVAR,"PGAUpdateGeneration", "ga.iter = ",
PGA_INT, (void *) &(ctx->ga.iter) );
ctx->ga.iter++;
if ((ctx->rep.PrintOptions & PGA_ONLINE) == PGA_ONLINE)
PGAUpdateOnline(ctx, PGA_NEWPOP);
if ((ctx->rep.PrintOptions & PGA_OFFLINE) == PGA_OFFLINE)
PGAUpdateOffline(ctx, PGA_NEWPOP);
if ((ctx->ga.StoppingRule & PGA_STOP_NOCHANGE) == PGA_STOP_NOCHANGE)
{
i = PGAGetBest(ctx, PGA_NEWPOP);
if (ctx->rep.Best == PGAGetEvaluate(ctx, i, PGA_NEWPOP))
ctx->ga.ItersOfSame++;
else
{
ctx->rep.Best = PGAGetEvaluate(ctx, i, PGA_NEWPOP);
ctx->ga.ItersOfSame = 1;
}
}
if ((ctx->ga.StoppingRule & PGA_STOP_TOOSIMILAR) == PGA_STOP_TOOSIMILAR)
ctx->ga.PercentSame = PGAComputeSimilarity(ctx, ctx->ga.newpop);
ctx->ga.SelectIndex = 0;
temp           = ctx->ga.oldpop;
ctx->ga.oldpop = ctx->ga.newpop;
ctx->ga.newpop = temp;
PGADebugPrint( ctx, PGADEBUG_PRINTVAR,"PGAUpdateGeneration", "ga.iter = ",
PGA_INT, (void *) &(ctx->ga.iter) );
PGADebugPrint( ctx, PGADEBUG_EXIT, "PGAUpdateGeneration", "Exit",
PGA_VOID, NULL );
return;
}
/*U****************************************************************************
PGADone - returns boolean to indicate if the termination condition(s)
has been met
Category: Generation
Inputs:
ctx  - context variable
Outputs:
returns PGATRUE if at least one of the termination conditions has been
met.  Otherwise, returns PGAFALSE
Example:
PGAContext *ctx;
:
PGADone(ctx);