GPLIB++
Public Member Functions | Protected Member Functions | List of all members
gplib::AnnealingGA Class Reference

AnnealingGA implements a genetic algorithm with an annealing style objective function. More...

#include <AnnealingGA.h>

Inheritance diagram for gplib::AnnealingGA:
Inheritance graph
[legend]

Public Member Functions

int GetBestIndex ()
 The index of the best population member. More...
 
void SetParams (const double InitT, const int AnnealG, const double AnnealR)
 Set the parameters for the annealing process. More...
 
unsigned virtual int GetNBestmodels ()
 How many best models exist in this iteration, for this GA it is always 1. More...
 
virtual std::vector< int > GetBestModelIndices ()
 Return the vector containing the best indices, here it has always one component equal to GetBestIndex. More...
 
virtual void CalcProbabilities (const int iterationnumber, gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation)
 Calculate the selection probabilities given the iterationnumber, misfit and population to store the results. More...
 
 AnnealingGA (GeneralPropagation *const LocalPropagation, GeneralPopulation *const LocalPopulation, GeneralTranscribe *const LocalTranscribe, const tObjectiveVector &IndObjective, const int nthreads=1)
 The constructor only passes on the parameters to GeneralGA. More...
 
virtual ~AnnealingGA ()
 
- Public Member Functions inherited from gplib::GeneralGA
const std::vector< double > & GetWeights ()
 Return the weight for each objecive function. More...
 
void SetupParams (const ttranscribed &member, tparamvector &params)
 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...
 
virtual void DoIteration (const int iterationnumber, const bool last)
 Do one iteration of the GA. 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)
 The implementation of Elitism for the AnnealingGA, in this case this function has no effect. More...
 

Additional Inherited Members

- Public Types inherited from gplib::GeneralGA
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
 
- Protected Attributes inherited from gplib::GeneralGA
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...
 

Detailed Description

AnnealingGA implements a genetic algorithm with an annealing style objective function.

For the first AnnealingGeneration iterations the objective function is kept constant after that the misfit is stretched with an exponential annealing function to focus on the minimum

Definition at line 15 of file AnnealingGA.h.

Constructor & Destructor Documentation

gplib::AnnealingGA::AnnealingGA ( GeneralPropagation *const  LocalPropagation,
GeneralPopulation *const  LocalPopulation,
GeneralTranscribe *const  LocalTranscribe,
const tObjectiveVector IndObjective,
const int  nthreads = 1 
)

The constructor only passes on the parameters to GeneralGA.

Definition at line 14 of file AnnealingGA.cpp.

gplib::AnnealingGA::~AnnealingGA ( )
virtual

Definition at line 24 of file AnnealingGA.cpp.

Member Function Documentation

void gplib::AnnealingGA::CalcProbabilities ( const int  iterationnumber,
gplib::rmat &  LocalMisFit,
GeneralPopulation LocalPopulation 
)
virtual

Calculate the selection probabilities given the iterationnumber, misfit and population to store the results.

Implements gplib::GeneralGA.

Definition at line 43 of file AnnealingGA.cpp.

References gplib::GeneralPopulation::GetPopsize(), gplib::GeneralPopulation::SetProbabilities(), and gplib::T.

void gplib::AnnealingGA::Elitism ( const int  iterationnumber)
protectedvirtual

The implementation of Elitism for the AnnealingGA, in this case this function has no effect.

Reimplemented from gplib::GeneralGA.

Definition at line 69 of file AnnealingGA.cpp.

int gplib::AnnealingGA::GetBestIndex ( )

The index of the best population member.

Definition at line 28 of file AnnealingGA.cpp.

References gplib::GeneralPopulation::GetProbabilities(), and gplib::GeneralGA::Population.

Referenced by GetBestModelIndices().

virtual std::vector<int> gplib::AnnealingGA::GetBestModelIndices ( )
inlinevirtual

Return the vector containing the best indices, here it has always one component equal to GetBestIndex.

Implements gplib::GeneralGA.

Definition at line 39 of file AnnealingGA.h.

References GetBestIndex().

unsigned virtual int gplib::AnnealingGA::GetNBestmodels ( )
inlinevirtual

How many best models exist in this iteration, for this GA it is always 1.

Implements gplib::GeneralGA.

Definition at line 34 of file AnnealingGA.h.

void gplib::AnnealingGA::SetParams ( const double  InitT,
const int  AnnealG,
const double  AnnealR 
)

Set the parameters for the annealing process.

Definition at line 35 of file AnnealingGA.cpp.

Referenced by SetupAnnealingGA().


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