Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

SIGEL_GP::SIG_GPPopulation Class Reference

The SIG_GPPopulation class defines the datastructure of the population of the individuals in the genetic programming system. More...

#include <SIG_GPPopulation.h>

List of all members.

Public Methods

 SIG_GPPopulation ()
 The constructor of a population, which builds an empty pool with default value initialisation. More...

 SIG_GPPopulation (int size)
 The constructor of a population, which builds a pool with a number of randomly created individuals. More...

 SIG_GPPopulation (int size, SIGEL_Tools::SIG_Randomizer &r, SIGEL_GP::SIG_GPParameter& param, SIGEL_Robot::SIG_LanguageParameters& languageP)
 This constructor should be the STANDARD constructor to create a pupoluation consisting of a number of SIZE individuals. More...

 SIG_GPPopulation (QString data)
 The constructor of an population, which is constructed from a QString. More...

 ~SIG_GPPopulation ()
 The destructor of a population object. More...

void sort ()
 The operation sorts the pool, due to the value of the fitness of the individuals. More...

SIG_GPIndividualgetIndividual (int poolpos)
 This operation returns an individual, which is placed in the population on position poolpos. More...

void setIndividual (SIG_GPIndividual& indi, int poolpos)
 This operation sets an individual to the demanded position in the population. More...

int getSize ()
 This operation returns the number of individuals, which are members of the population. More...

QString getNextIdentifier ()
 This operation returns the name for the next new individual. More...

void setNextIdentifier (QString identifier)
 This operation sets a new identifier for an experiment. More...

int getPoolGeneration ()
 This operation returns the number of generations of the population, or how long the pool exists. More...

void loadPool (QTextStream & pool)
 This operation accepts a qtextstream is an input, to build a new population. More...

void savePool (QTextStream & pool)
 This operation returns a qtextstream, in which the data of the population is encoded. More...

 SIG_GPPopulation (int size, SIGEL_Tools::SIG_Randomizer &r)
 This constructor creates a population that contains a number of randomly created individuals. More...

SIGEL_GP::SIG_GPIndividualgetIndividualPointer (int poolpos)
 This function returns the pointer to an individual. More...

void deleteIndividual (int poolpos)
 This function deletes an individual. More...

void setPoolGeneration (int pGen)
 This function sets the generation number of a pool. More...

void setRandomizer (SIGEL_Tools::SIG_Randomizer *r)
 This function sets a randomizer for all random operations. More...

SIGEL_Tools::SIG_Randomizer getRandomizer ()
 This function returns the pointer of the randomizer all random operations are connected with. More...

SIGEL_Tools::SIG_RandomizergetRandomizerPointer ()
 This function is obsolete (and will be deleted later). More...

void readFromFile (QTextStream &file)
 This function writes a complete population (including all individuals and their programs) to a text stream. More...

void writeToFile (QTextStream &file)
 This function reads a complete population out of a given text stream. More...

void addRandomIndividuals (int quantity, SIGEL_GP::SIG_GPParameter& param, SIGEL_Robot::SIG_LanguageParameters& languageP)
 This operation adds randomly created individuals to the pool. More...

double getBestFitness (bool high)
 This function searches for the best fitness within the population. More...

double getWorstFitness (bool high)
double getAverageFitness ()
void resetPool ()
void importNewIndividual ( QString& filename )
 This function imports a new individual. More...


Public Attributes

QString nextIdentifier
 This attribute contains the next free name for a new individual. More...

int poolGeneration
 The value, which indicates how old a population is. More...


Private Attributes

QVector<SIG_GPIndividualpool
 This is the main datastructure in the SIG_GPPopulation. More...

SIGEL_Tools::SIG_Randomizerrandomizer
 The is a refernce of the SIG_Randomizer object of the GPManager. More...


Detailed Description

The SIG_GPPopulation class defines the datastructure of the population of the individuals in the genetic programming system.

It uses the randomizer for the randomly creation of new individuals. The name of an new individual can be taken from the attribute nextidentifier, which contains the continuos name for new individuals. There are also other operations like sort, which sorts the pool.

Definition at line 26 of file SIG_GPPopulation.h.


Constructor & Destructor Documentation

SIGEL_GP::SIG_GPPopulation::SIG_GPPopulation ( )
 

The constructor of a population, which builds an empty pool with default value initialisation.

Precondition:
A new population is demanded by the user.
Postcondition:
The population object is created and all attributes are set to default values.

Definition at line 7 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPPopulation::SIG_GPPopulation ( int size )
 

The constructor of a population, which builds a pool with a number of randomly created individuals.

Precondition:
A new population is demanded by the user and he knows how many individuals he wants the population to contain in front.
Postcondition:
The population object is created and contains the demanded number of randomly created individuals.
Parameters:
size   The number of individuals, which have to be constructed by the construction of the pool.

Definition at line 16 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPPopulation::SIG_GPPopulation ( int size,
SIGEL_Tools::SIG_Randomizer & r,
SIGEL_GP::SIG_GPParameter & param,
SIGEL_Robot::SIG_LanguageParameters & languageP )
 

