Back to Top page.

EGTPopulation< TG > Class Template Reference

Base class template for a Population. More...

#include <EGTPopulation.h>

Collaboration diagram for EGTPopulation< TG >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TG Graph
typedef EGTVector< Graph * > Graphs
typedef Graphs::Iterator GraphsIterator
typedef Graphs::ConstIterator GraphsConstIterator
typedef EGTPopulation< GraphSelf
typedef EGTEvaluation< GraphEval

Public Methods

 EGTPopulation ()
 Constructor.

 EGTPopulation (const Self &)
 Copy constructor.

virtual ~EGTPopulation ()
 Destructor.

void InitPopulation (UInt n=0)
 Initializes this Population with the specified number of Graphs.

Float GetFitnessAvg () const
 Returns the average of fitness values.

void SavePopulation () const
 Saves the data of this Population.

bool LoadPopulation ()
 Loads the data of this Population.

void Display (std::ostream &) const
 Outputs the data of this Population.

void AssignGraphID ()
 Assigns ID number to each Graph.

GraphGetGraph (UInt)
 Returns the Graph with the ID number.

const GraphGetGraph (UInt) const
 Returns the Graph with the ID number (const version).

GraphGetBestGraph () const
 Returns the Graph with the highest fitness value.

EGTVector< const Graph * > GetGraphs () const
 Returns the array of Graphs.

void AddGraph (Graph *pg)
 Adds the specified Graph to this Population.

UInt GetNumGraphs () const
 Returns the number of Graphs included in this Population.


Protected Methods

void CheckIndex (UInt uNum, char *filename, UInt uLine) const
 Checks whether the Graph with the specified ID number exists. If not exists, throws an exception.


Detailed Description

template<class TG>
class EGTPopulation< TG >

Base class template for a Population.

It is assumed that <TG> is a subclass of EGTGraph.


Member Typedef Documentation

template<class TG>
typedef EGTEvaluation<Graph> EGTPopulation< TG >::Eval
 

template<class TG>
typedef TG EGTPopulation< TG >::Graph
 

template<class TG>
typedef EGTVector<Graph*> EGTPopulation< TG >::Graphs
 

template<class TG>
typedef Graphs::ConstIterator EGTPopulation< TG >::GraphsConstIterator
 

template<class TG>
typedef Graphs::Iterator EGTPopulation< TG >::GraphsIterator
 

template<class TG>
typedef EGTPopulation<Graph> EGTPopulation< TG >::Self
 


Constructor & Destructor Documentation

template<class TG>
EGTPopulation< TG >::EGTPopulation   [inline]
 

Constructor.

template<class TG>
EGTPopulation< TG >::EGTPopulation const Self   rhs
 

Copy constructor.

Parameters:
rhs  [in] Population

template<class TG>
EGTPopulation< TG >::~EGTPopulation   [virtual]
 

Destructor.


Member Function Documentation

template<class TG>
void EGTPopulation< TG >::AddGraph Graph   pg [inline]
 

Adds the specified Graph to this Population.

template<class TG>
void EGTPopulation< TG >::AssignGraphID  
 

Assigns ID number to each Graph.

template<class TG>
void EGTPopulation< TG >::CheckIndex UInt    uNum,
char *    filename,
UInt    uLine
const [protected]
 

Checks whether the Graph with the specified ID number exists. If not exists, throws an exception.

Parameters:
uNum  [in] ID number of the Graph to be checked
filename  [in] Filename
uLine  [in] Line number

template<class TG>
void EGTPopulation< TG >::Display std::ostream &    out const
 

Outputs the data of this Population.

Parameters:
out  [out] Output stream

template<class TG>
TG * EGTPopulation< TG >::GetBestGraph   const
 

Returns the Graph with the highest fitness value.

Returns:
Graph with the highest fitness value.

template<class TG>
Float EGTPopulation< TG >::GetFitnessAvg   const
 

Returns the average of fitness values.

Returns:
Average of fitness values

template<class TG>
const TG * EGTPopulation< TG >::GetGraph UInt    uNum const
 

Returns the Graph with the ID number (const version).

Parameters:
uNum  [in] ID number of the Graph.
Returns:
Graph with the ID number.

template<class TG>
TG * EGTPopulation< TG >::GetGraph UInt    uNum
 

Returns the Graph with the ID number.

Parameters:
uNum  [in] ID number of the Graph.
Returns:
Graph with the ID number.

template<class TG>
EGTVector< const TG * > EGTPopulation< TG >::GetGraphs   const
 

Returns the array of Graphs.

Returns:
The array of Graphs

template<class TG>
UInt EGTPopulation< TG >::GetNumGraphs   const [inline]
 

Returns the number of Graphs included in this Population.

template<class TG>
void EGTPopulation< TG >::InitPopulation UInt    n = 0
 

Initializes this Population with the specified number of Graphs.

Parameters:
n  [in] Number of Graphs
If n is omitted, the default value will be used.

template<class TG>
bool EGTPopulation< TG >::LoadPopulation  
 

Loads the data of this Population.

The number of Graphs to be loaded is defined in the Environment.

Return values:
true  All the data have been loaded successfully.
false  Otherwise.

template<class TG>
void EGTPopulation< TG >::SavePopulation   const
 

Saves the data of this Population.

Each individual is saved to a distinct file.


The documentation for this class was generated from the following file: