Chromosome< T > Class Template Reference

The super class for different type of chromosomes. More...

#include <Chromosome.h>

Inherits vector< T >.

List of all members.

Public Member Functions

 Chromosome ()
 Default constructor.
 Chromosome (const vector< T > &v)
 Constructor.
 Chromosome (const size_t size, vector< double > lowerBounds, vector< double > upperBounds)
 Constructor.
 Chromosome (vector< double > phenotype, vector< double > lowerBounds, vector< double > upperBounds)
 Constructor.
virtual void fromDoubleVector (vector< double > &phenotype)
 Encode function.
virtual vector< double > toDoubleVector ()
 Decode function.
virtual Chromosomeclone ()
 Clone function.
bool operator< (Chromosome< T > &chromosome)
 Compare 2 chromosome.
virtual string toString ()
 Convert the chromosome to string.
bool isInBound ()
 Bound checking.

Public Attributes

double fitness
 Fitness value.
vector< double > upperBounds
 Vector of upper bound values.
vector< double > lowerBounds
 Vector of lower bound values.


Detailed Description

template<typename T>
class Chromosome< T >

The super class for different type of chromosomes.

Parameters:
T Type T can be bool (binary problems), int (combinatorial problems) or real (continuous problems).
See also:
Chromosome_Binary | Chromosome_Real

Constructor & Destructor Documentation

template<typename T>
Chromosome< T >::Chromosome (  )  [inline]

Default constructor.

Create an instance of chromosome of type T.

template<typename T>
Chromosome< T >::Chromosome ( const vector< T > &  v  )  [inline]

Constructor.

Parameters:
v Input vector
Create the chromosome from a vector of type T.

Remarks:
Actually a copy constructor.

template<typename T>
Chromosome< T >::Chromosome ( const size_t  size,
vector< double >  lowerBounds,
vector< double >  upperBounds 
) [inline]

Constructor.

Parameters:
size Chromosome size, normally equal to the number of optimization variables.
lowerBounds Vector of lower bound values.
upperBounds Vector of upper bound values.
Create the chromosome of given size and bounds.

template<typename T>
Chromosome< T >::Chromosome ( vector< double >  phenotype,
vector< double >  lowerBounds,
vector< double >  upperBounds 
) [inline]

Constructor.

Parameters:
phenotype Input phenotype.
lowerBounds Vector of lower bound values.
upperBounds Vector of upper bound values.
Generate the chromosome from a vector of doubles.

Remarks:
Same as Chromosome<T>::fromDoubleVector(v).
See also:
Chromosome<T>::fromDoubleVector


Member Function Documentation

template<typename T>
virtual void Chromosome< T >::fromDoubleVector ( vector< double > &  phenotype  )  [inline, virtual]

Encode function.

Parameters:
phenotype Phenotype (optimization variables).
Exceptions:
<exception class> Description of criteria for throwing this exception.
Encode a phennotype to its genotype representation

Remarks:
Write remarks for fromDoubleVector here.
See also:
toDoubleVector()

Reimplemented in Chromosome_Binary, and Chromosome_Real.

template<typename T>
virtual vector<double> Chromosome< T >::toDoubleVector (  )  [inline, virtual]

Decode function.

Returns:
The decoded vector of doubles.
Decode a genotype to a double vector

See also:
fromDoubleVector()

Reimplemented in Chromosome_Binary, and Chromosome_Real.

template<typename T>
virtual Chromosome* Chromosome< T >::clone (  )  [inline, virtual]

Clone function.

Returns:
A "twin" of the current chromosome

Reimplemented in Chromosome_Binary, and Chromosome_Real.

template<typename T>
bool Chromosome< T >::operator< ( Chromosome< T > &  chromosome  )  [inline]

Compare 2 chromosome.

Parameters:
chromosome The chromosome to compare.
Returns:
True if the current chromosome has lower fitness value, false otherwise.
Compare the fitness value with another chromosome.

template<typename T>
string Chromosome< T >::toString (  )  [inline, virtual]

Convert the chromosome to string.

Returns:
The string representing the chromosome.
Convert the chromosome to string.

Remarks:
To be inherited by different chromosome classes. E.g.: we want a concatenated binary strings, but a space-delimited or comma-delimited double string, i.e., 0100110010010 vs. {1.2, 0.3, 5.9}

template<typename T>
bool Chromosome< T >::isInBound (  )  [inline]

Bound checking.

Returns:
True if all the variables is inbound, false otherwise.
Check if the chromsome is within the given bounds.

Remarks:
Used in many local search / constrained optimization problem


Member Data Documentation

template<typename T>
double Chromosome< T >::fitness

Fitness value.

See also:
ObjectiveFunction

template<typename T>
vector<double> Chromosome< T >::upperBounds

Vector of upper bound values.

See also:
lowerBounds

template<typename T>
vector<double> Chromosome< T >::lowerBounds

Vector of lower bound values.

See also:
upperBounds


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

Generated on Thu Aug 28 18:34:39 2008 for Dolphin by  doxygen 1.5.6