dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
SteadyGA< S > Class Template Reference

Class to represents a Steady State Genetic Algorithm (SSGA) At each generation, a new individual is included in the population. More...

#include <SteadyGA.h>

Inheritance diagram for SteadyGA< S >:
AbstractGA< S > AbstractEA< S >

Public Member Functions

 SteadyGA ()
 Creates a RAW Steady GA instance. More...
 
string getName () const override
 Get the Name. More...
 
string getID () const override
 Get the ID of the algorithm. More...
 
- Public Member Functions inherited from AbstractGA< S >
 AbstractGA ()
 Creates a new AbstractGA which initialises all parameter to default. The operators will be set to null. More...
 
json to_json () const override
 Creates and returns JSON object with the GA information. More...
 
virtual Front< S > getResults () const
 Returns a front with the feasible non repeated individuals in the last population of the Genetic Algorithm. This is the final solution of the algorithm to the problem at hand. More...
 
void run () override
 Runs the evolutionary process. This is the main EA method. This methods is in charge of: More...
 
void setProblem (shared_ptr< Problem< S >> prob) override
 Uptades the problem to solve using a share_ptr. The problem must be single-objective. More...
 
void setProblem (Problem< S > *prob) override
 Uptades the problem to solve using a raw pointer. The problem must be single-objective. More...
 
double getMutationRate () const
 Gets the mutation rate. More...
 
void setMutationRate (double mutationRate)
 Updates the mutation rate. More...
 
double getCrossRate () const
 Gets the crossover rate. More...
 
void setCrossRate (double crossRate)
 Updates the crossover rate. More...
 
const Mutation< S > * getMutation () const
 Gets a pointer to the mutation operator. More...
 
void setMutation (unique_ptr< Mutation< S >> mutation)
 Updates the mutation operator. Takes a unique_ptr pointing to the new Mutation operator and takes the ownership. More...
 
const Crossover< S > * getCrossover () const
 Returns a raw pointer to the crossover operator. More...
 
void setCrossover (unique_ptr< Crossover< S >> crossover)
 Updates the crossover operator. Takes a unique_ptr pointing to the new Crossover operator and takes the ownership. More...
 
const Selection< S > * getSelection () const
 Returns a raw pointer of the selection operator. More...
 
void setSelection (unique_ptr< Selection< S >> selectionOperator)
 Updates the selection operator. Takes a unique_ptr pointing to the new Selection operator and takes the ownership. More...
 
- Public Member Functions inherited from AbstractEA< S >
 AbstractEA ()
 Construct a new Abstract EA object with default parameter values. More...
 
 AbstractEA (const int &maxEvals, const int &popsize)
 AbstractEA constructor which initialises the parameters maxEvalautions and populationSize. More...
 
 AbstractEA (unique_ptr< PopulationEvaluator< S >>, const int &maxEvals, const int &popsize)
 AbstractEA constructor which initialises the parameters maxEvalautions, the populationSize and the evaluator approach. More...
 
int getPopulationSize () const
 Get the population size. More...
 
void setPopulationSize (int pSize)
 Setter to update the population size. More...
 
double getElapsedTime () const
 Get the elapsed time of the evolutionary process. More...
 
const vector< S > & getPopulation () const
 Gets a reference of the population. More...
 
int getMaxEvaluations () const
 Get the maximum number of evaluations to perform. More...
 
void setMaxEvaluations (int maxEval)
 Set a new maximum number of evaluations to perform. More...
 
const Problem< S > * getProblem () const
 Gets a pointer to the problem which is being solved. More...
 
PopulationEvaluator< S > * getEvaluator () const
 Gets a pointer to the population evaluator system. More...
 
void setEvaluator (unique_ptr< PopulationEvaluator< S >> eval)
 Updates the population evaluator system with the unique_ptr. The method takes the ownership of the object behind. More...
 
int getPerformedEvaluations () const
 Get the performed evaluations. More...
 
void setPerformedEvaluations (int pEvals)
 Set the Performed Evaluations. Useful for the updateProgress method. More...
 
void setPopulation (const vector< S > &pop)
 Set the Population. More...
 
virtual Evolution< S > getEvolution () const
 Get the Evolution data. More...
 
int getPrintingInterval () const
 Get the interval of checkpoints. More...
 

Protected Member Functions

