EvolvingObjects
eoPop< EOT > Class Template Reference

A std::vector of EO object, to be used in all algorithms (selectors, operators, replacements, ...). More...

#include <eoPop.h>

Inheritance diagram for eoPop< EOT >:
vector eoObject eoPersistent eoPrintable

List of all members.

Classes

struct  Cmp
 helper struct for comparing on pointers More...
struct  Cmp2
 helper struct for comparing (EA or PSO) More...
struct  GetFitness
struct  Ref
 helper struct for getting a pointer More...

Public Types

typedef EOT::Fitness Fitness

Public Member Functions

 eoPop ()
 Default ctor.
 eoPop (unsigned _popSize, eoInit< EOT > &_chromInit)
 Ctor for the initialization of chromosomes.
void append (unsigned _newPopSize, eoInit< EOT > &_chromInit)
 appends random guys at end of pop.
 eoPop (std::istream &_is)
 Ctor from an std::istream; reads the population from a stream, each element should be in different lines.
virtual ~eoPop ()
 Empty Dtor.
void sort (void)
 sort the population.
void sort (std::vector< const EOT * > &result) const
 creates a std::vector<EOT*> pointing to the individuals in descending order
void shuffle (void)
 shuffle the population.
void shuffle (std::vector< const EOT * > &result) const
 creates a std::vector<EOT*> pointing to the individuals in random order
eoPop< EOT >::iterator it_best_element ()
 returns an iterator to the best individual DOES NOT MOVE ANYBODY
const EOT & best_element () const
 returns an iterator to the best individual DOES NOT MOVE ANYBODY
const EOT & worse_element () const
 returns a const reference to the worse individual DOES NOT MOVE ANYBODY
eoPop< EOT >::iterator it_worse_element ()
 returns an iterator to the worse individual DOES NOT MOVE ANYBODY
eoPop< EOT >::iterator nth_element (int nth)
 slightly faster algorithm than sort to find all individuals that are better than the nth individual.
Fitness nth_element_fitness (int which) const
 returns the fitness of the nth element
void nth_element (int which, std::vector< const EOT * > &result) const
 const nth_element function, returns pointers to sorted individuals up the the nth
void swap (eoPop< EOT > &other)
 does STL swap with other pop
virtual void sortedPrintOn (std::ostream &_os) const
 Prints sorted pop but does NOT modify it!
virtual void printOn (std::ostream &_os) const
 Write object.
virtual void invalidate ()
 Invalidate the whole population.
Methods from eoObject
virtual void readFrom (std::istream &_is)
 Read object.
virtual std::string className () const
 Inherited from eoObject.

Detailed Description

template<class EOT>
class eoPop< EOT >

A std::vector of EO object, to be used in all algorithms (selectors, operators, replacements, ...).

We have no idea if a population can be some other thing that a std::vector, but if somebody thinks of it, this concrete implementation can be moved to "generic" and an abstract Population interface be provided.

The template can be instantiated with anything that accepts a "size" and eoInit derived object. in the ctor. EOT must also have a copy ctor, since temporaries are created and then passed to the eoInit object

Examples:
t-eoEasyEA.cpp, t-eoEasyPSO.cpp, t-eoExtendedVelocity.cpp, t-eoFitnessAssembledEA.cpp, t-eoGA.cpp, t-eoGenOp.cpp, t-eoInitPermutation.cpp, t-eoIQRStat.cpp, t-eoOrderXover.cpp, t-eoReal.cpp, t-eoRingTopology.cpp, t-eoRoulette.cpp, t-eoSecondsElapsedContinue.cpp, t-eoSharing.cpp, t-eoShiftMutation.cpp, t-eoSSGA.cpp, t-eoSwapMutation.cpp, t-eoSymreg.cpp, t-eoSyncEasyPSO.cpp, t-eoTwoOptMutation.cpp, and t-selectOne.cpp.

Definition at line 65 of file eoPop.h.


Constructor & Destructor Documentation

template<class EOT>
eoPop< EOT >::eoPop ( ) [inline]

Default ctor.

Creates empty pop

Definition at line 83 of file eoPop.h.

template<class EOT>
eoPop< EOT >::eoPop ( unsigned  _popSize,
eoInit< EOT > &  _chromInit 
) [inline]

Ctor for the initialization of chromosomes.

Parameters:
_popSizetotal population size
_chromInitInitialization routine, produces EO's, needs to be an eoInit

Definition at line 90 of file eoPop.h.

template<class EOT>
eoPop< EOT >::eoPop ( std::istream &  _is) [inline]

Ctor from an std::istream; reads the population from a stream, each element should be in different lines.

Parameters:
_isthe stream

Definition at line 128 of file eoPop.h.


Member Function Documentation

template<class EOT>
void eoPop< EOT >::append ( unsigned  _newPopSize,
eoInit< EOT > &  _chromInit 
) [inline]

appends random guys at end of pop.

Can be used to initialize it pop is empty

Parameters:
_newPopSizetotal population size
_chromInitInitialization routine, produces EO's, needs to be an eoInit

Definition at line 106 of file eoPop.h.

Referenced by do_make_pop().

template<class EOT>
void eoPop< EOT >::shuffle ( void  ) [inline]

shuffle the population.

Use this member to put the population in random order

Definition at line 182 of file eoPop.h.

Referenced by eoRandomReduce< EOT >::operator()(), eoTruncatedSelectMany< EOT >::operator()(), eoRandomSplit< EOT >::operator()(), eoSequentialSelect< EOT >::setup(), and eoEliteSequentialSelect< EOT >::setup().

template<class EOT>
eoPop<EOT>::iterator eoPop< EOT >::nth_element ( int  nth) [inline]

slightly faster algorithm than sort to find all individuals that are better than the nth individual.

INDIVIDUALS ARE MOVED AROUND in the pop.

Definition at line 265 of file eoPop.h.

Referenced by eoPop< POT >::nth_element(), eoPop< POT >::nth_element_fitness(), eoTruncateSplit< EOT >::operator()(), eoReduceMergeReduce< EOT >::operator()(), eoElitism< EOT >::operator()(), eoDeterministicSurviveAndDie< EOT >::operator()(), and eoTruncatedSelectOne< EOT >::setup().

template<class EOT>
virtual void eoPop< EOT >::sortedPrintOn ( std::ostream &  _os) const [inline, virtual]

Prints sorted pop but does NOT modify it!

Parameters:
_osA std::ostream.

Definition at line 319 of file eoPop.h.

template<class EOT>
virtual void eoPop< EOT >::printOn ( std::ostream &  _os) const [inline, virtual]

Write object.

It's called printOn since it prints the object _on_ a stream.

Parameters:
_osA std::ostream.

Implements eoPrintable.

Definition at line 335 of file eoPop.h.

template<class EOT>
virtual void eoPop< EOT >::readFrom ( std::istream &  _is) [inline, virtual]

Read object.

The EOT class must have a ctor from a stream;

Parameters:
_isA std::istream.

Implements eoPersistent.

Definition at line 348 of file eoPop.h.

Referenced by eoPop< POT >::eoPop().

template<class EOT>
virtual std::string eoPop< EOT >::className ( void  ) const [inline, virtual]

Inherited from eoObject.

Returns the class name.

See also:
eoObject

Implements eoObject.

Definition at line 364 of file eoPop.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends