Population Class Reference

A container for holding a collection of individual programs. More...

#include <Population.hpp>

List of all members.

Public Member Functions

 Population (Context *pcontext, Evaluator *peval, int iPopulationSize=100, int iTournamentSize=3, int iMinDepth=0, int iMaxDepth=30, int iTries=5)
void generateInitialPopulation ()
IndividualgetBestIndividual () const
IndividualselectIndividual () const
void addIndividual (Individual *ind)
double getBestFitness () const
int getBestHits () const
double getAverageFitness () const
double getAverageHits () const
void mutate (double dMutationRate)
void crossover (double dCrossoverRate)
void evaluate ()


Detailed Description

A container for holding a collection of individual programs.

Author:
Stephen E. Baker
Date:
2006-2007
Version:
1.0


Constructor & Destructor Documentation

Population::Population ( Context pcontext,
Evaluator peval,
int  iPopulationSize = 100,
int  iTournamentSize = 3,
int  iMinDepth = 0,
int  iMaxDepth = 30,
int  iTries = 5 
)

Create a new population object. This merely sets the population up, and does not populate it with individuals.

Parameters:
[in,out] pcontext A pointer to the context for the GP.
[in] peval A pointer to the evaluator object.
[in] iPopulationSize The number of individuals to allocate space for in the population.
[in] iTournamentSize The size of the pool of random individuals from which the best is chosen in the selection method.
[in] iMinDepth The minimum depth an individual in this population's symbol tree * must be to be considered valid.
[in] iMaxDepth The maximum depth an individual in this population's symbol tree must be to be considered valid.
[in] iTries The number of attempts a particular mutation or crossover will try before it will fail.


Member Function Documentation

void Population::addIndividual ( Individual ind  ) 

Adds the given individual to the population.

Parameters:
[in] ind The individual to be added to the population

void Population::crossover ( double  dCrossoverRate  ) 

Performs crossover on a given proportion of the population. The individuals crossed over are chosen at random, individuals are crossed with neighboring individuals in the population list. Since the order of the list is made random with the selection process in each generation this does not mean that the same two individuals are always crossed.

Parameters:
[in] dCrossoverRate The proportion of individuals to be crossed
See also:
Crossover

void Population::evaluate (  ) 

Evaluates the entire population, updating the best individual pointer and averages to reflect the new values. This should be called between any modification to the population and any access to these statistics.

See also:
Evaluator

void Population::generateInitialPopulation (  ) 

Constructs enough random individuals to fill the population.

double Population::getAverageFitness (  )  const

Returns the mean fitness value of the individuals in the population.

double Population::getAverageHits (  )  const

Returns the mean hit value of the individuals in the population.

double Population::getBestFitness (  )  const

Returns the highest fitness value of any individual in the population.

int Population::getBestHits (  )  const

Returns the number of hits in the individual with the best fitness

Note:
This may not be the number of hits from the individual with the most hits, but is consistent with other GP systems eg. OpenBEAGLE

Individual * Population::getBestIndividual (  )  const

Returns a copy of the individual in the population with the highest fitness value. A pointer to this individual is kept when the population is evaluated so this can be done in constant time.

See also:
evaluate

void Population::mutate ( double  dMutationRate  ) 

Performs mutations on a given proportion of the population. The actual individuals mutated are chosen at random.

Parameters:
[in] dMutationRate The proportion to be mutated
See also:
Mutate

Individual * Population::selectIndividual (  )  const

Performs tournament selection to choose an individual from the population. Specifically this picks a number of individuals from the population at random and returns the one with the highest fitness.

Returns:
A copy of the selected individual
See also:
iTournamentSize


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