vector< S > createMating () override
 Creates the mating of individuals to be evaluated. More...
 
void updateProgress () override
 Updates the performed evaluations by one on each call. More...
 
- Protected Member Functions inherited from AbstractGA< S >
virtual void initProgress ()
 Starts the evolutionary process. By default this methods sets the number of performed evaluations to the population size since it considers that all individuals have been evaluated in the createInitialPopulation method. More...
 
virtual void finishProgress ()
 Finishes the evolutionary process by computing the elapsed time. More...
 
virtual bool isStoppingConditionReached ()
 Checks whether the evolutionary process has reached the maximum limit. More...
 
virtual void createInitialPopulation ()
 Creates the initial population of individuals before starting the evolutionary process. More...
 
virtual void evaluatePopulation (vector< S > &pop)
 Evaluates the entire population of individuals using the problem evaluation function. More...
 
virtual void reproduction (S &, S &)
 Applies the genetic operator. This methods is invoked from createMating. More...
 
- Protected Member Functions inherited from AbstractEA< S >
virtual void updateEvolution (vector< S > &pop)
 
virtual void updateEvolution (const int &checkpoint, vector< S > &)
 

Additional Inherited Members

- Static Public Attributes inherited from AbstractGA< S >
static double DEFAULT_MUTATION_RATE = 0.05
 Default mutation rate for GAs set to 0.05. More...
 
static double DEFAULT_CROSSOVER_RATE = 0.8
 Default crossover rate to GAs set to 0.8. More...
 
static int DEFAULT_POPULATION_SIZE = 32
 Default population size to GAs set to 32 individuals. More...
 
- Static Public Attributes inherited from AbstractEA< S >
static const int DEFAULT_POPULATION_SIZE = 100
 Default population size equal to 100 individuals. More...
 
static const int DEFAULT_EVALUATIONS_LIMIT = 100000
 Default evaluation limit equal to 100000 evaluations. More...
 
static const std::string NAME = "Algorithm"
 
static const std::string MAX_EVALUATIONS = "Max Evaluations"
 
static const std::string POP_SIZE = "Population Size"
 
static const std::string ELAPSED_TIME = "Elapsed Time"
 
static const std::string EVALUATOR = "Evaluator"
 
static const int EVOLUTION_SIZE = 10
 
- Protected Attributes inherited from AbstractGA< S >
double mutationRate
 
double crossRate
 
unique_ptr< Mutation< S > > mutation
 
unique_ptr< Crossover< S > > crossover
 
unique_ptr< Selection< S > > selection
 
unique_ptr< Replacement< S > > replacement
 
- Protected Attributes inherited from AbstractEA< S >
int maxEvaluations
 
int performedEvaluations
 
int populationSize
 
vector< S > population
 
shared_ptr< Problem< S > > problem
 
unique_ptr< PopulationEvaluator< S > > evaluator
 
Evolution< S > evolution
 
AvgEvolution< S > avgEvolution
 
std::chrono::system_clock::time_point startTime
 
std::chrono::system_clock::time_point endTime
 
double elapsedTime
 
int nextCheckpoint
 
int evolutionInterval
 

Detailed Description

template<class S>
class SteadyGA< S >

Class to represents a Steady State Genetic Algorithm (SSGA) At each generation, a new individual is included in the population.

Template Parameters
SType of individual in the population

Constructor & Destructor Documentation

◆ SteadyGA()

template<class S >
SteadyGA< S >::SteadyGA

Creates a RAW Steady GA instance.

Template Parameters
Problem
S

Member Function Documentation

◆ createMating()

template<class S >
vector< S > SteadyGA< S >::createMating
overrideprotectedvirtual

Creates the mating of individuals to be evaluated.

Template Parameters
Problem
S

Reimplemented from AbstractGA< S >.

◆ getID()

template<class S >
string SteadyGA< S >::getID ( ) const
inlineoverridevirtual

Get the ID of the algorithm.

Returns
string

Implements AbstractEA< S >.

◆ getName()

template<class S >
string SteadyGA< S >::getName ( ) const
inlineoverridevirtual

Get the Name.

Returns
string

Implements AbstractGA< S >.

◆ updateProgress()

template<class S >
void SteadyGA< S >::updateProgress
overrideprotectedvirtual

Updates the performed evaluations by one on each call.

Template Parameters
Problem
S

Implements AbstractGA< S >.


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