GeneralGA Class Reference
[Genetic algorithm optimization]

General genetic algorithm class. More...

#include <GeneralGA.h>

Inheritance diagram for GeneralGA:

Inheritance graph
[legend]

List of all members.

Public Types

typedef std::vector< gplib::rvec > tparamvector
 We provide some typedefs that are used in other parts as well.
typedef std::vector
< boost::shared_ptr
< GeneralObjective > > 
tObjectiveVector
typedef std::vector
< std::vector< int > > 
tparamindv

Public Member Functions

const std::vector< double > & GetWeights ()
 Return the weight for each objecive function.
void SetupParams (const ttranscribed &member, tparamvector &params)
 Copy the appropriate parameter values from the transcribed vector for use with the objective functions.
const std::vector< double > & GetAvgFit ()
 Return the average fitness for each objective function.
void SetThreads (const int LocalThreads)
 Set the number of threads, only has an effect if openmp is enabled.
void SetElitist (const bool IsElitist)
 Do we want elitist behaviour, effect depends on the GA implementetion in the derived class.
void SetWeights (const std::vector< double > &LocalWeights)
 Set the weights for each objective function.
void SetParameterIndices (const tparamindv &Indices)
 Configure which parts of the complete parameter vector are used in each objective function.
void PrintFitStat (std::ostream &output)
 Print Fitness statistics for each objective function to output.
void PrintMisfit (std::ostream &output)
 Print misfit for each member to output.
void PrintTranscribed (std::ostream &output)
 Print transcribed values for each member to output.
void PrintUniquePop (std::ostream &output)
 Print each population member exactly once.
void PrintBestMisfit (std::ostream &output)
 Print misfit of the best population members.
unsigned virtual int GetNBestmodels ()=0
 This has to be implemented in the derived class to return the number of best models.
virtual std::vector< int > GetBestModelIndices ()=0
 Return the indices of the best models.
virtual void DoIteration (const int iterationnumber, const bool last)
 Do one iteration of the GA.
virtual void CalcProbabilities (const int iterationnumber, gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation)=0
 Calculate the Probabilities.
 GeneralGA (GeneralPropagation *const LocalPropagation, GeneralPopulation *const LocalPopulation, GeneralTranscribe *const LocalTranscribe, const tObjectiveVector &IndObjective)
virtual ~GeneralGA ()

Protected Member Functions

virtual void Elitism (const int iterationnumber)
 default implementation does nothing, this can be overriden

Protected Attributes

gplib::rmat OldMisFit
const unsigned int nobjective
 The number of objective functions we're using.
gplib::rmat Transcribed
 A matrix holding the numerical model vectors (transcribed from the genes) for each population member.
gplib::rmat MisFit
 Misfit first index objective function second index population member.
std::vector< tObjectiveVectorObjective
 Each population member gets its own instance of objective function objects for parallel calculations.
GeneralPropagation *const Propagation
 A pointer to an object dealing with propagation.
GeneralPopulation *const Population
 A pointer to an object holding the population.
GeneralTranscribe *const Transcribe
 A pointer to an object translating genes to model vectors.


Detailed Description

General genetic algorithm class.

GeneralGA implements the functionality that is common to all genetic algorithms it declares a bunch of virtual functions, that are implemented in derived classes and pointers to several other objects that together make up the genetic algorithm

Definition at line 25 of file GeneralGA.h.


Member Typedef Documentation

typedef std::vector<gplib::rvec > GeneralGA::tparamvector

We provide some typedefs that are used in other parts as well.

Definition at line 28 of file GeneralGA.h.

typedef std::vector<boost::shared_ptr<GeneralObjective> > GeneralGA::tObjectiveVector

Definition at line 29 of file GeneralGA.h.

typedef std::vector<std::vector<int> > GeneralGA::tparamindv

Definition at line 30 of file GeneralGA.h.


Constructor & Destructor Documentation

GeneralGA::GeneralGA ( GeneralPropagation *const   LocalPropagation,
GeneralPopulation *const   LocalPopulation,
GeneralTranscribe *const   LocalTranscribe,
const tObjectiveVector IndObjective 
)

Generate a separate objective function object for each population member, simplifies parallelization

Definition at line 37 of file GeneralGA.cpp.

References GeneralPopulation::GetPopsize(), and Objective.

GeneralGA::~GeneralGA (  )  [virtual]

Definition at line 59 of file GeneralGA.cpp.


Member Function Documentation

virtual void GeneralGA::Elitism ( const int  iterationnumber  )  [inline, protected, virtual]

default implementation does nothing, this can be overriden

See also:
ParetoGA

Reimplemented in AnnealingGA, and ParetoGA.

Definition at line 74 of file GeneralGA.h.

Referenced by DoIteration().

const std::vector<double>& GeneralGA::GetWeights (  )  [inline]

