MTK++ Latest version: 0.2.0

Public Member Functions | Protected Types | Protected Attributes | Friends
MTKpp::gaRegion Class Reference

Container for gaPopulations. More...

#include <mtkpp/src/GA/gaRegion.h>

Collaboration diagram for MTKpp::gaRegion:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 gaRegion (gaWorld *parent=0)
 gaRegion Constructor
virtual ~gaRegion ()
 gaRegion Destructor
void setup (const int &maxInds, const int &seed, const int &maxGens, const int &elitism, const double &selectionPressure, const int &curPop, const int &popKeep, const int &nChild, const double &chreDiff, const double &pKeep, const double &pCrossover, const double &pMutate, const double &pAverage, const std::string &selection, const std::string &crossover, const std::string &mutate, const std::string &average, const std::string &funcDir, std::vector< double > maxParameters, std::vector< double > minParameters, std::vector< double > stepSize)
 Setup gaRegion.
gaPopulationaddPopulation ()
 Add gaPopulation to gaRegion.
void delPopulation (gaPopulation *pop)
 Delete gaPopulation from gaRegion.
gaPopulationgetPopulation (const int &number, bool id, bool index)
 Get gaPopulation from gaRegion.
std::vector< gaPopulation * > getPopulations ()
 Get getPopulations in the gaRegion.
int getNumPopulations ()
 Get number of gaPopulations in gaRegion.
void initialize ()
 Initialize gaRegion.
void nextGeneration ()
 Form the next generation in the gaRegion.
void setId (int id)
 Set gaRegion id.
int getId ()
 Get gaRegion id.
void setName (std::string name)
 Set gaRegion name.
std::string getName ()
 Get gaRegion name.
gaWorldgetParent ()
 Get gaWorld which gaRegion is a member of.
void setFitness (double d)
 Set Current energy value.
std::vector< double > getFitness ()
 Get Convergence data.
void setMinParameters (std::vector< double > m)
 Set min parameters.
double getMinParameter (const int &chr, const int &gen, const int &pos)
 Get min parameter for certain gaGene bit.
void setMaxParameters (std::vector< double > m)
 Set max parameters.
double getMaxParameter (const int &chr, const int &gen, const int &pos)
 Get max parameter for certain gaGene bit.
void setStepSizes (std::vector< double > s)
 Set step sizes.
double getStepSize (const int &chr, const int &gen, const int &pos)
 Get step size for certain gaGene bit.
int getMaxGens ()
 Get max number of generations.
void setGeneValues (std::vector< std::vector< double > > gVs)
 Set the possible gene values (works for 1 chr per inds with, N genes in the chr)
std::vector< double > getGeneValues (const int &gen)
 Get possible values for gene (works for 1 chr per inds with, N genes in the chr)

Protected Types

typedef std::vector
< gaPopulation * >::iterator 
populationIterator
 gaPopulation iterator

Protected Attributes

std::vector< gaPopulation * > itsPopulationList
 gaPopulation vector
gaWorldpParent
 gaWorld pointer
gaPopulationpGaPopulation
 gaPopulation pointer
gaPopulationpPreviousGaPop
 gaPopulation pointer
gaOperatorspGaOperators
 gaOperator pointer
int maxInds
 Maximum number of gaIndividuals in gaRegion.
int seed
 Random number generation seed.
int maxGens
 Maximum number of generations to be carried out.
int elitism
 Elitism is carried out or not.
double selectionPressure
 Parameter used in the selection of gaIndividuals.
int curPop
 Current gaPopulation index.
int nChild
 Number of children allowed to be produced per pair of gaIndividual.
double chreDiff
 Chromosome or Genes must differ by at least this value.
int popKeep
 Number of gaPopulation to be stored.
double pKeep
 Percentage of the current gaPopulation to be retained for the next generation.
double pCrossover
 Percentage of the next generation to be created by crossover.
double pMutate
 Percentage of the next generation to be created by mutation.
double pAverage
 Percentage of the next generation to be created by averaging.
