GLBaseOrganism Class Reference

#include <GLBaseOrganism.h>

Inheritance diagram for GLBaseOrganism:

GLOrganismVector< T >

List of all members.

Classes

class  Cloner
class  CompareEqual
class  CompareFitnessLess
class  CompareLess

Public Member Functions

 GLBaseOrganism ()
 GLBaseOrganism (const GLBaseOrganism &source)
virtual ~GLBaseOrganism ()
virtual void assertCompatibility (const GLBaseOrganism *source, const string &message) const
virtual void copyGeneticData (const GLBaseOrganism *source)
virtual const GLBaseFitnessevaluate (GLBaseEvaluator *evaluator)
const GLBaseFitnessgetFitness () const
virtual int getSize () const =0
int getTag () const
bool invertMemoryLock ()
virtual bool isEqual (const GLBaseOrganism *organism, bool soft=true) const =0
bool isEvaluated () const
virtual bool isLess (const GLBaseOrganism *organism, bool soft=true) const =0
bool isLockedInMemory () const
void lockInMemory ()
virtual GLBaseOrganismmakeClone (bool soft=true) const =0
virtual void resetFitness ()
virtual void setFitnessValue (const GLBaseFitness *fitness)
void setMemoryLock (bool new_lock)
void setTag (int new_tag)
void unlockInMemory ()


Detailed Description

Base class for all organisms.

Definition at line 19 of file GLBaseOrganism.h.


Constructor & Destructor Documentation

GLBaseOrganism::GLBaseOrganism (  ) 

Simple constructor, create instance of the organism.

Definition at line 8 of file GLBaseOrganism.cpp.

GLBaseOrganism::GLBaseOrganism ( const GLBaseOrganism source  ) 

Copying constructor.

Parameters:
source source organism.

Definition at line 20 of file GLBaseOrganism.cpp.

GLBaseOrganism::~GLBaseOrganism (  )  [virtual]

Destructor, destoys fitness function value if was evaluated.

Definition at line 33 of file GLBaseOrganism.cpp.


Member Function Documentation

void GLBaseOrganism::assertCompatibility ( const GLBaseOrganism source,
const string &  message 
) const [virtual]

Checks if the passed pointer is compatible with the current class. If not will throw GLLogicError. Normally this class should be overloaded in parents.

Parameters:
source class to check the compatibility with the current.
message some text to be used in exception. E.g. where this function was called from.
Checks if the passed pointer is compatible with the current class. If not will throw GLLogicError. Normally this class should be overloaded in parents.
Parameters:
source class to check the compatibility with the current. some text to be used in exception. E.g. where this function was called from.

Reimplemented in GLOrganismVector< T >.

Definition at line 46 of file GLBaseOrganism.cpp.

virtual void GLBaseOrganism::copyGeneticData ( const GLBaseOrganism source  )  [inline, virtual]

Copies the genetic information from the source organism to the current one (e.g. chromosome, type or the organism, bounds etc.) leaving out fitness information and similar not-internal data. Normally will reset fitness value.

Parameters:
source source organism.

Reimplemented in GLOrganismVector< T >.

Definition at line 56 of file GLBaseOrganism.h.

const GLBaseFitness * GLBaseOrganism::evaluate ( GLBaseEvaluator evaluator  )  [virtual]

Evaluates the fitness of the organism. It is assumed, that implementations of the organism will then store the evaluated value somewhere within.

Parameters:
evaluator the class for evaluating the fitness of the organism.
Returns:
the value of the fitness function corresponding to this organism.

Definition at line 68 of file GLBaseOrganism.cpp.

const GLBaseFitness* GLBaseOrganism::getFitness (  )  const [inline]

Returns the pointer to the object with the fitness value or, if organism is not evaluated, to the NULL pointer.

Definition at line 73 of file GLBaseOrganism.h.

virtual int GLBaseOrganism::getSize (  )  const [pure virtual]

Returns the size of the organism.

Returns:
the size of the organism.

Implemented in GLOrganismVector< T >.

int GLBaseOrganism::getTag (  )  const [inline]

Return the organism's tag.

Returns:
the value of the organism's tag.

Definition at line 86 of file GLBaseOrganism.h.