Return the weight for each objecive function.

Definition at line 77 of file GeneralGA.h.

void GeneralGA::SetupParams ( const ttranscribed member,
tparamvector params 
)

Copy the appropriate parameter values from the transcribed vector for use with the objective functions.

Definition at line 63 of file GeneralGA.cpp.

References nobjective.

const std::vector<double>& GeneralGA::GetAvgFit (  )  [inline]

Return the average fitness for each objective function.

Definition at line 81 of file GeneralGA.h.

void GeneralGA::SetThreads ( const int  LocalThreads  )  [inline]

Set the number of threads, only has an effect if openmp is enabled.

Definition at line 83 of file GeneralGA.h.

void GeneralGA::SetElitist ( const bool  IsElitist  )  [inline]

Do we want elitist behaviour, effect depends on the GA implementetion in the derived class.

Definition at line 85 of file GeneralGA.h.

Referenced by main().

void GeneralGA::SetWeights ( const std::vector< double > &  LocalWeights  ) 

Set the weights for each objective function.

Definition at line 72 of file GeneralGA.cpp.

void GeneralGA::SetParameterIndices ( const tparamindv Indices  ) 

Configure which parts of the complete parameter vector are used in each objective function.

Definition at line 79 of file GeneralGA.cpp.

Referenced by main().

void GeneralGA::PrintFitStat ( std::ostream &  output  ) 

Print Fitness statistics for each objective function to output.

Definition at line 84 of file GeneralGA.cpp.

References nobjective.

void GeneralGA::PrintMisfit ( std::ostream &  output  ) 

Print misfit for each member to output.

Definition at line 94 of file GeneralGA.cpp.

References MisFit.

Referenced by main().

void GeneralGA::PrintTranscribed ( std::ostream &  output  ) 

Print transcribed values for each member to output.

Definition at line 109 of file GeneralGA.cpp.

References Transcribed.

void GeneralGA::PrintUniquePop ( std::ostream &  output  )  [inline]

Print each population member exactly once.

Definition at line 97 of file GeneralGA.h.

References UniquePop::PrintAll().

void GeneralGA::PrintBestMisfit ( std::ostream &  output  ) 

Print misfit of the best population members.

Definition at line 123 of file GeneralGA.cpp.

References GetBestModelIndices(), and MisFit.

unsigned virtual int GeneralGA::GetNBestmodels (  )  [pure virtual]

This has to be implemented in the derived class to return the number of best models.

Implemented in AnnealingGA, and ParetoGA.

virtual std::vector<int> GeneralGA::GetBestModelIndices (  )  [pure virtual]

Return the indices of the best models.

Implemented in AnnealingGA, and ParetoGA.

Referenced by PrintBestMisfit().

void GeneralGA::DoIteration ( const int  iterationnumber,
const bool  last 
) [virtual]

virtual void GeneralGA::CalcProbabilities ( const int  iterationnumber,
gplib::rmat &  LocalMisFit,
GeneralPopulation LocalPopulation 
) [pure virtual]

Calculate the Probabilities.

Implemented in AnnealingGA, and ParetoGA.

Referenced by DoIteration().


Member Data Documentation

gplib::rmat GeneralGA::OldMisFit [protected]

Definition at line 58 of file GeneralGA.h.

Referenced by DoIteration(), and ParetoGA::Elitism().

const unsigned int GeneralGA::nobjective [protected]

The number of objective functions we're using.

Definition at line 60 of file GeneralGA.h.

Referenced by PrintFitStat(), and SetupParams().

gplib::rmat GeneralGA::Transcribed [protected]

A matrix holding the numerical model vectors (transcribed from the genes) for each population member.

Definition at line 62 of file GeneralGA.h.

Referenced by PrintTranscribed().

gplib::rmat GeneralGA::MisFit [protected]

Misfit first index objective function second index population member.

Definition at line 64 of file GeneralGA.h.

Referenced by DoIteration(), ParetoGA::Elitism(), PrintBestMisfit(), ParetoGA::PrintFront(), PrintMisfit(), and ParetoGA::PrintRanks().

std::vector< tObjectiveVector > GeneralGA::Objective [protected]

Each population member gets its own instance of objective function objects for parallel calculations.

Definition at line 66 of file GeneralGA.h.

Referenced by GeneralGA().

A pointer to an object dealing with propagation.

Definition at line 68 of file GeneralGA.h.

Referenced by DoIteration().

A pointer to an object holding the population.

Definition at line 70 of file GeneralGA.h.

Referenced by DoIteration(), ParetoGA::Elitism(), and AnnealingGA::GetBestIndex().

A pointer to an object translating genes to model vectors.

Definition at line 72 of file GeneralGA.h.


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

Generated on Fri Jul 4 15:30:21 2008 for GPLIB++ by  doxygen 1.5.5