Population Class Reference

Base class for populations of individuals in an evolutionary algorithm. More...

#include <Population.h>

Inheritance diagram for Population:

PopulationCT< CT > PopulationCT< ChromosomeT< T > > PopulationT< T >

List of all members.

Public Member Functions

 Population ()
 Population (unsigned)
 Population (const Individual &)
 Population (unsigned, const Individual &)
 Population (unsigned, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &)
 Population (unsigned, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &, const Chromosome &)
 Population (unsigned, const std::vector< Chromosome * > &)
 Population (const Population &)
 Population (const std::vector< Individual * > &)
virtual ~Population ()
unsigned size () const
void resize (unsigned n)
void setMaximize ()
void setMinimize ()
void spinWheelOneTime ()
void spinWheelMultipleTimes ()
bool ascendingFitness () const
Individualoperator[] (unsigned i)
const Individualoperator[] (unsigned i) const
Population operator() (unsigned from, unsigned to) const
Populationoperator= (const Individual &ind)
Populationoperator= (const Population &pop)
std::vector< const Chromosome * > matingPool (unsigned chrom, unsigned from=0, unsigned to=0) const
void swap (unsigned i, unsigned j)
void sort ()
void shuffle ()
void replace (unsigned i, const Individual &ind)
void replace (unsigned i, const Population &pop)
void insert (unsigned i, const Individual &ind)
void insert (unsigned i, const Population &pop)
void append (const Individual &ind)
void append (const Population &pop)
void remove (unsigned i)
void remove (unsigned from, unsigned to)
void exchange (Population &pop)
unsigned bestIndex () const
unsigned worstIndex () const
IndividualoneOfBest ()
const IndividualoneOfBest () const
Individualbest ()
const Individualbest () const
Individualworst ()
const Individualworst () const
Individualrandom ()
const Individualrandom () const
void reproduce (Population &parents, unsigned nelitists=0)
void linearDynamicScaling (std::vector< double > &window, unsigned long t)
IndividualselectOneIndividual ()
void selectMuLambda (Population &parents, unsigned nelitists=0)
void selectMuLambdaKappa (Population &parents, unsigned lifespan=1, unsigned adolescence=0)
void selectProportional (Population &parents, unsigned nelitists=0)
void selectLinearRanking (Population &parents, double etaMax=1.1, unsigned nelitists=0)
void selectUniformRanking (Population &parents, unsigned nelitists=0)
void selectTournament (Population &parents, unsigned q=2, unsigned nelitists=0)
void selectLinearRankingWhitley (Population &parents, double a=1.1, unsigned nelitists=0)
void selectEPTournament (Population &parents, unsigned q)
void replaceUnconditional (Population &parents)
void replaceConditional (Population &parents)
void replaceRanking (Population &parents)
void replaceRankingConditional (Population &parents)
double minFitness () const
double maxFitness () const
double meanFitness () const
double stdDevFitness () const
void setAge (unsigned a=0)
void incAge ()
bool operator== (const Population &) const
bool operator< (const Population &) const
void setIndex (unsigned i)
unsigned getIndex () const
void setSubPop (bool sub)
bool getSubPop () const
bool getSpinOnce () const
int pvm_pkpop ()
int pvm_upkpop ()

Protected Member Functions

Individualbest (Individual &, Individual &) const
Individualworst (Individual &, Individual &) const
void sortIndividuals (std::vector< Individual * > &)
void selectInit ()
void selectElitists (Population &, unsigned)
void selectRouletteWheel (Population &, unsigned)

Static Protected Member Functions

static bool lessFitness (Individual *const &, Individual *const &)
static bool greaterFitness (Individual *const &, Individual *const &)
static bool greaterScoreAscending (Individual *const &i1, Individual *const &i2)
static bool greaterScoreDescending (Individual *const &i1, Individual *const &i2)

Protected Attributes

unsigned index
bool subPop
bool ascending
bool spinOnce

Friends