std::string selection
 Selection method to be used.
std::string crossover
 Crossover method to be used.
std::string mutate
 Mutation method to be used.
std::string average
 Averaging method to be used.
std::string funcDir
 Minimize or maximize the fitness function.
std::vector< double > maxParameters
 Maximum parameters.
std::vector< double > minParameters
 Minimum parameters.
std::vector< double > stepSize
 Step sizes.
std::vector< std::vector
< double > > 
geneValues
 possible gene values
std::string itsName
 gaRegion name
int itsId
 gaRegion id
std::vector< double > popConv
 Convergence tracker of gaRegion.

Friends

class gaPopulation
class gaGene
class gaOperators
class gaOutput

Detailed Description

Container for gaPopulations.

Author:
Martin Peters
Version:
0.1
Date:
2005

Member Typedef Documentation

typedef std::vector<gaPopulation*>::iterator MTKpp::gaRegion::populationIterator [protected]

gaPopulation iterator


Constructor & Destructor Documentation

MTKpp::gaRegion::gaRegion ( gaWorld parent = 0)
MTKpp::gaRegion::~gaRegion ( ) [virtual]

gaRegion Destructor


Member Function Documentation

void MTKpp::gaRegion::setup ( const int &  maxInds,
const int &  seed,
const int &  maxGens,
const int &  elitism,
const double &  selectionPressure,
const int &  curPop,
const int &  popKeep,
const int &  nChild,
const double &  chreDiff,
const double &  pKeep,
const double &  pCrossover,
const double &  pMutate,
const double &  pAverage,
const std::string &  selection,
const std::string &  crossover,
const std::string &  mutate,
const std::string &  average,
const std::string &  funcDir,
std::vector< double >  maxParameters,
std::vector< double >  minParameters,
std::vector< double >  stepSize 
)

Setup gaRegion.

Parameters:
maxIndsMaximum number of gaIndividuals in the gaRegion
seedRandom number generator seed
maxGensMaximum number of generations to be carried out
elitismElitism to be employed or not
selectionPressureParameter used in the selection of gaIndividuals
curPopCurrent gaPopulation index
popKeepNumber of gaPopulations to be stored
nChildNumber of children to be produced per pair of gaIndividuals
chreDiff????
pKeepPercentage of the current gaPopulation to be retained for the next generation
pCrossoverPercentage of the next generation to be created by crossover
pMutatePercentage of the next generation to be created by mutation
pAveragePercentage of the next generation to be created by averaging
selectionSelection method to be used
crossoverCrossover method to be used
mutateMutation method to be used
averageAveraging method to be used
funcDirEither minimize or maximize the fitness function
maxParametersMaximum parameters of the genetic information
minParametersMinimum parameters of the genetic information
stepSizeStep size for the genetic information

References average, chreDiff, crossover, curPop, elitism, funcDir, maxGens, maxInds, maxParameters, minParameters, mutate, nChild, pAverage, pCrossover, pKeep, pMutate, popKeep, seed, selection, selectionPressure, and stepSize.

gaPopulation * MTKpp::gaRegion::addPopulation ( )
void MTKpp::gaRegion::delPopulation ( gaPopulation pop)

Delete gaPopulation from gaRegion.

Parameters:
popgaPopulation pointer

References itsPopulationList.

gaPopulation * MTKpp::gaRegion::getPopulation ( const int &  number,
bool  id,
bool  index 
)

Get gaPopulation from gaRegion.

Parameters:
numbergaPopulation number, either id or index
idbool return by id
indexbool return by index
Returns:
gaPopulation pointer

NEED SOME ERROR HANDLING HERE

References MTKpp::gaPopulation::getId(), itsPopulationList, and pGaPopulation.

std::vector< gaPopulation * > MTKpp::gaRegion::getPopulations ( )

Get getPopulations in the gaRegion.

Returns:
vector of gaPopulation pointers

References itsPopulationList.

Referenced by MTKpp::gaOutput::prtWorld().

