This is the main algorithm base class; actual algorithms should be derived. More...
#include <Algorithm.hpp>
Public Member Functions | |
Algorithm () | |
Default constructor; doesn't initialize much, so setup() must be called. | |
virtual void | setup (const ptree &all, const string &outputdirname) |
Setup case-specific settings. | |
virtual void | run () |
Run the algorithm as the setup tells us to. | |
Protected Member Functions | |
virtual void | impl_setup (const ptree &all)=0 |
Derived classes must know how to setup their additional data structures. | |
virtual size_t | nextID () |
Give the next available ID (running index). | |
void | markAsParents (size_t childID, const vector< size_t > &parentIDs) |
Remember a parenting relationship, for tracing the runs. | |
void | traceMeasures (size_t childID, const vector< double > &measures) |
Trace some measures of an individual, possibly more than just objectives. | |
void | writeParentHistory (ostream &os) const |
Write the traced parenting history to a stream. | |
void | writeTracedMeasures (ostream &os) const |
Write the traced measures to a stream. | |
Protected Attributes | |
size_t | _maxiter |
Number of generations to carry out. | |
string | _outputdirname |
Output directory in which all the results and traces will be saved. | |
size_t | _nextID = 1 |
Next ID to give to a modified individual (unique running index). | |
vector< vector< size_t > > | _parentsOf |
The IDs of parents; for tracing the algorithm progression. | |
vector< vector< double > > | _tracedMeasures |
Traced measures; for tracing the algorithm progression. |
This is the main algorithm base class; actual algorithms should be derived.
This base class offers the general framework for setup and iterative running, but knows nothing about individual representation or operators actually used. This also handles the "dirty and mundane work" of logging outputs etc. Formatting can, of course, be done only by derived classes that know about the actual representation.
Boost property_tree is used for setup, because of its nice parser for structured configuration.
Algorithm::Algorithm | ( | ) |
Default constructor; doesn't initialize much, so setup() must be called.
void Algorithm::markAsParents | ( | size_t | childID, | |
const vector< size_t > & | parentIDs | |||
) | [protected] |
Remember a parenting relationship, for tracing the runs.
void Algorithm::run | ( | ) | [virtual] |
Run the algorithm as the setup tells us to.
Reimplemented in MlpLearnAlgorithm.
void Algorithm::setup | ( | const ptree & | all, | |
const string & | outputdirname | |||
) | [virtual] |
Setup case-specific settings.
void Algorithm::traceMeasures | ( | size_t | childID, | |
const vector< double > & | measures | |||
) | [protected] |
Trace some measures of an individual, possibly more than just objectives.
void Algorithm::writeParentHistory | ( | ostream & | os | ) | const [protected] |
Write the traced parenting history to a stream.
void Algorithm::writeTracedMeasures | ( | ostream & | os | ) | const [protected] |
Write the traced measures to a stream.
size_t Algorithm::_maxiter [protected] |
Number of generations to carry out.
size_t Algorithm::_nextID = 1 [protected] |
Next ID to give to a modified individual (unique running index).
string Algorithm::_outputdirname [protected] |
Output directory in which all the results and traces will be saved.
vector< vector <size_t> > Algorithm::_parentsOf [protected] |
The IDs of parents; for tracing the algorithm progression.
vector< vector <double> > Algorithm::_tracedMeasures [protected] |
Traced measures; for tracing the algorithm progression.