std::ostream & operator<< (std::ostream &os, const Population &pop)
std::istream & operator>> (std::istream &is, Population &pop)


Detailed Description

Base class for populations of individuals in an evolutionary algorithm.
Examples:

integerES.cpp, and pvmSphereGA.cpp.

Definition at line 55 of file Population.h.


Constructor & Destructor Documentation

Population::Population (  ) 

Definition at line 52 of file Population.cpp.

References ascending, spinOnce, and subPop.

Referenced by operator()().

Population::Population ( unsigned  n  )  [explicit]

Definition at line 67 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( const Individual indiv  ) 

Definition at line 77 of file Population.cpp.

References ascending, spinOnce, and subPop.

Population::Population ( unsigned  n,
const Individual indiv 
)

Definition at line 86 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0 
)

Definition at line 101 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1 
)

Definition at line 112 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1,
const Chromosome chrom2 
)

Definition at line 123 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1,
const Chromosome chrom2,
const Chromosome chrom3 
)

Definition at line 135 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1,
const Chromosome chrom2,
const Chromosome chrom3,
const Chromosome chrom4 
)

Definition at line 149 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1,
const Chromosome chrom2,
const Chromosome chrom3,
const Chromosome chrom4,
const Chromosome chrom5 
)

Definition at line 164 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1,
const Chromosome chrom2,
const Chromosome chrom3,
const Chromosome chrom4,
const Chromosome chrom5,
const Chromosome chrom6 
)

Definition at line 180 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  n,
const Chromosome chrom0,
const Chromosome chrom1,
const Chromosome chrom2,
const Chromosome chrom3,
const Chromosome chrom4,
const Chromosome chrom5,
const Chromosome chrom6,
const Chromosome chrom7 
)

Definition at line 198 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( unsigned  ,
const std::vector< Chromosome * > &   
)

Population::Population ( const Population pop  ) 

Definition at line 228 of file Population.cpp.

References ascending, size(), spinOnce, and subPop.

Population::Population ( const std::vector< Individual * > &   ) 

Population::~Population (  )  [virtual]

Definition at line 242 of file Population.cpp.

References size(), and subPop.


Member Function Documentation

void Population::append ( const Population pop  ) 

Definition at line 401 of file Population.cpp.

References insert(), and size().

void Population::append ( const Individual ind  ) 

Definition at line 394 of file Population.cpp.

bool Population::ascendingFitness (  )  const [inline]

Definition at line 128 of file Population.h.

References ascending.

Individual & Population::best ( Individual ind0,
Individual ind1 
) const [protected]

Definition at line 457 of file Population.cpp.

References ascending, and Individual::fitness.

const Individual& Population::best (  )  const [inline]

Individual& Population::best (  )  [inline]

unsigned Population::bestIndex (  )  const

Definition at line 529 of file Population.cpp.

References ascending, and size().

Referenced by best().

void Population::exchange ( Population pop  ) 

Definition at line 429 of file Population.cpp.

References ascending, index, size(), spinOnce, and subPop.

unsigned Population::getIndex (  )  const [inline]

Definition at line 275 of file Population.h.

References index.

bool Population::getSpinOnce (  )  const [inline]

Definition at line 290 of file Population.h.

References spinOnce.

bool Population::getSubPop (  )  const [inline]

Definition at line 285 of file Population.h.

References subPop.

bool Population::greaterFitness ( Individual *const &  i1,
Individual *const &  i2 
) [static, protected]

Definition at line 329 of file Population.cpp.

References Individual::fitness.

bool Population::greaterScoreAscending ( Individual *const &  i1,
Individual *const &  i2 
) [static, protected]

Definition at line 1112 of file Population.cpp.

References Individual::fitness, and Individual::scaledFitness.

Referenced by selectEPTournament().

bool Population::greaterScoreDescending ( Individual *const &  i1,
Individual *const &  i2 
) [static, protected]

Definition at line 1121 of file Population.cpp.

References Individual::fitness, and Individual::scaledFitness.

Referenced by selectEPTournament().

void Population::incAge (  ) 

