Skip to content
Snippets Groups Projects
Commit 5059beec authored by Caron Olivier's avatar Caron Olivier
Browse files

small updates

parent ce41fd37
No related branches found
No related tags found
No related merge requests found
Pipeline #4106 failed
......@@ -90,11 +90,11 @@ int main(int argc, char *argv[]) {
STOP stopGen(5000) ; // using TimeCriterion with 5 seconds
SELECTION sel(3, population.size());
CROSSOVER crossover(1, eval) ;
SELECTION sel(5, population.size()*.8);
CROSSOVER crossover(0.8, eval) ;
// Opérateur de mutation
MUTATION mutation(0.2, eval,*neighbor);
MUTATION mutation(0.15, eval,*neighbor);
REPLACEMENT replace ;
opt::checkpoint::ArchiveCheckpoint<POPULATION> archiveCheckpoint;
......
......@@ -77,25 +77,24 @@ namespace opt::manySolutions::geneticAlgorithm {
this->criterion->init();
}
// tag::algoGA[]
/**
* The operator that runs the genetic algorithm
* @param POPULATION population
*/
void operator()(POPULATION &sol) override {
this->init(sol);
while (this->criterion->operator()()) {
while (this->criterion->operator()()) { // <1>
this->numberOfGenerations++;
this->selection->operator()(sol);
this->crossover->operator()(this->selection->getSelectedPopulation());
this->mutation->operator()(this->crossover->getOffspring());
this->replacement->operator()(sol,this->mutation->getOffspring()) ;
this->criterion->update();
//sol.sort();
//std::cout << "the population after the generation:"<< this->numberOfGenerations << std::endl << sol << std::endl ;
this->checkpoint->operator()(sol);
this->selection->operator()(sol); // <2>
this->crossover->operator()(this->selection->getSelectedPopulation()); // <3>
this->mutation->operator()(this->crossover->getOffspring()); // <4>
this->replacement->operator()(sol,this->mutation->getOffspring()) ; // <5>
this->criterion->update(); // <6>
this->checkpoint->operator()(sol); // <7>
}
}
// end::algoGA[]
/**
* update the selection operator
* @param _selection the new selection operator
......
......@@ -21,14 +21,13 @@
#ifndef MH_BUILDER_ONEMAXEVAL_H
#define MH_BUILDER_ONEMAXEVAL_H
#include "representation/bitstring/BitstringSolution.h"
#include "core/fitness/FitnessMax.h"
#include "core/Eval.h"
namespace representation {
namespace bitstring {
namespace problems {
namespace onemax {
namespace representation::bitstring::problems::onemax {
/*! Define type for a OneMax solution */
typedef representation::bitstring::BitstringSolution<core::fitness::FitnessMax<unsigned int>> OneMaxSol;
......@@ -80,7 +79,6 @@ namespace representation {
}
};
}
}
}
}
#endif //MH_BUILDER_ONEMAXEVAL_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment