GAChromosome Class Reference

Chromosome class for genetic algorithm. More...

#include <GA/GAChromosome.H>

List of all members.

Public Member Functions

Constructor, destructor and initialization.

 GAChromosome ()
 Uninitialized constructor. Need to call resize() later.
 GAChromosome (const int N, const int *a)
 Construct from C array.
 GAChromosome (const int N)
 Construct random chromosome.
 GAChromosome (const GAChromosome &c)
 Copy constructor.
void resize (const int N)
 Change size, do not initialize.
void init (const int N, const int *a)
 Initialize from C array.
void init (const int N)
 Initialize randomly.
 ~GAChromosome ()
 Destructor.
Acces functions

int get_size () const
 Return the size of the chromosome.
void set_gene (const int i, const int a)
 Set the gene i to a.
int get_gene (const int i) const
 Return the gene i.
void set_fitness (const float a)
 Set the fitness to a.
float get_fitness () const
 Return the fitness.
void set_linear_fitness (const float a)
 Set the linear fitness to a.
float get_linear_fitness () const
 Return the linear fitness.
void set_breedings (const int a)
 Set breedings to a.
int get_breedings () const
 Return the breedings.
Operators overloading

GAChromosomeoperator= (const GAChromosome &c)
 Overload of assignment operator.
bool operator< (const GAChromosome &c) const
 Overload of less-than operator.
Evolve functions

void mutation ()
 Change one gene randomly.
void add_breeding ()
 Add one breeding.
void use_breeding ()
 Use one breeding.

Friends

std::istream & operator>> (std::istream &in, GAChromosome &c)
 << overloading.
std::ostream & operator<< (std::ostream &in, GAChromosome &c)
 >> overloading.

Detailed Description

Chromosome class for genetic algorithm.

This is a chromosome class for genetic algorithm, which is an array of genes (int with value of -1, 0 or 1).

Definition at line 47 of file GAChromosome.H.


Constructor & Destructor Documentation

GAChromosome::GAChromosome (  ) 

Uninitialized constructor. Need to call resize() later.

Definition at line 48 of file GAChromosome.C.

GAChromosome::GAChromosome ( const int  N,
const int *  a 
)

Construct from C array.

Definition at line 58 of file GAChromosome.C.

References init().

GAChromosome::GAChromosome ( const int  N  ) 

Construct random chromosome.

Definition at line 52 of file GAChromosome.C.

References init().

GAChromosome::GAChromosome ( const GAChromosome c  ) 

Copy constructor.

Definition at line 64 of file GAChromosome.C.

References init().

GAChromosome::~GAChromosome (  ) 

Destructor.

Definition at line 91 of file GAChromosome.C.


Member Function Documentation

void GAChromosome::add_breeding (  ) 

Add one breeding.

Definition at line 166 of file GAChromosome.C.

Referenced by GAPopulation::selection().

int GAChromosome::get_breedings (  )  const

Return the breedings.

Definition at line 141 of file GAChromosome.C.

Referenced by GAPopulation::crossover().

float GAChromosome::get_fitness (  )  const

Return the fitness.

Definition at line 119 of file GAChromosome.C.

Referenced by GAPopulation::compute_sigma(), and GAPopulation::linear_scaling().

int GAChromosome::get_gene ( const int  i  )  const

Return the gene i.

Definition at line 107 of file GAChromosome.C.

References ASSERT.

float GAChromosome::get_linear_fitness (  )  const

Return the linear fitness.

Definition at line 130 of file GAChromosome.C.

Referenced by GAPopulation::selection().

int GAChromosome::get_size (  )  const

Return the size of the chromosome.

Definition at line 96 of file GAChromosome.C.

Referenced by GAPopulation::set_chromosome().

void GAChromosome::init ( const int  N  ) 

Initialize randomly.

Definition at line 84 of file GAChromosome.C.

References resize().

void GAChromosome::init ( const int  N,
const int *  a 
)

Initialize from C array.

Definition at line 78 of file GAChromosome.C.

References resize().

Referenced by GAChromosome(), GAPopulation::init(), and operator=().

void GAChromosome::mutation (  ) 

Change one gene randomly.

Definition at line 160 of file GAChromosome.C.

Referenced by GAPopulation::mutate().

bool GAChromosome::operator< ( const GAChromosome c  )  const

Overload of less-than operator.

c1 < c2 if c1 as less breedings than c2

Definition at line 155 of file GAChromosome.C.

GAChromosome & GAChromosome::operator= ( const GAChromosome c  ) 

Overload of assignment operator.

Definition at line 146 of file GAChromosome.C.

References init().

void GAChromosome::resize ( const int  N  ) 

Change size, do not initialize.

Definition at line 71 of file GAChromosome.C.

Referenced by init(), and operator>>().

void GAChromosome::set_breedings ( const int  a  ) 

Set breedings to a.

Definition at line 135 of file GAChromosome.C.

References ASSERT.

void GAChromosome::set_fitness ( const float  a  ) 

Set the fitness to a.

Definition at line 113 of file GAChromosome.C.

References ASSERT.

void GAChromosome::set_gene ( const int  i,
const int  a 
)

Set the gene i to a.

Definition at line 101 of file GAChromosome.C.

References abs(), and ASSERT.

Referenced by GAPopulation::crossover().

void GAChromosome::set_linear_fitness ( const float  a  ) 

Set the linear fitness to a.

Definition at line 124 of file GAChromosome.C.

References ASSERT.

Referenced by GAPopulation::linear_scaling().

void GAChromosome::use_breeding (  ) 

Use one breeding.

Definition at line 171 of file GAChromosome.C.

References ASSERT.

Referenced by GAPopulation::crossover().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  in,
GAChromosome c 
) [friend]

>> overloading.

Definition at line 196 of file GAChromosome.C.

std::istream& operator>> ( std::istream &  in,
GAChromosome c 
) [friend]

<< overloading.

Definition at line 177 of file GAChromosome.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