Definition at line 1311 of file Population.cpp.

References size().

Referenced by selectMuLambdaKappa().

void Population::insert ( unsigned  i,
const Population pop 
)

Definition at line 383 of file Population.cpp.

References insert(), and size().

void Population::insert ( unsigned  i,
const Individual ind 
)

Definition at line 375 of file Population.cpp.

References size().

Referenced by append(), insert(), and resize().

bool Population::lessFitness ( Individual *const &  i1,
Individual *const &  i2 
) [static, protected]

Definition at line 324 of file Population.cpp.

References Individual::fitness.

void Population::linearDynamicScaling ( std::vector< double > &  window,
unsigned long  t 
)

vector< const Chromosome * > Population::matingPool ( unsigned  chrom,
unsigned  from = 0,
unsigned  to = 0 
) const

Definition at line 307 of file Population.cpp.

References size().

double Population::maxFitness (  )  const

Definition at line 1251 of file Population.cpp.

References size().

Referenced by oneOfBest().

double Population::meanFitness (  )  const

Definition at line 1266 of file Population.cpp.

References size().

double Population::minFitness (  )  const

Definition at line 1236 of file Population.cpp.

References size().

Referenced by oneOfBest().

const Individual & Population::oneOfBest (  )  const

Individual & Population::oneOfBest (  ) 

Population Population::operator() ( unsigned  from,
unsigned  to 
) const [inline]

bool Population::operator< ( const Population pop  )  const

Definition at line 1334 of file Population.cpp.

References size().

Population & Population::operator= ( const Population pop  ) 

Definition at line 284 of file Population.cpp.

References operator=(), size(), and subPop.

Population & Population::operator= ( const Individual ind  ) 

Definition at line 274 of file Population.cpp.

References size().

Referenced by operator=().

bool Population::operator== ( const Population pop  )  const

Definition at line 1319 of file Population.cpp.

References ascending, index, size(), spinOnce, and subPop.

const Individual& Population::operator[] ( unsigned  i  )  const [inline]

Individual& Population::operator[] ( unsigned  i  )  [inline]

int Population::pvm_pkpop (  ) 

Part of PVM-send routine for populations

Definition at line 786 of file Population.cpp.

References ascending, index, pvm_pkuint(), size(), spinOnce, and subPop.

int Population::pvm_upkpop (  ) 

Part of PVM-receive routine for populations

Definition at line 811 of file Population.cpp.

References ascending, index, pvm_upkuint(), size(), spinOnce, and subPop.

const Individual& Population::random (  )  const [inline]

Individual& Population::random (  )  [inline]

void Population::remove ( unsigned  from,
unsigned  to 
)

Definition at line 417 of file Population.cpp.

References size().

void Population::remove ( unsigned  i  ) 

Definition at line 408 of file Population.cpp.

References size().

void Population::replace ( unsigned  i,
const Population pop 
)

Definition at line 366 of file Population.cpp.

References size().

void Population::replace ( unsigned  i,
const Individual ind 
)

Definition at line 357 of file Population.cpp.

References size().

void Population::replaceConditional ( Population parents  ) 

void Population::replaceRanking ( Population parents  ) 

void Population::replaceRankingConditional ( Population parents  ) 

void Population::replaceUnconditional ( Population parents  ) 

void Population::reproduce ( Population parents,
unsigned  nelitists = 0 
) [inline]

Definition at line 226 of file Population.h.

References selectUniformRanking().

void Population::resize ( unsigned  n  ) 

void Population::selectElitists ( Population parents,
unsigned  numElitists 
) [protected]

void Population::selectEPTournament ( Population parents,
unsigned  q 
)

void Population::selectInit (  )  [protected]

void Population::selectLinearRanking ( Population parents,
double  etaMax = 1.1,
unsigned  nelitists = 0 
)

void Population::selectLinearRankingWhitley ( Population parents,
double  a = 1.1,
unsigned  nelitists = 0 
)

Definition at line 1067 of file Population.cpp.

