PO< F > Class Template Reference

PO inheriting from EO is specially designed for particle swarm optimization particle.POs have got a fitness, which at the same time needs to be only an object with the operation less than (<) defined. More...

#include <PO.h>

Inheritance diagram for PO< F >:

EO< F > eoObject eoPersistent eoPrintable eoVectorParticle< FitT, PositionType, VelocityType > eoBitParticle< FitT > eoRealParticle< FitT >

List of all members.

Public Types

typedef PO< F >::Fitness Fitness

Public Member Functions

 PO ()
 Default constructor.
Fitness fitness () const
 Return fitness value.
void fitness (const Fitness &_fitness)
 Set fitness.
Fitness best () const
 Return the best fitness.
void best (const Fitness &_bestFitness)
 Set the best fitness.
bool invalid () const
 Return true If fitness value is invalid, false otherwise.
void invalidate ()
 Invalidate the fitness.
bool invalidBest () const
 Return true If the best fitness value is invalid, false otherwise.
void invalidateBest ()
 Invalidate the best fitness.
virtual std::string className () const
 Return the class id.
bool operator< (const PO &_po2) const
 Returns true if.
bool operator> (const PO &_po2) const
virtual void printOn (std::ostream &_os) const
 Write object.
virtual void readFrom (std::istream &_is)
 Read object.

Private Attributes

Fitness repFitness
bool invalidFitness
Fitness bestFitness
bool invalidBestFitness


Detailed Description

template<class F>
class PO< F >

PO inheriting from EO is specially designed for particle swarm optimization particle.POs have got a fitness, which at the same time needs to be only an object with the operation less than (<) defined.

A best fitness also belongs to the particle.Fitness says how good is the particle for a current iteration whereas the best fitness can be saved for many iterations.

Definition at line 39 of file PO.h.


Constructor & Destructor Documentation

template<class F>
PO< F >::PO (  )  [inline]

Default constructor.

Fitness must have a ctor which takes 0 as a value. Best fitness mush also have the same constructor.

Definition at line 49 of file PO.h.


Member Function Documentation

template<class F>
void PO< F >::fitness ( const Fitness &  _fitness  )  [inline]

Set fitness.

At the same time, validates it.

Parameters:
_fitness New fitness value.

Definition at line 65 of file PO.h.

template<class F>
Fitness PO< F >::best (  )  const [inline]

Return the best fitness.

Returns:
bestFitness

Definition at line 74 of file PO.h.

Referenced by eoVectorParticle< eoScalarFitness, bool, double >::operator<().

template<class F>
void PO< F >::best ( const Fitness &  _bestFitness  )  [inline]

Set the best fitness.

Parameters:
_bestFitness New best fitness found for the particle.

Definition at line 85 of file PO.h.

template<class F>
bool PO< F >::invalid (  )  const [inline]

Return true If fitness value is invalid, false otherwise.

Returns:
true If fitness is invalid.

Reimplemented from EO< F >.

Definition at line 95 of file PO.h.

Referenced by PO< eoScalarFitness >::best(), and PO< eoScalarFitness >::fitness().

template<class F>
void PO< F >::invalidate ( void   )  [inline]

Invalidate the fitness.

Returns:

Reimplemented from EO< F >.

Definition at line 103 of file PO.h.

template<class F>
bool PO< F >::invalidBest (  )  const [inline]

Return true If the best fitness value is invalid, false otherwise.

Returns:
true If the bestfitness is invalid.

Definition at line 111 of file PO.h.

template<class F>
void PO< F >::invalidateBest (  )  [inline]

Invalidate the best fitness.

Returns:

Definition at line 119 of file PO.h.

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

Return the class id.

Returns:
the class name as a std::string

Reimplemented from EO< F >.

Reimplemented in eoBitParticle< FitT >, and eoRealParticle< FitT >.

Definition at line 127 of file PO.h.

template<class F>
bool PO< F >::operator< ( const PO< F > &  _po2  )  const [inline]

Returns true if.

Returns:
true if the fitness is higher

Definition at line 135 of file PO.h.

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

Write object.

Called printOn since it prints the object _on_ a stream.

Parameters:
_os A std::ostream.

Reimplemented from EO< F >.

Reimplemented in eoVectorParticle< FitT, PositionType, VelocityType >, eoVectorParticle< eoScalarFitness, double, double >, and eoVectorParticle< eoScalarFitness, bool, double >.

Definition at line 143 of file PO.h.

Referenced by eoVectorParticle< eoScalarFitness, bool, double >::printOn().

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

Read object.

\ Calls base class, just in case that one had something to do. The read and print methods should be compatible and have the same format. In principle, format is "plain": they just print a number

Parameters:
_is a std::istream.
Exceptions:
runtime_std::exception If a valid object can't be read.

Reimplemented from EO< F >.

Definition at line 154 of file PO.h.


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

Generated on Thu Jan 1 23:19:52 2009 for EvolvingObjects by  doxygen 1.5.5