mc2lib
Public Types | Public Member Functions | Protected Attributes | List of all members
mc2lib::simplega::Genome< T > Class Template Referenceabstract

Simple Genome interface. More...

#include <simplega.hpp>

Public Types

typedef std::vector< T > Container
 

Public Member Functions

 Genome ()
 Default constructor. More...
 
 Genome (Container g)
 Converting constructor. More...
 
virtual ~Genome ()
 
const Containerget () const
 Read-only genome accessor. More...
 
Containerget_ptr ()
 Modifiable genome accessor. More...
 
virtual bool operator< (const Genome &rhs) const
 Less than comparison operator. More...
 
virtual void Mutate (float rate)=0
 Mutate this Genome. More...
 
virtual float Fitness () const =0
 Fitness accessor. More...
 
virtual operator float () const
 Converting operator to float. More...
 
virtual operator std::string () const
 Converting operator to std::string. More...
 

Protected Attributes

Container genome_
 Raw genome of individual genes of T. More...
 

Detailed Description

template<class T>
class mc2lib::simplega::Genome< T >

Simple Genome interface.

Use as a baseclass for genome implementations, but this is optional, as long as the interface is implemented (see GenePool).

Note that this class is virtual, as it is possible that we could have a heterogeneous collection of genomes, all based off of the same baseclass, e.g., where a specialized crossover_mutate operator yields children of different classes.

Template Parameters
TThe type of genes in this Genome.

Member Typedef Documentation

§ Container

template<class T>
typedef std::vector<T> mc2lib::simplega::Genome< T >::Container

Constructor & Destructor Documentation

§ Genome() [1/2]

template<class T>
mc2lib::simplega::Genome< T >::Genome ( )
inline

Default constructor.

Yields an empty genome.

§ Genome() [2/2]

template<class T>
mc2lib::simplega::Genome< T >::Genome ( Container  g)
inlineexplicit

Converting constructor.

Parameters
gA raw vector of type T genes forming this new Genome.

§ ~Genome()

template<class T>
virtual mc2lib::simplega::Genome< T >::~Genome ( )
inlinevirtual

Member Function Documentation

§ Fitness()

template<class T>
virtual float mc2lib::simplega::Genome< T >::Fitness ( ) const
pure virtual

Fitness accessor.

Returns
Current fitness.

Implemented in mc2lib::codegen::RandInstTest< URNG, OperationFactory >.

§ get()

template<class T>
const Container& mc2lib::simplega::Genome< T >::get ( ) const
inline

Read-only genome accessor.

Returns
Const reference to vector of genes.

§ get_ptr()

template<class T>
Container* mc2lib::simplega::Genome< T >::get_ptr ( )
inline

Modifiable genome accessor.

Returns
Pointer to vector of genes.

§ Mutate()

template<class T>
virtual void mc2lib::simplega::Genome< T >::Mutate ( float  rate)
pure virtual

Mutate this Genome.

Parameters
rateMutation rate.

Implemented in mc2lib::codegen::RandInstTest< URNG, OperationFactory >.

§ operator float()

template<class T>
virtual mc2lib::simplega::Genome< T >::operator float ( ) const
inlinevirtual

Converting operator to float.

As this is also used for the roulette selection, the assumption is that higher fitness means better.

§ operator std::string()

template<class T>
virtual mc2lib::simplega::Genome< T >::operator std::string ( ) const
inlinevirtual

Converting operator to std::string.

§ operator<()

template<class T>
virtual bool mc2lib::simplega::Genome< T >::operator< ( const Genome< T > &  rhs) const
inlinevirtual

Less than comparison operator.

Use to rank genomes from best fitness to worst fitness. Assumes higher fitness means better.

Returns
True if this instance (lhs) is fitter than rhs, false otherwise.

Member Data Documentation

§ genome_

template<class T>
Container mc2lib::simplega::Genome< T >::genome_
protected

Raw genome of individual genes of T.


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