Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
Evolver Class Reference

Class that performs a genetic algorithm. More...

#include <evolver.h>

Inheritance diagram for Evolver:
EvolutionaryMonteCarlo FunctionEvolver GeneticMinimizer

List of all members.

Public Member Functions

 Evolver (int nGenes, int nIndividuals, int nPopulations)
void setPopulationData (int nGenes, int nIndividuals, int nPopulations)
void evolve (int nSteps, int populationMatchingPeriod)
void setRescaleLimits (double low, double high)
void setRescaleCycles (int rescaleCycles)
void rescale ()

Public Attributes

vec allBestGenes

Protected Member Functions

virtual double fitness (vec &coefficients, int population, int individual)=0
void updateBest ()

Protected Attributes

int nIndividuals
int nGenes
int nPopulations
int cycle
long * idum
double scale
double lowScaleLimit
double highScaleLimit
double initialLowScaleLimit
double initialHighScaleLimit
double rescalePrecisionLimit
vec ** populations
uvec * bestIndices
vec * values
double allBestValue
int allBestIndex
int allBestPopulationIndex
int rescaleCycles
int cyclesSinceLastImprovement
int cyclesSinceLastRescale
double lastWorkingScale
bool veryFirst

Detailed Description

Class that performs a genetic algorithm.

This class must be inherited and have its fitness function defined to be used.


Member Function Documentation

void Evolver::evolve ( int  nSteps,
int  populationMatchingPeriod 
)

The evolutionary algorithm. Runs for the given number of cycles, uses the fitness function on all individuals' genes and ranks them each cycle. Then the best individuals are mated to produce offspring while the offspring and worst individuals are mutated. Some new individuals are introduced. See the report for more information.

void Evolver::rescale ( )

Updates the scaling of new suggestions for mutations within the given scale. This works logarithmically so that it is a uniform probability for the logarithmic powers between the scale limits.

void Evolver::setPopulationData ( int  nGenes,
int  nIndividuals,
int  nPopulations 
)

Defines the number of genes, populations and individuals and allocates memory to these.

Warning:
This must be called only once, as there is no memory clean up if called twice!
Todo:
Fix memory leak
void Evolver::updateBest ( ) [protected]

Updates the scoreboard over which individuals are best within each population.


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