From 7b8e3936705a18c0212d7155ef1e10ade10471c7 Mon Sep 17 00:00:00 2001 From: BertheasLeo <108930465+BertheasLeo@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:02:16 +0200 Subject: [PATCH 1/7] Update eoSIGContinue.h Correction sighandler is not defined on Windows --- eo/src/eoSIGContinue.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eo/src/eoSIGContinue.h b/eo/src/eoSIGContinue.h index 727c74a01..e30eeb24e 100644 --- a/eo/src/eoSIGContinue.h +++ b/eo/src/eoSIGContinue.h @@ -35,6 +35,8 @@ #include #include "eoContinue.h" +typedef void (*sighandler_t)(int); + /** @addtogroup Continuators * @{ */ From afa0d18d1e3515dcdc608fbb81836a41e780d86b Mon Sep 17 00:00:00 2001 From: BertheasLeo <108930465+BertheasLeo@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:03:44 +0200 Subject: [PATCH 2/7] Update edoEstimatorNormalAdaptive.h Correction aliasing errror on Eigen --- edo/src/edoEstimatorNormalAdaptive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edo/src/edoEstimatorNormalAdaptive.h b/edo/src/edoEstimatorNormalAdaptive.h index 8dd03af1f..a19e14b91 100644 --- a/edo/src/edoEstimatorNormalAdaptive.h +++ b/edo/src/edoEstimatorNormalAdaptive.h @@ -233,7 +233,7 @@ public: Matrix mD = eigensolver.eigenvalues().asDiagonal(); // from variance to standard deviations - mD.cwiseSqrt(); + mD=mD.cwiseSqrt(); d.scaling( mD.diagonal() ); d.coord_sys( eigensolver.eigenvectors() ); From 399b22266199cf9a9c37ea97c5a287c0fd3c98a6 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 09:47:58 +0100 Subject: [PATCH 3/7] feat(EO): allow overriding fitness accessors May be useful for debugging, by tracing when fitness assignement occurs. --- eo/src/EO.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index 490dd7d83..f0e5213ac 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -72,7 +72,7 @@ public: virtual ~EO() {}; /// Return fitness value. - const Fitness& fitness() const { + virtual const Fitness& fitness() const { if (invalid()) throw eoInvalidFitnessError("Cannot retrieve unevaluated fitness"); return repFitness; @@ -86,12 +86,12 @@ public: } // Set fitness as invalid. - void invalidate() { invalidFitness = true; repFitness = Fitness(); } + virtual void invalidate() { invalidFitness = true; repFitness = Fitness(); } /** Set fitness. At the same time, validates it. * @param _fitness New fitness value. */ - void fitness(const Fitness& _fitness) + virtual void fitness(const Fitness& _fitness) { repFitness = _fitness; invalidFitness = false; From ab375d55ac9327598333a37386ad144b5298566b Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 09:51:56 +0100 Subject: [PATCH 4/7] refactor(mo): use clog instead of cout & use at accessors in Debug builds Should really use eo::log, but waiting for logger refactoring. --- .../continuator/moBestNoImproveContinuator.h | 2 +- mo/src/continuator/moIterContinuator.h | 2 +- mo/src/continuator/moNeighborFitnessStat.h | 2 +- mo/src/continuator/moTimeContinuator.h | 2 +- mo/src/eval/moFullEvalByModif.h | 4 ++- mo/src/explorer/moILSexplorer.h | 2 +- mo/src/explorer/moMetropolisHastingExplorer.h | 2 +- mo/src/explorer/moNeighborhoodExplorer.h | 6 ++--- mo/src/explorer/moRandomBestHCexplorer.h | 27 +++++++++++++++---- mo/src/explorer/moRandomNeutralWalkExplorer.h | 2 +- mo/src/explorer/moRandomWalkExplorer.h | 2 +- mo/src/explorer/moSAexplorer.h | 2 +- mo/src/sampling/moSampling.h | 2 +- 13 files changed, 38 insertions(+), 19 deletions(-) diff --git a/mo/src/continuator/moBestNoImproveContinuator.h b/mo/src/continuator/moBestNoImproveContinuator.h index d772180f3..c14c4b87d 100644 --- a/mo/src/continuator/moBestNoImproveContinuator.h +++ b/mo/src/continuator/moBestNoImproveContinuator.h @@ -84,7 +84,7 @@ public: bool res = (cpt < maxNoImprove); if (!res && verbose) - std::cout << "STOP in moBestNoImproveContinuator: Reached maximum number of iterations without improvement [" << cpt << "/" << maxNoImprove << "]" << std::endl; + std::clog << "STOP in moBestNoImproveContinuator: Reached maximum number of iterations without improvement [" << cpt << "/" << maxNoImprove << "]" << std::endl; return res; } diff --git a/mo/src/continuator/moIterContinuator.h b/mo/src/continuator/moIterContinuator.h index f9400254c..ff3056062 100644 --- a/mo/src/continuator/moIterContinuator.h +++ b/mo/src/continuator/moIterContinuator.h @@ -57,7 +57,7 @@ public: cpt++; res = (cpt < maxIter); if (!res && verbose) - std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl; + std::clog << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl; return res; } diff --git a/mo/src/continuator/moNeighborFitnessStat.h b/mo/src/continuator/moNeighborFitnessStat.h index ab0d3bcb9..5cbe3351d 100644 --- a/mo/src/continuator/moNeighborFitnessStat.h +++ b/mo/src/continuator/moNeighborFitnessStat.h @@ -62,7 +62,7 @@ public : neighborhood(_neighborhood), eval(_eval) { if (!neighborhood.isRandom()) { - std::cout << "moNeighborFitnessStat::Warning -> the neighborhood used is not random, the neighbor will not be random" << std::endl; + std::clog << "moNeighborFitnessStat::Warning -> the neighborhood used is not random, the neighbor will not be random" << std::endl; } } diff --git a/mo/src/continuator/moTimeContinuator.h b/mo/src/continuator/moTimeContinuator.h index 172fec933..67804dda9 100644 --- a/mo/src/continuator/moTimeContinuator.h +++ b/mo/src/continuator/moTimeContinuator.h @@ -94,7 +94,7 @@ public: time_t elapsed = (time_t) difftime(time(NULL), start); res = (elapsed < max); if (!res && verbose) - std::cout << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl; + std::clog << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl; return res; } diff --git a/mo/src/eval/moFullEvalByModif.h b/mo/src/eval/moFullEvalByModif.h index 80ee94d1c..a4cb9369a 100644 --- a/mo/src/eval/moFullEvalByModif.h +++ b/mo/src/eval/moFullEvalByModif.h @@ -40,7 +40,9 @@ /** * Full evaluation to use with a moBackableNeighbor - * !!!WARNING!!! Use only when your solution is composed by a fitness Value and a "genotype" + * + * @warning Use only when your solution is composed by a fitness Value and a "genotype", + * and no any other data structure. * */ template diff --git a/mo/src/explorer/moILSexplorer.h b/mo/src/explorer/moILSexplorer.h index 49d74fea5..89d7bfd47 100644 --- a/mo/src/explorer/moILSexplorer.h +++ b/mo/src/explorer/moILSexplorer.h @@ -126,7 +126,7 @@ public: //apply the local search on the copy ls(currentSol); -// std::cout << "(solution)\t" << current << std::endl; +// std::clog << "(solution)\t" << current << std::endl; }; diff --git a/mo/src/explorer/moMetropolisHastingExplorer.h b/mo/src/explorer/moMetropolisHastingExplorer.h index ea0913f1e..9716469b9 100644 --- a/mo/src/explorer/moMetropolisHastingExplorer.h +++ b/mo/src/explorer/moMetropolisHastingExplorer.h @@ -71,7 +71,7 @@ public: moMetropolisHastingExplorer(Neighborhood& _neighborhood, moEval& _eval, moNeighborComparator& _neighborComparator, moSolNeighborComparator& _solNeighborComparator, unsigned int _nbStep) : moNeighborhoodExplorer(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator), nbStep(_nbStep) { isAccept = false; if (!neighborhood.isRandom()) { - std::cout << "moMetropolisHastingExplorer::Warning -> the neighborhood used is not random" << std::endl; + std::clog << "moMetropolisHastingExplorer::Warning -> the neighborhood used is not random" << std::endl; } } diff --git a/mo/src/explorer/moNeighborhoodExplorer.h b/mo/src/explorer/moNeighborhoodExplorer.h index 8b4113b7a..2db8623ac 100644 --- a/mo/src/explorer/moNeighborhoodExplorer.h +++ b/mo/src/explorer/moNeighborhoodExplorer.h @@ -44,16 +44,16 @@ #include /** - * Explore the neighborhood according to the local search algorithm + * Explore the neighborhood according to the local search algorithm * * During this exploration, * the parameters are updated * one neighbor is selected * a comparason with the solution is made to acccept or not this new neighbor - * + * * The current neighbor (currentNeigbor) is the neighbor under consideration during the search (in operator()(EOT &)) * - * The selected neighbor (selectedNeighbor) is the neighbor selected in method operator()(EOT &). + * The selected neighbor (selectedNeighbor) is the neighbor selected in method operator()(EOT &). * If this neighbor is accepted, then the solution is moved on this neighbor (in move(EOT &)) * */ diff --git a/mo/src/explorer/moRandomBestHCexplorer.h b/mo/src/explorer/moRandomBestHCexplorer.h index 92e690e37..3e7218065 100644 --- a/mo/src/explorer/moRandomBestHCexplorer.h +++ b/mo/src/explorer/moRandomBestHCexplorer.h @@ -120,6 +120,7 @@ public: eval(_solution, currentNeighbor); //initialize the best neighbor + assert(not currentNeighbor.invalid()); bestVector.push_back(currentNeighbor); //test all others neighbors @@ -129,21 +130,37 @@ public: //eval eval(_solution, currentNeighbor); + assert(not currentNeighbor.invalid()); //if we found a better neighbor, update the best + #ifndef NDEBUG + assert(bestVector.size() > 0); + assert(not bestVector.at(0).invalid()); + if (neighborComparator(bestVector.at(0), currentNeighbor)) { + #else if (neighborComparator(bestVector[0], currentNeighbor)) { + #endif bestVector.clear(); + assert(not currentNeighbor.invalid()); bestVector.push_back(currentNeighbor); } - else if (neighborComparator.equals(currentNeighbor, bestVector[0])) //if the current is equals to previous best solutions then update vector of the best solution + //if the current is equals to previous best solutions + // then update vector of the best solution + #ifndef NDEBUG + else if (neighborComparator.equals(currentNeighbor, bestVector.at(0))) { + #else + else if (neighborComparator.equals(currentNeighbor, bestVector[0])) { + #endif + assert(not currentNeighbor.invalid()); bestVector.push_back(currentNeighbor); + } } - // choose randomly one of the best solutions - unsigned int i = rng.random(bestVector.size()); + // choose randomly one of the best solutions + unsigned int i = rng.random(bestVector.size()); - // the selected Neighbor - selectedNeighbor = bestVector[i]; + // the selected Neighbor + selectedNeighbor = bestVector[i]; } else { //if _solution hasn't neighbor, diff --git a/mo/src/explorer/moRandomNeutralWalkExplorer.h b/mo/src/explorer/moRandomNeutralWalkExplorer.h index e8f9713bf..521c357e6 100644 --- a/mo/src/explorer/moRandomNeutralWalkExplorer.h +++ b/mo/src/explorer/moRandomNeutralWalkExplorer.h @@ -73,7 +73,7 @@ public: nbStep(_nbStep) { isAccept = false; if (!neighborhood.isRandom()) { - std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random (" << neighborhood.className() << ")" << std::endl; + std::clog << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random (" << neighborhood.className() << ")" << std::endl; } } diff --git a/mo/src/explorer/moRandomWalkExplorer.h b/mo/src/explorer/moRandomWalkExplorer.h index 889382a2b..d0a84fe29 100644 --- a/mo/src/explorer/moRandomWalkExplorer.h +++ b/mo/src/explorer/moRandomWalkExplorer.h @@ -68,7 +68,7 @@ public: moRandomWalkExplorer(Neighborhood& _neighborhood, moEval& _eval) : moNeighborhoodExplorer(_neighborhood, _eval) { isAccept = false; if (!neighborhood.isRandom()) { - std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random (" << neighborhood.className() << ")" << std::endl; + std::clog << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random (" << neighborhood.className() << ")" << std::endl; } } diff --git a/mo/src/explorer/moSAexplorer.h b/mo/src/explorer/moSAexplorer.h index b774d5c57..132d584f9 100644 --- a/mo/src/explorer/moSAexplorer.h +++ b/mo/src/explorer/moSAexplorer.h @@ -72,7 +72,7 @@ public: isAccept = false; if (!neighborhood.isRandom()) { - std::cout << "moSAexplorer::Warning -> the neighborhood used is not random" << std::endl; + std::clog << "moSAexplorer::Warning -> the neighborhood used is not random" << std::endl; } } diff --git a/mo/src/sampling/moSampling.h b/mo/src/sampling/moSampling.h index 90dee4707..93ae19615 100644 --- a/mo/src/sampling/moSampling.h +++ b/mo/src/sampling/moSampling.h @@ -75,7 +75,7 @@ public: checkpoint = new moCheckpoint(*continuator); add(_stat, _monitoring); // precision of the output by default - precisionOutput = std::cout.precision(); + precisionOutput = std::clog.precision(); } /** From e5c387b5671e23e2425e45d734f047fa0417dc50 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:51:29 +0100 Subject: [PATCH 5/7] fix(eoStandardBitMutation): - Fix all operators in eoStandardBitMutation.h - Bitflip componennt was not bound, use explicit assignement of rates. - Fix normal and fast operators algorithms. Co-authored-by: Potalas --- eo/src/ga/eoStandardBitMutation.h | 174 +++++++++++++++++++----------- eo/test/t-eoFoundryFastGA.cpp | 14 +-- 2 files changed, 116 insertions(+), 72 deletions(-) diff --git a/eo/src/ga/eoStandardBitMutation.h b/eo/src/ga/eoStandardBitMutation.h index fd6e4263e..32ece1342 100644 --- a/eo/src/ga/eoStandardBitMutation.h +++ b/eo/src/ga/eoStandardBitMutation.h @@ -7,6 +7,8 @@ /** Standard bit mutation with mutation rate p: * choose k from the binomial distribution Bin(n,p) and apply flip_k(x). * + * If rate is null (the default), use 1/chrom.size(). + * * @ingroup Bitstrings * @ingroup Variators */ @@ -14,7 +16,11 @@ template class eoStandardBitMutation : public eoMonOp { public: - eoStandardBitMutation(double rate = 0.5) : + /** Constructor. + * + * @param rate mutation rate, 1/chrom.size() if ignored or zero (the default) + */ + eoStandardBitMutation(double rate = 0) : _rate(rate), _nb(1), _bitflip(_nb) @@ -22,9 +28,12 @@ class eoStandardBitMutation : public eoMonOp virtual bool operator()(EOT& chrom) { + assert(chrom.size()>0); + if(_rate == 0) { + _rate = (double) 1/chrom.size(); + } _nb = eo::rng.binomial(chrom.size(),_rate); - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. + _bitflip.number_bits(_nb); return _bitflip(chrom); } @@ -46,8 +55,7 @@ template class eoUniformBitMutation : public eoMonOp { public: - eoUniformBitMutation(double rate = 0.5) : - _rate(rate), + eoUniformBitMutation() : _nb(1), _bitflip(_nb) {} @@ -55,15 +63,13 @@ class eoUniformBitMutation : public eoMonOp virtual bool operator()(EOT& chrom) { _nb = eo::rng.random(chrom.size()); - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. + _bitflip.number_bits(_nb); return _bitflip(chrom); } virtual std::string className() const {return "eoUniformBitMutation";} protected: - double _rate; unsigned _nb; eoDetSingleBitFlip _bitflip; }; @@ -84,17 +90,21 @@ template class eoConditionalBitMutation : public eoStandardBitMutation { public: - eoConditionalBitMutation(double rate = 0.5) : + eoConditionalBitMutation(double rate = 0) : eoStandardBitMutation(rate) {} virtual bool operator()(EOT& chrom) { assert(chrom.size()>0); - this->_nb = eo::rng.binomial(chrom.size()-1,this->_rate); - this->_nb++; - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. + if(this->_rate == 0) { + this->_rate = (double) 1/chrom.size(); + } + this->_nb = 0; + while(this->_nb < 1) { + this->_nb = eo::rng.binomial(chrom.size(),this->_rate); + } + this->_bitflip.number_bits(this->_nb); return this->_bitflip(chrom); } @@ -123,12 +133,14 @@ class eoShiftedBitMutation : public eoStandardBitMutation virtual bool operator()(EOT& chrom) { assert(chrom.size()>0); - this->_nb = eo::rng.binomial(chrom.size()-1,this->_rate); + if(this->_rate == 0) { + this->_rate = (double) 1/chrom.size(); + } + this->_nb = eo::rng.binomial(chrom.size(),this->_rate); if(this->_nb == 0) { this->_nb = 1; } - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. + this->_bitflip.number_bits(this->_nb); return this->_bitflip(chrom); } @@ -142,7 +154,7 @@ class eoShiftedBitMutation : public eoStandardBitMutation * * From: * Furong Ye, Carola Doerr, and Thomas Back. - * Interpolating local and global search by controllingthe variance of standard bit mutation. + * Interpolating local and global search by controlling the variance of standard bit mutation. * In 2019 IEEE Congress on Evolutionary Computation(CEC), pages 2292–2299. * * In contrast to standard bit mutation, this operators allows to scale @@ -152,29 +164,40 @@ class eoShiftedBitMutation : public eoStandardBitMutation * @ingroup Variators */ template -class eoNormalBitMutation : public eoStandardBitMutation +class eoNormalBitMutation : public eoMonOp { public: - eoNormalBitMutation(double rate = 0.5, double variance = 1) : - eoStandardBitMutation(rate), - _variance(variance) + eoNormalBitMutation(double mean = 0, double variance = 0) : + _mean(mean), + _variance(variance), + _nb(1), + _bitflip(_nb) {} virtual bool operator()(EOT& chrom) { - this->_nb = eo::rng.normal(this->_rate * chrom.size(), _variance); - if(this->_nb >= chrom.size()) { - this->_nb = eo::rng.random(chrom.size()); + assert(chrom.size() > 0); + if(_mean == 0) { + _mean = (double) 1/chrom.size(); } - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. - return this->_bitflip(chrom); + if(_variance == 0) { + _variance = std::log(chrom.size()); + } + _nb = eo::rng.normal(_mean, _variance); + if(_nb >= chrom.size()) { + _nb = eo::rng.random(chrom.size()); + } + _bitflip.number_bits(_nb); + return _bitflip(chrom); } virtual std::string className() const {return "eoNormalBitMutation";} protected: + double _mean; double _variance; + unsigned _nb; + eoDetSingleBitFlip _bitflip; }; /** Fast mutation which size is sampled from an adaptive power law. @@ -188,11 +211,10 @@ class eoNormalBitMutation : public eoStandardBitMutation * @ingroup Variators */ template -class eoFastBitMutation : public eoStandardBitMutation +class eoFastBitMutation : public eoMonOp { public: - eoFastBitMutation(double rate = 0.5, double beta = 1.5) : - eoStandardBitMutation(rate), + eoFastBitMutation(double beta = 1.5) : _beta(beta) { assert(beta > 1); @@ -200,74 +222,96 @@ class eoFastBitMutation : public eoStandardBitMutation virtual bool operator()(EOT& chrom) { - this->_nb = powerlaw(chrom.size(),_beta); - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. - return this->_bitflip(chrom); + _nb = powerlaw(chrom.size(),_beta); + _bitflip.number_bits(_nb); + return _bitflip(chrom); } virtual std::string className() const {return "eoFastBitMutation";} protected: - - double powerlaw(unsigned n, double beta) + double powerlaw(unsigned int n, double beta) { double cnb = 0; - for(unsigned i=1; i= trigger) { + rate = static_cast(i) / static_cast(n); + break; + } + } + return eo::rng.binomial(n,rate); } + // double powerlaw(unsigned n, double beta) + // { + // double cnb = 0; + // for(unsigned i=1; i _bitflip; }; /** Bucket mutation which assign probability for each bucket + * + * @warning Highly untested code, use with caution. * * From: - * Carola Doerr, Johann Dréo, Alexis Robbes + * Carola Doerr, Johann Dreo, Alexis Robbes */ template -class eoBucketBitMutation : public eoStandardBitMutation +class eoBucketBitMutation : public eoMonOp { public: - eoBucketBitMutation(std::vector bucketsSizes, std::vector bucketValues) : - _bucketsSizes(bucketsSizes), - _bucketValues(bucketValues) - + eoBucketBitMutation(std::vector> buckets, std::vector bucketsValues) : + _buckets(buckets), + _bucketsValues(bucketsValues) { - assert(bucketsSizes.size() != bucketValues.size()); + assert(buckets.size() == bucketsValues.size()); } virtual bool operator()(EOT& chrom) { - - this->_nb = customlaw(chrom.size(), _bucketsSizes, _bucketValues); - // BitFlip operator is bound to the _nb reference, - // thus one don't need to re-instantiate. - return this->_bitflip(chrom); + _nb = customlaw(chrom.size(), _buckets, _bucketsValues); + _bitflip.number_bits(_nb); + return _bitflip(chrom); } virtual std::string className() const {return "eoBucketBitMutation";} protected: - double customlaw(unsigned n, std::vector bucketsSizes, std::vector bucketValues) + double customlaw(unsigned n, std::vector> buckets, std::vector bucketsValues) { - int targetBucketIndex = eo::rng.roulette_wheel(bucketValues); - int nb = 0; - int bucketIndex = 0; - while (nb < n && bucketIndex <= targetBucketIndex) - { - if (bucketIndex < targetBucketIndex) nb += int(n*bucketsSizes[bucketIndex]); - else nb += int(eo::rng.uniform(1, n*bucketsSizes[targetBucketIndex])); - } - if (nb > n) nb = n; - - return nb; - } + int bucketIndex = eo::rng.roulette_wheel(bucketsValues); + int startBit = buckets[bucketIndex][0]; + int endBit = buckets[bucketIndex][1]; + int gapBit = endBit - startBit; - std::vector _bucketsSizes; - std::vector _bucketValues; + int nbBits; + if (gapBit > 0) { + nbBits = rand() % gapBit + startBit; + } else { + nbBits = endBit; + } + return nbBits; + } + std::vector _bucketsValues; + std::vector> _buckets; + + unsigned _nb; + eoDetSingleBitFlip _bitflip; }; + #endif // _eoStandardBitMutation_h_ diff --git a/eo/test/t-eoFoundryFastGA.cpp b/eo/test/t-eoFoundryFastGA.cpp index 6a6ee0322..24231d639 100644 --- a/eo/test/t-eoFoundryFastGA.cpp +++ b/eo/test/t-eoFoundryFastGA.cpp @@ -30,13 +30,13 @@ eoAlgoFoundryFastGA& make_foundry(eoFunctorStore& store, eoInit& ini foundry.crossovers.add< eo1PtBitXover >(); /***** Mutations ****/ - double p = 1.0; // Probability of flipping eath bit. - foundry.mutations.add< eoUniformBitMutation >(p); // proba of flipping k bits, k drawn in uniform distrib - foundry.mutations.add< eoStandardBitMutation >(p); // proba of flipping k bits, k drawn in binomial distrib - foundry.mutations.add< eoConditionalBitMutation >(p); // proba of flipping k bits, k drawn in binomial distrib, minus zero - foundry.mutations.add< eoShiftedBitMutation >(p); // proba of flipping k bits, k drawn in binomial distrib, changing zeros to one - foundry.mutations.add< eoNormalBitMutation >(p); // proba of flipping k bits, k drawn in normal distrib - foundry.mutations.add< eoFastBitMutation >(p); // proba of flipping k bits, k drawn in powerlaw distrib + // Use defaults for all operators (usually falls back to p=1/chrom.size()). + foundry.mutations.add< eoUniformBitMutation >(); // proba of flipping k bits, k drawn in uniform distrib + foundry.mutations.add< eoStandardBitMutation >(); // proba of flipping k bits, k drawn in binomial distrib + foundry.mutations.add< eoConditionalBitMutation >(); // proba of flipping k bits, k drawn in binomial distrib, minus zero + foundry.mutations.add< eoShiftedBitMutation >(); // proba of flipping k bits, k drawn in binomial distrib, changing zeros to one + foundry.mutations.add< eoNormalBitMutation >(); // proba of flipping k bits, k drawn in normal distrib + foundry.mutations.add< eoFastBitMutation >(); // proba of flipping k bits, k drawn in powerlaw distrib for(size_t i=1; i < 11; i+=1) { foundry.mutations.add< eoDetSingleBitFlip >(i); // mutate k bits without duplicates } From dcac78cdf5ef27ddb33902ae8e94e651e2679fa7 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:54:18 +0100 Subject: [PATCH 6/7] fix(mo): missing include --- mo/src/explorer/moRandomBestHCexplorer.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mo/src/explorer/moRandomBestHCexplorer.h b/mo/src/explorer/moRandomBestHCexplorer.h index 3e7218065..bac6cc66b 100644 --- a/mo/src/explorer/moRandomBestHCexplorer.h +++ b/mo/src/explorer/moRandomBestHCexplorer.h @@ -35,11 +35,13 @@ #ifndef _moRandomBestHCexplorer_h #define _moRandomBestHCexplorer_h +#include +#include + #include #include #include #include -#include #include /** From 1c853ecdb95f9c99b42c6fcb62725d79487371ea Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:54:45 +0100 Subject: [PATCH 7/7] revert 399b22266 (virtual fitness interface temptative) Incompatible with MOEO's change of interface. --- eo/src/EO.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index f0e5213ac..a2c3b490a 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -72,7 +72,9 @@ public: virtual ~EO() {}; /// Return fitness value. - virtual const Fitness& fitness() const { + // virtual const Fitness& fitness() const { // This would be impossible with MOEO. + // virtual Fitness fitness() const { // Cannot do that either, MOEO changes the interface. + Fitness fitness() const { if (invalid()) throw eoInvalidFitnessError("Cannot retrieve unevaluated fitness"); return repFitness; @@ -91,7 +93,7 @@ public: /** Set fitness. At the same time, validates it. * @param _fitness New fitness value. */ - virtual void fitness(const Fitness& _fitness) + void fitness(const Fitness& _fitness) { repFitness = _fitness; invalidFitness = false;