bool GLBaseOrganism::invertMemoryLock (  )  [inline]

Inverts the current state of the memory lock.

Returns:
the resulting state of the memory lock.

Definition at line 93 of file GLBaseOrganism.h.

virtual bool GLBaseOrganism::isEqual ( const GLBaseOrganism organism,
bool  soft = true 
) const [pure virtual]

Returns true if 2 organisms are equal. The comparison is NOT based on fittness (at least not fully).

Parameters:
organism another organism to be compared with.
soft when true soft comparison is done -- only gene's value. When false compares all others values -- fitness fucntion etc. Tag's value are never compared.

Implemented in GLOrganismVector< T >.

bool GLBaseOrganism::isEvaluated (  )  const [inline]

Returns true if the fitness function for this organism was calculated.

Returns:
true if the fitness function for this organism was calculated and false otherwise. It is assumed, when true, the value of the fitness function can be obtained from the organism.

Definition at line 113 of file GLBaseOrganism.h.

virtual bool GLBaseOrganism::isLess ( const GLBaseOrganism organism,
bool  soft = true 
) const [pure virtual]

Returns true if this organism is less than one passed as a parameter. The comparison is NOT based on fittness (at least not fully).

Parameters:
organism another organism to be compared with.
soft when true soft comparison is done -- based only on gene's value. When false compares all others values -- fitness fucntion etc. Tag's value are never compared.

Implemented in GLOrganismVector< T >.

bool GLBaseOrganism::isLockedInMemory (  )  const [inline]

Indicates, if the instance of this class is 'locked' in memory -- i.e. if the organism was dynamically allocated, should it be deleted (false) or not (true). As normally in GenLib pointers to the organisms should be copied, instead of real organisms (to minimise the overheads) this method may be used to mark those organism which can be deleted safely.

Returns:
true if organism should not be deleted (e.g. another pointer on it exists) and false if it can be done.

Definition at line 138 of file GLBaseOrganism.h.

void GLBaseOrganism::lockInMemory (  )  [inline]

Lock the organism in memory -- indicates to container of pointers to organisms that this organism should not be deleted.

Definition at line 145 of file GLBaseOrganism.h.

virtual GLBaseOrganism* GLBaseOrganism::makeClone ( bool  soft = true  )  const [pure virtual]

Creates the copy of the current organism. Do not forget to delete it, once not needed anymore. this->isEqual(makeClone(true), true) == true; this->isEqual(makeClone(true), false) == ?; this->isEqual(makeClone(false), false) == true;

Parameters:
soft when true only genetic information (chromosome) is copied to the clone.
Returns:
the copy of the current organsim.

Implemented in GLOrganismVector< T >.

void GLBaseOrganism::resetFitness (  )  [virtual]

Resets the fitness function -- sets the isEvaluated flag to false and deletes the class which stores the fitness value of the organism.

Resets the fitness function -- sets the isEvaluated flag to false and deletes the class which stores the fitness value of the organism.

Parameters:
flag new value of the flag to be set.

Definition at line 81 of file GLBaseOrganism.cpp.

void GLBaseOrganism::setFitnessValue ( const GLBaseFitness fitness  )  [virtual]

Sets the new fitness value, destroying the previous one. If fitness is == NULL that isEvaluated flag will be set to false, otherwise to true.

Parameters:
fitness new fitness value of the organism.

Definition at line 96 of file GLBaseOrganism.cpp.

void GLBaseOrganism::setMemoryLock ( bool  new_lock  )  [inline]

Sets value to the memory lock (see isLockedInMemory() method).

Parameters:
new_lock -- new value for the memory lock. False means this object may be deleted from memory, true -- otherwise.

Definition at line 179 of file GLBaseOrganism.h.

void GLBaseOrganism::setTag ( int  new_tag  )  [inline]

Tag the organism with the new value. Note, that method is const, but as the m_tag is mutable the tag of the organism may be changed.

Parameters:
new_tag new value to be assiged to tag.

Definition at line 187 of file GLBaseOrganism.h.

void GLBaseOrganism::unlockInMemory (  )  [inline]

Unlock the organism in memory -- allows it to be destoyed.

Definition at line 193 of file GLBaseOrganism.h.


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

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