PGASortPop(8) PGAPack PGASortPop(8)NAME
PGASortPop - Creates an (internal) array of indices according to one of three criteria.
DESCRIPTION
If PGA_POPREPL_BEST is used (the default) the array is sorted from most fit to least fit. If PGA_POPREPL_RANDOM_REP is used the indices in
the array are selected randomly with replacement. If PGA_POPREPL_RANDOM_NOREP is used the indices in the array are selected randomly with-
out replacement. The function PGASetPopReplaceType() is used to specify which strategy is used. The indices of the sorted population mem-
bers may then be accessed from the internal array via PGAGetSortedPopIndex(). This routine is typically used during population replace-
ment.
INPUT PARAMETERS
ctx - context variable
popindex
- symbolic constant of the population from which to create the srted array.
OUTPUT PARAMETERS
none
SYNOPSIS
#include "pgapack.h"
void PGASortPop(ctx, pop)
PGAContext *ctx
int pop
LOCATION
pop.c
EXAMPLE
Example:
Copy the five best strings from the old population into the new
population. The rest of the new population will be created by
recombination, and is not shown.
PGAContext *ctx;
int i,j;
:
PGASetPopReplaceType(ctx,PGA_POPREPL_BEST)
:
PGASortPop(ctx, PGA_OLDPOP);
for ( i=0; i < 5; i++) {
j = PGAGetSortedPopIndex(ctx, i);
PGACopyIndividual (ctx, j, PGA_OLDPOP, i, PGA_NEWPOP);
:
05/01/95 PGASortPop(8)
Check Out this Related Man Page
PGADuplicate(8) PGAPack PGADuplicate(8)NAME
PGADuplicate - determines if a specified string is a duplicate of one already in an existing population
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
SYNOPSIS
#include "pgapack.h"
int PGADuplicate(ctx, p, pop1, pop2, n)
PGAContext *ctx
int p
int pop1
int pop2
int n
LOCATION
duplcate.c
EXAMPLE
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);
05/01/95 PGADuplicate(8)
Dear all,
I'm have a sorted array like this:
177
220
1001
2000
2001
2003
2005
notice that 2002 and 2004 are NOT in array.
Then user input a number INPUT, our script should return OUTPUT value like this:
if INPUT is not in array => OUTPUT=INPUT
if INPUT is in array => OUTPUT is the... (4 Replies)
Hi,
I am trying to populate an array with data from a text file. I have a working method using awk but it is too slow and inefficent. See below.
The text file has 70,000 lines. As awk is a line editor it reads each line of the file until it gets to the required line and then processes it.... (3 Replies)
Dear Folks
I have one column of 15000 lines and want to select randomly 5000 of them in five different times without replacement. I am aware that command 'shuf' and 'sort -R' could select randomly those lines but I am not sure how could I avoid the replacement of selection line. Does anyone have... (10 Replies)