Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

BBPopulation< T > Class Template Reference

The template class represents a population of indiviuals. More...

#include <BB2004Evo.h>

Collaboration diagram for BBPopulation< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BBPopulation (int size, const BBIndividual &initial)
 Constructor.

 ~BBPopulation ()
 Destructor.

int getSize () const
 The function returns the number of Individuals.

T & operator[] (int index)
 The operator provides access to the individuals.

const T & operator[] (int index) const
 The constant operator provides access to the individuals.

void interpolate ()
 The function evolves the population.

void extrapolate ()
const BBIndividualgetFittest ()
StatisticsgetStatistics ()

Private Member Functions

const T & drawIndividual ()
 The function draws an indiviual from the previous population.

void updateFitness ()
 The function updates the fitness of the whole population.

void mutate ()
 The function mutates the half of the population if a single individual was drawn too often.


Static Private Member Functions

double random ()
 The function provides random values.


Private Attributes

Statistics statistics
 The object is used to do some statistics on drawing individuals.

T * current
 The current set of individuals.

T * old
 The previous set of individuals.

int size
 The number of individuals in the population.

double * fitness
 The fitnesses of the individuals.

double * fitnessSum
 The accumulated fitnesses of the individuals.

double overallFitness
 The sum of fitness in the current population.


Detailed Description

template<class T>
class BBPopulation< T >

The template class represents a population of indiviuals.

Parameters:
T The class of the individuals. It has to be derived from class BBIndividual.

Definition at line 143 of file BB2004Evo.h.


Constructor & Destructor Documentation

template<class T>
BBPopulation< T >::BBPopulation int  size,
const BBIndividual initial
[inline]
 

Constructor.

Parameters:
size The number of individuals in the population.
initial The individual the population is initialized with.

Definition at line 217 of file BB2004Evo.h.

template<class T>
BBPopulation< T >::~BBPopulation  )  [inline]
 

Destructor.

Definition at line 232 of file BB2004Evo.h.


Member Function Documentation

template<class T>
double BBPopulation< T >::random  )  [inline, static, private]
 

The function provides random values.

Returns:
A random value in the range of [0 ... 1[.

Definition at line 158 of file BB2004Evo.h.

Referenced by BBPopulation< CalibrationIndividual >::drawIndividual().

template<class T>
const T& BBPopulation< T >::drawIndividual  )  [inline, private]
 

The function draws an indiviual from the previous population.

The probability of being drawn is based on the ratio of the individual fitness in relation to the overall fitness of the population.

Returns:
The individual that has been drawn.

Definition at line 166 of file BB2004Evo.h.

Referenced by BBPopulation< CalibrationIndividual >::extrapolate(), and BBPopulation< CalibrationIndividual >::interpolate().

template<class T>
void BBPopulation< T >::updateFitness  )  [inline, private]
 

The function updates the fitness of the whole population.

It also updates the overall fitness.

Definition at line 187 of file BB2004Evo.h.

Referenced by BBPopulation< CalibrationIndividual >::extrapolate(), BBPopulation< CalibrationIndividual >::getFittest(), and BBPopulation< CalibrationIndividual >::interpolate().

template<class T>
void BBPopulation< T >::mutate  )  [inline, private]
 

The function mutates the half of the population if a single individual was drawn too often.

Definition at line 201 of file BB2004Evo.h.

Referenced by BBPopulation< CalibrationIndividual >::extrapolate(), and BBPopulation< CalibrationIndividual >::interpolate().

template<class T>
int BBPopulation< T >::getSize  )  const [inline]
 

The function returns the number of Individuals.

Returns:
The number of individuals.

Definition at line 244 of file BB2004Evo.h.

template<class T>
T& BBPopulation< T >::operator[] int  index  )  [inline]
 

The operator provides access to the individuals.

Parameters:
index The index of the individual.
Returns:
A reference to the individual with the index.

Definition at line 251 of file BB2004Evo.h.

template<class T>
const T& BBPopulation< T >::operator[] int  index  )  const [inline]
 

The constant operator provides access to the individuals.

Parameters:
index The index of the individual.
Returns:
A reference to the individual with the index.

Definition at line 258 of file BB2004Evo.h.

template<class T>
void BBPopulation< T >::interpolate  )  [inline]
 

The function evolves the population.

Returns:
The fittest individual.

Definition at line 264 of file BB2004Evo.h.

template<class T>
void BBPopulation< T >::extrapolate  )  [inline]
 

Definition at line 282 of file BB2004Evo.h.

template<class T>
const BBIndividual& BBPopulation< T >::getFittest  )  [inline]
 

Definition at line 300 of file BB2004Evo.h.

template<class T>
Statistics& BBPopulation< T >::getStatistics  )  [inline]
 

Definition at line 311 of file BB2004Evo.h.


Member Data Documentation

template<class T>
Statistics BBPopulation< T >::statistics [private]
 

The object is used to do some statistics on drawing individuals.

Definition at line 146 of file BB2004Evo.h.

template<class T>
T* BBPopulation< T >::current [private]
 

The current set of individuals.

Definition at line 147 of file BB2004Evo.h.

template<class T>
T * BBPopulation< T >::old [private]
 

The previous set of individuals.

Definition at line 147 of file BB2004Evo.h.

template<class T>
int BBPopulation< T >::size [private]
 

The number of individuals in the population.

Definition at line 149 of file BB2004Evo.h.

template<class T>
double* BBPopulation< T >::fitness [private]
 

The fitnesses of the individuals.

Definition at line 150 of file BB2004Evo.h.

template<class T>
double* BBPopulation< T >::fitnessSum [private]
 

The accumulated fitnesses of the individuals.

Definition at line 151 of file BB2004Evo.h.

template<class T>
double BBPopulation< T >::overallFitness [private]
 

The sum of fitness in the current population.

Definition at line 152 of file BB2004Evo.h.


The documentation for this class was generated from the following file:
Generated on Thu Sep 23 20:04:35 2004 for GT2004 by doxygen 1.3.6