This constructor should be the STANDARD constructor to create a pupoluation consisting of a number of SIZE individuals.

All individuals are created as defined in the language and GP parameters.

Precondition:
A randomizer, the language and GP parameters must exist.
Postcondition:
A population consisting of SIZE individuals is created. Each individual contains a randomly created program.

Definition at line 60 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPPopulation::SIG_GPPopulation ( QString data )
 

The constructor of an population, which is constructed from a QString.

Precondition:
The user want to construct a population from a QString.
Postcondition:
The population object is constructed correctly, due to the data from the QString.
Parameters:
data   The data represent a population encoded in a QString.

Definition at line 39 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPPopulation::~SIG_GPPopulation ( )
 

The destructor of a population object.

Precondition:
A termination condition is fulfilled and the genetic programming system is forced to break down.
Postcondition:
The population object is destructed correctly.

Definition at line 95 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPPopulation::SIG_GPPopulation ( int size,
SIGEL_Tools::SIG_Randomizer & r )
 

This constructor creates a population that contains a number of randomly created individuals.

Postcondition:
A population with the given number of individuals is created. All individuals will also contain complete programs.

Definition at line 80 of file SIG_GPPopulation.cpp.


Member Function Documentation

void SIGEL_GP::SIG_GPPopulation::addRandomIndividuals ( int quantity,
SIGEL_GP::SIG_GPParameter & param,
SIGEL_Robot::SIG_LanguageParameters & languageP )
 

This operation adds randomly created individuals to the pool.

First the individuals are created and than they are appended to the population of the current experiment.

Precondition:
The user wants to add some individuals to the population, which can be empty or already filled with individuals.
Postcondition:
The demanded quantity fo individuals are appended to the population.
Parameters:
quantity   The quantity expresses how many individuals are to be added to the pool.

Definition at line 140 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::deleteIndividual ( int poolpos )
 

This function deletes an individual.

Postcondition:
The individual at position poolpos will be deleted. The individuals at the following pool positions will be moved a position backwards.

Definition at line 230 of file SIG_GPPopulation.cpp.

double SIGEL_GP::SIG_GPPopulation::getAverageFitness ( )
 

Definition at line 471 of file SIG_GPPopulation.cpp.

double SIGEL_GP::SIG_GPPopulation::getBestFitness ( bool high )
 

This function searches for the best fitness within the population.

It returns the best found fitness and the position of the intdividual the fitness belongs to. HIGH = TRUE defines a high fitness to be a better fitness. Vice versa, HIGH=FALSE defines a low fitness to be better fitness.

Definition at line 421 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPIndividual & SIGEL_GP::SIG_GPPopulation::getIndividual ( int poolpos )
 

This operation returns an individual, which is placed in the population on position poolpos.

Precondition:
An individual is needed, for example for a genetic operation.
Postcondition:
A refernce to the demanded individual is returned.
Parameters:
poolpos   The position of the demanded individual in the pool.

Definition at line 116 of file SIG_GPPopulation.cpp.

SIGEL_GP::SIG_GPIndividual * SIGEL_GP::SIG_GPPopulation::getIndividualPointer ( int poolpos )
 

This function returns the pointer to an individual.

Returns:
The pointer to the current individual will be returned.

Definition at line 225 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation(), addRandomIndividuals(), deleteIndividual(), getBestFitness(), readFromFile(), and writeToFile().

QString SIGEL_GP::SIG_GPPopulation::getNextIdentifier ( )
 

This operation returns the name for the next new individual.

The individual names are continous and so, it is necessary to controll the name giver operation to ensure that the right names for new individuals are taken.

Precondition:
In a genetic operation or in the addRandomIndividual operation is a new individual created and therefore new name is needed.
Returns:
A new name for a new individual is returned.

Definition at line 187 of file SIG_GPPopulation.cpp.

Referenced by addRandomIndividuals(), and importNewIndividual().

int SIGEL_GP::SIG_GPPopulation::getPoolGeneration ( )
 

This operation returns the number of generations of the population, or how long the pool exists.

Returns:
The number of generations, which indicates how long a opoulation exists.

Definition at line 203 of file SIG_GPPopulation.cpp.

Referenced by writeToFile().

SIGEL_Tools::SIG_Randomizer SIGEL_GP::SIG_GPPopulation::getRandomizer ( )
 

This function returns the pointer of the randomizer all random operations are connected with.

Returns:
The pointer of the randomizer will be returned.

Definition at line 255 of file SIG_GPPopulation.cpp.

SIGEL_Tools::SIG_Randomizer * SIGEL_GP::SIG_GPPopulation::getRandomizerPointer ( )
 

This function is obsolete (and will be deleted later).

Definition at line 260 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation(), and addRandomIndividuals().

int SIGEL_GP::SIG_GPPopulation::getSize ( )
 

This operation returns the number of individuals, which are members of the population.

Returns:
The size, which means the number of individuals, of the population.