int MTKpp::gaRegion::getNumPopulations ( )

Get number of gaPopulations in gaRegion.

Returns:
number of gaPopulations in gaRegion

References itsPopulationList.

Referenced by nextGeneration().

void MTKpp::gaRegion::initialize ( )
void MTKpp::gaRegion::nextGeneration ( )
void MTKpp::gaRegion::setId ( int  id)

Set gaRegion id.

Parameters:
idgaRegion id

References itsId.

int MTKpp::gaRegion::getId ( )

Get gaRegion id.

Returns:
gaRegion id

References itsId.

Referenced by MTKpp::gaWorld::getRegion().

void MTKpp::gaRegion::setName ( std::string  name)

Set gaRegion name.

Parameters:
namegaRegion name

References itsName.

std::string MTKpp::gaRegion::getName ( )
gaWorld * MTKpp::gaRegion::getParent ( )
void MTKpp::gaRegion::setFitness ( double  d)

Set Current energy value.

Parameters:
dcurrent fitness value

References popConv.

std::vector< double > MTKpp::gaRegion::getFitness ( )

Get Convergence data.

Returns:
convergence data

References popConv.

Referenced by MTKpp::gaOutput::writeConvergence().

void MTKpp::gaRegion::setMinParameters ( std::vector< double >  m)

Set min parameters.

Parameters:
mmin parameter

References minParameters.

double MTKpp::gaRegion::getMinParameter ( const int &  chr,
const int &  gen,
const int &  pos 
)

Get min parameter for certain gaGene bit.

Parameters:
chrgaChromosome index in gaIndividual
gengaGene index in gaChromosome
posbit index in gaGene
Returns:
minimum value

References MTKpp::gaWorld::chrPerInd, MTKpp::gaWorld::genePerChr, MTKpp::gaWorld::geneSizes, minParameters, and pParent.

void MTKpp::gaRegion::setMaxParameters ( std::vector< double >  m)

Set max parameters.

Parameters:
mmax parameter

References maxParameters.

double MTKpp::gaRegion::getMaxParameter ( const int &  chr,
const int &  gen,
const int &  pos 
)

Get max parameter for certain gaGene bit.

Parameters:
chrgaChromosome index in gaIndividual
gengaGene index in gaChromosome
posbit index in gaGene
Returns:
maximum value

References MTKpp::gaWorld::chrPerInd, MTKpp::gaWorld::genePerChr, MTKpp::gaWorld::geneSizes, maxParameters, and pParent.

Referenced by MTKpp::gaGene::initialize(), and MTKpp::gaGene::mutate().

void MTKpp::gaRegion::setStepSizes ( std::vector< double >  s)

Set step sizes.

Parameters:
sstep sizes

References stepSize.

double MTKpp::gaRegion::getStepSize ( const int &  chr,
const int &  gen,
const int &  pos 
)

Get step size for certain gaGene bit.

Parameters:
chrgaChromosome index in gaIndividual
gengaGene index in gaChromosome
posbit index in gaGene
Returns:
minimum value

References MTKpp::gaWorld::chrPerInd, MTKpp::gaWorld::genePerChr, MTKpp::gaWorld::geneSizes, pParent, and stepSize.

Referenced by MTKpp::gaGene::initialize(), and MTKpp::gaGene::mutate().

int MTKpp::gaRegion::getMaxGens ( )

Get max number of generations.

Returns:
maximum number of generations

References maxGens.

void MTKpp::gaRegion::setGeneValues ( std::vector< std::vector< double > >  gVs)

Set the possible gene values (works for 1 chr per inds with, N genes in the chr)

Parameters:
gVsgene values

References geneValues.

std::vector< double > MTKpp::gaRegion::getGeneValues ( const int &  gen)

Get possible values for gene (works for 1 chr per inds with, N genes in the chr)

Parameters:
gengaGene index in gaChromosome
Returns:
possible gene value

References geneValues.

