ECF 1.7
Cartesian::Cartesian Class Reference

#include <Cartesian_c.h>

Inheritance diagram for Cartesian::Cartesian:
Genotype Genotype

Public Member Functions

 Cartesian (const Cartesian &other)=default
bool initialize (StateP state)
Cartesian * copy ()
std::vector< CrossoverOpP > getCrossoverOp ()
std::vector< MutationOpP > getMutationOp ()
void registerParameters (StateP state)
void read (XMLNode &xCart)
void write (XMLNode &xCart)
uint getGenomeSize ()
void buildRandomGenome ()
void evaluate (std::vector< double > &inputData, std::vector< double > &results)
uint randomNodeInputConnection (uint column)
uint randomOutputConnection ()
void getActiveFunctionNodes (std::vector< uint > &)
 Cartesian (const Cartesian &other)=default
bool initialize (StateP state)
Cartesian * copy ()
std::vector< CrossoverOpP > getCrossoverOp ()
std::vector< MutationOpP > getMutationOp ()
void registerParameters (StateP state)
void read (XMLNode &xCart)
void write (XMLNode &xCart)
uint getGenomeSize ()
void buildRandomGenome ()
void evaluate (std::vector< double > &inputData, std::vector< double > &results)
uint randomNodeInputConnection (uint column)
uint randomOutputConnection ()
void getActiveFunctionNodes (std::vector< uint > &)
Public Member Functions inherited from Genotype
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.
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.

Public Attributes

StateP state_
 local copy of state
FunctionSetP functionSet_
 pointer to function set
std::vector< Nodenodes_
 genotype nodes (input nodes and function nodes)
std::vector< uint > outputs_
 output nodes
std::vector< double > constants_
 input nodes with constant values
uint nVariables_
 number of input variables
uint nConstants_
 number of input constants
uint nOutputs_
 number of final outputs
uint nRows_
 number of rows
uint nCols_
 number of columns
uint nLevelsBack_
 levels back parameter
uint nFunctions_
 number of used functions
uint nInputs_
 total number of inputs (variables and constants)
uint maxArity_
 max number of inputs for all function nodes

Protected Member Functions

void addRecursivelyActiveFunctionNodes (std::vector< bool > &activeFlags, uint node)
void addRecursivelyActiveFunctionNodes (std::vector< bool > &activeFlags, uint node)

Additional Inherited Members

Protected Attributes inherited from Genotype
std::string name_
 genotype's name
uint genotypeId_
 this genotype's unique index in individual structure

Detailed Description

CGP (Cartesian genetic programming) is implemented as a vector of Nodes and final output connections.

Nodes can be input nodes (variables and constants) or function nodes. A function Node points to a function primitive which has a predefined number of arguments.

Definition at line 27 of file Cartesian_c.h.

Constructor & Destructor Documentation

◆ Cartesian()

Cartesian::Cartesian::Cartesian ( void )

Definition at line 20 of file Cartesian.cpp.

◆ ~Cartesian()

Cartesian::Cartesian::~Cartesian ( void )

Definition at line 27 of file Cartesian.cpp.

Member Function Documentation

◆ addRecursivelyActiveFunctionNodes()

void Cartesian::Cartesian::addRecursivelyActiveFunctionNodes ( std::vector< bool > & activeFlags,
uint node )
protected

Definition at line 367 of file Cartesian.cpp.

◆ buildRandomGenome() [1/2]

void Cartesian::Cartesian::buildRandomGenome ( )

Build random genotype choosing functions and argument connections

Definition at line 256 of file Cartesian.cpp.

◆ buildRandomGenome() [2/2]

void Cartesian::Cartesian::buildRandomGenome ( )

Build random genotype choosing functions and argument connections

◆ copy() [1/2]

Cartesian * Cartesian::Cartesian::copy ( )
virtual

Create an identical copy of the genotype object

Implements Genotype.

Definition at line 31 of file Cartesian.cpp.

◆ copy() [2/2]

Cartesian * Cartesian::Cartesian::copy ( )
virtual

Create an identical copy of the genotype object

Implements Genotype.

◆ evaluate() [1/2]

void Cartesian::Cartesian::evaluate ( std::vector< double > & inputData,
std::vector< double > & results )

Calculate CGP results for given inputs

Definition at line 319 of file Cartesian.cpp.

◆ evaluate() [2/2]

void Cartesian::Cartesian::evaluate ( std::vector< double > & inputData,
std::vector< double > & results )

Calculate CGP results for given inputs

◆ getActiveFunctionNodes() [1/2]

void Cartesian::Cartesian::getActiveFunctionNodes ( std::vector< uint > & activeNodes)

Build a vector with indexes of active function nodes (excluding input nodes)

Definition at line 348 of file Cartesian.cpp.

◆ getActiveFunctionNodes() [2/2]

void Cartesian::Cartesian::getActiveFunctionNodes ( std::vector< uint > & )

Build a vector with indexes of active function nodes (excluding input nodes)

◆ getCrossoverOp() [1/2]

std::vector< CrossoverOpP > Cartesian::Cartesian::getCrossoverOp ( )
virtual

Create and return a vector of crossover operators

Reimplemented from Genotype.

Definition at line 38 of file Cartesian.cpp.

◆ getCrossoverOp() [2/2]

std::vector< CrossoverOpP > Cartesian::Cartesian::getCrossoverOp ( )
virtual

Create and return a vector of crossover operators

Reimplemented from Genotype.