Definition at line 181 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation(), addRandomIndividuals(), deleteIndividual(), getBestFitness(), getIndividual(), importNewIndividual(), readFromFile(), and writeToFile().

double SIGEL_GP::SIG_GPPopulation::getWorstFitness ( bool high )
 

Definition at line 449 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::importNewIndividual ( QString & filename )
 

This function imports a new individual.

A new individual will be created automatically before. Hence, the population size will be increased.

Definition at line 265 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::loadPool ( QTextStream & pool )
 

This operation accepts a qtextstream is an input, to build a new population.

Postcondition:
The population is rebuilded containing the data of the qtextstream.
Parameters:
pool   The population, which has to be loaded, encoded in a qtextstream.

Definition at line 213 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::readFromFile ( QTextStream & file )
 

This function writes a complete population (including all individuals and their programs) to a text stream.

Precondition:
The QTextStream file must exist.
Postcondition:
The current population will be written to the given text stream.

Definition at line 280 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation(), and loadPool().

void SIGEL_GP::SIG_GPPopulation::resetPool ( )
 

Definition at line 443 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::savePool ( QTextStream & pool )
 

This operation returns a qtextstream, in which the data of the population is encoded.

Postcondition:
The data of the population is encoded in a qtextstream.
Parameters:
pool   A qtextstream, which contains the data of a population.

Definition at line 219 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::setIndividual ( SIG_GPIndividual & indi,
int poolpos )
 

This operation sets an individual to the demanded position in the population.

Precondition:
A new individual, for example after a genetic operation, have to be set in the population.
Postcondition:
The individual is set to the population. A previous individual at this position will be deleted!
Parameters:
indi   A reference to the individual will be set to the population.
poolpos   The position in the population where the individual has to be set.

Definition at line 131 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::setNextIdentifier ( QString identifier )
 

This operation sets a new identifier for an experiment.

The operation is usefull in the terms of creating a new experiment.

Precondition:
A new experiment is created and a new continous name for the individual is needed.
Postcondition:
The attribute NextIdentifier is set to the parameter.
Parameters:
identifier   A set of strings, which is the new base for the individual names.

Definition at line 198 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation(), and readFromFile().

void SIGEL_GP::SIG_GPPopulation::setPoolGeneration ( int pGen )
 

This function sets the generation number of a pool.

Postcondition:
The generation number will be set to the given value.

Definition at line 208 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation(), and readFromFile().

void SIGEL_GP::SIG_GPPopulation::setRandomizer ( SIGEL_Tools::SIG_Randomizer * r )
 

This function sets a randomizer for all random operations.

Postcondition:
The randomizer will be set to the given randomizer

Definition at line 249 of file SIG_GPPopulation.cpp.

Referenced by SIG_GPPopulation().

void SIGEL_GP::SIG_GPPopulation::sort ( )
 

The operation sorts the pool, due to the value of the fitness of the individuals.

The individuals with the highest fitness value is placed on top of the pool, which means position zero, and so on.

Postcondition:
The population is sorted, with the individual with the highest fitness value on top.

Definition at line 109 of file SIG_GPPopulation.cpp.

void SIGEL_GP::SIG_GPPopulation::writeToFile ( QTextStream & file )
 

This function reads a complete population out of a given text stream.

Precondition:
The QTextStream file must exist, and it has to contain a complete population. Either this text stream has been created by writeToFile, or the stream has been edited by the user. The stream has to have a defined format, which is described more in detail in the corresponding specification.
Postcondition:
The population, which is described in the text stream, has been transfered (and translated) into (new created) individuals. All neccessary data is prepared. WARNING: An existing population will be deleted by calling this function.

Definition at line 393 of file SIG_GPPopulation.cpp.

Referenced by savePool().


Member Data Documentation

QString SIGEL_GP::SIG_GPPopulation::nextIdentifier
 

This attribute contains the next free name for a new individual.

It is assembled from the experiment name, an continuos number at the end and other characters, which are needed to build funny individual names.

Definition at line 51 of file SIG_GPPopulation.h.

QVector< SIG_GPIndividual > SIGEL_GP::SIG_GPPopulation::pool [private]
 

This is the main datastructure in the SIG_GPPopulation.

This QVector holds the individual objects, which contains the robot control program.

Definition at line 34 of file SIG_GPPopulation.h.

int SIGEL_GP::SIG_GPPopulation::poolGeneration
 

The value, which indicates how old a population is.

A generation change occurs after a special number of played tournaments, default is the half of the individuals. Is the number of tournaments reached, the generation value of the population is increased by one and all ages of the individuals are increased by one too.

Definition at line 61 of file SIG_GPPopulation.h.

SIGEL_Tools::SIG_Randomizer * SIGEL_GP::SIG_GPPopulation::randomizer [private]
 

The is a refernce of the SIG_Randomizer object of the GPManager.

It is used for the randomly individual creation and the use of the genetic generation.

Definition at line 42 of file SIG_GPPopulation.h.


The documentation for this class was generated from the following files:
Generated at Mon Sep 3 01:32:48 2001 for PG 368 - SIGEL by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000