ECF 1.7
Genotype Class Referenceabstract

Genotype base class. More...

#include <Genotype.h>

Inheritance diagram for Genotype:
BitString::BitString Cartesian::Cartesian Cartesian::Cartesian ClassifierParams GEP::GEPChromosome IntGenotype::IntGenotype Permutation::Permutation RealValueGenotype Tree::Tree

Public Member Functions

virtual bool initialize (StateP state)=0
 Initialize a genotype object (read parameters, perform sanity check, build data).
virtual Genotypecopy ()=0
 Create an identical copy of the genotype object.
virtual std::vector< CrossoverOpP > getCrossoverOp ()
 Create and return a vector of crossover operators.
virtual std::vector< MutationOpP > getMutationOp ()
 Create and return a vector of mutation operators.
virtual void registerParameters (StateP)
 Register genotype's parameters (called before Genotype::initialize).
bool registerParameter (StateP state, std::string name, voidP value, enum ECF::type T, std::string description="")
 Register a single parameter.
voidP getParameterValue (StateP state, std::string name)
 Read single parameter value from Registry.
bool setParameterValue (StateP state, std::string name, voidP value)
 Write single parameter value to Registry.
bool isParameterDefined (StateP state, std::string name)
 Check if parameter is defined in the configuration.
virtual void read (XMLNode &)=0
 Read genotype data from XMLNode.
virtual void write (XMLNode &)=0
 Write genotype data to XMLNode.
virtual uint getGenomeSize ()
std::string getName ()
 Return genotype's name (each genotype is uniquely identified with its name).
uint getGenotypeId ()
 Return this genotype's index in individual structure.
void setGenotypeId (uint id)
 Set genotype index in an individual.
std::string toString ()
 Output genotype to string.

Protected Attributes

std::string name_
 genotype's name
uint genotypeId_
 this genotype's unique index in individual structure

Detailed Description

Genotype base class.

All Genotypes must inherit this one. Each individual contains a vector of Genotype objects. Each Genotype is an independent object with independent parameters.

Each Genotype class must provide its CrossoverOp and MutationOp operator classes!

Genotype usage
A Genotype instance is active if it is used in the individual structure. Active genotypes may be of any number and kind; each active Genotype instance gets an index, e.g.:
  • Binary (id: 0) Binary (id: 1) Bitstring (id: 2) Tree (id: 3)

A genotype instance becomes active if:

  • it is stated in <Genotype> block of configuration file;
  • it is added with State::setGenotype function.

Definition at line 35 of file Genotype.h.

Constructor & Destructor Documentation

◆ Genotype()

Genotype::Genotype ( )
inline

Definition at line 40 of file Genotype.h.

◆ ~Genotype()

virtual Genotype::~Genotype ( )
inlinevirtual

Definition at line 42 of file Genotype.h.

Member Function Documentation

◆ copy()

◆ getCrossoverOp()

virtual std::vector< CrossoverOpP > Genotype::getCrossoverOp ( )
inlinevirtual

◆ getGenomeSize()

virtual uint Genotype::getGenomeSize ( )
inlinevirtual

Reimplemented in Cartesian::Cartesian, and Cartesian::Cartesian.

Definition at line 82 of file Genotype.h.

◆ getGenotypeId()

uint Genotype::getGenotypeId ( )
inline

Return this genotype's index in individual structure.

Definition at line 90 of file Genotype.h.

◆ getMutationOp()

virtual std::vector< MutationOpP > Genotype::getMutationOp ( )
inlinevirtual

◆ getName()

std::string Genotype::getName ( )
inline

Return genotype's name (each genotype is uniquely identified with its name).

Definition at line 86 of file Genotype.h.

◆ getParameterValue()

voidP Genotype::getParameterValue ( StateP state,
std::string name )

Read single parameter value from Registry.

Definition at line 10 of file Genotype.cpp.

◆ initialize()

virtual bool Genotype::initialize ( StateP state)
pure virtual

◆ isParameterDefined()

bool Genotype::isParameterDefined ( StateP state,
std::string name )

Check if parameter is defined in the configuration.

Definition at line 22 of file Genotype.cpp.

◆ read()

◆ registerParameter()

bool Genotype::registerParameter ( StateP state,
std::string name,
voidP value,
enum ECF::type T,
std::string description = "" )

Register a single parameter.

Definition at line 4 of file Genotype.cpp.

◆ registerParameters()

virtual void Genotype::registerParameters ( StateP )
inlinevirtual

◆ setGenotypeId()

void Genotype::setGenotypeId ( uint id)
inline

Set genotype index in an individual.

Definition at line 94 of file Genotype.h.

◆ setParameterValue()

bool Genotype::setParameterValue ( StateP state,
std::string name,
voidP value )

Write single parameter value to Registry.

Definition at line 16 of file Genotype.cpp.

◆ toString()

std::string Genotype::toString ( )
inline

Output genotype to string.

Definition at line 98 of file Genotype.h.

◆ write()

Member Data Documentation

◆ genotypeId_

uint Genotype::genotypeId_
protected

this genotype's unique index in individual structure

Definition at line 110 of file Genotype.h.

◆ name_

std::string Genotype::name_
protected

genotype's name

Definition at line 109 of file Genotype.h.


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