GLBaseSelectionist Class Reference

#include <GLBaseSelectionist.h>

Inheritance diagram for GLBaseSelectionist:

GLSelectionistMixer GLSelectionistStandard

List of all members.

Public Member Functions

 GLBaseSelectionist (GLBaseRanker *ranker)
virtual ~GLBaseSelectionist ()
virtual int 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)=0
GLBaseRankergetRanker ()
const GLBaseRankergetRanker () const
virtual void reset ()

Protected Member Functions

virtual void assertNewSize (int new_size, const vector< GLBaseOrganism * > &current_population, const vector< GLBaseOrganism * > &candidates)
virtual int countSurvivedCandidates (const vector< GLBaseOrganism * > &to_live, const vector< GLBaseOrganism * > &to_die, const vector< GLBaseOrganism * > &current_population, const vector< GLBaseOrganism * > &candidates)


Detailed Description

Class to choose from the vector of organism which one to carry forward to the next population and which one to reject.

Definition at line 12 of file GLBaseSelectionist.h.


Constructor & Destructor Documentation

GLBaseSelectionist::GLBaseSelectionist ( GLBaseRanker ranker  ) 

Constructor. Assigns the operator which will be used for ranking the organisms. Note, that the ranker will be destroyed when destructor is called.

Parameters:
ranker operator for arranging the organisms in accordance with their rank.

Definition at line 13 of file GLBaseSelectionist.cpp.

GLBaseSelectionist::~GLBaseSelectionist (  )  [virtual]

Destructor. Destroys everything, including the ranker.

Definition at line 27 of file GLBaseSelectionist.cpp.


Member Function Documentation

void GLBaseSelectionist::assertNewSize ( int  new_size,
const vector< GLBaseOrganism * > &  current_population,
const vector< GLBaseOrganism * > &  candidates 
) [protected, virtual]

Asserts the validity of the size of the new generation -- should be > 0 and <= the total size of current and new generations. Probably not for all selectionists this method will be necessary. If the new size is not valid - throws an exception GLLogicError.

Parameters:
new_size number of organisms in next generations.
current_population vector of organisms which form the current population.
candidates vector of candidates on adding to new generation.

Definition at line 42 of file GLBaseSelectionist.cpp.

int GLBaseSelectionist::countSurvivedCandidates ( const vector< GLBaseOrganism * > &  to_live,
const vector< GLBaseOrganism * > &  to_die,
const vector< GLBaseOrganism * > &  current_population,
const vector< GLBaseOrganism * > &  candidates 
) [protected, virtual]

Counts the number of survived candidates (those, which get to the new generation). Note, that this is general and, therefore, not very efficient way of obtaining this number. It may well be possible, that some selection algorithm will be able to get this number without calling this method. Note, that following is assumed: to_live + to_die == current_population + candidates where '+' means 'union'

Parameters:
to_live vector of organisms which will form the next generation.
to_die vector of organisms which will be disposed of.
current_population vector of organisms which form the current generation.
candidates vector of 'candidate' organisms.

Definition at line 74 of file GLBaseSelectionist.cpp.

virtual int GLBaseSelectionist::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 
) [pure 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.

Parameters:
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.
Returns:
number of NEW organisms (not present in current generation) in next generation.

Implemented in GLSelectionistMixer, and GLSelectionistStandard.

const GLBaseRanker* GLBaseSelectionist::getRanker (  )  const [inline]

Provides access to the ranker used by selector.

Returns:
pointer to ranker.

Definition at line 68 of file GLBaseSelectionist.h.

GLBaseRanker* GLBaseSelectionist::getRanker (  )  [inline]

Provides access to the ranker used by selector.

Returns:
pointer to ranker.

Definition at line 61 of file GLBaseSelectionist.h.

void GLBaseSelectionist::reset (  )  [virtual]

Resets the selectionist (e.g. sets counter, if any, to zero etc.) and its ranker.

Definition at line 102 of file GLBaseSelectionist.cpp.


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

Generated on Sat Jun 13 13:58:07 2009 for GenLib by  doxygen 1.5.9