|
GPLIB++
|
General genetic algorithm class. More...
#include <GeneralGA.h>

Public Types | |
| typedef std::vector< gplib::rvec > | tparamvector |
| We provide some typedefs that are used in other parts as well. More... | |
| 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. More... | |
| void | SetupParams (const ttranscribed &member, tparamvector ¶ms) |
| Copy the appropriate parameter values from the transcribed vector for use with the objective functions. More... | |
| const std::vector< double > & | GetAvgFit () |
| Return the average fitness for each objective function. More... | |
| void | SetElitist (const bool IsElitist) |
| Do we want elitist behaviour, effect depends on the GA implementetion in the derived class. More... | |
| void | SetWeights (const std::vector< double > &LocalWeights) |
| Set the weights for each objective function. More... | |
| void | SetParameterIndices (const tparamindv &Indices) |
| Configure which parts of the complete parameter vector are used in each objective function. More... | |
| void | PrintFitStat (std::ostream &output) |
| Print Fitness statistics for each objective function to output. More... | |
| void | PrintMisfit (std::ostream &output) |
| Print misfit for each member to output. More... | |
| void | PrintTranscribed (std::ostream &output) |
| Print transcribed values for each member to output. More... | |
| void | PrintUniquePop (std::ostream &output) |
| Print each population member exactly once. More... | |
| void | PrintBestMisfit (std::ostream &output) |
| Print misfit of the best population members. More... | |
| unsigned virtual int | GetNBestmodels ()=0 |
| This has to be implemented in the derived class to return the number of best models. More... | |
| virtual std::vector< int > | GetBestModelIndices ()=0 |
| Return the indices of the best models. More... | |
| virtual void | DoIteration (const int iterationnumber, const bool last) |
| Do one iteration of the GA. More... | |
| virtual void | CalcProbabilities (const int iterationnumber, gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation)=0 |
| Calculate the Probabilities. More... | |
| 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 More... | |
Protected Attributes | |
| gplib::rmat | OldMisFit |
| const unsigned int | nobjective |
| The number of objective functions we're using. More... | |
| gplib::rmat | Transcribed |
| A matrix holding the numerical model vectors (transcribed from the genes) for each population member. More... | |
| gplib::rmat | MisFit |
| Misfit first index objective function second index population member. More... | |
| tObjectiveVector | Objective |
| The vector holding the objective functions. More... | |
| GeneralPropagation *const | Propagation |
| A pointer to an object dealing with propagation. More... | |
| GeneralPopulation *const | Population |
| A pointer to an object holding the population. More... | |
| GeneralTranscribe *const | Transcribe |
| A pointer to an object translating genes to model vectors. More... | |
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.
| typedef std::vector<boost::shared_ptr<GeneralObjective> > gplib::GeneralGA::tObjectiveVector |
Definition at line 31 of file GeneralGA.h.
| typedef std::vector<std::vector<int> > gplib::GeneralGA::tparamindv |
Definition at line 32 of file GeneralGA.h.
| typedef std::vector<gplib::rvec> gplib::GeneralGA::tparamvector |
We provide some typedefs that are used in other parts as well.
Definition at line 29 of file GeneralGA.h.
| gplib::GeneralGA::GeneralGA | ( | GeneralPropagation *const | LocalPropagation, |
| GeneralPopulation *const | LocalPopulation, | ||
| GeneralTranscribe *const | LocalTranscribe, | ||
| const tObjectiveVector & | IndObjective, | ||
| const int | nthreads = 1 |
||
| ) |
Definition at line 54 of file GeneralGA.cpp.
|
virtual |
Definition at line 72 of file GeneralGA.cpp.
|
pure virtual |
Calculate the Probabilities.
Implemented in gplib::AnnealingGA, and gplib::ParetoGA.
Referenced by DoIteration().
|
virtual |
Do one iteration of the GA.
Definition at line 229 of file GeneralGA.cpp.
References CalcProbabilities(), Elitism(), gplib::Mean(), MisFit, gplib::GeneralPropagation::NextGeneration(), nobjective, OldMisFit, Population, Propagation, and gplib::GeneralPopulation::StoreOldPopulation().
|
inlineprotectedvirtual |
default implementation does nothing, this can be overriden
Reimplemented in gplib::ParetoGA, and gplib::AnnealingGA.
Definition at line 78 of file GeneralGA.h.
Referenced by DoIteration().
|
inline |
Return the average fitness for each objective function.
Definition at line 92 of file GeneralGA.h.
|
pure virtual |
Return the indices of the best models.
Implemented in gplib::AnnealingGA, and gplib::ParetoGA.
Referenced by PrintBestMisfit().
|
pure virtual |
This has to be implemented in the derived class to return the number of best models.
Implemented in gplib::AnnealingGA, and gplib::ParetoGA.
|
inline |
Return the weight for each objecive function.
Definition at line 84 of file GeneralGA.h.
| void gplib::GeneralGA::PrintBestMisfit | ( | std::ostream & | output | ) |
Print misfit of the best population members.
Definition at line 141 of file GeneralGA.cpp.
References GetBestModelIndices(), and MisFit.
| void gplib::GeneralGA::PrintFitStat | ( | std::ostream & | output | ) |
Print Fitness statistics for each objective function to output.
Definition at line 100 of file GeneralGA.cpp.
References nobjective.
| void gplib::GeneralGA::PrintMisfit | ( | std::ostream & | output | ) |
Print misfit for each member to output.
Definition at line 111 of file GeneralGA.cpp.
References MisFit.
| void gplib::GeneralGA::PrintTranscribed | ( | std::ostream & | output | ) |
Print transcribed values for each member to output.
Definition at line 127 of file GeneralGA.cpp.
References Transcribed.
|
inline |
Print each population member exactly once.
Definition at line 114 of file GeneralGA.h.
References gplib::UniquePop::PrintAll().
|
inline |
Do we want elitist behaviour, effect depends on the GA implementetion in the derived class.
Definition at line 98 of file GeneralGA.h.
| void gplib::GeneralGA::SetParameterIndices | ( | const tparamindv & | Indices | ) |
Configure which parts of the complete parameter vector are used in each objective function.
Definition at line 95 of file GeneralGA.cpp.
| void gplib::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 77 of file GeneralGA.cpp.
References nobjective.
| void gplib::GeneralGA::SetWeights | ( | const std::vector< double > & | LocalWeights | ) |
Set the weights for each objective function.
Definition at line 87 of file GeneralGA.cpp.
|
protected |
Misfit first index objective function second index population member.
Definition at line 68 of file GeneralGA.h.
Referenced by DoIteration(), PrintBestMisfit(), and PrintMisfit().
|
protected |
The number of objective functions we're using.
Definition at line 64 of file GeneralGA.h.
Referenced by DoIteration(), PrintFitStat(), and SetupParams().
|
protected |
The vector holding the objective functions.
Definition at line 70 of file GeneralGA.h.
|
protected |
Definition at line 62 of file GeneralGA.h.
Referenced by DoIteration().
|
protected |
A pointer to an object holding the population.
Definition at line 74 of file GeneralGA.h.
Referenced by DoIteration(), and gplib::AnnealingGA::GetBestIndex().
|
protected |
A pointer to an object dealing with propagation.
Definition at line 72 of file GeneralGA.h.
Referenced by DoIteration().
|
protected |
A pointer to an object translating genes to model vectors.
Definition at line 76 of file GeneralGA.h.
|
protected |
A matrix holding the numerical model vectors (transcribed from the genes) for each population member.
Definition at line 66 of file GeneralGA.h.
Referenced by PrintTranscribed().
1.8.6