#include <Individual.hpp>
Public Member Functions | |
Individual () | |
Individual (Context *pcontext, bool bInitialize=true, int iMinDepth=0, int iMaxDepth=0) | |
Grammar * | getRandomNode () const |
Grammar * | getRandomNodeMatching (std::string strGrammarID) const |
double | getFitness () const |
void | setFitness (double dFitness) |
int | getHits () const |
void | setHits (int iHits) |
int | getMinDepth () const |
int | getMaxDepth () const |
std::string | toString () const |
bool | buildTree (Grammar *pgramNode, int iTries) |
void | formNodeList () |
Result * | execute (Context &context) |
Individual * | clone () const |
Individual::Individual | ( | ) |
Empty constructor for creating Individual objects that are not initialized.
Individual::Individual | ( | Context * | pcontext, | |
bool | bInitialize = true , |
|||
int | iMinDepth = 0 , |
|||
int | iMaxDepth = 0 | |||
) |
Creates an individual object with metainformation concerning this individual.
[in,out] | pcontext | A reference to the context of execution |
[in] | bInitialize | If true, below are set to class variables and root node of GStart is set. |
[in] | iMinDepth | The minimum depth the symbol tree is allowed to be. |
[in] | iMaxDepth | The maximum depth the symbol tree is allowed to be |
bool Individual::buildTree | ( | Grammar * | pgramNode, | |
int | iTries | |||
) |
Creates a subtree for the given node.
[in,out] | pgramNode | A pointer to the node for which the subtree will be built. |
[in] | iTries | The number of attempts at building a subtree within the individual's contraints before the process is abandoned. The value 0 is used when infinite tries may be made. |
Individual * Individual::clone | ( | ) | const |
Performs a deep copy, creating another Individual identical to this.
Runs the program defined by the symbol tree.
[in,out] | context | The argument values the program uses. These may be modified by the program and should be reset between executions if there are any symbols included in the language which do. |
void Individual::formNodeList | ( | ) |
Forms a vector of all the nodes in the symbol tree for fast access.
double Individual::getFitness | ( | ) | const |
int Individual::getHits | ( | ) | const |
int Individual::getMaxDepth | ( | ) | const |
int Individual::getMinDepth | ( | ) | const |
Grammar * Individual::getRandomNode | ( | ) | const |
Selects a random grammar symbol from the individual. The symbol returned is guaranteed not to be a leaf node.
Grammar* Individual::getRandomNodeMatching | ( | std::string | strGrammarID | ) | const |
Selects a random grammar symbol from the individual which matches the symbol type defined by the passed in grammar ID.
[in] | strGrammarID | A string to be matched against the grammar ID's of the symbols in the symbol tree |
void Individual::setFitness | ( | double | dFitness | ) |
[in] | dFitness | A fitness value to be associated with this individual |
void Individual::setHits | ( | int | iHits | ) |
[in] | iHits | A hit count to be associated with this individual |
string Individual::toString | ( | ) | const |
Forms a LISP expression representing the individual's phenotype