Individual Class Reference

Individual. More...

#include <Individual.hpp>

List of all members.

Public Member Functions

 Individual ()
 Individual (Context *pcontext, bool bInitialize=true, int iMinDepth=0, int iMaxDepth=0)
GrammargetRandomNode () const
GrammargetRandomNodeMatching (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 ()
Resultexecute (Context &context)
Individualclone () const


Detailed Description

Individual.

Author:
Stephen E. Baker
Date:
2006-2007
Version:
1.0
A program, which may be modified or executed by the GP system. This object also contains the fitness and number of hits of the stored individual as determined the last time it was evaluated.


Constructor & Destructor Documentation

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.

Parameters:
[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


Member Function Documentation

bool Individual::buildTree ( Grammar pgramNode,
int  iTries 
)

Creates a subtree for the given node.

Warning:
The node should be part of this individual. While this is not a formal requirement in this version it may be changed in the future.
Parameters:
[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.

Returns:
A new Individual with indentical structure but in its own memory

Result * Individual::execute ( Context context  ) 

Runs the program defined by the symbol tree.

Parameters:
[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.
Returns:
The program output

void Individual::formNodeList (  ) 

Forms a vector of all the nodes in the symbol tree for fast access.

Note:
This method should be called after any direct modifcation to the symbol tree.

double Individual::getFitness (  )  const

Returns:
The fitness of this individual as determined by the Evaluator
See also:
Evaluator::evaluate

int Individual::getHits (  )  const

Returns:
The number of hits this individual obtained as determined by the Evaluator
See also:
Evaluator::evaluate

int Individual::getMaxDepth (  )  const

Returns:
The maximum depth which this individual's symbol tree is allowed to have.

int Individual::getMinDepth (  )  const

Returns:
The minimum depth which this individual's symbol tree is allowed have.

Grammar * Individual::getRandomNode (  )  const

Selects a random grammar symbol from the individual. The symbol returned is guaranteed not to be a leaf node.

Returns:
A pointer to a Grammar object in the individual's symbol tree

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.

Parameters:
[in] strGrammarID A string to be matched against the grammar ID's of the symbols in the symbol tree
Returns:
A pointer to a Grammar object in the individual's symbol tree

void Individual::setFitness ( double  dFitness  ) 

Parameters:
[in] dFitness A fitness value to be associated with this individual

void Individual::setHits ( int  iHits  ) 

Parameters:
[in] iHits A hit count to be associated with this individual

string Individual::toString (  )  const

Forms a LISP expression representing the individual's phenotype

Returns:
A string representing this individual


The documentation for this class was generated from the following files:
Generated on Mon Jan 15 01:21:05 2007 for Creatively Named Grammar Guided Genetic Programming System by  doxygen 1.4.7