◆ getGenomeSize() [1/2]

uint Cartesian::Cartesian::getGenomeSize ( )
virtual

Returns number of mutable genotype elements (function and output nodes)

Reimplemented from Genotype.

Definition at line 250 of file Cartesian.cpp.

◆ getGenomeSize() [2/2]

uint Cartesian::Cartesian::getGenomeSize ( )
virtual

Returns number of mutable genotype elements (function and output nodes)

Reimplemented from Genotype.

◆ getMutationOp() [1/2]

std::vector< MutationOpP > Cartesian::Cartesian::getMutationOp ( )
virtual

Create and return a vector of mutation operators

Reimplemented from Genotype.

Definition at line 48 of file Cartesian.cpp.

◆ getMutationOp() [2/2]

std::vector< MutationOpP > Cartesian::Cartesian::getMutationOp ( )
virtual

Create and return a vector of mutation operators

Reimplemented from Genotype.

◆ initialize() [1/2]

bool Cartesian::Cartesian::initialize ( StateP state)
virtual

Initialize a genotype object (read parameters, perform sanity check, build data)

Implements Genotype.

Definition at line 70 of file Cartesian.cpp.

◆ initialize() [2/2]

bool Cartesian::Cartesian::initialize ( StateP state)
virtual

Initialize a genotype object (read parameters, perform sanity check, build data)

Implements Genotype.

◆ randomNodeInputConnection() [1/2]

uint Cartesian::Cartesian::randomNodeInputConnection ( uint column)

Return a random connection from given column, considering levels_back

Definition at line 288 of file Cartesian.cpp.

◆ randomNodeInputConnection() [2/2]

uint Cartesian::Cartesian::randomNodeInputConnection ( uint column)

Return a random connection from given column, considering levels_back

◆ randomOutputConnection() [1/2]

uint Cartesian::Cartesian::randomOutputConnection ( )

Return a random connection for the output (currently excludes input nodes)

Definition at line 313 of file Cartesian.cpp.

◆ randomOutputConnection() [2/2]

uint Cartesian::Cartesian::randomOutputConnection ( )

Return a random connection for the output (currently excludes input nodes)

◆ read() [1/2]

void Cartesian::Cartesian::read ( XMLNode & xCart)
virtual

Read genotype data from XMLNode

Implements Genotype.

Definition at line 186 of file Cartesian.cpp.

◆ read() [2/2]

void Cartesian::Cartesian::read ( XMLNode & xCart)
virtual

Read genotype data from XMLNode

Implements Genotype.

◆ registerParameters() [1/2]

void Cartesian::Cartesian::registerParameters ( StateP state)
virtual

Register genotype's parameters (called before Genotype::initialize)

Reimplemented from Genotype.

Definition at line 58 of file Cartesian.cpp.

◆ registerParameters() [2/2]

void Cartesian::Cartesian::registerParameters ( StateP state)
virtual

Register genotype's parameters (called before Genotype::initialize)

Reimplemented from Genotype.

◆ write() [1/2]

void Cartesian::Cartesian::write ( XMLNode & xCart)
virtual

Write genotype data to XMLNode

Implements Genotype.

Definition at line 223 of file Cartesian.cpp.

◆ write() [2/2]

void Cartesian::Cartesian::write ( XMLNode & xCart)
virtual

Write genotype data to XMLNode

Implements Genotype.

Member Data Documentation

◆ constants_

std::vector< double > Cartesian::Cartesian::constants_

input nodes with constant values

Definition at line 108 of file Cartesian_c.h.

◆ functionSet_

FunctionSetP Cartesian::Cartesian::functionSet_

pointer to function set

Definition at line 105 of file Cartesian_c.h.

◆ maxArity_

uint Cartesian::Cartesian::maxArity_

max number of inputs for all function nodes

Definition at line 121 of file Cartesian_c.h.

◆ nCols_

uint Cartesian::Cartesian::nCols_

number of columns

Definition at line 115 of file Cartesian_c.h.

◆ nConstants_

uint Cartesian::Cartesian::nConstants_

number of input constants

Definition at line 112 of file Cartesian_c.h.

◆ nFunctions_

uint Cartesian::Cartesian::nFunctions_

number of used functions

Definition at line 117 of file Cartesian_c.h.

◆ nInputs_

uint Cartesian::Cartesian::nInputs_

total number of inputs (variables and constants)

Definition at line 120 of file Cartesian_c.h.

◆ nLevelsBack_

uint Cartesian::Cartesian::nLevelsBack_

levels back parameter

Definition at line 116 of file Cartesian_c.h.

◆ nodes_

std::vector< Node > Cartesian::Cartesian::nodes_

genotype nodes (input nodes and function nodes)

Definition at line 106 of file Cartesian_c.h.

◆ nOutputs_

uint Cartesian::Cartesian::nOutputs_

number of final outputs

Definition at line 113 of file Cartesian_c.h.

◆ nRows_

uint Cartesian::Cartesian::nRows_

number of rows

Definition at line 114 of file Cartesian_c.h.

◆ nVariables_

uint Cartesian::Cartesian::nVariables_

number of input variables

Definition at line 111 of file Cartesian_c.h.

◆ outputs_

std::vector< uint > Cartesian::Cartesian::outputs_

output nodes

Definition at line 107 of file Cartesian_c.h.

◆ state_

StateP Cartesian::Cartesian::state_

local copy of state

Definition at line 104 of file Cartesian_c.h.


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