References selectElitists(), selectInit(), size(), and sortIndividuals().

void Population::selectMuLambda ( Population parents,
unsigned  nelitists = 0 
)

Definition at line 670 of file Population.cpp.

References selectElitists(), selectInit(), size(), and sortIndividuals().

Referenced by CMSASearch::run(), and CMASearch::run().

void Population::selectMuLambdaKappa ( Population parents,
unsigned  lifespan = 1,
unsigned  adolescence = 0 
)

Definition at line 708 of file Population.cpp.

References incAge(), selectInit(), size(), sort(), and sortIndividuals().

Individual & Population::selectOneIndividual (  ) 

void Population::selectProportional ( Population parents,
unsigned  nelitists = 0 
)

Definition at line 878 of file Population.cpp.

References selectElitists(), selectInit(), selectRouletteWheel(), and size().

void Population::selectRouletteWheel ( Population parents,
unsigned  numElitists 
) [protected]

Definition at line 620 of file Population.cpp.

References size(), and spinOnce.

Referenced by selectLinearRanking(), selectProportional(), and selectUniformRanking().

void Population::selectTournament ( Population parents,
unsigned  q = 2,
unsigned  nelitists = 0 
)

void Population::selectUniformRanking ( Population parents,
unsigned  nelitists = 0 
)

Definition at line 990 of file Population.cpp.

References selectElitists(), selectInit(), selectRouletteWheel(), and size().

Referenced by reproduce().

void Population::setAge ( unsigned  a = 0  ) 

Definition at line 1305 of file Population.cpp.

References size().

void Population::setIndex ( unsigned  i  )  [inline]

Definition at line 270 of file Population.h.

References index.

void Population::setMaximize (  )  [inline]

Definition at line 110 of file Population.h.

References ascending.

void Population::setMinimize (  )  [inline]

Examples:
paraboloidElitistCMA.cpp.

Definition at line 114 of file Population.h.

References ascending.

Referenced by CMAElitistSearch::init(), CMSASearch::init(), and CMASearch::init().

void Population::setSubPop ( bool  sub  )  [inline]

Definition at line 280 of file Population.h.

References subPop.

void Population::shuffle (  ) 

Definition at line 349 of file Population.cpp.

References size(), and swap().

unsigned Population::size (  )  const [inline]

void Population::sort (  ) 

Definition at line 342 of file Population.cpp.

References sortIndividuals().

Referenced by selectEPTournament(), and selectMuLambdaKappa().

void Population::sortIndividuals ( std::vector< Individual * > &   )  [protected]

void Population::spinWheelMultipleTimes (  )  [inline]

Definition at line 123 of file Population.h.

References spinOnce.

void Population::spinWheelOneTime (  )  [inline]

Definition at line 119 of file Population.h.

References spinOnce.

double Population::stdDevFitness (  )  const

Definition at line 1281 of file Population.cpp.

References size().

void Population::swap ( unsigned  i,
unsigned  j 
) [inline]

Definition at line 159 of file Population.h.

References size().

Referenced by shuffle().

Individual & Population::worst ( Individual ind0,
Individual ind1 
) const [protected]

Definition at line 468 of file Population.cpp.

References ascending, and Individual::fitness.

const Individual& Population::worst (  )  const [inline]

Individual& Population::worst (  )  [inline]

unsigned Population::worstIndex (  )  const

Definition at line 551 of file Population.cpp.

References ascending, and size().

Referenced by worst().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Population pop 
) [friend]

Definition at line 332 of file Population.h.

std::istream& operator>> ( std::istream &  is,
Population pop 
) [friend]

Definition at line 345 of file Population.h.


Member Data Documentation

bool Population::ascending [protected]

unsigned Population::index [protected]

Definition at line 311 of file Population.h.

Referenced by exchange(), getIndex(), operator==(), pvm_pkpop(), pvm_upkpop(), and setIndex().

bool Population::spinOnce [protected]

bool Population::subPop [protected]


The documentation for this class was generated from the following files: