Chromosome::Representation::GaMultiValueChromosome< TYPE > Class Template Reference

This class can be used for chromosomes which code has multiple values. Values can be of any type, but all values must have same type, they must use same value set and must obey requirements introduced by the value set. More...

#include <D:/Temp/vs/gal/source/MultiValueChromosome.h>

Inherits Chromosome::Representation::GaDomainChromosome< TYPE >, Chromosome::Representation::GaSwapableCode, Chromosome::Representation::GaSizableCode, Chromosome::Representation::GaMutableCode, and Chromosome::Representation::GaMultiValueCode.

Inherited by Chromosome::Representation::GaMVArithmeticChromosome< TYPE >.

List of all members.

Public Member Functions

virtual void GACALL Remove (int start, int size)
 More details are given in specification of GaSizableCode::Remove method.
virtual void GACALL Insert (int start, GaCodeValue *data, int size)
 More details are given in specification of GaSizableCode::Insert method.
virtual void GACALL Swap (int start1, int size1, int start2, int size2)
 If swapping two parts overlap, position of second part is moved after the end of first part.
virtual void GACALL Flip (int start, int size)
 More details are given in specification of GaMutableCode::Flip method.
virtual void GACALL Invert (int start, int size)
 More details are given in specification of GaMutableCode::Invert method.
virtual GaCodeValuesBuffer *GACALL MakeBuffer (int size) const
 More details are given in specification of GaMultiValueCode::MakeBuffer method.
virtual void GACALL FillBuffer (int pos, int size, GaCodeValuesBuffer &buffer) const
 More details are given in specification of GaMultiValueCode::FillBuffer method.
virtual void GACALL FromBuffer (const GaCodeValuesBuffer &buffer)
 More details are given in specification of GaMultiValueCode::FromBuffer method.
 GaMultiValueChromosome (TYPE *values, int size, GaChromosomeDomainBlock< TYPE > *configBlock)
 This constructor initializes chromosome with CCB and user-defined code.
 GaMultiValueChromosome (int size, GaChromosomeDomainBlock< TYPE > *configBlock)
 This constructor initializes chromosome with CCB and random code with defined size.
 GaMultiValueChromosome (GaChromosomeDomainBlock< TYPE > *configBlock)
 This constructor initializes chromosome with CCB.
 GaMultiValueChromosome (const GaMultiValueChromosome< TYPE > &c, bool setupOnly)
 This is copy constructor.
virtual GaChromosomePtr GACALL MakeCopy (bool setupOnly) const
 More details are given in specification of GaChromosome::MakeCopy method.
virtual GaChromosomePtr GACALL MakeNewFromPrototype () const
 This method uses MakeCopy method to create chromosome's object, so if additional steps are not needed for creating chromosome from prototype, classes which inherits this class don't have to override this method.
virtual int GACALL GetCodeSize () const
 This method is not thread-safe.
TYPE GACALL GetAt (int pos) const
 GetAt method returns value of chromosome's at specified position.
void GACALL SetAt (TYPE value, int pos)
 SetAt method sets value of chromosome's code at given position.
const vector< TYPE > &GACALL GetCode () const
 This method is not thread-safe.
virtual GaChromosome &GACALL operator= (const GaChromosome &rhs)
 More details are given in specification of GaChromosome::operator =.
virtual float GACALL operator== (const GaChromosome &c) const
 More details are given in specification of GaChromosome::operator ==.

Protected Member Functions

virtual void GACALL PreapareForMutation ()
 PreapareForMutation method copies values form chromosome's code to backup vector.
virtual void GACALL AcceptMutation ()
 This method only clears backup vector.
virtual void GACALL RejectMutation ()
 RejectMutation method restores chromosome's code from backup vector. It also clears backup vector.

Protected Attributes

vector< TYPE > _values
 Chromosome's code.
vector< TYPE > _backup
 Backup copy chromosome's code before mutation if improving-only mutation flag is set in chromosome's parameters.


Detailed Description

template<typename TYPE>
class Chromosome::Representation::GaMultiValueChromosome< TYPE >

This class can be used for chromosomes which code has multiple values. Values can be of any type, but all values must have same type, they must use same value set and must obey requirements introduced by the value set.

This class has no built-in synchronizator, so LOCK_OBJECT and LOCK_THIS_OBJECT macros cannot be used with instances of this class. No public or private methods are thread-safe.

Parameters:
TYPE type of value in chromosome's code.

Constructor & Destructor Documentation

template<typename TYPE>
Chromosome::Representation::GaMultiValueChromosome< TYPE >::GaMultiValueChromosome ( TYPE *  values,
int  size,
GaChromosomeDomainBlock< TYPE > *  configBlock 
) [inline]

This constructor initializes chromosome with CCB and user-defined code.

Parameters:
values values of chromosome's code.
size size of chromosome's code.
configBlock pointer to CCB.

template<typename TYPE>
Chromosome::Representation::GaMultiValueChromosome< TYPE >::GaMultiValueChromosome ( int  size,
GaChromosomeDomainBlock< TYPE > *  configBlock 
) [inline]

This constructor initializes chromosome with CCB and random code with defined size.

Parameters:
size size of chromosome's code.
configBlock pointer to CCB.

template<typename TYPE>
Chromosome::Representation::GaMultiValueChromosome< TYPE >::GaMultiValueChromosome ( GaChromosomeDomainBlock< TYPE > *  configBlock  )  [inline]

This constructor initializes chromosome with CCB.

Parameters:
configBlock pointer to CCB.

