#include <Population.h>
Public Member Functions | |
Population (Problem< T > *problem) | |
Constructs a new Population without initialising. | |
Population (Problem< T > *problem, int size, int chromoLength) | |
Constructs a new Population and fills and initialises it. | |
~Population () | |
Destroys this Population, freeing all used resources. | |
void | addMember (Chromosome< T > *g) |
Adds a Chromosome as a member to this Population. | |
int const | size () |
The number of Chromosomes in this Population. | |
void | initialise (int size, int chromoLength) |
Initialises this population with a number of random members. | |
void | setEliteSize (int nrElite) |
Sets the size of the elite subgroup. | |
void | setProbabilities (double probMutate, double probCrossover) |
Sets probabilities for genetic evolution. | |
void | evaluateFitness () |
Evaluates the fitness of the current population. | |
void | markElite () |
Selects the new elite members for the current population. | |
void | mutate () |
Performs mutation on the population members. | |
int | selectByRoulette () |
Selects a new Chromosome from the current population by roulette wheel selection. | |
void | selectAndReproduce () |
Evolves the current population (generation) into the next generation with the following techniques: 1. | |
void | nextGeneration () |
Evolutes the population into a new generation. | |
void const | print (int generationNr, int printbits, int printmode, std::ostream &outstr) |
Prints population details on screen. | |
int | testConvergence (int nrequal) |
Tests whether the Population has 'converged'. | |
void | writePopulation (std::ostream &outstr) |
Writes all members in current population to a file (or other output stream). | |
void | readPopulation (std::istream &instr) |
Reads population data from a file (or other input stream) as produced by writePopulation and updates the population with the chromosome data. |
The Population type is a template type and needs to be instantiated with the base type of the search domain. For a function f: R -> R this type is simply 'double'.
|
Constructs a new Population without initialising.
|
|
Constructs a new Population and fills and initialises it.
|
|
Destroys this Population, freeing all used resources.
|
|
Adds a Chromosome as a member to this Population.
|
|
Evaluates the fitness of the current population. It uses the evaluateObjective function from the Problem object and then normalizes all values, so that they sum up to 1. Note that a Population aims at MAXIMISING the objective. |
|
Initialises this population with a number of random members.
|
|
Selects the new elite members for the current population. The selected member Chromosomes are marked as elite, and stored in a Population variable as well. |
|
Performs mutation on the population members.
|
|
Evolutes the population into a new generation. This is done by mutation, selection and crossover.
|
|
Prints population details on screen. printmodes for bitstrings: PRINTINTERP, PRINTBITSTRING, PRINTVALUE, PRINTOBJECTIVE, PRINTFITNESS These modes may be added in any combination, e.g. PRINTBITSTRING | PRINTVALUE printmodes/selectionmodes for Population members: PRINTALL, PRINTBEST, PRINTWORST, PRINTAVG, ONLYIFBETTER These modes can not be combined, except for ONLYIFBETTER with the others.
|
|
Reads population data from a file (or other input stream) as produced by writePopulation and updates the population with the chromosome data. NOTE! Current population should be initialised with same settings for problem, size, elite count, etc.!
|
|
Evolves the current population (generation) into the next generation with the following techniques: 1. roulette wheel selection to select good chromosomes with high probability. 2. crossover on selected chromosomes to produce offspring. |
|
Selects a new Chromosome from the current population by roulette wheel selection. Don't forget to disable selected chromosome (at the call site) to prevent double selection.
|
|
Sets the size of the elite subgroup. The next generation will be the first to include elite members. |
|
Sets probabilities for genetic evolution.
|
|
The number of Chromosomes in this Population.
|
|
Tests whether the Population has 'converged'. Conversion is defined as an unchanged objective value over several generations.
|
|
Writes all members in current population to a file (or other output stream). This can serve as input later for a 'resume'.
|