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

Simulated Annealing Algorithm. More...

#include <SimulatedAnnealing.h>

Inheritance diagram for SimulatedAnnealing< S >:
AbstractEA< S >

Public Member Functions

 SimulatedAnnealing (const int &maxEvaluations, const float &initialTemp, const float &tempVariation)
 Construct a new Simulated Annealing object with all the parameters. More...
 
void run () override
 Runs the Simulated Annealing algorithm during maxEvaluations. More...
 
string getName () const override
 Get the Name. More...
 
string getID () const override
 Get the ID of the algorithm. More...
 
Front< S > getResults () const override
 Returns the results obtained by the SA algorithm at the end of the process. More...
 
void setProblem (shared_ptr< Problem< S >> prob) override
 Sets the problem to solve using Simulated Annealing. More...
 
void setProblem (Problem< S > *prob) override
 Sets the problem to solve using Simulated Annealing. More...
 
float getTempVariation () const
 Get the temperature variation constant for each generation. More...
 
void setTempVariation (float tempVariation)
 Set the temperature variation constant for each generation. More...
 
float getCurrentTemp () const
 Get the current temperature. More...
 
void setCurrentTemp (float currentTemp)
 Set the current temperature of the process. More...
 
void setPopulationSize (const int &pSize)
 This methods is not implemented for this class. The population size of a SA algorithm is always 1. 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...
 
virtual json to_json () const
 Generates and returns the JSON representation of the EA. 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

void initProgress () override
 Initialises the evolutionary process. Sets the number of performedEvaluations to 1. More...
 
void updateProgress () override
 Updates the evolutionary process by increasing the performedEvaluations in two. More...
 
void finishProgress () override
 Finishes the evolutionary process and computes the elapsed time. More...
 
bool isStoppingConditionReached () override
 Checks whether the maximum number of evaluations have been performed. More...
 
void createInitialPopulation () override
 Creates the initial population for the SA. The population of the SA is just one individual. More...
 
void evaluatePopulation (vector< S > &vector1) override
 Evaluates the entire population of solutions. This is a virtual method that must be implemented in the subclasses to adapt special cases.
 
evaluateInds (S &popInd, S &offspring)
 Evaluates the parent and offspring individuals at each generation. 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 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 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 SimulatedAnnealing< S >

Simulated Annealing Algorithm.

Template Parameters
SType of individual in the population

Constructor & Destructor Documentation

◆ SimulatedAnnealing()

template<class S >
SimulatedAnnealing< S >::SimulatedAnnealing ( const int &  maxEvaluations,
const float &  initialTemp,
const float &  tempVariation 
)

Construct a new Simulated Annealing object with all the parameters.

Template Parameters
S
Parameters
maxEvaluations
initialTemp
tempVariation

Member Function Documentation

◆ createInitialPopulation()

template<class S >
void SimulatedAnnealing< S >::createInitialPopulation
overrideprotectedvirtual

Creates the initial population for the SA. The population of the SA is just one individual.

Template Parameters
S

Implements AbstractEA< S >.

◆ evaluateInds()

template<class S >
S SimulatedAnnealing< S >::evaluateInds ( S &  popInd,
S &  offspring 
)
protected

Evaluates the parent and offspring individuals at each generation.

Template Parameters
S
Parameters
popInd
offspring
Returns
S

◆ finishProgress()

template<class S >
void SimulatedAnnealing< S >::finishProgress
overrideprotectedvirtual

Finishes the evolutionary process and computes the elapsed time.

Template Parameters
S

Implements AbstractEA< S >.

◆ getCurrentTemp()

template<class S >
float SimulatedAnnealing< S >::getCurrentTemp ( ) const
inline

Get the current temperature.

Returns
float

◆ getID()

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

Get the ID of the algorithm.

Returns
string

Implements AbstractEA< S >.

◆ getName()

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

Get the Name.

Returns
string

Implements AbstractEA< S >.

◆ getResults()

template<class S >
Front< S > SimulatedAnnealing< S >::getResults
overridevirtual

Returns the results obtained by the SA algorithm at the end of the process.

Template Parameters
S
Returns
Front

Implements AbstractEA< S >.

◆ getTempVariation()

template<class S >
float SimulatedAnnealing< S >::getTempVariation ( ) const
inline

Get the temperature variation constant for each generation.

Returns
float

◆ initProgress()

template<class S >
void SimulatedAnnealing< S >::initProgress
overrideprotectedvirtual

Initialises the evolutionary process. Sets the number of performedEvaluations to 1.

Template Parameters
S

Implements AbstractEA< S >.

◆ isStoppingConditionReached()

template<class S >
bool SimulatedAnnealing< S >::isStoppingConditionReached
overrideprotectedvirtual

Checks whether the maximum number of evaluations have been performed.

Template Parameters
S
Returns
true
false

Implements AbstractEA< S >.

◆ run()

template<class S >
void SimulatedAnnealing< S >::run
overridevirtual

Runs the Simulated Annealing algorithm during maxEvaluations.

Template Parameters
S

Implements AbstractEA< S >.

◆ setCurrentTemp()

template<class S >
void SimulatedAnnealing< S >::setCurrentTemp ( float  currentTemp)
inline

Set the current temperature of the process.

Parameters
currentTemp

◆ setPopulationSize()

template<class S >
void SimulatedAnnealing< S >::setPopulationSize ( const int &  pSize)

This methods is not implemented for this class. The population size of a SA algorithm is always 1.

Template Parameters
S
Parameters
prob

◆ setProblem() [1/2]

template<class S >
void SimulatedAnnealing< S >::setProblem ( Problem< S > *  prob)
overridevirtual

Sets the problem to solve using Simulated Annealing.

Template Parameters
S
Parameters
prob

Reimplemented from AbstractEA< S >.

◆ setProblem() [2/2]

template<class S >
void SimulatedAnnealing< S >::setProblem ( shared_ptr< Problem< S >>  prob)
overridevirtual

Sets the problem to solve using Simulated Annealing.

Template Parameters
S
Parameters
prob

Reimplemented from AbstractEA< S >.

◆ setTempVariation()

template<class S >
void SimulatedAnnealing< S >::setTempVariation ( float  tempVariation)
inline

Set the temperature variation constant for each generation.

Parameters
tempVariation

◆ updateProgress()

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

Updates the evolutionary process by increasing the performedEvaluations in two.

Template Parameters
S

Implements AbstractEA< S >.


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