Karva chromosome template. Implemented as a vector<unsigned short> holding indexes of elements in _oneArgFunction, _twoArgFunction and _terminals vectors. More...
#include <Chromosome.h>

Public Types | |
| typedef ChromosomeType | CType |
Public Member Functions | |
| Chromosome () | |
| Chromosome (const Chromosome &) | |
| virtual | ~Chromosome () |
| Chromosome (const std::vector< CElement > &chromo) | |
| u_short | evaluateTreeDepth (const u_short &idx) const |
| ChromosomeType | evaluateGeneTree (const u_short &idx) const |
| virtual ChromosomeType | calculateValue () |
| void | calculateSubValues (std::vector< std::pair< bool, ChromosomeType > > &vals) |
| void | terminalsUsed (const u_short &idx, std::vector< short > &ref, const bool &append=false) const |
| void | terminalsUsed (std::vector< short > &ref) const |
| CElement & | operator[] (const u_short &idx) |
| CElement | operator[] (const u_short &idx) const |
| CElement | getElement (const u_short &gidx, const u_short &idx) const |
| CElement | getElement (const u_short &gidx, const u_short &idx) |
| std::vector< CElement > & | getChromosome () |
| const std::vector< CElement > & | getChromosome () const |
| std::vector< u_short > & | getLinks () |
| const std::vector< u_short > & | getLinks () const |
| twoArg< ChromosomeType > * | getLink (const u_short &idx) |
| twoArg< ChromosomeType > * | getLink (const u_short &idx) const |
| std::vector< double > & | getRandomConstants () |
| const std::vector< double > & | getRandomConstants () const |
| bool | isViable () const |
| void | setElement (const u_short &gidx, const u_short &idx, const CElement &element) |
| void | insertHeadElement (const u_short &gidx, const u_short &idx, const CElement &element) |
| void | setEmpty () |
| void | setChromosome (const std::vector< CElement > &fchromo) |
| void | setLinks (const std::vector< u_short > &links) |
| void | setLink (const u_short &link, const size_t &pos) |
| void | setViable (const bool &b) |
| void | setRandomConstants (const std::vector< double > &rcs) |
| void | kill () |
| std::string | geneToString (const u_short &numGene) const |
| virtual std::string | toString () const |
Static Public Member Functions | |
| static void | readConfig (const std::string &path) |
| static void | readConfig (const ConfigArgs &cfg) |
| static std::string | symbolic (const CElement &a) |
| static std::string | terminalToLetter (const u_short &a) |
| static CElement | getCombinedIndex (const std::string &name) |
| static u_short | getRcLength () |
| static u_short | getTermLength () |
| static u_short | getHeadLength () |
| static u_short | getTailLength () |
| static u_short | getGeneLength () |
| static u_short | getChromosomeLength () |
| static u_short | getNumGenes () |
| static std::vector< twoArg < ChromosomeType > * > | getLinkPool () |
| static std::vector< oneArg < ChromosomeType > * > | getOneArgFunctions () |
| static std::vector< oneArg < ChromosomeType > * > & | getROneArgFunctions () |
| static std::vector< twoArg < ChromosomeType > * > | getTwoArgFunctions () |
| static std::vector< twoArg < ChromosomeType > * > & | getRTwoArgFunctions () |
| static std::vector < ChromosomeType > | getTerminals () |
| static std::vector < ChromosomeType > & | getRTerminals () |
| static void | setHeadLength (const u_short &fhead) |
| static void | setLinkPool (const std::string &easy) |
| static void | setOneArgFunctions (const std::string &easyones) |
| static void | setTwoArgFunctions (const std::string &easytwos) |
| static void | assignValues (const std::vector< ChromosomeType > &vals, const size_t pop_age=0) |
| static void | clearFunctionPointers () |
| static void | setNumGenes (const u_short &fgenes) |
| static void | setOneArgFunctions (const std::vector< oneArg< ChromosomeType > * > &ones) |
| static void | setTwoArgFunctions (const std::vector< twoArg< ChromosomeType > * > &twos) |
| static void | setLinkPool (const std::vector< twoArg< ChromosomeType > * > &pool) |
| static void | setLinkPool (const twoArg< ChromosomeType > *&pool) |
| static void | setTerminals (const std::vector< ChromosomeType > &terms) |
| static void | setTerminals (const u_short &tSize) |
| static void | setTerminal (const ChromosomeType &term, const size_t &idx) |
| static void | setRcLength (const u_short &length) |
Protected Attributes | |
| std::vector< CElement > | _chromosome |
| std::vector< u_short > | _links |
| std::vector< double > | _rconstants |
| bool | _viable |
Static Protected Attributes | |
| static std::vector< twoArg < ChromosomeType > * > | _linkPool = std::vector< twoArg<ChromosomeType>* >() |
| static std::vector< oneArg < ChromosomeType > * > | _oneArgFunctions = std::vector< oneArg<ChromosomeType>* >() |
| static std::vector< twoArg < ChromosomeType > * > | _twoArgFunctions = std::vector< twoArg<ChromosomeType>* >() |
| static std::vector < ChromosomeType > | _terminals = std::vector<ChromosomeType>() |
| static std::vector < ChromosomeType > | _results = std::vector<ChromosomeType>() |
| static u_short | _termLength = 0 |
| static u_short | _rcLength = 0 |
| static u_short | _numGenes = 3 |
| static u_short | _headLength = 10 |
| static u_short | _tailLength = (_headLength + 1) |
| static u_short | _geneLength = Chromosome<ChromosomeType>::_headLength + Chromosome<ChromosomeType>::_tailLength |
Friends | |
| template<class T2 > | |
| std::ostream & | operator<< (std::ostream &os, const Chromosome< T2 > &a) |
Karva chromosome template. Implemented as a vector<unsigned short> holding indexes of elements in _oneArgFunction, _twoArgFunction and _terminals vectors.
| ChromosomeType | - type of variables held in _terminals and calculated by fuctions. |
| typedef ChromosomeType GEP::Chromosome< ChromosomeType >::CType |
Type of the chromosome terminals and functions
| GEP::Chromosome< ChromosomeType >::Chromosome | ( | ) | [inline] |
Default constructor
| GEP::Chromosome< ChromosomeType >::Chromosome | ( | const Chromosome< ChromosomeType > & | copy | ) | [inline] |
Copy constructor
| virtual GEP::Chromosome< ChromosomeType >::~Chromosome | ( | ) | [inline, virtual] |
| GEP::Chromosome< ChromosomeType >::Chromosome | ( | const std::vector< CElement > & | chromo | ) | [inline] |
"We know better" Constructor - sets head, tail and the lengths.
| chromo | - new chromosome |
| void GEP::Chromosome< ChromosomeType >::assignValues | ( | const std::vector< ChromosomeType > & | vals, | |
| const size_t | pop_age = 0 | |||
| ) | [inline, static] |
Assigns the values of the _terminals vector.
| vals | values of the terminals | |
| pop_age | supportive parameter for ABFT analysis, by default - unused |
| void GEP::Chromosome< ChromosomeType >::calculateSubValues | ( | std::vector< std::pair< bool, ChromosomeType > > & | vals | ) | [inline] |
Calculates value of the chromosome genes. places values of genes of a given chromosome in
| vals |
| ChromosomeType GEP::Chromosome< ChromosomeType >::calculateValue | ( | ) | [inline, virtual] |
Calculates value of the chromosome, linking the results of ORFs with the linking function of the chromosome.
| void GEP::Chromosome< ChromosomeType >::clearFunctionPointers | ( | ) | [inline, static] |
Gracefully deletes the pointers to the linking function, one argument and two argument functions. Should be invoked after the work with GEP::Chromosome.
| ChromosomeType GEP::Chromosome< ChromosomeType >::evaluateGeneTree | ( | const u_short & | idx | ) | const [inline] |
Evaluates value of given ORF, following ET. Uses _treeDepth[idx].
| idx | - index of ORF to be evaluated |
| u_short GEP::Chromosome< ChromosomeType >::evaluateTreeDepth | ( | const u_short & | idx | ) | const [inline] |
Evaluates ET depth for a given ORF, results will be placed in _treeDepth[idx].
| idx | - index of ORF to be evaluated |
| std::string GEP::Chromosome< ChromosomeType >::geneToString | ( | const u_short & | numGene | ) | const [inline] |
| numGene | ORF represented as string. |
| const std::vector<CElement>& GEP::Chromosome< ChromosomeType >::getChromosome | ( | ) | const [inline] |
| std::vector<CElement>& GEP::Chromosome< ChromosomeType >::getChromosome | ( | ) | [inline] |
| static u_short GEP::Chromosome< ChromosomeType >::getChromosomeLength | ( | ) | [inline, static] |
| CElement GEP::Chromosome< ChromosomeType >::getCombinedIndex | ( | const std::string & | name | ) | [inline, static] |
Returns the absolute index of the searched function, i.e. if the searched name will be in _twoArgFunctions vector, result will be _oneArgFunctions.size()+index of searched function.
| name | name of the searched function |
| CElement GEP::Chromosome< ChromosomeType >::getElement | ( | const u_short & | gidx, | |
| const u_short & | idx | |||
| ) | [inline] |
| gidx | - index of gene | |
| idx | - index of gene element |
| CElement GEP::Chromosome< ChromosomeType >::getElement | ( | const u_short & | gidx, | |
| const u_short & | idx | |||
| ) | const [inline] |
| static u_short GEP::Chromosome< ChromosomeType >::getGeneLength | ( | ) | [inline, static] |
| static u_short GEP::Chromosome< ChromosomeType >::getHeadLength | ( | ) | [inline, static] |
| twoArg<ChromosomeType>* GEP::Chromosome< ChromosomeType >::getLink | ( | const u_short & | idx | ) | const [inline] |
| twoArg<ChromosomeType>* GEP::Chromosome< ChromosomeType >::getLink | ( | const u_short & | idx | ) | [inline] |
| static std::vector< twoArg<ChromosomeType>* > GEP::Chromosome< ChromosomeType >::getLinkPool | ( | ) | [inline, static] |
| const std::vector<u_short>& GEP::Chromosome< ChromosomeType >::getLinks | ( | ) | const [inline] |
| std::vector<u_short>& GEP::Chromosome< ChromosomeType >::getLinks | ( | ) | [inline] |
| static u_short GEP::Chromosome< ChromosomeType >::getNumGenes | ( | ) | [inline, static] |
| static std::vector< oneArg<ChromosomeType>* > GEP::Chromosome< ChromosomeType >::getOneArgFunctions | ( | ) | [inline, static] |
| const std::vector<double>& GEP::Chromosome< ChromosomeType >::getRandomConstants | ( | ) | const [inline] |
| std::vector<double>& GEP::Chromosome< ChromosomeType >::getRandomConstants | ( | ) | [inline] |
| static u_short GEP::Chromosome< ChromosomeType >::getRcLength | ( | ) | [inline, static] |
| static std::vector< oneArg<ChromosomeType>* >& GEP::Chromosome< ChromosomeType >::getROneArgFunctions | ( | ) | [inline, static] |
| static std::vector<ChromosomeType>& GEP::Chromosome< ChromosomeType >::getRTerminals | ( | ) | [inline, static] |
| static std::vector< twoArg<ChromosomeType>* >& GEP::Chromosome< ChromosomeType >::getRTwoArgFunctions | ( | ) | [inline, static] |
| static u_short GEP::Chromosome< ChromosomeType >::getTailLength | ( | ) | [inline, static] |
| static std::vector<ChromosomeType> GEP::Chromosome< ChromosomeType >::getTerminals | ( | ) | [inline, static] |
| static u_short GEP::Chromosome< ChromosomeType >::getTermLength | ( | ) | [inline, static] |
| static std::vector< twoArg<ChromosomeType>* > GEP::Chromosome< ChromosomeType >::getTwoArgFunctions | ( | ) | [inline, static] |
| void GEP::Chromosome< ChromosomeType >::insertHeadElement | ( | const u_short & | gidx, | |
| const u_short & | idx, | |||
| const CElement & | element | |||
| ) | [inline] |
Inserts element in head of given ORF (gidx), on a given position(idx). Last element of the head is removed.
| gidx | - index of gene | |
| idx | - index of gene element | |
| element | - element to be placed at a given position |
| bool GEP::Chromosome< ChromosomeType >::isViable | ( | ) | const [inline] |
| void GEP::Chromosome< ChromosomeType >::kill | ( | ) | [inline] |
| CElement GEP::Chromosome< ChromosomeType >::operator[] | ( | const u_short & | idx | ) | const [inline] |
Operator[] overload.
| idx). |
| CElement& GEP::Chromosome< ChromosomeType >::operator[] | ( | const u_short & | idx | ) | [inline] |
Operator[] overload.
| idx). |
| void GEP::Chromosome< ChromosomeType >::readConfig | ( | const ConfigArgs & | cfg | ) | [inline, static] |
Reads the config stored in
| cfg | of type ConfigArgs. |
| void GEP::Chromosome< ChromosomeType >::readConfig | ( | const std::string & | path | ) | [inline, static] |
Reads the config stored in the file indicated by
| path |
| void GEP::Chromosome< ChromosomeType >::setChromosome | ( | const std::vector< CElement > & | fchromo | ) | [inline] |
| void GEP::Chromosome< ChromosomeType >::setElement | ( | const u_short & | gidx, | |
| const u_short & | idx, | |||
| const CElement & | element | |||
| ) | [inline] |
Sets element in given ORF (gidx), on a given position(idx) to element.
| gidx | - index of gene | |
| idx | - index of gene element | |
| element | - element to be placed at a given position |
| void GEP::Chromosome< ChromosomeType >::setEmpty | ( | ) | [inline] |
| void GEP::Chromosome< ChromosomeType >::setHeadLength | ( | const u_short & | fhead | ) | [inline, static] |
Function setting head, tail and result lengths.
| fhead | size of the head part of the chromosome |
| void GEP::Chromosome< ChromosomeType >::setLink | ( | const u_short & | link, | |
| const size_t & | pos | |||
| ) | [inline] |
| static void GEP::Chromosome< ChromosomeType >::setLinkPool | ( | const twoArg< ChromosomeType > *& | pool | ) | [inline, static] |
| static void GEP::Chromosome< ChromosomeType >::setLinkPool | ( | const std::vector< twoArg< ChromosomeType > * > & | pool | ) | [inline, static] |
| void GEP::Chromosome< ChromosomeType >::setLinkPool | ( | const std::string & | easy | ) | [inline, static] |
Sets the linking function on the basis of the given symbol - the name of the function. Looks up only functions in the basic Function set.
| easy | symbol of the linking functions pool |
| void GEP::Chromosome< ChromosomeType >::setLinks | ( | const std::vector< u_short > & | links | ) | [inline] |
| static void GEP::Chromosome< ChromosomeType >::setNumGenes | ( | const u_short & | fgenes | ) | [inline, static] |
| static void GEP::Chromosome< ChromosomeType >::setOneArgFunctions | ( | const std::vector< oneArg< ChromosomeType > * > & | ones | ) | [inline, static] |
| void GEP::Chromosome< ChromosomeType >::setOneArgFunctions | ( | const std::string & | easyones | ) | [inline, static] |
Sets the vector of one argument functiona on the basis of the vector of given symbols - the names of the functions. Looks up only functions in the basic Function set.
| easyones | - vector of symbols of the one argument functions. |
| void GEP::Chromosome< ChromosomeType >::setRandomConstants | ( | const std::vector< double > & | rcs | ) | [inline] |
| static void GEP::Chromosome< ChromosomeType >::setRcLength | ( | const u_short & | length | ) | [inline, static] |
| static void GEP::Chromosome< ChromosomeType >::setTerminal | ( | const ChromosomeType & | term, | |
| const size_t & | idx | |||
| ) | [inline, static] |
| static void GEP::Chromosome< ChromosomeType >::setTerminals | ( | const u_short & | tSize | ) | [static] |
| static void GEP::Chromosome< ChromosomeType >::setTerminals | ( | const std::vector< ChromosomeType > & | terms | ) | [inline, static] |
| static void GEP::Chromosome< ChromosomeType >::setTwoArgFunctions | ( | const std::vector< twoArg< ChromosomeType > * > & | twos | ) | [inline, static] |
| void GEP::Chromosome< ChromosomeType >::setTwoArgFunctions | ( | const std::string & | easytwos | ) | [inline, static] |
Sets the vector of two argument functiona on the basis of the vector of given symbols - the names of the functions. Looks up only functions in the basic Function set.
| easytwos | - vector of symbols of the two argument functions. |
| void GEP::Chromosome< ChromosomeType >::setViable | ( | const bool & | b | ) | [inline] |
| std::string GEP::Chromosome< ChromosomeType >::symbolic | ( | const CElement & | a | ) | [inline, static] |
| a). |
| void GEP::Chromosome< ChromosomeType >::terminalsUsed | ( | std::vector< short > & | ref | ) | const [inline] |
Provides the set of indexes of terminals used by functions in the chromosome.
| void GEP::Chromosome< ChromosomeType >::terminalsUsed | ( | const u_short & | idx, | |
| std::vector< short > & | ref, | |||
| const bool & | append = false | |||
| ) | const [inline] |
Provides the set of indexes of terminals used by functions in a given gene.
| idx | index of a gene to check | |
| ref | target vector | |
| append | if false, ref will be cleared |
| std::string GEP::Chromosome< ChromosomeType >::terminalToLetter | ( | const u_short & | a | ) | [inline, static] |
| a). |
| std::string GEP::Chromosome< ChromosomeType >::toString | ( | ) | const [inline, virtual] |
| std::ostream& operator<< | ( | std::ostream & | os, | |
| const Chromosome< T2 > & | a | |||
| ) | [friend] |
std::vector<CElement> GEP::Chromosome< ChromosomeType >::_chromosome [protected] |
GEP Chromosome - a vector of CElements holding indexes of elements in _oneArgFunction, _twoArgFunction and _terminals vectors. CElement.first describes the type anf CElement.second the value of an element
u_short GEP::Chromosome< ChromosomeType >::_geneLength = Chromosome<ChromosomeType>::_headLength + Chromosome<ChromosomeType>::_tailLength [inline, static, protected] |
Gene length
u_short GEP::Chromosome< ChromosomeType >::_headLength = 10 [inline, static, protected] |
Head length
std::vector< twoArg< ChromosomeType > * > GEP::Chromosome< ChromosomeType >::_linkPool = std::vector< twoArg<ChromosomeType>* >() [inline, static, protected] |
Linking function. Two argument, as it has to link values of genes, thus take more than one value and return one value.
std::vector<u_short> GEP::Chromosome< ChromosomeType >::_links [protected] |
Linking functions between the genes.
u_short GEP::Chromosome< ChromosomeType >::_numGenes = 3 [inline, static, protected] |
Number of genes in one chromosome
std::vector< oneArg< ChromosomeType > * > GEP::Chromosome< ChromosomeType >::_oneArgFunctions = std::vector< oneArg<ChromosomeType>* >() [inline, static, protected] |
One Argument Functions
u_short GEP::Chromosome< ChromosomeType >::_rcLength = 0 [inline, static, protected] |
'Random constants' vector length
std::vector<double> GEP::Chromosome< ChromosomeType >::_rconstants [protected] |
Random constants vector.
std::vector< ChromosomeType > GEP::Chromosome< ChromosomeType >::_results = std::vector<ChromosomeType>() [inline, static, protected] |
Holds the results of evaluation
u_short GEP::Chromosome< ChromosomeType >::_tailLength = (_headLength + 1) [inline, static, protected] |
Tail length
std::vector< ChromosomeType > GEP::Chromosome< ChromosomeType >::_terminals = std::vector<ChromosomeType>() [inline, static, protected] |
Terminals
u_short GEP::Chromosome< ChromosomeType >::_termLength = 0 [inline, static, protected] |
'Terminals' vector length
std::vector< twoArg< ChromosomeType > * > GEP::Chromosome< ChromosomeType >::_twoArgFunctions = std::vector< twoArg<ChromosomeType>* >() [inline, static, protected] |
Two Argument Functions
bool GEP::Chromosome< ChromosomeType >::_viable [protected] |
Is this chromosome viable.
1.6.1