14 #include <boost/shared_ptr.hpp>
30 typedef std::vector<boost::shared_ptr<GeneralObjective> >
35 void CalcMisfit(
const int iterationnumber);
49 std::vector<double> CombMisFit;
50 std::vector<double> AvgFit;
52 std::vector<double> MaxFit;
54 std::vector<double> MinFit;
56 std::vector<double> Weights;
78 void virtual Elitism(
const int iterationnumber)
104 void SetWeights(
const std::vector<double> &LocalWeights);
126 void virtual DoIteration(
const int iterationnumber,
const bool last);
138 #endif // CGENERALGA_H
The base class for the population of a genetic algorithm, implements storage and access functions...
ublas::vector< double > ttranscribed
void PrintUniquePop(std::ostream &output)
Print each population member exactly once.
GeneralPopulation *const Population
A pointer to an object holding the population.
GeneralGA(GeneralPropagation *const LocalPropagation, GeneralPopulation *const LocalPopulation, GeneralTranscribe *const LocalTranscribe, const tObjectiveVector &IndObjective, const int nthreads=1)
void PrintTranscribed(std::ostream &output)
Print transcribed values for each member to output.
virtual void DoIteration(const int iterationnumber, const bool last)
Do one iteration of the GA.
virtual std::vector< int > GetBestModelIndices()=0
Return the indices of the best models.
virtual void Elitism(const int iterationnumber)
default implementation does nothing, this can be overriden
const unsigned int nobjective
The number of objective functions we're using.
The base class for genetic algorithm propagation methods.
gplib::rmat MisFit
Misfit first index objective function second index population member.
std::vector< gplib::rvec > tparamvector
We provide some typedefs that are used in other parts as well.
void PrintFitStat(std::ostream &output)
Print Fitness statistics for each objective function to output.
void PrintBestMisfit(std::ostream &output)
Print misfit of the best population members.
std::vector< std::vector< int > > tparamindv
GeneralTranscribe *const Transcribe
A pointer to an object translating genes to model vectors.
tObjectiveVector Objective
The vector holding the objective functions.
General Transcribe base class for genetic algorithm parameter transcription.
void PrintAll(std::ostream &output)
void SetWeights(const std::vector< double > &LocalWeights)
Set the weights for each objective function.
void SetElitist(const bool IsElitist)
Do we want elitist behaviour, effect depends on the GA implementetion in the derived class...
This class stores a single unique copy of each population member that is added to it...
virtual void CalcProbabilities(const int iterationnumber, gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation)=0
Calculate the Probabilities.
unsigned virtual int GetNBestmodels()=0
This has to be implemented in the derived class to return the number of best models.
General genetic algorithm class.
GeneralPropagation *const Propagation
A pointer to an object dealing with propagation.
const std::vector< double > & GetAvgFit()
Return the average fitness for each objective function.
const std::vector< double > & GetWeights()
Return the weight for each objecive function.
void SetParameterIndices(const tparamindv &Indices)
Configure which parts of the complete parameter vector are used in each objective function...
std::vector< boost::shared_ptr< GeneralObjective > > tObjectiveVector
gplib::rmat Transcribed
A matrix holding the numerical model vectors (transcribed from the genes) for each population member...
void SetupParams(const ttranscribed &member, tparamvector ¶ms)
Copy the appropriate parameter values from the transcribed vector for use with the objective function...
void PrintMisfit(std::ostream &output)
Print misfit for each member to output.