Referenced by MTKpp::gaGene::initialize(), and MTKpp::gaGene::mutate().


Friends And Related Function Documentation

friend class gaPopulation [friend]

Referenced by addPopulation().

friend class gaGene [friend]
friend class gaOperators [friend]

Referenced by gaRegion().

friend class gaOutput [friend]

Member Data Documentation

gaPopulation pointer

Referenced by nextGeneration().

gaOperator pointer

See also:
gaOperator for more details

Referenced by gaRegion(), initialize(), and nextGeneration().

int MTKpp::gaRegion::maxInds [protected]
int MTKpp::gaRegion::seed [protected]

Random number generation seed.

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), and setup().

int MTKpp::gaRegion::maxGens [protected]

Maximum number of generations to be carried out.

Referenced by gaRegion(), getMaxGens(), MTKpp::gaOutput::prtOptions(), and setup().

int MTKpp::gaRegion::elitism [protected]

Elitism is carried out or not.

Referenced by gaRegion(), MTKpp::gaOperators::keep(), MTKpp::gaOutput::prtOptions(), and setup().

Parameter used in the selection of gaIndividuals.

Should be between 0 and 1. The lower the number means that you are more likely to pick a fitter gaIndividual.

See also:
gaSelection gaGaussian

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

int MTKpp::gaRegion::curPop [protected]

Current gaPopulation index.

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), and setup().

int MTKpp::gaRegion::nChild [protected]

Number of children allowed to be produced per pair of gaIndividual.

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

double MTKpp::gaRegion::chreDiff [protected]

Chromosome or Genes must differ by at least this value.

Referenced by MTKpp::gaGene::compare(), gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

int MTKpp::gaRegion::popKeep [protected]

Number of gaPopulation to be stored.

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), and setup().

double MTKpp::gaRegion::pKeep [protected]

Percentage of the current gaPopulation to be retained for the next generation.

See also:
gaOperator

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

double MTKpp::gaRegion::pCrossover [protected]

Percentage of the next generation to be created by crossover.

See also:
gaOperator

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

double MTKpp::gaRegion::pMutate [protected]

Percentage of the next generation to be created by mutation.

See also:
gaOperator

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

double MTKpp::gaRegion::pAverage [protected]

Percentage of the next generation to be created by averaging.

See also:
gaOperator

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), and setup().

std::string MTKpp::gaRegion::selection [protected]

Selection method to be used.

See also:
gaSelection

Referenced by MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

std::string MTKpp::gaRegion::crossover [protected]

Crossover method to be used.

See also:
gaCrossover

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

std::string MTKpp::gaRegion::mutate [protected]

Mutation method to be used.

See also:
gaMutate

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

std::string MTKpp::gaRegion::average [protected]

Averaging method to be used.

See also:
gaAverage

Referenced by gaRegion(), MTKpp::gaOutput::prtOptions(), MTKpp::gaOperators::setup(), and setup().

std::string MTKpp::gaRegion::funcDir [protected]

Minimize or maximize the fitness function.

Referenced by MTKpp::gaPopulation::getBestIndividual(), MTKpp::gaPopulation::rank(), and setup().

std::vector<double> MTKpp::gaRegion::maxParameters [protected]
std::vector<double> MTKpp::gaRegion::minParameters [protected]
std::vector<double> MTKpp::gaRegion::stepSize [protected]
std::vector<std::vector<double> > MTKpp::gaRegion::geneValues [protected]

possible gene values

Referenced by getGeneValues(), and setGeneValues().

std::string MTKpp::gaRegion::itsName [protected]

gaRegion name

Referenced by gaRegion(), getName(), and setName().

int MTKpp::gaRegion::itsId [protected]

gaRegion id

Referenced by gaRegion(), getId(), and setId().

std::vector<double> MTKpp::gaRegion::popConv [protected]

Convergence tracker of gaRegion.

Referenced by getFitness(), and setFitness().


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

Generated on Fri Dec 23 2011 09:28:55 for MTK++ by Doxygen 1.7.5.1