template<typename TYPE>
Chromosome::Representation::GaMultiValueChromosome< TYPE >::GaMultiValueChromosome ( const GaMultiValueChromosome< TYPE > &  c,
bool  setupOnly 
) [inline]

This is copy constructor.

Parameters:
c reference to chromosome which is copied.
setupOnly if this parameter is true, only pointer to CCB is copied. If this parameter is false, chromosome's data and CCB is copied.


Member Function Documentation

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::Remove ( int  start,
int  size 
) [inline, virtual]

More details are given in specification of GaSizableCode::Remove method.

This method is not thread-safe.

Implements Chromosome::Representation::GaSizableCode.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::Insert ( int  start,
GaCodeValue data,
int  size 
) [inline, virtual]

More details are given in specification of GaSizableCode::Insert method.

This method is not thread-safe.

Implements Chromosome::Representation::GaSizableCode.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::Swap ( int  start1,
int  size1,
int  start2,
int  size2 
) [inline, virtual]

If swapping two parts overlap, position of second part is moved after the end of first part.

More details are given in specification of GaSwapableCode::Swap method.

This method is not thread-safe.

Implements Chromosome::Representation::GaSwapableCode.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::Flip ( int  start,
int  size 
) [inline, virtual]

More details are given in specification of GaMutableCode::Flip method.

This method is not thread-safe.

Implements Chromosome::Representation::GaMutableCode.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::Invert ( int  start,
int  size 
) [inline, virtual]

More details are given in specification of GaMutableCode::Invert method.

This method is not thread-safe.

Implements Chromosome::Representation::GaMutableCode.

template<typename TYPE>
virtual GaCodeValuesBuffer* GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::MakeBuffer ( int  size  )  const [inline, virtual]

More details are given in specification of GaMultiValueCode::MakeBuffer method.

This method is not thread-safe.

Implements Chromosome::Representation::GaMultiValueCode.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::FillBuffer ( int  pos,
int  size,
GaCodeValuesBuffer buffer 
) const [inline, virtual]

More details are given in specification of GaMultiValueCode::FillBuffer method.

This method is not thread-safe.

Implements Chromosome::Representation::GaMultiValueCode.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::FromBuffer ( const GaCodeValuesBuffer buffer  )  [inline, virtual]

More details are given in specification of GaMultiValueCode::FromBuffer method.

This method is not thread-safe.

Implements Chromosome::Representation::GaMultiValueCode.

template<typename TYPE>
virtual GaChromosomePtr GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::MakeCopy ( bool  setupOnly  )  const [inline, virtual]

More details are given in specification of GaChromosome::MakeCopy method.

This method is not thread-safe.

Implements Chromosome::GaChromosome.

Reimplemented in Chromosome::Representation::GaMVArithmeticChromosome< TYPE >.

template<typename TYPE>
virtual GaChromosomePtr GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::MakeNewFromPrototype (  )  const [inline, virtual]

This method uses MakeCopy method to create chromosome's object, so if additional steps are not needed for creating chromosome from prototype, classes which inherits this class don't have to override this method.

More details are given in specification of GaChromosome::MakeNewFromPrototype method.

Implements Chromosome::GaChromosome.

template<typename TYPE>
virtual int GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::GetCodeSize (  )  const [inline, virtual]

This method is not thread-safe.

Returns:
Method always returns number of values in chromosome's code.

Implements Chromosome::GaChromosome.

template<typename TYPE>
TYPE GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::GetAt ( int  pos  )  const [inline]

GetAt method returns value of chromosome's at specified position.

This method is not thread-safe.

Parameters:
pos position of the value.
Returns:
Method returns value of chromosome's code at specified position.

template<typename TYPE>
void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::SetAt ( TYPE  value,
int  pos 
) [inline]

SetAt method sets value of chromosome's code at given position.

This method is not thread-safe.

Parameters:
value new value.
pos position of value.

template<typename TYPE>
const vector<TYPE>& GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::GetCode (  )  const [inline]

This method is not thread-safe.

Returns:
Method returns reference to vector of values which represent chromosome's code.

template<typename TYPE>
virtual GaChromosome& GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::operator= ( const GaChromosome rhs  )  [inline, virtual]

More details are given in specification of GaChromosome::operator =.

This method is not thread-safe.

Reimplemented from Chromosome::GaDefaultChromosome.

template<typename TYPE>
virtual float GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::operator== ( const GaChromosome c  )  const [inline, virtual]

More details are given in specification of GaChromosome::operator ==.

This method is not thread-safe.

Implements Chromosome::GaChromosome.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::PreapareForMutation (  )  [inline, protected, virtual]

PreapareForMutation method copies values form chromosome's code to backup vector.

Implements Chromosome::GaDefaultChromosome.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::AcceptMutation (  )  [inline, protected, virtual]

This method only clears backup vector.

Implements Chromosome::GaDefaultChromosome.

template<typename TYPE>
virtual void GACALL Chromosome::Representation::GaMultiValueChromosome< TYPE >::RejectMutation (  )  [inline, protected, virtual]

RejectMutation method restores chromosome's code from backup vector. It also clears backup vector.

Implements Chromosome::GaDefaultChromosome.


Member Data Documentation

template<typename TYPE>
vector<TYPE> Chromosome::Representation::GaMultiValueChromosome< TYPE >::_values [protected]

Chromosome's code.

template<typename TYPE>
vector<TYPE> Chromosome::Representation::GaMultiValueChromosome< TYPE >::_backup [protected]

Backup copy chromosome's code before mutation if improving-only mutation flag is set in chromosome's parameters.


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

Genetic Algorithm Library
Coolsoft Software Development