#include <GeneralGA.h>

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 ¶ms) |
| 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 | 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, const int nthreads=1) | |
| 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. | |
| tObjectiveVector | Objective |
| The vector holding the objective functions. | |
| 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. | |
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 24 of file GeneralGA.h.
| typedef std::vector<boost::shared_ptr<GeneralObjective> > GeneralGA::tObjectiveVector |
Definition at line 28 of file GeneralGA.h.
| typedef std::vector<std::vector<int> > GeneralGA::tparamindv |
Definition at line 29 of file GeneralGA.h.
| typedef std::vector<gplib::rvec> GeneralGA::tparamvector |
We provide some typedefs that are used in other parts as well.
Definition at line 27 of file GeneralGA.h.
| GeneralGA::GeneralGA | ( | GeneralPropagation *const | LocalPropagation, | |
| GeneralPopulation *const | LocalPopulation, | |||
| GeneralTranscribe *const | LocalTranscribe, | |||
| const tObjectiveVector & | IndObjective, | |||
| const int | nthreads = 1 | |||
| ) |
Definition at line 50 of file GeneralGA.cpp.
| GeneralGA::~GeneralGA | ( | ) | [virtual] |
Definition at line 69 of file GeneralGA.cpp.
| virtual void GeneralGA::CalcProbabilities | ( | const int | iterationnumber, | |
| gplib::rmat & | LocalMisFit, | |||
| GeneralPopulation & | LocalPopulation | |||
| ) | [pure virtual] |
| void GeneralGA::DoIteration | ( | const int | iterationnumber, | |
| const bool | last | |||
| ) | [virtual] |
Do one iteration of the GA.
Definition at line 205 of file GeneralGA.cpp.
References CalcProbabilities(), Elitism(), Mean(), MisFit, GeneralPropagation::NextGeneration(), OldMisFit, Population, Propagation, and GeneralPopulation::StoreOldPopulation().
| virtual void GeneralGA::Elitism | ( | const int | iterationnumber | ) | [inline, protected, virtual] |
default implementation does nothing, this can be overriden
Reimplemented in AnnealingGA, and ParetoGA.
Definition at line 75 of file GeneralGA.h.
Referenced by DoIteration().
| const std::vector<double>& GeneralGA::GetAvgFit | ( | ) | [inline] |
| virtual std::vector<int> GeneralGA::GetBestModelIndices | ( | ) | [pure virtual] |
Return the indices of the best models.
Implemented in AnnealingGA, and ParetoGA.
Referenced by PrintBestMisfit().
| 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.
| const std::vector<double>& GeneralGA::GetWeights | ( | ) | [inline] |
| void GeneralGA::PrintBestMisfit | ( | std::ostream & | output | ) |
Print misfit of the best population members.
Definition at line 137 of file GeneralGA.cpp.
References GetBestModelIndices(), and MisFit.
| void GeneralGA::PrintFitStat | ( | std::ostream & | output | ) |
Print Fitness statistics for each objective function to output.
Definition at line 96 of file GeneralGA.cpp.
References nobjective.
| void GeneralGA::PrintMisfit | ( | std::ostream & | output | ) |
Print misfit for each member to output.
Definition at line 107 of file GeneralGA.cpp.
References MisFit.
| void GeneralGA::PrintTranscribed | ( | std::ostream & | output | ) |
Print transcribed values for each member to output.
Definition at line 123 of file GeneralGA.cpp.
References Transcribed.
| void GeneralGA::PrintUniquePop | ( | std::ostream & | output | ) | [inline] |
Print each population member exactly once.
Definition at line 107 of file GeneralGA.h.
References UniquePop::PrintAll().
| 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 92 of file GeneralGA.h.
| void GeneralGA::SetParameterIndices | ( | const tparamindv & | Indices | ) |
Configure which parts of the complete parameter vector are used in each objective function.
Definition at line 91 of file GeneralGA.cpp.
| 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 74 of file GeneralGA.cpp.
References nobjective.
| void GeneralGA::SetWeights | ( | const std::vector< double > & | LocalWeights | ) |
gplib::rmat GeneralGA::MisFit [protected] |
Misfit first index objective function second index population member.
Definition at line 65 of file GeneralGA.h.
Referenced by DoIteration(), ParetoGA::Elitism(), PrintBestMisfit(), ParetoGA::PrintFront(), PrintMisfit(), and ParetoGA::PrintRanks().
const unsigned int GeneralGA::nobjective [protected] |
The number of objective functions we're using.
Definition at line 61 of file GeneralGA.h.
Referenced by PrintFitStat(), and SetupParams().
tObjectiveVector GeneralGA::Objective [protected] |
gplib::rmat GeneralGA::OldMisFit [protected] |
GeneralPopulation* const GeneralGA::Population [protected] |
A pointer to an object holding the population.
Definition at line 71 of file GeneralGA.h.
Referenced by DoIteration(), ParetoGA::Elitism(), and AnnealingGA::GetBestIndex().
GeneralPropagation* const GeneralGA::Propagation [protected] |
A pointer to an object dealing with propagation.
Definition at line 69 of file GeneralGA.h.
Referenced by DoIteration().
GeneralTranscribe* const GeneralGA::Transcribe [protected] |
A pointer to an object translating genes to model vectors.
Definition at line 73 of file GeneralGA.h.
gplib::rmat GeneralGA::Transcribed [protected] |
A matrix holding the numerical model vectors (transcribed from the genes) for each population member.
Definition at line 63 of file GeneralGA.h.
Referenced by PrintTranscribed().
1.5.8