dignea
1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
|
Instance Generation Algorithm. Known as Meta-Evolutionary Algorithm (EIG). This algorithm uses a Weighted Fitness Function (WFF) to evaluate how biased and diverse are the instances generated during the evolutionary process. The instances generated should be biased to the performance of the target algorithm in the portfolio but also should show some diversity between them. More...
#include <EIG.h>
Public Types | |
using | Alg = AbstractEA< OS > |
Public Member Functions | |
EIG (const float &fitness=0.6f, const float &novelty=0.4f) | |
Construct a new EIG object using a fitness ratio of 0.6 and novelty of 0.4 by default. Use the EIGBuilder instead of the constructor for safe experimentation. More... | |
void | run () override |
Interface to run the EIG for generating a set of instances for the optimisation problem defined (OP) More... | |
json | to_json () const override |
Creates the JSON representation of the EIG. More... | |
string | getName () const override |
Get the name of the algorithm. More... | |
string | getID () const override |
Get the ID. Similar to getName. | |
virtual Front< IS > | getResults () const override |
Returns a set of individuals as a result of the evolutionary method. The individual are instances for the OP. More... | |
const IP * | getInstanceProblem () const |
Get a raw pointer to the Instance Generation Problem. More... | |
void | setInstanceProblem (unique_ptr< IP > problem) |
Set the Instance Generation Problem. More... | |
vector< Alg * > | getPortfolio () const |
Get the portfolio of algorithms used in the evolutionary process. More... | |
void | setPortfolio (vector< unique_ptr< Alg >> &configs) |
Set the portfolio of algorithms to use in the evolutionary process. The order of the algorithms in the portfolio is crucial. Notice that the first algorithm in the portfolio will be considered the target and therefore the instances will be generated according to its performance. Also, it is important to know the order of the remaining algorithms in order to analysis the results obtained since not tags are included in the results at this moment. More... | |
float | getMutationRate () const |
Get the mutation rate used in EIG for mutation instances during the evolutionary process. More... | |
void | setMutationRate (float mRate) |
Set the mutation rate used in EIG for mutation instances during the evolutionary process. More... | |
float | getCrossoverRate () const |
Get the crossover rate used in EIG for applying the crossover operator to instances during the evolutionary process. More... | |
void | setCrossoverRate (float cRate) |
Set the crossover rate used in EIG for applying the crossover operator to instances during the evolutionary process. More... | |
int | getRepetitions () const |
Get the number of repetitions that each algorithm in the portfolio must perform over each instance at every generation of the EIG. More... | |
void | setRepetitions (int reps) |
Set the number of repetitions that each algorithm in the portfolio must perform over each instance at every generation of the EIG. Due to stochastic nature of most algorithms used in EIG the number of repetitions should vary between 10 to 30. For deterministic heuristics can be set to one. More... | |
Mutation< IS > * | getMutation () const |
Get the mutation operator used to mutate instances in EIG. More... | |
void | setMutation (unique_ptr< Mutation< IS >> mut) |
Set the mutation operator. Takes ownership of the pointer. More... | |
Crossover< IS > * | getCrossover () const |
Get the crossover operator used in EIG. More... | |
void | setCrossover (unique_ptr< Crossover< IS >> cx) |
Set the crossover operator. Takes ownership of the pointer. More... | |
Selection< IS > * | getSelection () const |
Get the selection operator. More... | |
void | setSelection (unique_ptr< Selection< IS >> sel) |
Set the selection operator. Takes ownership of the pointer. More... | |
void | setReplacement (unique_ptr< Replacement< IS >> rep) |
Set the selection operator. Takes ownership of the pointer. More... | |
InstanceFitness * | getEvaluation () const |
Get the evaluation approach for the instances. More... | |
void | setInstanceFitness (unique_ptr< InstanceFitness > eval) |
Set the evaluation approach for the instances. More... | |
int | getGenerations () |
Get the number of generations that EIG must perform. More... | |
const NoveltySearch< IS > * | getNoveltySearch () const |
Get the Novelty Search approach used in EIG. More... | |
void | setNoveltySearch (unique_ptr< NoveltySearch< IS >> noveltySearch) |
Set the Novelty Search approach to use. More... | |
void | setWeightedFunction (const float &fW, const float &nW) |
Set the weights to use in the WFF. More... | |
Public Member Functions inherited from AbstractEA< IS > | |
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< IS >>, 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< IS > & | 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< IS > * | getProblem () const |
Gets a pointer to the problem which is being solved. More... | |
virtual void | setProblem (shared_ptr< Problem< IS >> prob) |
Set the new problem to solve. Uses a shared_ptr pointer which updates the reference counter. Does no take the ownership. More... | |
virtual void | setProblem (Problem< IS > *prob) |
Set the new problem to solve. Uses a raw pointer and takes the ownership of the object. More... | |
PopulationEvaluator< IS > * | getEvaluator () const |
Gets a pointer to the population evaluator system. More... | |
void | setEvaluator (unique_ptr< PopulationEvaluator< IS >> 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< IS > &pop) |
Set the Population. More... | |
virtual Evolution< IS > | getEvolution () const |
Get the Evolution data. More... | |
int | getPrintingInterval () const |
Get the interval of checkpoints. More... | |
Protected Member Functions | |
void | initProgress () override |
Initialises the number of generations performed to 0. More... | |
void | updateProgress () override |
Updates the evolution by increasing the number of generations performed. More... | |
void | finishProgress () override |
Finishes the execution of the EIG. More... | |
bool | isStoppingConditionReached () override |
Checks whether the number of performed generations has reached the maximum allowed. More... | |
void | createInitialPopulation () override |
Creates a initial population of Problem Instances of the OP type. Uses the IP method "createSolutions". More... | |
void | evaluatePopulation (vector< IS > &individuals) override |
Evaluates the population of individuals with all the algorithms in the portfolio. More... | |
void | evaluateIndividual (IS &individual) |
Evaluates the given IS with all the algorithms in the porftolio. More... | |
virtual void | evaluationPhase (vector< IS > &individuals) |
Evaluation phase of the EIG All the stages necessary to evaluated the population of individuals are performed from this method. More... | |
virtual void | reproduction (IS &solution, IS &solution2) |
Executes the genetic operator over two instances to generate new individuals. More... | |
virtual void | replacement (vector< IS > &individuals) |
Replacement method for the population. In this case, the replacement is a simple generational approach, which also includes the comparison of individuals with the archive and the feature set of the NS. More... | |
virtual void | updateEvolution (vector< IS > &solutions) |
Updates the evolution results of the algorithm for the given checkpoint. More... | |
Protected Member Functions inherited from AbstractEA< IS > | |
virtual void | updateEvolution (vector< IS > &pop) |
virtual void | updateEvolution (const int &checkpoint, vector< IS > &) |
Protected Attributes | |
unique_ptr< IP > | instProb |
vector< unique_ptr< Alg > > | algPortfolio |
unique_ptr< Mutation< IS > > | mutation |
unique_ptr< Crossover< IS > > | crossover |
unique_ptr< Selection< IS > > | selection |
unique_ptr< Replacement< IS > > | repOperator |
float | mutationRate |
float | crossoverRate |
int | repetitions |
unique_ptr< NoveltySearch< IS > > | noveltySearch |
unique_ptr< InstanceFitness > | instanceFitness |
unique_ptr< Weighted< IS > > | weightedFitness |
AverageFitness< OS > | averageFitness |
BestFitness< OS > | bestFitness |
Protected Attributes inherited from AbstractEA< IS > | |
int | maxEvaluations |
int | performedEvaluations |
int | populationSize |
vector< IS > | population |
shared_ptr< Problem< IS > > | problem |
unique_ptr< PopulationEvaluator< IS > > | evaluator |
Evolution< IS > | evolution |
AvgEvolution< IS > | avgEvolution |
std::chrono::system_clock::time_point | startTime |
std::chrono::system_clock::time_point | endTime |
double | elapsedTime |
int | nextCheckpoint |
int | evolutionInterval |
Additional Inherited Members | |
Static Public Attributes inherited from AbstractEA< IS > | |
static const int | DEFAULT_POPULATION_SIZE |
Default population size equal to 100 individuals. More... | |
static const int | DEFAULT_EVALUATIONS_LIMIT |
Default evaluation limit equal to 100000 evaluations. More... | |
static const std::string | NAME |
static const std::string | MAX_EVALUATIONS |
static const std::string | POP_SIZE |
static const std::string | ELAPSED_TIME |
static const std::string | EVALUATOR |
static const int | EVOLUTION_SIZE |
Instance Generation Algorithm. Known as Meta-Evolutionary Algorithm (EIG). This algorithm uses a Weighted Fitness Function (WFF) to evaluate how biased and diverse are the instances generated during the evolutionary process. The instances generated should be biased to the performance of the target algorithm in the portfolio but also should show some diversity between them.
using EIG< IP, IS, OP, OS >::Alg = AbstractEA<OS> |
Acronym for an AbstractEA<OS>
EIG< IP, IS, OP, OS >::EIG | ( | const float & | fitness = 0.6f , |
const float & | novelty = 0.4f |
||
) |
Construct a new EIG object using a fitness ratio of 0.6 and novelty of 0.4 by default. Use the EIGBuilder instead of the constructor for safe experimentation.
Creates a default EIG with only the evaluation as EasyInstances.
fitness | Ratio of fitness for the WFF |
novelty | Ratio of novelty for the WFF |
|
overrideprotectedvirtual |
Creates a initial population of Problem Instances of the OP type. Uses the IP method "createSolutions".
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
Reimplemented in MapElites< IP, IS, OP, OS >.
|
protected |
Evaluates the given IS with all the algorithms in the porftolio.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
individual | IS individual to evaluate using all the configurations |
|
overrideprotectedvirtual |
Evaluates the population of individuals with all the algorithms in the portfolio.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
individuals | Population of IS to evaluate using the configurations |
Implements AbstractEA< IS >.
Reimplemented in MapElites< IP, IS, OP, OS >.
|
protectedvirtual |
Evaluation phase of the EIG All the stages necessary to evaluated the population of individuals are performed from this method.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
individuals |
|
overrideprotectedvirtual |
Finishes the execution of the EIG.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
|
inline |
Get the crossover operator used in EIG.
|
inline |
Get the crossover rate used in EIG for applying the crossover operator to instances during the evolutionary process.
|
inline |
Get the evaluation approach for the instances.
|
inline |
Get the number of generations that EIG must perform.
|
inline |
Get a raw pointer to the Instance Generation Problem.
|
inline |
Get the mutation operator used to mutate instances in EIG.
|
inline |
Get the mutation rate used in EIG for mutation instances during the evolutionary process.
|
inlineoverridevirtual |
Get the name of the algorithm.
Implements AbstractEA< IS >.
Reimplemented in MapElites< IP, IS, OP, OS >.
|
inline |
vector< AbstractEA< OS > * > EIG< IP, IS, OP, OS >::getPortfolio |
Get the portfolio of algorithms used in the evolutionary process.
Returns the portfolio used by the EIG.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
|
inline |
Get the number of repetitions that each algorithm in the portfolio must perform over each instance at every generation of the EIG.
|
overridevirtual |
Returns a set of individuals as a result of the evolutionary method. The individual are instances for the OP.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
Reimplemented in MapElites< IP, IS, OP, OS >.
|
inline |
Get the selection operator.
|
overrideprotectedvirtual |
Initialises the number of generations performed to 0.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
|
overrideprotectedvirtual |
Checks whether the number of performed generations has reached the maximum allowed.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
|
protectedvirtual |
Replacement method for the population. In this case, the replacement is a simple generational approach, which also includes the comparison of individuals with the archive and the feature set of the NS.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
individuals | New population of individuals to replace the current one |
|
protectedvirtual |
Executes the genetic operator over two instances to generate new individuals.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
solution1 | First child of type IS |
solution2 | Second child of type IS |
|
overridevirtual |
Interface to run the EIG for generating a set of instances for the optimisation problem defined (OP)
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
Reimplemented in MapElites< IP, IS, OP, OS >.
|
inline |
Set the crossover operator. Takes ownership of the pointer.
cx |
|
inline |
Set the crossover rate used in EIG for applying the crossover operator to instances during the evolutionary process.
cRate |
|
inline |
Set the evaluation approach for the instances.
eval |
void EIG< IP, IS, OP, OS >::setInstanceProblem | ( | unique_ptr< IP > | problem | ) |
Set the Instance Generation Problem.
Sets the instance generation problem to toSolve.
problem |
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
problem |
|
inline |
Set the mutation operator. Takes ownership of the pointer.
mut | unique_ptr |
|
inline |
Set the mutation rate used in EIG for mutation instances during the evolutionary process.
mRate |
|
inline |
Set the Novelty Search approach to use.
noveltySearch |
void EIG< IP, IS, OP, OS >::setPortfolio | ( | vector< unique_ptr< Alg >> & | configs | ) |
Set the portfolio of algorithms to use in the evolutionary process. The order of the algorithms in the portfolio is crucial. Notice that the first algorithm in the portfolio will be considered the target and therefore the instances will be generated according to its performance. Also, it is important to know the order of the remaining algorithms in order to analysis the results obtained since not tags are included in the results at this moment.
Updates the portfolio to solve the Instance Generation Problem.
configs |
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
configs |
|
inline |
Set the number of repetitions that each algorithm in the portfolio must perform over each instance at every generation of the EIG. Due to stochastic nature of most algorithms used in EIG the number of repetitions should vary between 10 to 30. For deterministic heuristics can be set to one.
reps |
|
inline |
Set the selection operator. Takes ownership of the pointer.
sel |
|
inline |
Set the selection operator. Takes ownership of the pointer.
sel |
|
inline |
Set the weights to use in the WFF.
fW | |
nW |
|
overridevirtual |
Creates the JSON representation of the EIG.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Reimplemented from AbstractEA< IS >.
Reimplemented in MapElites< IP, IS, OP, OS >.
|
protectedvirtual |
|
overrideprotectedvirtual |
Updates the evolution by increasing the number of generations performed.
IP | Type of Instance Problem to toSolve |
IS | Type of instances of the Optimisation Problem |
OP | Optimisation problem to toSolve with the configurations |
OS | Solutions to the OP type |
Implements AbstractEA< IS >.
|
protected |
Portfolio of algorithms to evaluate the instances
|
protected |
Avg fitness calculation for each instance at every generation
|
protected |
Best fitness calculation for each algorithm after solving a instance at every generation
|
protected |
Crossover operator
|
protected |
Crossover rate
|
protected |
Instance Generation Problem
|
protected |
Mutation operator
|
protected |
Mutation rate
|
protected |
Novelty Search
|
protected |
Number of repetitions to perform by the algorithms
|
protected |
Selection operator