#include <GLSelectionistMixer.h>
Classes | |
struct | TParameters |
Public Member Functions | |
GLSelectionistMixer (GLBaseRanker *ranker, const double &proportion_old=0.2) | |
GLSelectionistMixer (GLBaseRanker *ranker, const GLSelectionistMixer::TParameters *parameters) | |
virtual | ~GLSelectionistMixer () |
virtual int | doSelection (const vector< GLBaseOrganism * > ¤t_population, const vector< GLBaseOrganism * > &candidates, size_t new_size, vector< GLBaseOrganism * > &to_live, vector< GLBaseOrganism * > &to_die, vector< const GLBaseOrganism * > &best_survived) |
double | getProportionOld () const |
void | setProportionOld (const double &new_proportion_old) |
Definition at line 13 of file GLSelectionistMixer.h.
GLSelectionistMixer::GLSelectionistMixer | ( | GLBaseRanker * | ranker, | |
const double & | proportion_old = 0.2 | |||
) |
Constructor. Assigns the operator which will be used for ranking the organisms. Note, that the ranker will be destroyed when destructor is called.
ranker | operator for arranging the organisms in accordance with their rank. | |
proportion_old | number between 0 and 1 inclusive which determines how many organisms from the old generation will be passed to the new one. In any new generation of size S the S * proportion_old organism will come from the old generaion and S * (1 - proportion_old) organisms will be new. |
Definition at line 17 of file GLSelectionistMixer.cpp.
GLSelectionistMixer::GLSelectionistMixer | ( | GLBaseRanker * | ranker, | |
const GLSelectionistMixer::TParameters * | parameters | |||
) |
Constructor. Assigns the operator which will be used for ranking the organisms. Note, that the ranker will be destroyed when destructor is called.
ranker | operator for arranging the organisms in accordance with their rank. | |
parameters | parameters specific for this selectionist. |
Definition at line 33 of file GLSelectionistMixer.cpp.
GLSelectionistMixer::~GLSelectionistMixer | ( | ) | [virtual] |
Destructor. Destroys everything, including ranker.
Definition at line 43 of file GLSelectionistMixer.cpp.
int GLSelectionistMixer::doSelection | ( | const vector< GLBaseOrganism * > & | current_population, | |
const vector< GLBaseOrganism * > & | candidates, | |||
size_t | new_size, | |||
vector< GLBaseOrganism * > & | to_live, | |||
vector< GLBaseOrganism * > & | to_die, | |||
vector< const GLBaseOrganism * > & | best_survived | |||
) | [virtual] |
Choose which organism to leave and which one to die in the next generation. It is assumed, that all organisms passed as input parameters were evaluated already. The algorithm is as following: if the number of organism in the next generation should be S then keep S*getProportionOld() best organisms from the old generation and mix them with S * (1 - getProportionOld()) new organisms. If there is not enough organisms in either set then more organisms from the opposit set will be added. If number of organisms in both generation is too small then all of them will be part of the new generation.
current_population | organisms from the this generation's population. | |
candidates | newly created organisms (e.g. mutants and/or children). It is desirable, that both arrays have not common organisms. | |
new_size | size of the next generation. | |
to_live | output array of organisms to live (will be cleaned). | |
to_die | output array of organisms to die in the next generation (will be cleaned). | |
best_survived | best survived organism(s). May be single organism for single objective optimisation or the whole Pareto-front for multi-objective optimisation. The previous content of this array will be lost. |
Implements GLBaseSelectionist.
Definition at line 74 of file GLSelectionistMixer.cpp.
double GLSelectionistMixer::getProportionOld | ( | ) | const [inline] |
Returns the current settings for the proportion of old organisms in the new generation.
Definition at line 88 of file GLSelectionistMixer.h.
void GLSelectionistMixer::setProportionOld | ( | const double & | new_proportion_old | ) |
Sets the new value for the proportion of old organisms in the new generation.
new_proportion_old | new value for the proportion of old organisms in the new generation. Must be between 0 and 1.0 inclusive. |
Definition at line 141 of file GLSelectionistMixer.cpp.