GAPopulation Class Reference

Population class for genetic algorithm. More...

#include <GA/GAPopulation.H>

Collaboration diagram for GAPopulation:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Constructor and destructor

 GAPopulation ()
 Uninitialized constructor. Need to call resize() later.
 GAPopulation (const int N, const int a)
 Construct a size N-population of random chromosomes of size a.
void resize (const int N, const int a)
 Change sizes, do not initialize.
void init (const int N, const int a)
 Initialize with N random chromosomes of size a.
 ~GAPopulation ()
 Destructor.
Access functions

void set_chromosome (const int i, const GAChromosome &c)
 Set the chromosome i to c.
GAChromosome get_chromosome (const int i) const
 Return the chromosome i.
float get_mean_fitness () const
 Return the mean fitness.
float get_sigma () const
 Return the standard deviation.
Evolution functions

void update ()
 The offspring become the new generation.
void compute_pop_fitness ()
 Compute the mean and total fitness of the chromosomes.
void compute_sigma ()
 Compute the standard deviation of the chromosomes' fitness.
void linear_scaling ()
 Apply a linear scaling to the chromosomes' fitness.
void selection ()
 Select chromosomes for breeding.
void crossover ()
 Breed chromosomes to produce the offspring.
void mutate ()
 Mutate the offspring with probability 1/size.

Friends

std::istream & operator>> (std::istream &in, GAPopulation &pop)
std::ostream & operator<< (std::ostream &out, GAPopulation &pop)

Detailed Description

Population class for genetic algorithm.

This is a population class for genetic algorithm. It's a size N array of chromosomes, and their potential offspring and comes with various method to handle them.

Definition at line 50 of file GAPopulation.H.


Constructor & Destructor Documentation

GAPopulation::GAPopulation (  ) 

Uninitialized constructor. Need to call resize() later.

Definition at line 53 of file GAPopulation.C.

GAPopulation::GAPopulation ( const int  N,
const int  a 
)

Construct a size N-population of random chromosomes of size a.

Definition at line 58 of file GAPopulation.C.

References init().

GAPopulation::~GAPopulation (  ) 

Destructor.

Definition at line 88 of file GAPopulation.C.


Member Function Documentation

void GAPopulation::compute_pop_fitness (  ) 

Compute the mean and total fitness of the chromosomes.

Definition at line 124 of file GAPopulation.C.

void GAPopulation::compute_sigma (  ) 

Compute the standard deviation of the chromosomes' fitness.

Definition at line 132 of file GAPopulation.C.

References GAChromosome::get_fitness(), and sqrt().

void GAPopulation::crossover (  ) 

Breed chromosomes to produce the offspring.

Definition at line 183 of file GAPopulation.C.

References GAChromosome::get_breedings(), GAChromosome::set_gene(), and GAChromosome::use_breeding().

GAChromosome GAPopulation::get_chromosome ( const int  i  )  const

Return the chromosome i.

Definition at line 103 of file GAPopulation.C.

float GAPopulation::get_mean_fitness (  )  const

Return the mean fitness.

Definition at line 108 of file GAPopulation.C.

float GAPopulation::get_sigma (  )  const

Return the standard deviation.

Definition at line 113 of file GAPopulation.C.

void GAPopulation::init ( const int  N,
const int  a 
)

Initialize with N random chromosomes of size a.

Definition at line 78 of file GAPopulation.C.

References GAChromosome::init(), and resize().

Referenced by GAPopulation().

void GAPopulation::linear_scaling (  ) 

Apply a linear scaling to the chromosomes' fitness.

Definition at line 144 of file GAPopulation.C.

References GAChromosome::get_fitness(), and GAChromosome::set_linear_fitness().

void GAPopulation::mutate (  ) 

Mutate the offspring with probability 1/size.

Definition at line 218 of file GAPopulation.C.

References GAChromosome::mutation().

void GAPopulation::resize ( const int  N,
const int  a 
)

Change sizes, do not initialize.

Definition at line 65 of file GAPopulation.C.

Referenced by init().

void GAPopulation::selection (  ) 

Select chromosomes for breeding.

Definition at line 165 of file GAPopulation.C.

References GAChromosome::add_breeding(), and GAChromosome::get_linear_fitness().

void GAPopulation::set_chromosome ( const int  i,
const GAChromosome c 
)

Set the chromosome i to c.

Definition at line 97 of file GAPopulation.C.

References ASSERT, and GAChromosome::get_size().

void GAPopulation::update (  ) 

The offspring become the new generation.

Definition at line 118 of file GAPopulation.C.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3