From 3b7ffbbfae845c27d2846c7462b9435ed365f4bb Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 31 Jan 2022 20:14:38 +0100 Subject: [PATCH 01/69] fix Ubuntu-related memory allocation bug --- eo/contrib/irace/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eo/contrib/irace/CMakeLists.txt b/eo/contrib/irace/CMakeLists.txt index 1c713bf5b..bee473be7 100644 --- a/eo/contrib/irace/CMakeLists.txt +++ b/eo/contrib/irace/CMakeLists.txt @@ -70,10 +70,9 @@ endif() ###################################################################################### add_executable(fastga fastga.cpp) -# target_link_libraries(fastga ${PARADISEO_LIBRARIES} ${IOH_LIBRARY} stdc++fs) -target_link_libraries(fastga ${PARADISEO_LIBRARIES} fmt) +# Link to stdc++fs at the end because of an Ubuntu bug, see: https://stackoverflow.com/a/57760267 +target_link_libraries(fastga ${PARADISEO_LIBRARIES} fmt stdc++fs) add_executable(onlymutga onlymutga.cpp) -# target_link_libraries(onlymutga ${PARADISEO_LIBRARIES} ${IOH_LIBRARY} stdc++fs) target_link_libraries(onlymutga ${PARADISEO_LIBRARIES} fmt) From 1f1f59831472412d092400be8998c5c4775e8e0d Mon Sep 17 00:00:00 2001 From: AI Xin Date: Sun, 8 May 2022 18:59:34 +0800 Subject: [PATCH 02/69] add mo tutorial doc in Markdown format The original tutorial link[http://paradiseo.gforge.inria.fr/index.php?n=Doc.Tutorials] is broken. I found the archive from here: https://web.archive.org/web/20210119160107/http://paradiseo.gforge.inria.fr/index.php?n=Doc.Tutorials --- mo/tutorial/Lesson1/README.md | 448 ++++++++++++++++++ mo/tutorial/Lesson1/schemaLS.jpg | Bin 0 -> 30185 bytes mo/tutorial/Lesson2/README.md | 124 +++++ mo/tutorial/Lesson3/README.md | 110 +++++ mo/tutorial/Lesson4/README.md | 67 +++ mo/tutorial/Lesson5/README.md | 64 +++ mo/tutorial/Lesson6/README.md | 250 ++++++++++ .../Lesson6/multimodalFitnessLandscape.jpg | Bin 0 -> 19455 bytes mo/tutorial/Lesson7/README.md | 60 +++ 9 files changed, 1123 insertions(+) create mode 100644 mo/tutorial/Lesson1/README.md create mode 100755 mo/tutorial/Lesson1/schemaLS.jpg create mode 100644 mo/tutorial/Lesson2/README.md create mode 100644 mo/tutorial/Lesson3/README.md create mode 100644 mo/tutorial/Lesson4/README.md create mode 100644 mo/tutorial/Lesson5/README.md create mode 100644 mo/tutorial/Lesson6/README.md create mode 100755 mo/tutorial/Lesson6/multimodalFitnessLandscape.jpg create mode 100644 mo/tutorial/Lesson7/README.md diff --git a/mo/tutorial/Lesson1/README.md b/mo/tutorial/Lesson1/README.md new file mode 100644 index 000000000..466986cd3 --- /dev/null +++ b/mo/tutorial/Lesson1/README.md @@ -0,0 +1,448 @@ +# How to implement your first hill-climber algorithm? +This lesson will let you +* Run your first simple Hill-Climber within MO library +* Learn the main principles of MO +* Browse through the code of these algorithm +* Run other kind of Hill-Climbers: first-improvment, random best, neutral hill-climbers. +* Design your own evaluation functions +* Add your own stopping criteria + +## 1. I want to run my first hill-climber! +If you followed the the Install instructions, all examples would be compiled. If it is not the case, refer to the above instructions. + +You can run your hill-climber. From the "build/mo/tutorial/Lesson1" directory, type: +```shell +./lesson1_simpleHC -V=20 +``` +Great! A very simple hill-climber had solved the oneMax problem (which maximizes the number of ones in the bit string) for the bit strings of size 20. On your output screen, you can see on the first line the random initial solution, and the second line, the final solution which is (I hope) the bit string of size 20 with all ones. For example: +```text +initial: 6 20 00010000011000100101 +final: 20 20 11111111111111111111 +``` +The first number is the fitness of the solution, the second the size of the bit string and following all the bits of the solution. + +## 2. The main principles of MO +In MO a local search is defined by this schema: + +![](./schemaLS.jpg) + +At each iteration, from the current solution: +* Generate neighbors from the neighborhood and evaluate them +* Select a neighbor +* Decide to replace solution by the selected neighbor + +Like in paradisEO-eo, MO separates the representation-dependent part (represention of solution, neighbor, evaluation) from the generic part (the order of neighbors generation, selection, replacement, etc.). + +So, to define a local search, it is necessary to define: +* the solution representation, +* the neighbor representation, +* the evaluation function of a solution, +* the evaluation function of a neighbor, +* the neighborhood (generation of the neighbors) + +If you can define the representation-dependent part of your problem, you can use all local search algorithms from MO (Hill-climbing, simulated annealing, tabu search, iterated local search, variable neighborhood search, and more) and even combined them with evolutionary algorithms ! + +Of course a lot of classical representations, neighborhoods and problems are already defined in MO. They will be explained all along this tutorial. +Let's first have a look on the oneMax problem solved by a simple Hill-Climber algorithm defined as follows: +```text +Choose randomly initial solution x +Do + best <- first neighbor of x + For all y in the neighborhood of x + If (f(y) > f(best)) + best <- y + endif + endfor + If (f(x) < f(best)) + x <- best + continue <- true + else + continue <- false + endif + While continue == true +``` + +The simple HC stops on local optima when no improvement can not be made. + +## 3. Browsing the code + +Now let's have a look on the code. All the elements of the simple HC are already defined in the MO framework, and the code only puts all this bricks together. The code following the previous general principles. It defines the solution and neighbor representation, the solution and neighbor evaluation, the neighborhood, and the local search used. +Please, open the file "mo/tutorial/Lesson1/lesson1_simpleHC.cpp", and follow me in the code: + +### 1. The includes part: + +The general includes for the c++ stdlib streams: +```c++ +#include +#include +#include +#include +#include +``` + +This includes for eo which contains all include files of EO: +```c++ +#include +``` + +The first line to include the bit string representation defined in eo, and the second one to include the bit string neighbor representation. All classical problem-dependent part of MO are defined in the sub-directory "problems". How to define your representation is explained in EO tutorial, and how to design your neighbor will be explain in the next lesson 2. Here just use it. +```c++ +#include +#include +``` + +This includes the evaluation function of a solution (full evaluation), the incremental evaluation of a neighbor for the oneMax problem, and a possible evaluation of neighbor using the full evaluation. You will learn at the end how to define your evaluations. +```c++ +#include +#include +#include +``` + +This neighborhood visits all bit string at Hamming distance 1 in increasing order of bit index from bit 0 to bit vecSize-1. All the neighborhoods are included in the "neighborhood" directory. +```c++ +#include +``` + +Now we can include the simple hill-climbing local search. All local search algorithms are included in the "algo" directory. +```c++ +#include +``` + +### 2. The typedef part: + +EO can apply an evolutionary algorithm on any type of solution. So, all EO classes are parametrized by the type of solutions, and it is useful to use a synonym (with a typedef) of the solution's type. +MO can apply an local search algorithm on any type of solution and neighbor. So, for the same reason, all classes of MO are parametrized by the neighbor's type. In the neighbor class, the solution's type is defined. More precision on the neighbor design will be given in the lesson 2. +Here the solution representation is a bit string and the neighbor representation is related to a bit string solution and Hamming distance 1 (only 1 bit can be flipped), both using an "unsigned int" fitness value. +```c++ +typedef eoBit Indi; +typedef moBitNeighbor Neighbor; +``` + +### 3. Object definition part: + +Follows the main function "main_function" where all useful objects are defined.\\ +First, a code to parse the command line and a file. It gives the value of the random seed and the size of bit string. The lesson 3 of EO tutorial gives more precision on this code. Here we have only to understand that the variables "seed" and "vecSize" are initialized. +```c++ +eoParser parser(argc, argv); + +eoValueParam seedParam(time(0), "seed", "Random number seed", 'S'); +parser.processParam( seedParam ); +unsigned seed = seedParam.value(); + +// length of the bit string +eoValueParam vecSizeParam(8, "vecSize", "Genotype size", 'V'); +parser.processParam( vecSizeParam, "Representation" ); +unsigned vecSize = vecSizeParam.value(); +(...) +``` + +To seed the random seed (see lesson 1 of EO tutorial for more precision): +```c++ +rng.reseed(seed); +``` + +The definition the initialization of solutions is not defined is MO but in EO. The "eoInitFixedLength" is a class that makes a random intialization of bit string of a given length. Each bit is true with 1/2 rate. You can see the lesson 1 of EO tutorial lesson 1 for more precision. +```c++ +eoUniformGenerator uGen; +eoInitFixedLength random(vecSize, uGen); +``` + +The fitness function of the oneMax problem is the number of 1 in the bit string. It is already defined in MO: +```c++ +oneMaxFullEval fullEval; +``` + +A neighbor is not necessary a modified copy of the solution. But often a neighbor defines how to move, i.e. how to modify a solution to compute the neighbor. For example, for the bit string, a neighbor indicates which bit is flipped. +In the same way, it is often possible to define the incremental evaluation of a neighbor knowing the modification (the move). +The incremental evaluation for the oneMax problem is already defined and adds +1 or -1 at the fitness value according to the flipped bit. +```c++ +moOneMaxIncrEval neighborEval; +``` + +When the incremental evaluation can not be defined. The neighbor can be evaluated with the full evaluation. First the solution is modified on the neighbor, than the full evaluation is computed on it and then the solution is move back. This is done by the class "moFullEvalByModif". If you want you to test it comment the line with moOneMaxIncrEval and uncomment the line with moFullEvalByCopy: +```c++ +// moFullEvalByModif neighborEval(fullEval); +``` + +For the simple hill-climbing, all the neighbors are explored in increasing order of their bit flip. So, you can use the class "moOrderNeighborhood" where the size of the neighborhood has to be precise in the constructor: +```c++ +moOrderNeighborhood neighborhood(vecSize); +``` + +All representation-dependent part is now defined, so the simple Hill-Climbing can be defined. The constructor needs the neighborhood, the solution and neighbor evaluations. The solution and neighbor representation are defined by the template of the class: +```c++ +moSimpleHC hc(neighborhood, fullEval, neighborEval); + +``` + +### 4. The execution of hill-climbing part: + +Always in the "main_function" function, it is the execution part. +In MO, the local search algorithm never initializes the solution. It must be made outside the local search algorithm. This allows to combine local search algorithms with evolutionary algorithms or with others local search algorithms. +Now apply your local search on the solution as follows: +```c++ +// The current solution +Indi solution; + +// random initialization +random(solution); + +// Evaluation of the intial solution: +// can be evaluated here, or else it will be done at the beginning of the local search +fullEval(solution); + +// output: the initial solution +std::cout << "initial: " << solution << std::endl ; + +// apply the local search on the solution ! +hc(solution); + +// output: the final solution +std::cout << "final: " << solution << std::endl ; +``` + +The main line is "hc(solution)" which apply the local search on the solution. +Easy, isn't it? + +## 4. Others hill-climbing algorithms + +You may think that the simple hill-climbing is not the hill-climbing you need because you don't want to explore all the neighborhood or because there is several solutions with the same fitness value. + +You may want to implement the first improvement hill-climbing defined as follows: +```text +Choose randomly initial solution x +Do + y <- not visited random neighbor of x + If (f(x) < f(y)) + x <- y + else + y.visited <- true + endif + While number of non visited neighbor of x > 0 +``` + +In the first improvement HC, if the fitness of a random neighbor is higher than the current fitness, the neighbor is selected. And this hill-climber stops on local optima when no more fitness improvement can be made in the neighborhood. + +To implement the first improvement HC, you have to change only 2 lines in the previous code. +The one to change the neighborhood generation: +```c++ +moRndWithoutReplNeighborhood neighborhood(vecSize); +``` +In this neighborhood, the neighbors are generated in an randomly order (not from 0 to vecSize-1) without replacement which means that the neighbors are generated only once. + +And of course, the other one to change the local search algorithm: +```c++ +moFirstImprHC hc(neighborhood, fullEval, neighborEval); +``` + +The corresponding include files have to be changed too. See and run the code "mo/tutorial/Lesson1/lesson1_firstImprHC.cpp". + +For a hill-climbing which takes care on the solutions with equal fitness value such as this one: +```text +Choose randomly initial solution x +Do + bestVect <- [ first neighbor of x ] + For all y in the neighborhood of x + If (f(y) > f(bestVect.first)) + bestVect <- [ y ] + else if (f(y) == f(bestVect.first) and y != bestVect.first) + bestVect.push_back(y) + endif + endfor + If (f(x) < f(bestVect.first)) + x <- choose randomly a solution from bestVect + continue <- true + else + continue <- false + endif + While continue == true +``` + +You only have to change the local search algorithm by (see the code in mo/tutorial/Lesson1/lesson1_randomBestHC.cpp) : +```c++ +moRandomBestHC hc(neighborhood, fullEval, neighborEval); +``` + +Easy, isn't it? + +And if you don't want that your hill-climber stops if there is some solution with the same fitness in the neighborhood like this: +```text +nbStep <- 0 +Choose randomly initial solution x +Do + bestVect <- [ first neighbor of x ] + For all y in the neighborhood of x + If (f(y) > f(bestVect.first)) + bestVect <- [ y ] + else if (f(y) == f(bestVect.first)) + bestVect.push_back(y) + endif + endfor + If (f(x) <= f(bestVect.first)) + x <- choose randomly a solution from bestVect + continue <- true + else + continue <- false + endif + nbStep <- nbStep + 1 + While continue == true and nbStep > nbStepMax +``` + +This hill-climber stops on strict local optima, but not plateau which are local optima. So, another parameter is need to stop the algorithm (nbStepMax). Then you only have to change the local search algorithm by (see the code in Lesson1/lesson1_neutralHC.cpp) : +```c++ +moNeutralHC hc(neighborhood, fullEval, neighborEval, nbStepMax); +``` + +Easy, isn't it? + +## 5. Define your evaluation + +### 1. Evaluation of solutions: +You can learn to define your fitness function in the EO tutorial lesson 1. But let's me shortly explain how to do. +You have to define a class inherited from the "eoEvalFunc". For example, the oneMaxFullEval is defined as follows: +```c++ +#include +template< class EOT > +class oneMaxFullEval : public eoEvalFunc +{ +public: + + /** + * Count the number of 1 in a bitString + * @param _sol the solution to evaluate + */ + void operator() (EOT& _solution) { + unsigned int sum = 0; + for (unsigned int i = 0; i < _solution.size(); i++) + sum += _solution[i]; + _solution.fitness(sum); + } +}; +``` + +The file "eoEvalFunc.h" must be included at the begining. The class "oneMaxFullEval" inherits from the "eoEvalFunc" class. Like all class in EO, the classes are templatized by the solution type "EOT". +EO uses a functor style: the fitness function is computed in the method "operator()(EOT& _sol)". Do what you want to compute the fitness value in this method, and puts the fitness value in the solution at the end by using its method "fitness": +```c++ +_solution.fitness( fitnessValue ); +``` + +The "eoBit" class is vector of boolean. The size of the vector is obtained by the method "size()": +```c++ +_solution.size() +``` +and the value of the ith bit is given by the classical method "operator[]": +```c++ +_solution[i] +``` +The fitness value of a solution can be obtained with the method "fitness()": +```c++ +_solution.fitness() +``` + +### 2. Evaluation of neighbors: +MO uses the same idea to evaluate a neighbor. You have to define a class which inherits from "moEval" class. For example, the oneMaxIncrEval is defined as follows: +```c++ +#include +template< class Neighbor > +class moOneMaxIncrEval : public moEval +{ +public: + + typedef typename Neighbor::EOT EOT; + + /* + * incremental evaluation of the neighbor for the oneMax problem + * @param _solution the solution to move (bit string) + * @param _neighbor the neighbor to consider (of type moBitNeigbor) + */ + virtual void operator()(EOT & _solution, Neighbor & _neighbor) { + if (_solution[_neighbor.index()] == 0) + _neighbor.fitness(_solution.fitness() + 1); + else + _neighbor.fitness(_solution.fitness() - 1); + } +}; + +``` + +The file "moEval.h" must be included at the begining. All class to define evalutation function are in the "eval" directory of MO. The class "oneMaxIncrEval" inherits from the "moEval" class. Like all class in MO, the classes are templatized by the neighbor's type "Neighbor". +A typedef is defined to easily have access to the solution type "EOT". The solution type is the type "EOT" in the class of Neighbor: +```c++ +typedef typename Neighbor::EOT EOT; +``` + +MO also uses a functor style: the evaluation function is computed in the method "operator()(EOT& _solution, Neighbor & _neighbor)" which depends on the current solution and its neighbor to consider. Do what you want to compute the fitness value of the neighbor in this method, and puts the fitness value in the neighbor by using its method "fitness": +```c++ +_neighbor.fitness( fitnessValue ); +``` + +The "moBitNeighbor" has a method "index()" which gives the number of flipped bit. When the flipped bit of the solution is set to "0" the number of 1 in the neighbor is increased by one, and decreased by one otherwise. +When it is possible the incremental evaluation of neighbor gives a better complexity. For example the full evaluation needs vecSize comparisons, and the incremental evaluation only one comparison. +This prototypical example helps you to define your own solution and neighbor evaluations ! + +### 6. Use your stopping criteria + +All local search algorithms have their own stopping criteria, but it is possible to add other stopping criteria. The predefined stopping criteria you can add are: +* stop on the number of iterations +* stop on the number of full evaluation +* stop on the number of neighbor evaluation +* stop on the fitness value reached +* stop on a time limit + +All criteria inherit from the class "moContinuator" in the directory "continuator". To use one of them, you have to include the correct file, to define your object from the class and add the continuator to the local search constructor. +For example, to add a maximum number of iteration to your simple hill-climber. First include the correct file: +```c++ +#include +``` + +Define an object from the class: +```c++ +moIterContinuator continuator(iterMax); +``` + +And add the continuator in the constructor of the HC: +```c++ +moSimpleHC hc(neighborhood, fullEval, neighborEval, continuator); +``` + +Examples on all continuators are given in the source codes "lesson1_iterContinuator.cpp", "lesson1_fitContinuator.cpp", "lesson1_fullevalContinuator.cpp", "lesson1_evalContinuator.cpp". + +It is also possible to combine several continuators with the class "moCombinedContinuator.h" as follows: +```c++ +moIterContinuator iterCont(iterMax); +moFitContinuator fitCont(fitnessMax); +moFullEvalContinuator fullevalCont(fullEval, fullevalMax); +moNeighborEvalContinuator evalCont(neighborEval, evalMax); + +moCombinedContinuator continuator(iterCont); +continuator.add(fitCont); +continuator.add(fullevalCont); +continuator.add(evalCont); +``` + +The local search stops when one of the continuators is false. +Easy, isn't it? + +Of course, you can define your own continuator. You must inherit your own class from the "moContinuator" class. Then 2 methods must be defined: +* the test method: + ```c++ + virtual bool operator()(EOT & _solution) + ``` + + The returned value is true when the local search can continue for the next iteration, and false otherwise. + +* the intialisation method: + ```c++ + virtual void init(EOT & _solution) + ``` + Something you want to initialize before starting the local search (for example a counter). + The predefined continuator can help you to define your own continuator. Have fun now! + +## 7. Exercices + +1. Define the evaluation function and the incremental evaluation of the Royal Road problem. And run a first-improvement hill-climber on it! + + The Royal Road is defined in this paper: + "[The Royal Road for Genetic Algorithms: Fitness Landscapes and GA Performance](http://web.cecs.pdx.edu/~mm/handbook-of-ec-rr.pdf)" Mitchell, Forerest, Holland. + +2. Define the evaluation function and the incremental evaluation of the MAX-SAT problem. And run a first-improvement hill-climber on it! \ No newline at end of file diff --git a/mo/tutorial/Lesson1/schemaLS.jpg b/mo/tutorial/Lesson1/schemaLS.jpg new file mode 100755 index 0000000000000000000000000000000000000000..701b9dc7f855c517e2468ba19164aec92f0a8efb GIT binary patch literal 30185 zcmb@tQ*F?e<#(6vE;lEW6 zYt*P(v+AKnVa>TdS3iFPkU`>7;s6K;2!Q0j3i#Xri2T?3AC><={zm}+Ie+#6P~ZUb z5MxjfBmhVh2q+YY&p`ko00IC70f2=1x8VP;z`-NH!hC^({tEfu05)U*;0qK00vZw$ z0tyNW2JmkzG|U%R00bO73Mv{p0tS#6lZ2ERi;R^;$N-yL*rn~C7v4WO2$=tk`41Wz z>Yo=J1mwS7K9ql*00<~ZXlN*Cgn!cm{!IY+AL>6uVmNeWAq)~l15y?TAZC0%tFVZ& zp`(97{U4)%f}78Ez_di0`ckbFb zs>Dg%>X5~igJ z;k6l2Xq>bGDGv7(M2FZZD>T znBiR5Bz$x8&fIBO^y|f1aa$r$d=u8PgL#aSuZAXlRE<2Kz8Y0k@tjQUUSDSP6A%;M zR16abU-z`Q@A-t$@#HE43Hu_VyeIWazi(s9bH-KAR4NhMz|dDAU7t z%1oBw?I^b;Uq6Y6@p&UJp5h(MK}faO+}PONQS;C_u?RKs{jo)F;?W~Vi$E*49@ z>nVJ!R$j4|0wRHFRj+He&%v|om^RPhrf|0fJ8$3bWxfZdOc2fMLt;ivk9z$v^g;`{gcS`qpY#sBKrjc* zm=g0WlAbrvV5~5c{*a`)M1umh*b-NH7nf##9ic3rJSr{a`3G)RN^q_iZe>8vzP`CMkff*x!>b^5Nb_2r`@xu+D_Gs;;woFF6Fa<{!P}UMqjaNAjHI{4$=h|MQLkcUz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/Lesson2/README.md b/mo/tutorial/Lesson2/README.md new file mode 100644 index 000000000..8d5d8aba0 --- /dev/null +++ b/mo/tutorial/Lesson2/README.md @@ -0,0 +1,124 @@ +# How to implement and use neighborhoods +In this lesson, you will learn how to implement a neighbor, neighborhood and the evaluation function. Two ways will be show, one generic and one using an indexed neighborhoods. As an example, it will be illustrated on the Queens problem. + +1. Classical neighborhoods (example with a swap operator) +2. Indexed neighbordhoods (example with a shift operator) +3. Evaluation of neighbors +4. Exercise + +## 1. Classical neighborhoods (example with a swap operator) + +### Implementation +To implement a neighborhood for your problem, you must have a class that inherits from "moNeighborhood" and a class that inherits from "moNeighbor" for the corresponding neighbors. As a consequence, in the neighborhood class, you have to implement the following methods: + +hasNeighbor (test if there is at least one valid neighbor) +init (init the first neighbor) +cont (test if there is again a valid neighbor) +next (compute the next valid neighbor) +And in the neighbor class: + +move (how to apply the move corresponding to the neighbor on a solution) +### Example +In the "paradiseo-mo/src/problems/permutation" directory, classical neighborhood and neighbor for swap operator (moSwapNeighborhood.h and moSwapNeighbor.h) are defined. Some methods are specific to the swap operator and you can see a "move_back" methods that is explained at the end of this tutorial. + +In "mo/tutorial/Lesson2" directory, open the source file "testNeighborhood.cpp". You can see how to use this first neighborhood... + +After inclusion, useful types are defined for more lisibility: + +Define type of representation +```c++ +typedef eoInt Queen; +``` +Define type of a swap neighbor +```c++ +typedef moSwapNeighbor swapNeighbor; +``` +Define type of the swap neighborhood +```c++ +typedef moSwapNeighborhood swapNeighborhood; +``` +And in the "main" fonction, a neighborhood, a solution and a neighbor are declared: +```c++ +swapNeighborhood swapNH; +Queen solution; +swapNeighbor n1; +``` + +Then they are used to explore and print all the neighbors of the neighborhood for a Queen problem of size 8 (swapEval is the evaluation function declared previously) +```c++ +swapNH.init(solution, n1); +swapEval(solution,n1); +n1.print(); +while(swapNH.cont(solution)){ + swapNH.next(solution, n1); + swapEval(solution,n1); + n1.print(); +} +``` + +You can run the executable on the lesson 2 directory and see the output (the beginning). + +## 2. Indexed neighbordhoods (example with a shift operator) + +### Implementation +Three indexed neighborhoods are already defined in Paradiseo-MO. To use them you have to know the size of your neighborhoods and define a mapping that associates a neighbor from a known key, in your class neighbor. This neighbor must inherit from "moIndexNeighbor". + +### Example +In the mo/src/problems/permutation" directory, a neighbor for shift operator (moShiftNeighbor.h) is defined. In this class, the mapping is done in the method "translate". + +After inclusion useful types are defined for more lisibility: + +Define type of a shift neighbor +```c++ +typedef moShiftNeighbor shiftNeighbor; +``` +Define three different indexed neighborhoods for shift operator +```c++ +typedef moOrderNeighborhood orderShiftNeighborhood; +typedef moRndWithoutReplNeighborhood rndWithoutReplShiftNeighborhood; +typedef moRndWithReplNeighborhood rndWithReplShiftNeighborhood; +``` + +And in the "main" fonction, a shift neighbor and the three indexed neighborhoods are declared: +```c++ +shiftNeighbor n2; +orderShiftNeighborhood orderShiftNH(pow(vecSize-1, 2)); +rndWithoutReplShiftNeighborhood rndNoReplShiftNH(pow(vecSize-1, 2)); +rndWithReplShiftNeighborhood rndReplShiftNH(pow(vecSize-1, 2)); +``` + +Exploration of the neighborhoods is done like with a classical neighborhood. + +You can run the executable on the lesson 2 directory and see the output. + +## 3. Evaluation of neighbors + +There are three ways to evaluate a neighbor: + +1. Incremental evaluation +2. Full evaluation by modification +3. Full evaluation by copy + +In terms of performance, it is more efficient to use incremental evaluation and if it cannot be defined, full evaluation by modification is better than that one by copy. + +### Incremental evaluation +To implement an incremental evaluation, you have to create a class which inherits of "**moEval**". So you have to define the method: +```c++ +void operator()(EOT&, Neighbor&){ ... } +``` +EOT and Neighbor are respectively the templates for a solution and a neighbor. + +### Full evaluation +The two full evaluations are already defined in Paradiseo-MO. The full evaluation by modification applies the move on the initial solution, evaluates the obtained solution and affects the fitness value to the neighbor. Then the "moveBack" is applied to come back to the initial solution. On the other hand, the full evaluation by copy applies the move on a temporary copy of the solution, evaluates it and affects the fitness value to the neighbor. + +To use these evaluations, you need your classical full evaluation function ("eoEvalFunc") in the constructors: +```c++ +moFullEvalByCopy(eoEvalFunc& _eval) +moFullEvalByModif(eoEvalFunc& _eval) +``` + +Be carefull, if you want to use the class "moFullEvalByModif", your neighbor must be "backable" and so it has to inherit of the class "**moBackableNeighbor**" and consequently to have a method "moveBack". + +## 4. Exercise + +Try to define an indexed swap neighbor like in the file "moShiftNeighbor.h". Then explore and print the neighborhood randomly. \ No newline at end of file diff --git a/mo/tutorial/Lesson3/README.md b/mo/tutorial/Lesson3/README.md new file mode 100644 index 000000000..ea68ad686 --- /dev/null +++ b/mo/tutorial/Lesson3/README.md @@ -0,0 +1,110 @@ +# Lesson3 - How to use Simulated Annealing and Checkpointing +In this lesson, a simple simulated annealing is presented, using an order neighborhood based on a shift operator, to solve the Queen problem. Then, a checkpoint will be used to save some informations during the search. + +1. Simulating Annealing on the Queen problem. +2. Checkpointing +3. Avalaible statistics in MO +4. Exercise + +## 1. Simulating Annealing (example on the Queen problem) + +First you have to define the representation of a Queen, how to initialize and evaluate it. So you have to declare three classes: +```c++ +queenFullEval fullEval; +eoInitPermutation init(vecSize); +Queen solution1; +``` + +Then, you have to ramdomly intialize and evaluate the solution: +```c++ +init(solution1); +fullEval(solution1); +``` + +Let see the most simple constructor of a Simulated Annealing (in algo/moSA.h). You need three parameters: +* a neighborhood +* a full evaluation function (declared before) +* a neighbor's evaluation function +```c++ +moFullEvalByCopy shiftEval(fullEval); +rndShiftNeighborhood rndShiftNH(pow(vecSize-1, 2)); +``` + +You can now declare the Simulated Annealing: +```c++ +moSA localSearch1(rndShiftNH, fullEval, shiftEval); +``` +This simple constructor uses by default three components: +* moSimpleCoolingSchedule (with default parameters) +* moSolNeighborComparator +* moTrueContinuator + +More flexible constructors exist in which you can change these components. In the following, the "moTrueContinuator" is replaced by a "moCheckpoint". + +You can try this first algorithm with different problem sizes (use parameter file or the option --vecSize=X on command line to execute "testSimulatedAnnealing"). It prints the initial and final solution1. + +## 2. Checkpointing (example on the Queen problem) + +The class "moCheckpoint" inherits of the abstract class "moContinuator" and allows to incorporate one or many "moContinuator" classes (Composite pattern). It also allows to incorporate many "eoMonitor", "eoUpdater" and "moStatBase" classes. + +Here, an example of checkpointing is presented, including: +* a continuator returning always true (moTrueContinuator) +* a monitor saving information in a file (eoFileMonitor) +* an updater using the file monitor with a determinated frequency (moCounterMonitorSaver) +* a very simple statistical operator giving only the fitness of the current solution (moFitnessStat) + +First, you have to define the "moTrueContinuator" and build the "moCheckpoint": +```c++ +moTrueContinuator continuator; +moCheckpoint checkpoint(continuator); +``` + +Then, create the "moFitnessStat" and add it in the checkpoint: +```c++ +moFitnessStat fitStat; +checkpoint.add(fitStat); +``` + +Finally, create the "eoFileMonitor" to write fitness values in the file fitness.out and the "moCounterMonitorSaver" to use the file monitor only for each 100 iterations. +```c++ +eoFileMonitor monitor("fitness.out", ""); +moCounterMonitorSaver countMon(100, monitor); +checkpoint.add(countMon); +monitor.add(fitStat); +``` + +So you can create a Simulated Annealing with this checkpoint: +```c++ +moSA localSearch2(rndShiftNH, fullEval, shiftEval, coolingSchedule, solComparator, checkpoint); +``` + +Try this second algorithm with different problem sizes (use parameter file or the option --vecSize=X on command line to execute "testSimulatedAnnealing"). It prints the initial and final solution2 and you can see the evolution of fitness values in the file fitness.out (only 1 value each 100 iterations). + +## 3. Avalaible statistics + +A lot of statistics are avalaible to have informations during the search: + +* moCounterStat +* moMinusOneCounterStat +* moStatFromStat +* moFitnessStat +* moNbInfNeighborStat +* moNbSupNeighborStat +* moNeutralDegreeNeighborStat +* moSizeNeighborStat +* moNeighborhoodStat +* moDistanceStat +* moSolutionStat +* moBestSoFarStat +* moSecondMomentNeighborStat +* moMaxNeighborStat +* moMinNeighborStat +* moNeighborBestStat +* moNeighborFitnessStat +* moAverageFitnessNeighborStat +* moStdFitnessNeighborStat + +## 4. Exercise + +1. Try to add the cooling schedule parameters into the parameters file. Then, try the simulated annealing with different parameters to see theirs impacts on the search. +2. Add an existed operator (in continuator directory) to print the solution each 100 iterations. \ No newline at end of file diff --git a/mo/tutorial/Lesson4/README.md b/mo/tutorial/Lesson4/README.md new file mode 100644 index 000000000..c416fbd1a --- /dev/null +++ b/mo/tutorial/Lesson4/README.md @@ -0,0 +1,67 @@ +# How to use Tabu Search +In this lesson, a simple tabu search is presented, using an order neighborhood based on a shift operator, to solve the Queen problem. +1. Tabu Search on the Queen problem. +2. Exercise + +## 1. Tabu Search (example on the Queen problem) + +First you have to define the representation of a Queen, how to initialize and how to evaluate it. So you have to declare three classes: +```c++ +queenFullEval fullEval; +eoInitPermutation init(vecSize); +Queen sol1; +``` + +Then, you have to ramdomly intialize a solution: +```c++ +init(sol1); +fullEval(sol1); +``` + +Let see the most simple constructor of a Tabu Search (in mo/src/algo/moTS.h). You need five parameters: + +* a neighborhood +```c++ +orderShiftNeighborhood orderShiftNH(pow(vecSize-1, 2)); +``` +* a full evaluation function (declared before) +* a neighbor evaluation function* +```c++ +moFullEvalByCopy shiftEval(fullEval); +``` +* a time limit for the search (in seconds) +* a size for the tabu list + +You can now declare the Tabu Search: +```c++ +moTS localSearch1(orderShiftNH, fullEval, shiftEval, 2, 7); +// 2 is the time limit, 7 is the size of the tabu List +``` + +This simple constructor uses by default seven components: +* moTimeContinuator +* moNeighborComparator +* moSolNeighborComparator +* moNeighborVectorTabuList +* moDummyIntensification +* moDummyDiversification +* moBestImprAspiration + +More flexible constructors exist as you can change these components: +```c++ +moNeighborVectorTabuList tl(sizeTabuList,0); +moTS localSearch2(orderShiftNH, fullEval, shiftEval, 3, tl); +// 3 is the time limit +``` +In this one, the tabuList has been specified. +```c++ +moTS localSearch3(orderShiftNH, fullEval, shiftEval, + comparator, solComparator, continuator, tl, inten, div, asp); +``` +In this one, comparators, continuator, tabu list, intensification strategy, diversification strategy and aspiration criteria have been specified. + +You can test these three algorithms by changing problem sizes, time limit and the size of tabu list (use parameters file or the option --vecSize=X, --timeLimit=Y and --sizeTabuList=Z on command line to execute "testSimpleTS"). It prints the initial and final solutions. + +## 2. Exercise + +1. Try to implement and use a diversification strategy in 'testSimpleTS". You can also use a predifined strategy: moMonOpDiversification (in "memory" directory) \ No newline at end of file diff --git a/mo/tutorial/Lesson5/README.md b/mo/tutorial/Lesson5/README.md new file mode 100644 index 000000000..8a684df71 --- /dev/null +++ b/mo/tutorial/Lesson5/README.md @@ -0,0 +1,64 @@ +# How to use Iterated Local Search +In this lesson, an Iterated Local Search is presented. The Tabu Search of the Lesson 4 is used with an order neighborhood based on a shift operator, to solve the Queen problem. + +1. Iterated Tabu Search on the Queen problem. +2. Exercise + +## 1. Iterated Tabu Search (example on the Queen problem) + +As in Lesson 4, you have to define a Solution, the method to initialize and evaluate it. Then you have to define a Tabu Search. + +Declaration of the Tabu Search: +```c++ +moTS ts(orderShiftNH, fullEval, shiftEval, 1, 7); +``` + +To use a simple Iterated Local Search, a mutation operator is needed. So the swap mutation defined in EO is used: +```c++ +eoSwapMutation mut; +``` + +Now, a simple Iterated Tabu Search can be declared as follow: +```c++ +moILS localSearch1(ts, fullEval, mut, 3); +``` +This constructor has got 4 parameters: +1. a local search (ts) +2. a full evaluation function (fullEval) +3. a mutation operator (mut) +4. a number of iterations (3) + +**localSearch1** performs the Tabu Search 3 times. The first solution of each iteration(except the first one) is obtained by applying the mutation operator on the last visited solution. + +A constructor allows to specify the continuator. **_Be carefull_**, the continuator must be templatized by a "moDummyNeighbor": +```c++ +moIterContinuator > cont(4, false); +``` +The explorer of the Iterated local search don't use its own neighborhood. Here, the neighborhood of the Tabu Search is used. But to respect the conception, we create a "moDummyNeighbor" using as template for Iterated Local Search. + +An Iterated Tabu Search with this continuator can be declared as: +```c++ +moILS localSearch2(ts, fullEval, mut, cont); +``` + +A general constructor is available allowing to specify the perturbation operator and the acceptance criteria. First, you have to declare a perturbation operator: +```c++ +moMonOpPerturb perturb(mut, fullEval); +``` +And, the acceptance criteria: +```c++ +moSolComparator solComp; +moBetterAcceptCrit accept(solComp); +``` +Finally, the Iterated Local Search can be declared as: +```c++ +moILS localSearch3(ts, fullEval, cont, perturb, accept); +``` + +You can test these three algorithms by changing problem sizes(use parameter file or the option --vecSize=X on command line to execute "testILS"). It prints the initial and the final solutions. + +## 2. Exercise + +* Try to implement an Iterated Hill Climbing on the Queen problem with these caracteristics: + 1. Hill Climbing with a "moShiftNeighborhood" and a "moTrueContinuator" + 2. Iterated Local Search using a "moIterContinuator" and a "moNeighborhoodPerturb" with a "moSwapNeighborhood". \ No newline at end of file diff --git a/mo/tutorial/Lesson6/README.md b/mo/tutorial/Lesson6/README.md new file mode 100644 index 000000000..e8f4ba747 --- /dev/null +++ b/mo/tutorial/Lesson6/README.md @@ -0,0 +1,250 @@ +# How to perform a fitness analysis? + +![](multimodalFitnessLandscape.jpg) + +A lot of tools to perform the fitness landscapes analysis are defined in paradisEO-MO: +* Density Of States +* Fitness Distance Correlation +* Autocorrelation length and autocorrelation functions +* Sampling the local optima by adaptive walks +* Neutral degree distribution +* Evolvability of neutral networks by neutral walks +* Fitness Cloud + +With the same code (and effort ;-) ), you can make an apriori study of your problem with fitness landscapes analysis and use efficient solution-based metaheuristics. You can also make an aposteriori fitness landscapes analysis of your problem to explain why your metaheuristics works or not. + +This lesson will let you: +* Use the fitness analysis tools of MO library +* Learn to perform your own fitness landscapes analysis + +In lesson 1, you have learnt to define the fitness function. In lesson 2, you have learn to define a neighbor and a neighborhoods. This lesson will used those previous lessons. + +This tutorial is made to learn how to perform a fitness landscapes analysis with paradisEO-MO. It is not a course to learn fitness landscapes analysis. You can find some information about fitness landscapes analysis here: [tutorial GECCO 09 (pdf)](http://www.i3s.unice.fr/~verel/talks/tutorialFitnessLandscapes_gecco2009.pdf) or [tutorial WCCI-CEC 10 (pdf)](http://www.i3s.unice.fr/~verel/talks/tutorialCEC2010.pdf) + +## 1. I want to compute the Fitness Distance Correlation (FDC)! + +You can compute the FDC. From the "paradiseo-mo/build/tutorial/Lesson6" directory, type: +```shell +./fdc -V=20 -n=500 +``` + +Great! You have sample fitness and distance to global optimum of 500 random solutions on the oneMax problem (which maximizes the number of ones in the bit string) for the bit strings of size 20. On your output screen, you can see the fitness and distance of the first and last solution of the sample. For example: +```text +First values: +Fitness 8 +Distance 12 +Last values: +Fitness 6 +Distance 14 +``` + +In the file "out.dat", you have all the sample. First column is the fitness and the second column is the distance to global optimum of the 500 solutions. + +After you can compute the correlation coefficient with your best statistical software such as R (with this small script) or excel with this help (import data and correlation) or with this small awk script. + +I found -1 with my sample which means that it is very easy function, isn't it? + +## 2. The main principles of fitness landscapes analysis with MO + +The fitness landscapes analysis is based on a sampling of the search space. During this sampling, data are collected, and then some statistics can be computed to deduce the structure of the search space. + +The class to define a sampling is moSampling in the directory mo/src/sampling. All classes of the standard tools of fitness landscapes analysis inherit from this class (see documentation): +* moDensityOfStatesSampling : density of states (distribution of fitness values) +* moAutocorrelationSampling : autocorrelation length and functions +* moFDCsampling : fitness distance correlation +* moHillClimberSampling : adaptive walks +* moNeutralDegreeSampling : neutral degree +* moNeutralWalkSampling : evolvability of neutral networks +* moFitnessCloudSampling : evolvability of the operator, and the neighborhood + +The constructor of moSampling is: +```c++ +moSampling (eoInit< EOT > &_init, moLocalSearch< Neighbor > &_localSearch, moStat< EOT, ValueType > &_stat, bool _monitoring=true) +``` + +As usual in paradiseo, EOT is the typedef of the solution, and Neighbor is the typedef of the neighbor (see lesson 1). This constructor needs an initialization methods (see tutorial on paradiseo-eo), a local search which perform the sampling of the search space (see previous lessons to define it), and a object which able to compute a statistic. At each iteration of the local search, the given statistic is computed, and is saved if boolean monitoring is true. + +The statistics inherit from the class moStat. The include file can be found in mo/src/continuator directory. The pre-defined statistics are: +* moFitnessStat : the fitness of the current solution +* moDistanceStat : the distance between the current solution and a given solution +* moSolutionStat : the current solution +* moCounterStat : the number of iterations +* moBestSoFarStat : the best current solution found +* moNeighborBestStat : best fitness over k neighbors +* moNeighborhoodStat : to compute the statistics from the neighbors solutions : + * moAverageFitnessNeighborStat : average fitness in the neighborhood + * moStdFitnessNeighborStat : standard deviation of fitness + * moMaxNeighborStat : maximum fitness + * moMinNeighborStat : minimum fitness + * moSecondMomentNeighborStat : average and standard deviation + * moSizeNeighborStat : size of the neighborhood + * moNeutralDegreeNeighborStat : number of neighbors with equal fitness + * moNbInfNeighborStat : number of neighbors with lower fitness + * moNbSupNeighborStat : number of neighbor with higher fitness + +All those statistics can be used in the sampling. Of course you can define your own statistic class. Several statistics can be collected at each iteration: use the method add of the class moSampling to collect another statistic. + +For standard tools of fitness landscapes analysis, there is no need to give the sampling method, and the statistics objects. You only have to give which is specific to your problem such as the initialization method, the fitness function, the neighborhood, or the evaluation function of a neighbor. + +## 3. Browsing the code + +Please, open the file "mo/tutorial/Lesson6/fdc.cpp", and follow me in the code: + +### 1. The includes part: + +The general includes for the c++ stdlib streams: +```c++ +#include +#include +#include +#include +#include +``` + +This includes for eo which contains all include files of EO: +```c++ +#include +``` + +The first line to include the bit string representation defined in eo, and the second one to include the bit string neighbor representation. All classical problem-dependent part of MO are defined in the sub-directory "problems". How to define your representation is explained in EO tutorial, and how to design your neighbor is explained in the lesson 2. Here just use it. +```c++ +#include +#include +``` + +This includes the evaluation function of a solution (full evaluation). There is no evaluation function for the neighbor because there is no need in FDC. Some others tools such as autocorrelation neighbor evaluation is defined such as the lesson 1. +```c++ +#include +``` + +The fitness distance correlation is the correlation between the fitness of solution and the distance to global optimum (or at least to some best known solution). So, this include file uses the Hamming distance. +```c++ +#include +``` + +Now we can include the FDC tool. +```c++ +#include +``` + +### 2. The typedef part: + +EO can apply an evolutionary algorithm on any type of solution. So, all EO classes are parametrized by the type of solutions, and it is useful to use a synonym (with a typedef) of the solution's type. +MO can apply an local search algorithm on any type of solution and neighbor. So, for the same reason, all classes of MO are parametrized by the neighbor's type. In the neighbor class, the solution's type is defined. More precision on the neighbor design will be given in the lesson 2. +Here the solution representation is a bit string and the neighbor representation is related to a bit string solution and Hamming distance 1 (only 1 bit can be flipped), both using an "unsigned int" fitness value. +```c++ +typedef eoBit Indi; +typedef moBitNeighbor Neighbor; +``` + +### 3. Object definition part: + +Follows the main function "main_function" where all useful objects are defined.\\ +First, a code to parse the command line and a file. It gives the value of the random seed and the size of bit string. The lesson 3 of EO tutorial gives more precision on this code. Here we have only to understand that the variables "seed" and "vecSize" are initialized. +```c++ +eoParser parser(argc, argv); + +eoValueParam seedParam(time(0), "seed", "Random number seed", 'S'); +parser.processParam( seedParam ); +unsigned seed = seedParam.value(); + +// length of the bit string +eoValueParam vecSizeParam(20, "vecSize", "Genotype size", 'V'); +parser.processParam( vecSizeParam, "Representation" ); +unsigned vecSize = vecSizeParam.value(); + +// the number of solution sampled +eoValueParam solParam(100, "nbSol", "Number of random solution", 'n'); +parser.processParam( solParam, "Representation" ); +unsigned nbSol = solParam.value(); + +// the name of the output file +string str_out = "out.dat"; // default value +eoValueParam outParam(str_out.c_str(), "out", "Output file of the sampling", 'o'); +``` + +To seed the random seed (see lesson 1 of EO tutorial for more precision): +```c++ +rng.reseed(seed); +``` + +The definition the initialization of solutions is not defined is MO but in EO. The "eoInitFixedLength" is a class that makes a random intialization of bit string of a given length. Each bit is true with 1/2 rate. You can see the lesson 1 of EO tutorial lesson 1 for more precision. +```c++ +eoUniformGenerator uGen; +eoInitFixedLength random(vecSize, uGen); +``` + +The fitness function of the oneMax problem is the number of 1 in the bit string. It is already defined in MO: +```c++ +oneMaxFullEval fullEval; +``` + +The distance used is the classical Hamming distance: +```c++ +eoHammingDistance distance; +``` + +For this analysis, the best solution is needed: the solution with all 1s. +```c++ +Indi bestSolution(vecSize, true); // global optimum +``` + +All representation-dependent part is now defined, so the FDC sampling can be defined. The constructor needs the initialization, the fitness function, the distance used, the reference solution, and the size of the sample: +```c++ +moFDCsampling sampling(random, fullEval, distance, bestSolution, nbSol); +``` + +### 4. The execution of sampling part: + +Now apply your sampling as follows: +```c++ +sampling(); +``` + +This sampling uses the initialization method to define a pure random search, and at each iteration the fitness and the distance are computed. + +4. The export part: + +To export your sample into a file: +```c++ +sampling.fileExport(str_out); +``` + +The first column of the file is the fitness and the second the distance from the global optimum. + +Maybe you may want to read the data from your c++ code. So it is possible to export the data into a vector: +```c++ +const std::vector & fitnessValues = sampling.getValues(0); +const std::vector & distValues = sampling.getValues(1); +``` + +Note that the indexes of the statistics (here 0 and 1) are in the same order of the declaration with the constructor and the "add" method of moSampling. + +After you can use the vector as you want: +```c++ +std::cout << "Fitness " << fitnessValues[0] << std::endl; +std::cout << "First values:" << std::endl; +std::cout << "Distance " << distValues[0] << std::endl; + +std::cout << "Last values:" << std::endl; +std::cout << "Fitness " << fitnessValues[fitnessValues.size() - 1] << std::endl; +std::cout << "Distance " << distValues[distValues.size() - 1] << std::endl; + +``` + +Easy, isn't it? + +## 4. Others fitness landscapes tools + +The other tools can be used in the same way. For each tool, an example has been made. Please read the code of: + +* densityOfStates.cpp : density of states example +* autocorrelation.cpp : autocorrelation length and functions +* adaptiveWalks.cpp : sampling by hill-climbings, length of adaptative walks +* fdc.cpp : ;-) +* fitnessCloud.cpp : bivariate density of fitness of solutions and fitness of neighbors +* neutralDegree.cpp : number of neighbor with the same fitness +* neutralWalk.cpp : evolvability of the neutral networks +* sampling.cpp : general sampling method + +If you have some questions or remarks, please contact us! sebastien.verel aaattt unice.fr or member of the development team. \ No newline at end of file diff --git a/mo/tutorial/Lesson6/multimodalFitnessLandscape.jpg b/mo/tutorial/Lesson6/multimodalFitnessLandscape.jpg new file mode 100755 index 0000000000000000000000000000000000000000..ad3b52ce09369b311417fc897bd6f3558978b935 GIT binary patch literal 19455 zcmdqJcR*9k);AguP?~fQkY1H4RRKXdh!mxF5vd_WdXNB0?^U|ed+(u!-kWp@Jrt!U zpb(^e@j2yt&U^2<@Bep_o&DQ0Yt~w`X7}1%QKt15m?$05?c{ zR&_;1OPyERD(Wwku?YYGKDpJqcTTvh0079@-BtCKys?q73G3~z09?Rb00{satgPMM z$?NF6_=BCn&NhF}{~1o_09Z}{z_h?0UjLc)zh2?LwQ;k?Qgvbvu$TKgcK`rK7>lWa zdao3*SP6^oTEBDs6R(HGkKejkgRnRX0Js(O&%D@Z0FA1RvyH2RHLI$tl{c%7E7;b- z>F>J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3Y@Fv~-UT}9&rqLn zhTWbf-lO%l8tGK^TUr}fsw)y+ug{F)@$8^pi5r;i0eRWI$0QMY7k;3@=<$cb|IYvB Hjd#BT_^tD& literal 0 HcmV?d00001 diff --git a/mo/tutorial/Lesson7/README.md b/mo/tutorial/Lesson7/README.md new file mode 100644 index 000000000..5f493a130 --- /dev/null +++ b/mo/tutorial/Lesson7/README.md @@ -0,0 +1,60 @@ +# How to hybrid an evolutionary algorithm and a local search +In this lesson, a hybridization between an evolutionary algorithm(EA) and a local search is presented. It will be illustrated by an example on the Queen problem. Here, the hybridization consists in replacing the mutation operator of the EA by a first improvement hill climber. + +1. hybridization +2. Exercise + +## 1. Hybridization (example on the Queen problem) + +First, you have to define the represenation of a Queen, how to initialize and how to evaluate a population of solutions: +```c++ +queenFullEval fullEval; + +eoInitPermutation init(vecSize); + +eoPop pop; +Queen tmp; +for(unsigned int i=0; i<20; i++){ //population size is fixed to 20 + init(tmp); + fullEval(tmp); + pop.push_back(tmp); +} +``` + +As in previous lessons, a local search is declared (first improvement hill climber): +```c++ +moFullEvalByCopy shiftEval(fullEval); + +orderShiftNeighborhood orderShiftNH(pow(vecSize-1, 2)); + +moFirstImprHC hc(orderShiftNH, fullEval, shiftEval); +``` +To hybrid this local search with an EA, you just have to use it instead of a classical mutation: +```c++ +eoOrderXover cross; +eoSGATransform transform(cross, 0.3, hc, 0.7); // cross and mutation probabilities are fixed +``` + +Others components of the "eoEasyEA" have to be declared: +```c++ +eoGenContinue EAcont(50); //nb generations is fixed to 50 +eoDetTournamentSelect selectOne(2); //size of tournament is fixed to 2 +eoSelectMany select(selectOne, 1); //rate of selection is fixed to 1 +eoGenerationalReplacement repl; +``` +More details are available in EO lessons. + +Finally, the hybrid algorithm is declared as: +```c++ +eoEasyEA hybridAlgo(EAcont, fullEval, select, transform, repl); +``` +and should be applied on the population with: +```c++ +hybridAlgo(pop); +``` + +You can test this hybrid algorithm by changing problem size (use parameters file or the option --vecSize=X on command line to execute "hybridAlgo"). It prints the initial and final population. + +## 2. Exercise + +Try to use a hybridization at the checkpointing step rather than at the mutation step. You have to implement an "eoUpdater" which applies a local search. This updater should be added in a "eoCheckpoint". \ No newline at end of file From ff09b4bcc75ee4a25daacecaac65abb56fe8b6b1 Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 31 Aug 2022 23:46:46 +0200 Subject: [PATCH 03/69] fix logo display in readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 59ded2801..686b08334 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ It focus on the efficiency of the implementation of solvers, by providing: - tools for ***automated design and selection*** of algorithms, - a focus on ***speed*** and several ***parallelization*** options. -![Paradiseo logo](https://github.com/nojhan/paradiseo/blob/master/website/paradiseo_logo_200px_dark.png) +
+ Paradiseo logo +
# Quick Start From 1a980c442d208d72d42d499c430268f8fcb5c7cf Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 31 Jan 2022 22:33:36 +0100 Subject: [PATCH 04/69] feat: add an eoForgeMap Same features than an eoForgeVector, but allowing to bind a string name to the instance. --- eo/src/eoForge.h | 138 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 133 insertions(+), 5 deletions(-) diff --git a/eo/src/eoForge.h b/eo/src/eoForge.h index bc2dbb67d..6fcccf811 100644 --- a/eo/src/eoForge.h +++ b/eo/src/eoForge.h @@ -192,13 +192,13 @@ class eoForgeOperator : public eoForgeInterface * with different parametrization (or not). * * @warning When passing a reference (as it is often the case within ParadisEO), - * it is MANDATORY to wrap it in `std::ref`, or else it will default to use copy. - * This is is a source of bug which your compiler will to detect and that would - * disable any link between operators. + * it is MANDATORY to wrap it in `std::ref`, or else it will default to use copy. + * This is is a source of bug which your compiler will fail to detect and that would + * disable any link between operators. * * @warning You may want to enable instantiation cache to grab some performances. - * The default is set to disable the cache, because its use with operators - * which hold a state will lead to unwanted behaviour. + * The default is set to disable the cache, because its use with operators + * which hold a state will lead to unwanted behaviour. * * @code eoForgeVector> factories(false); @@ -320,6 +320,134 @@ class eoForgeVector : public std::vector*> bool _no_cache; }; +/** A map holding an operator (with deferred instantiation) at a given name. + * + * @note You can actually store several instances of the same class, + * with different parametrization (or not). + * + * @warning When passing a reference (as it is often the case within ParadisEO), + * it is MANDATORY to wrap it in `std::ref`, or else it will default to use copy. + * This is is a source of bug which your compiler will fail to detect and that would + * disable any link between operators. + * + * @warning You may want to enable instantiation cache to grab some performances. + * The default is set to disable the cache, because its use with operators + * which hold a state will lead to unwanted behaviour. + * + * @code + eoForgeMap> factories(false); + + // Capture constructor's parameters and defer instantiation. + factories.add>(1); + factories.setup>(0, 5); // Edit + + // Actually instantiate. + eoSelect& op = factories.instantiate(0); + + // Call. + op(); + * @endcode + * + * @ingroup Foundry + */ +template +class eoForgeMap : public std::map*> +{ + public: + using Interface = Itf; + + /** Default constructor do not cache instantiations. + * + * @warning + * You most probably want to disable caching for operators that hold a state. + * If you enable the cache, the last used instantiation will be used, + * at its last state. + * For example, continuators should most probably not be cached, + * as they very often hold a state in the form of a counter. + * At the end of a search, the continuator will be in the end state, + * and thus always ask for a stop. + * Reusing an instance in this state will de facto disable further searches. + * + * @param always_reinstantiate If false, will enable cache for the forges in this container. + */ + eoForgeMap( bool always_reinstantiate = true ) : + _no_cache(always_reinstantiate) + { } + + /** instantiate the operator managed at the given name. + */ + Itf& instantiate(const std::string& name) + { + return this->at(name)->instantiate(_no_cache); + } + + /** Add an operator to the list. + * + * @warning When passing a reference (as it is often the case within ParadisEO), + * it is MANDATORY to wrap it in `std::ref`, or else it will default to use copy. + * This is is a source of bug which your compiler will to detect and that would + * disable any link between operators. + * + */ + template + void add(const std::string& name, Args... args) + { + // We decay all args to ensure storing everything by value within the forge. + // The references should thus be wrapped in a std::ref. + auto pfo = new eoForgeOperator...>( + std::forward(args)...); + this->insert({name, pfo}); + } + + /** Specialization for operators with empty constructors. + */ + template + void add(const std::string& name) + { + eoForgeInterface* pfo = new eoForgeOperator; + this->insert({name, pfo}); + } + + /** Change the set up arguments to the constructor. + * + * @warning When passing a reference (as it is often the case within ParadisEO), + * it is MANDATORY to wrap it in `std::ref`, or else it will default to use copy. + * This is is a source of bug which your compiler will to detect and that would + * disable any link between operators. + * + * @warning The operator at `name` should have been added with eoForgeMap::add already.. + */ + template + void setup(const std::string& name, Args... args) + { + delete this->at(name); // Silent on nullptr. + auto pfo = new eoForgeOperator...>( + std::forward(args)...); + this->emplace({name, pfo}); + } + + /** Specialization for empty constructors. + */ + template + void setup(const std::string& name) + { + delete this->at(name); + auto pfo = new eoForgeOperator; + this->emplace({name, pfo}); + } + + virtual ~eoForgeMap() + { + for(auto kv : *this) { + delete kv.second; + } + } + + protected: + bool _no_cache; +}; + + /** A range holding a parameter value at a given index. * * This is essential a scalar numerical parameter, with bounds check From 843aa6fc373fa29f169691ef84750288ef5a1e63 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 10 Sep 2022 06:26:34 +0200 Subject: [PATCH 05/69] fix(mo): comment out unused parameters Removes -Wunused-parameters warnings. --- mo/src/acceptCrit/moAlwaysAcceptCrit.h | 2 +- mo/src/algo/eoDummyMonOp.h | 2 +- mo/src/continuator/moAverageFitnessNeighborStat.h | 4 ++-- mo/src/continuator/moBestNoImproveContinuator.h | 2 +- mo/src/continuator/moBooleanStat.h | 4 ++-- mo/src/continuator/moContinuator.h | 4 ++-- mo/src/continuator/moCounterStat.h | 4 ++-- mo/src/continuator/moEvalsContinuator.h | 4 ++-- mo/src/continuator/moFullEvalContinuator.h | 4 ++-- mo/src/continuator/moIterContinuator.h | 4 ++-- mo/src/continuator/moMaxNeighborStat.h | 4 ++-- mo/src/continuator/moMedianNeighborStat.h | 4 ++-- mo/src/continuator/moMinNeighborStat.h | 4 ++-- mo/src/continuator/moMinusOneCounterStat.h | 4 ++-- mo/src/continuator/moNbInfNeighborStat.h | 4 ++-- mo/src/continuator/moNbSupNeighborStat.h | 4 ++-- mo/src/continuator/moNeighborEvalContinuator.h | 4 ++-- mo/src/continuator/moNeutralDegreeNeighborStat.h | 4 ++-- mo/src/continuator/moQ1NeighborStat.h | 4 ++-- mo/src/continuator/moQ3NeighborStat.h | 4 ++-- mo/src/continuator/moSecondMomentNeighborStat.h | 4 ++-- mo/src/continuator/moSizeNeighborStat.h | 4 ++-- mo/src/continuator/moSolutionStat.h | 2 +- mo/src/continuator/moStatFromStat.h | 4 ++-- mo/src/continuator/moStdFitnessNeighborStat.h | 4 ++-- mo/src/continuator/moTimeContinuator.h | 4 ++-- mo/src/continuator/moTrueContinuator.h | 4 ++-- mo/src/continuator/moUnsignedStat.h | 4 ++-- mo/src/continuator/moValueStat.h | 4 ++-- mo/src/continuator/moVectorMonitor.h | 2 +- mo/src/coolingSchedule/moDynSpanCoolingSchedule.h | 4 ++-- mo/src/coolingSchedule/moSimpleCoolingSchedule.h | 4 ++-- mo/src/eval/moDoubleIncrEvaluation.h | 2 +- mo/src/eval/moDummyEval.h | 2 +- mo/src/explorer/moDummyExplorer.h | 14 +++++++------- mo/src/explorer/moFirstImprHCexplorer.h | 8 ++++---- mo/src/explorer/moILSexplorer.h | 4 ++-- mo/src/explorer/moMetropolisHastingExplorer.h | 8 ++++---- mo/src/explorer/moNeutralHCexplorer.h | 2 +- mo/src/explorer/moRandomBestHCexplorer.h | 8 ++++---- mo/src/explorer/moRandomNeutralWalkExplorer.h | 8 ++++---- mo/src/explorer/moRandomSearchExplorer.h | 12 ++++++------ mo/src/explorer/moRandomWalkExplorer.h | 8 ++++---- mo/src/explorer/moSAexplorer.h | 6 +++--- mo/src/explorer/moSimpleHCexplorer.h | 8 ++++---- mo/src/explorer/moTSexplorer.h | 4 ++-- mo/src/explorer/moVNSexplorer.h | 2 +- mo/src/memory/moBestImprAspiration.h | 4 ++-- mo/src/memory/moCountMoveMemory.h | 6 +++--- mo/src/memory/moDummyMemory.h | 6 +++--- mo/src/memory/moIndexedVectorTabuList.h | 8 ++++---- mo/src/memory/moNeighborVectorTabuList.h | 8 ++++---- mo/src/memory/moRndIndexedVectorTabuList.h | 2 +- mo/src/memory/moSolVectorTabuList.h | 6 +++--- mo/src/neighborhood/moBackwardVectorVNSelection.h | 6 +++--- mo/src/neighborhood/moDummyNeighbor.h | 2 +- mo/src/neighborhood/moDummyNeighborhood.h | 8 ++++---- mo/src/neighborhood/moForwardVectorVNSelection.h | 6 +++--- mo/src/neighborhood/moIndexNeighbor.h | 2 +- mo/src/neighborhood/moNeighbor.h | 2 +- mo/src/neighborhood/moOrderNeighborhood.h | 4 ++-- mo/src/neighborhood/moRndVectorVNSelection.h | 6 +++--- mo/src/neighborhood/moRndWithReplNeighborhood.h | 4 ++-- mo/src/neighborhood/moRndWithoutReplNeighborhood.h | 4 ++-- mo/src/perturb/moNeighborhoodPerturb.h | 4 ++-- .../bitString/moBitsWithReplNeighborhood.h | 6 +++--- .../bitString/moBitsWithoutReplNeighborhood.h | 6 +++--- mo/src/problems/permutation/moSwapNeighborhood.h | 2 +- .../problems/permutation/moTwoOptExNeighborhood.h | 2 +- 69 files changed, 159 insertions(+), 159 deletions(-) diff --git a/mo/src/acceptCrit/moAlwaysAcceptCrit.h b/mo/src/acceptCrit/moAlwaysAcceptCrit.h index 777ef0b18..ef2541d2f 100644 --- a/mo/src/acceptCrit/moAlwaysAcceptCrit.h +++ b/mo/src/acceptCrit/moAlwaysAcceptCrit.h @@ -48,7 +48,7 @@ public: * @param _sol2 the new solution after local search * @return always true */ - bool operator()(EOT& _sol1, EOT& _sol2) { + bool operator()(EOT& /*_sol1*/, EOT& /*_sol2*/) { return true; } diff --git a/mo/src/algo/eoDummyMonOp.h b/mo/src/algo/eoDummyMonOp.h index dba88fa7f..bdb303844 100644 --- a/mo/src/algo/eoDummyMonOp.h +++ b/mo/src/algo/eoDummyMonOp.h @@ -47,7 +47,7 @@ public: * Do nothing on the solution * @param _solution the related solution */ - virtual bool operator()(EOT & _solution) { + virtual bool operator()(EOT & /*_solution*/) { return true; } }; diff --git a/mo/src/continuator/moAverageFitnessNeighborStat.h b/mo/src/continuator/moAverageFitnessNeighborStat.h index 7d12abc0a..130b96663 100644 --- a/mo/src/continuator/moAverageFitnessNeighborStat.h +++ b/mo/src/continuator/moAverageFitnessNeighborStat.h @@ -61,7 +61,7 @@ public : * Set the average of fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getMean(); } @@ -69,7 +69,7 @@ public : * Set the average of fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getMean(); } diff --git a/mo/src/continuator/moBestNoImproveContinuator.h b/mo/src/continuator/moBestNoImproveContinuator.h index 86981bef4..d772180f3 100644 --- a/mo/src/continuator/moBestNoImproveContinuator.h +++ b/mo/src/continuator/moBestNoImproveContinuator.h @@ -93,7 +93,7 @@ public: * reset the counter of iteration * @param _solution a solution */ - virtual void init(EOT & _solution) { + virtual void init(EOT & /*_solution*/) { cpt = 0; } diff --git a/mo/src/continuator/moBooleanStat.h b/mo/src/continuator/moBooleanStat.h index a098efc23..10fa7008e 100644 --- a/mo/src/continuator/moBooleanStat.h +++ b/mo/src/continuator/moBooleanStat.h @@ -56,7 +56,7 @@ public : * Init the number of iteration * @param _sol a solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = *b; } @@ -64,7 +64,7 @@ public : * Set the number of iteration * @param _sol a solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = *b; } diff --git a/mo/src/continuator/moContinuator.h b/mo/src/continuator/moContinuator.h index cec268038..a58cad718 100644 --- a/mo/src/continuator/moContinuator.h +++ b/mo/src/continuator/moContinuator.h @@ -52,13 +52,13 @@ public: * Init Continuator parameters * @param _solution the related solution */ - virtual void init(EOT& _solution) {}; + virtual void init(EOT& /*_solution*/) {}; /** * Last Call to terminate the checkpoint * @param _solution the related solution */ - virtual void lastCall(EOT& _solution) {}; + virtual void lastCall(EOT& /*_solution*/) {}; }; #endif diff --git a/mo/src/continuator/moCounterStat.h b/mo/src/continuator/moCounterStat.h index 85534e67e..14b062784 100644 --- a/mo/src/continuator/moCounterStat.h +++ b/mo/src/continuator/moCounterStat.h @@ -56,7 +56,7 @@ public : * Init the number of iteration * @param _sol a solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = 0; } @@ -64,7 +64,7 @@ public : * Set the number of iteration * @param _sol a solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = value() + 1; } diff --git a/mo/src/continuator/moEvalsContinuator.h b/mo/src/continuator/moEvalsContinuator.h index 1a020da6c..7c9f4e902 100644 --- a/mo/src/continuator/moEvalsContinuator.h +++ b/mo/src/continuator/moEvalsContinuator.h @@ -65,7 +65,7 @@ public: * @param _solution a solution * @return true if number of evaluations < maxEvals */ - virtual bool operator()(EOT & _solution) { + virtual bool operator()(EOT & /*_solution*/) { return (fullEval.value() + neighborEval.value() - nbEval_start < maxEvals); } @@ -73,7 +73,7 @@ public: * Reset the number of evaluations * @param _solution a solution */ - virtual void init(EOT & _solution) { + virtual void init(EOT & /*_solution*/) { if (restartCounter) nbEval_start = fullEval.value() + neighborEval.value(); else diff --git a/mo/src/continuator/moFullEvalContinuator.h b/mo/src/continuator/moFullEvalContinuator.h index 5239c1dea..bf9a9ea96 100644 --- a/mo/src/continuator/moFullEvalContinuator.h +++ b/mo/src/continuator/moFullEvalContinuator.h @@ -63,7 +63,7 @@ public: * @param _solution a solution * @return true if number of evaluations < maxFullEval */ - virtual bool operator()(EOT & _solution) { + virtual bool operator()(EOT & /*_solution*/) { return (eval.value() - nbEval_start < maxFullEval); } @@ -71,7 +71,7 @@ public: * Reset the number of evaluations * @param _solution a solution */ - virtual void init(EOT & _solution) { + virtual void init(EOT & /*_solution*/) { if (restartCounter) nbEval_start = eval.value(); else diff --git a/mo/src/continuator/moIterContinuator.h b/mo/src/continuator/moIterContinuator.h index f10db39f5..f9400254c 100644 --- a/mo/src/continuator/moIterContinuator.h +++ b/mo/src/continuator/moIterContinuator.h @@ -52,7 +52,7 @@ public: *@param _solution a solution *@return true if counter < maxIter */ - virtual bool operator()(EOT & _solution) { + virtual bool operator()(EOT & /*_solution*/) { bool res; cpt++; res = (cpt < maxIter); @@ -65,7 +65,7 @@ public: * reset the counter of iteration * @param _solution a solution */ - virtual void init(EOT & _solution) { + virtual void init(EOT & /*_solution*/) { cpt = 0; } diff --git a/mo/src/continuator/moMaxNeighborStat.h b/mo/src/continuator/moMaxNeighborStat.h index f0b165d72..94f9cc137 100644 --- a/mo/src/continuator/moMaxNeighborStat.h +++ b/mo/src/continuator/moMaxNeighborStat.h @@ -62,7 +62,7 @@ public : * Set the max fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getMax(); } @@ -70,7 +70,7 @@ public : * Set the max fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getMax(); } diff --git a/mo/src/continuator/moMedianNeighborStat.h b/mo/src/continuator/moMedianNeighborStat.h index 4c3cfb8f2..241c1adce 100644 --- a/mo/src/continuator/moMedianNeighborStat.h +++ b/mo/src/continuator/moMedianNeighborStat.h @@ -63,7 +63,7 @@ public : * Set the median fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getMedian(); } @@ -71,7 +71,7 @@ public : * Set the median fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getMedian(); } diff --git a/mo/src/continuator/moMinNeighborStat.h b/mo/src/continuator/moMinNeighborStat.h index bd1cae1f9..f77d91973 100644 --- a/mo/src/continuator/moMinNeighborStat.h +++ b/mo/src/continuator/moMinNeighborStat.h @@ -62,7 +62,7 @@ public : * Set the worst fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getMin(); } @@ -70,7 +70,7 @@ public : * Set the worst fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getMin(); } diff --git a/mo/src/continuator/moMinusOneCounterStat.h b/mo/src/continuator/moMinusOneCounterStat.h index dfb9be881..0d6fd1f3a 100644 --- a/mo/src/continuator/moMinusOneCounterStat.h +++ b/mo/src/continuator/moMinusOneCounterStat.h @@ -58,7 +58,7 @@ public : * Init the number of iteration * @param _sol a solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { counter = 0; value() = 0; } @@ -67,7 +67,7 @@ public : * Set the number of iteration * @param _sol a solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { counter++; if (counter > 0) value() = counter - 1; diff --git a/mo/src/continuator/moNbInfNeighborStat.h b/mo/src/continuator/moNbInfNeighborStat.h index e3bc27bb7..5699b5268 100644 --- a/mo/src/continuator/moNbInfNeighborStat.h +++ b/mo/src/continuator/moNbInfNeighborStat.h @@ -63,7 +63,7 @@ public : * Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getNbInf(); } @@ -71,7 +71,7 @@ public : * Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getNbInf(); } diff --git a/mo/src/continuator/moNbSupNeighborStat.h b/mo/src/continuator/moNbSupNeighborStat.h index 8febf94f8..d81e07591 100644 --- a/mo/src/continuator/moNbSupNeighborStat.h +++ b/mo/src/continuator/moNbSupNeighborStat.h @@ -63,7 +63,7 @@ public : * Set the number of solutions in the neighborhood with better fitness than the current solution * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getNbSup(); } @@ -71,7 +71,7 @@ public : * Set the number of solutions in the neighborhood with better fitness than the current solution * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getNbSup(); } diff --git a/mo/src/continuator/moNeighborEvalContinuator.h b/mo/src/continuator/moNeighborEvalContinuator.h index ba3a41a9d..bcfd0563a 100644 --- a/mo/src/continuator/moNeighborEvalContinuator.h +++ b/mo/src/continuator/moNeighborEvalContinuator.h @@ -61,7 +61,7 @@ public: * @param _solution a solution * @return true if number of evaluations < maxNeighborEval */ - virtual bool operator()(EOT & _solution) { + virtual bool operator()(EOT & /*_solution*/) { return (eval.value() - nbEval_start < maxNeighborEval); } @@ -69,7 +69,7 @@ public: * Reset the number of evaluations * @param _solution a solution */ - virtual void init(EOT & _solution) { + virtual void init(EOT & /*_solution*/) { if (restartCounter) nbEval_start = eval.value(); else diff --git a/mo/src/continuator/moNeutralDegreeNeighborStat.h b/mo/src/continuator/moNeutralDegreeNeighborStat.h index d46e99475..1cbe47321 100644 --- a/mo/src/continuator/moNeutralDegreeNeighborStat.h +++ b/mo/src/continuator/moNeutralDegreeNeighborStat.h @@ -63,7 +63,7 @@ public : * Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getNbEqual(); } @@ -71,7 +71,7 @@ public : * Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getNbEqual(); } diff --git a/mo/src/continuator/moQ1NeighborStat.h b/mo/src/continuator/moQ1NeighborStat.h index 4d74be68d..2ee9bd294 100644 --- a/mo/src/continuator/moQ1NeighborStat.h +++ b/mo/src/continuator/moQ1NeighborStat.h @@ -63,7 +63,7 @@ public : * Set the first quartile of fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getQ1(); } @@ -71,7 +71,7 @@ public : * Set the first quartile of fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getQ1(); } diff --git a/mo/src/continuator/moQ3NeighborStat.h b/mo/src/continuator/moQ3NeighborStat.h index 50426e65f..7e4768e57 100644 --- a/mo/src/continuator/moQ3NeighborStat.h +++ b/mo/src/continuator/moQ3NeighborStat.h @@ -63,7 +63,7 @@ public : * Set the third quartile of fitness in the neighborhood * @param _sol the third solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getQ3(); } @@ -71,7 +71,7 @@ public : * Set the third quartile of fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getQ3(); } diff --git a/mo/src/continuator/moSecondMomentNeighborStat.h b/mo/src/continuator/moSecondMomentNeighborStat.h index 7c3a08fff..ba99c6d48 100644 --- a/mo/src/continuator/moSecondMomentNeighborStat.h +++ b/mo/src/continuator/moSecondMomentNeighborStat.h @@ -61,7 +61,7 @@ public : * Set the average and the standard deviation of fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value().first = nhStat.getMean(); value().second = nhStat.getSD(); } @@ -70,7 +70,7 @@ public : * Set the average and the standard deviation of fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value().first = nhStat.getMean(); value().second = nhStat.getSD(); } diff --git a/mo/src/continuator/moSizeNeighborStat.h b/mo/src/continuator/moSizeNeighborStat.h index 1a5b5b123..5ac3caf19 100644 --- a/mo/src/continuator/moSizeNeighborStat.h +++ b/mo/src/continuator/moSizeNeighborStat.h @@ -62,7 +62,7 @@ public : * Set the number of solutions in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getSize(); } @@ -70,7 +70,7 @@ public : * Set the number of solutions in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getSize(); } diff --git a/mo/src/continuator/moSolutionStat.h b/mo/src/continuator/moSolutionStat.h index 93c4f57f5..90baafd44 100644 --- a/mo/src/continuator/moSolutionStat.h +++ b/mo/src/continuator/moSolutionStat.h @@ -52,7 +52,7 @@ public : * Constructor * @param _description a description of the parameter */ - moSolutionStat(std::string _description = "solution"): + moSolutionStat(std::string /*_description */= "solution"): moStat(EOT(), "fitness solution") { } /** diff --git a/mo/src/continuator/moStatFromStat.h b/mo/src/continuator/moStatFromStat.h index 962106eb0..2dea43ce1 100644 --- a/mo/src/continuator/moStatFromStat.h +++ b/mo/src/continuator/moStatFromStat.h @@ -57,7 +57,7 @@ public : * The value of this stat is a copy of the value of the initial stat * @param _sol a solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = stat.value(); } @@ -65,7 +65,7 @@ public : * The value of this stat is a copy of the value of the initial stat * @param _sol a solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = stat.value(); } diff --git a/mo/src/continuator/moStdFitnessNeighborStat.h b/mo/src/continuator/moStdFitnessNeighborStat.h index 649308f74..5e4098a8d 100644 --- a/mo/src/continuator/moStdFitnessNeighborStat.h +++ b/mo/src/continuator/moStdFitnessNeighborStat.h @@ -61,7 +61,7 @@ public : * Set the average and the standard deviation of fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = nhStat.getSD(); } @@ -69,7 +69,7 @@ public : * Set the average and the standard deviation of fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = nhStat.getSD(); } diff --git a/mo/src/continuator/moTimeContinuator.h b/mo/src/continuator/moTimeContinuator.h index 513928000..172fec933 100644 --- a/mo/src/continuator/moTimeContinuator.h +++ b/mo/src/continuator/moTimeContinuator.h @@ -88,7 +88,7 @@ public: * Returns false when the running time is reached. * @param _sol the current solution */ - virtual bool operator() (EOT& _sol) + virtual bool operator() (EOT& /*_sol*/) { bool res; time_t elapsed = (time_t) difftime(time(NULL), start); @@ -102,7 +102,7 @@ public: * reset the start time * @param _solution a solution */ - virtual void init(EOT & _solution) { + virtual void init(EOT & /*_solution*/) { if (!external) start = time(NULL); } diff --git a/mo/src/continuator/moTrueContinuator.h b/mo/src/continuator/moTrueContinuator.h index 88feb91a3..020e138a5 100644 --- a/mo/src/continuator/moTrueContinuator.h +++ b/mo/src/continuator/moTrueContinuator.h @@ -53,7 +53,7 @@ public: * @param _solution a solution * @return always true */ - virtual bool operator()(EOT & _solution) { + virtual bool operator()(EOT & /*_solution*/) { return true; } @@ -61,7 +61,7 @@ public: * NOTHING TO DO * @param _solution a solution */ - virtual void init(EOT & _solution) {} + virtual void init(EOT & /*_solution*/) {} }; diff --git a/mo/src/continuator/moUnsignedStat.h b/mo/src/continuator/moUnsignedStat.h index c1f8342cd..8c5122539 100644 --- a/mo/src/continuator/moUnsignedStat.h +++ b/mo/src/continuator/moUnsignedStat.h @@ -56,7 +56,7 @@ public : * Init the number of iteration * @param _sol a solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value() = *b; } @@ -64,7 +64,7 @@ public : * Set the number of iteration * @param _sol a solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = *b; } diff --git a/mo/src/continuator/moValueStat.h b/mo/src/continuator/moValueStat.h index 0d8d8877d..1e9bf06a9 100644 --- a/mo/src/continuator/moValueStat.h +++ b/mo/src/continuator/moValueStat.h @@ -60,7 +60,7 @@ public : * Init the number of iteration * @param _sol a solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { if (restart) value_start = valueParam.value(); else @@ -73,7 +73,7 @@ public : * Set the number of iteration * @param _sol a solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value() = (double) (valueParam.value() - value_start); } diff --git a/mo/src/continuator/moVectorMonitor.h b/mo/src/continuator/moVectorMonitor.h index 67535219d..30c331771 100644 --- a/mo/src/continuator/moVectorMonitor.h +++ b/mo/src/continuator/moVectorMonitor.h @@ -126,7 +126,7 @@ public: * @param _param unvalid Parameter */ template - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), intLongLongParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam & /*_param*/) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), intLongLongParam(NULL), eotParam(NULL) { std::cerr << "Sorry the type can not be in a vector of moVectorMonitor" << std::endl; } diff --git a/mo/src/coolingSchedule/moDynSpanCoolingSchedule.h b/mo/src/coolingSchedule/moDynSpanCoolingSchedule.h index 34b386312..e92992e87 100644 --- a/mo/src/coolingSchedule/moDynSpanCoolingSchedule.h +++ b/mo/src/coolingSchedule/moDynSpanCoolingSchedule.h @@ -63,7 +63,7 @@ public: * Initial temperature * @param _solution initial solution */ - virtual double init(EOT & _solution) { + virtual double init(EOT & /*_solution*/) { // number of tries since the last temperature change spanTries = 0; @@ -105,7 +105,7 @@ public: * @param _temp current temperature * @return true if the search can continue */ - virtual bool operator()(double _temp) { + virtual bool operator()(double /*_temp*/) { return nbSpan <= nbSpanMax; } diff --git a/mo/src/coolingSchedule/moSimpleCoolingSchedule.h b/mo/src/coolingSchedule/moSimpleCoolingSchedule.h index 5ff4f4920..940dd258a 100644 --- a/mo/src/coolingSchedule/moSimpleCoolingSchedule.h +++ b/mo/src/coolingSchedule/moSimpleCoolingSchedule.h @@ -59,7 +59,7 @@ public: * @param _solution initial solution * @return the initial temperature */ - virtual double init(EOT & _solution) { + virtual double init(EOT & /*_solution*/) { // number of iteration with the same temperature step = 0; @@ -71,7 +71,7 @@ public: * @param _temp current temperature to update * @param _acceptedMove true when the move is accepted, false otherwise */ - virtual void update(double& _temp, bool _acceptedMove) { + virtual void update(double& _temp, bool /*_acceptedMove*/) { if (step >= span) { _temp *= alpha; step = 0; diff --git a/mo/src/eval/moDoubleIncrEvaluation.h b/mo/src/eval/moDoubleIncrEvaluation.h index c7027e2b8..2f1ac305c 100644 --- a/mo/src/eval/moDoubleIncrEvaluation.h +++ b/mo/src/eval/moDoubleIncrEvaluation.h @@ -85,7 +85,7 @@ public: * * @param _solution the current solution */ - virtual void operator()(EOT & _solution) { + virtual void operator()(EOT & /*_solution*/) { } /** the delta of fitness for each neighbors diff --git a/mo/src/eval/moDummyEval.h b/mo/src/eval/moDummyEval.h index 2809f12a3..ac855e0fc 100644 --- a/mo/src/eval/moDummyEval.h +++ b/mo/src/eval/moDummyEval.h @@ -46,7 +46,7 @@ public: * @param _sol unused solution * @param _n unused neighbor */ - void operator()(EOT& _sol, Neighbor& _n) {} + void operator()(EOT& /*_sol*/, Neighbor& /*_n*/) {} }; diff --git a/mo/src/explorer/moDummyExplorer.h b/mo/src/explorer/moDummyExplorer.h index 3d58dbb08..ae6a293cb 100644 --- a/mo/src/explorer/moDummyExplorer.h +++ b/mo/src/explorer/moDummyExplorer.h @@ -54,20 +54,20 @@ public: * NOTHING TO DO * @param _solution unused solution */ - void initParam (EOT& _solution) { } ; + void initParam (EOT& /*_solution*/) { } ; /** * NOTHING TO DO * @param _solution unused solution */ - void updateParam (EOT& _solution) { } ; + void updateParam (EOT& /*_solution*/) { } ; /** * NOTHING TO DO * @param _solution unused solution * @return always false */ - bool isContinue(EOT& _solution) { + bool isContinue(EOT& /*_solution*/) { return false; } ; @@ -75,14 +75,14 @@ public: * NOTHING TO DO * @param _solution unused solution */ - void move(EOT& _solution) { } ; + void move(EOT& /*_solution*/) { } ; /** * NOTHING TO DO * @param _solution unused solution * @return always false */ - virtual bool accept(EOT& _solution) { + virtual bool accept(EOT& /*_solution*/) { return false; } ; @@ -90,13 +90,13 @@ public: * NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT& _solution) { } ; + virtual void terminate(EOT& /*_solution*/) { } ; /** * NOTHING TO DO * @param _solution unused solution */ - void operator()(EOT & _solution) { } + void operator()(EOT & /*_solution*/) { } /** * Return the class name diff --git a/mo/src/explorer/moFirstImprHCexplorer.h b/mo/src/explorer/moFirstImprHCexplorer.h index e341908d3..530f2953a 100644 --- a/mo/src/explorer/moFirstImprHCexplorer.h +++ b/mo/src/explorer/moFirstImprHCexplorer.h @@ -85,19 +85,19 @@ public: * initParam: NOTHING TO DO * @param _solution unused solution */ - virtual void initParam(EOT & _solution) {}; + virtual void initParam(EOT & /*_solution*/) {}; /** * updateParam: NOTHING TO DO * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) {}; + virtual void updateParam(EOT & /*_solution*/) {}; /** * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood of a solution until an ameliorated neighbor is found @@ -135,7 +135,7 @@ public: * @param _solution the solution * @return true if an ameliorated neighbor was found */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { if (stop) return isAccept ; else diff --git a/mo/src/explorer/moILSexplorer.h b/mo/src/explorer/moILSexplorer.h index 761009005..49d74fea5 100644 --- a/mo/src/explorer/moILSexplorer.h +++ b/mo/src/explorer/moILSexplorer.h @@ -106,7 +106,7 @@ public: * terminate: NOTHING TO DO * @param _solution a solution (unused) */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Perturb and apply local search on a solution @@ -135,7 +135,7 @@ public: * @param _solution the solution * @return always true */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return true; }; diff --git a/mo/src/explorer/moMetropolisHastingExplorer.h b/mo/src/explorer/moMetropolisHastingExplorer.h index 1989ff1c3..ea0913f1e 100644 --- a/mo/src/explorer/moMetropolisHastingExplorer.h +++ b/mo/src/explorer/moMetropolisHastingExplorer.h @@ -85,7 +85,7 @@ public: * initialization of the number of step to be done * @param _solution unused solution */ - virtual void initParam(EOT & _solution) { + virtual void initParam(EOT & /*_solution*/) { step = 0; isAccept = true; }; @@ -94,7 +94,7 @@ public: * increase the number of step * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) { + virtual void updateParam(EOT & /*_solution*/) { step++; }; @@ -102,7 +102,7 @@ public: * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood of a solution @@ -128,7 +128,7 @@ public: * @param _solution the solution * @return true there is some steps to do */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return (step < nbStep) ; }; diff --git a/mo/src/explorer/moNeutralHCexplorer.h b/mo/src/explorer/moNeutralHCexplorer.h index 40443de40..2eefa797d 100644 --- a/mo/src/explorer/moNeutralHCexplorer.h +++ b/mo/src/explorer/moNeutralHCexplorer.h @@ -105,7 +105,7 @@ public: * @param _solution the solution * @return true there is some steps to do */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return (step < nbStep) && isAccept ; }; diff --git a/mo/src/explorer/moRandomBestHCexplorer.h b/mo/src/explorer/moRandomBestHCexplorer.h index e96f6673b..92e690e37 100644 --- a/mo/src/explorer/moRandomBestHCexplorer.h +++ b/mo/src/explorer/moRandomBestHCexplorer.h @@ -85,7 +85,7 @@ public: * empty the vector of best solutions * @param _solution unused solution */ - virtual void initParam(EOT & _solution) { + virtual void initParam(EOT & /*_solution*/) { // delete all the best solutions bestVector.clear(); }; @@ -94,7 +94,7 @@ public: * empty the vector of best solutions * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) { + virtual void updateParam(EOT & /*_solution*/) { // delete all the best solutions bestVector.clear(); }; @@ -103,7 +103,7 @@ public: * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood of a solution @@ -156,7 +156,7 @@ public: * @param _solution the solution * @return true if an ameliorated neighbor was be found */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return isAccept ; }; diff --git a/mo/src/explorer/moRandomNeutralWalkExplorer.h b/mo/src/explorer/moRandomNeutralWalkExplorer.h index 95995c753..e8f9713bf 100644 --- a/mo/src/explorer/moRandomNeutralWalkExplorer.h +++ b/mo/src/explorer/moRandomNeutralWalkExplorer.h @@ -87,7 +87,7 @@ public: * initialization of the number of step to be done * @param _solution unused solution */ - virtual void initParam(EOT & _solution) { + virtual void initParam(EOT & /*_solution*/) { step = 0; isAccept = true; }; @@ -96,7 +96,7 @@ public: * increase the number of step * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) { + virtual void updateParam(EOT & /*_solution*/) { step++; }; @@ -104,7 +104,7 @@ public: * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood of a solution @@ -142,7 +142,7 @@ public: * @param _solution the solution * @return true there is some steps to do */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return (step < nbStep) && isAccept ; }; diff --git a/mo/src/explorer/moRandomSearchExplorer.h b/mo/src/explorer/moRandomSearchExplorer.h index 0b09da1d9..f8b81d00c 100644 --- a/mo/src/explorer/moRandomSearchExplorer.h +++ b/mo/src/explorer/moRandomSearchExplorer.h @@ -74,7 +74,7 @@ public: * initialization of the number of step to be done * @param _solution unused solution */ - virtual void initParam(EOT & _solution) { + virtual void initParam(EOT & /*_solution*/) { step = 0; }; @@ -82,7 +82,7 @@ public: * increase the number of step * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) { + virtual void updateParam(EOT & /*_solution*/) { step++; }; @@ -90,7 +90,7 @@ public: * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood with only one random solution @@ -111,7 +111,7 @@ public: * @param _solution the solution * @return true there is some steps to do */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return (step < nbStep) ; }; @@ -119,7 +119,7 @@ public: * move the solution with the best neighbor * @param _solution the solution to move */ - virtual void move(EOT & _solution) { + virtual void move(EOT & /*_solution*/) { // the solution is already move. So nothing to do ! }; @@ -128,7 +128,7 @@ public: * @param _solution the solution * @return true if the best neighbor ameliorate the fitness */ - virtual bool accept(EOT & _solution) { + virtual bool accept(EOT & /*_solution*/) { return true; }; diff --git a/mo/src/explorer/moRandomWalkExplorer.h b/mo/src/explorer/moRandomWalkExplorer.h index 78f1be303..889382a2b 100644 --- a/mo/src/explorer/moRandomWalkExplorer.h +++ b/mo/src/explorer/moRandomWalkExplorer.h @@ -82,7 +82,7 @@ public: * initialization of the number of step to be done * @param _solution unused solution */ - virtual void initParam(EOT & _solution) { + virtual void initParam(EOT & /*_solution*/) { isAccept = true; }; @@ -90,14 +90,14 @@ public: * increase the number of step * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) { + virtual void updateParam(EOT & /*_solution*/) { }; /** * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood with only one random solution @@ -127,7 +127,7 @@ public: * @param _solution the solution * @return true there is some steps to do */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return isAccept ; }; diff --git a/mo/src/explorer/moSAexplorer.h b/mo/src/explorer/moSAexplorer.h index 08d859035..b774d5c57 100644 --- a/mo/src/explorer/moSAexplorer.h +++ b/mo/src/explorer/moSAexplorer.h @@ -95,7 +95,7 @@ public: * decrease the temperature if necessary * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) { + virtual void updateParam(EOT & /*_solution*/) { coolingSchedule.update(temperature, this->moveApplied()); }; @@ -103,7 +103,7 @@ public: * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore one random solution in the neighborhood @@ -129,7 +129,7 @@ public: * @param _solution the solution * @return true if the criteria from the cooling schedule is true */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return coolingSchedule(temperature); }; diff --git a/mo/src/explorer/moSimpleHCexplorer.h b/mo/src/explorer/moSimpleHCexplorer.h index b4f235ae8..ee1cded53 100644 --- a/mo/src/explorer/moSimpleHCexplorer.h +++ b/mo/src/explorer/moSimpleHCexplorer.h @@ -76,19 +76,19 @@ public: * initParam: NOTHING TO DO * @param _solution unused solution */ - virtual void initParam(EOT & _solution) {}; + virtual void initParam(EOT & /*_solution*/) {}; /** * updateParam: NOTHING TO DO * @param _solution unused solution */ - virtual void updateParam(EOT & _solution) {}; + virtual void updateParam(EOT & /*_solution*/) {}; /** * terminate: NOTHING TO DO * @param _solution unused solution */ - virtual void terminate(EOT & _solution) {}; + virtual void terminate(EOT & /*_solution*/) {}; /** * Explore the neighborhood of a solution @@ -130,7 +130,7 @@ public: * @param _solution the solution * @return true if an ameliorated neighbor was be found */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return isAccept ; }; diff --git a/mo/src/explorer/moTSexplorer.h b/mo/src/explorer/moTSexplorer.h index 062af93cc..8438d58af 100644 --- a/mo/src/explorer/moTSexplorer.h +++ b/mo/src/explorer/moTSexplorer.h @@ -195,7 +195,7 @@ public: * @param _solution the solution * @return true */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return true; }; @@ -204,7 +204,7 @@ public: * @param _solution the solution * @return true if the best neighbor ameliorate the fitness */ - virtual bool accept(EOT & _solution) { + virtual bool accept(EOT & /*_solution*/) { return isAccept; }; diff --git a/mo/src/explorer/moVNSexplorer.h b/mo/src/explorer/moVNSexplorer.h index 3c9c2ef27..b7633c26e 100644 --- a/mo/src/explorer/moVNSexplorer.h +++ b/mo/src/explorer/moVNSexplorer.h @@ -124,7 +124,7 @@ public: * @param _solution the solution * @return true if an ameliorated neighbor was be found */ - virtual bool isContinue(EOT & _solution) { + virtual bool isContinue(EOT & /*_solution*/) { return !stop; }; diff --git a/mo/src/memory/moBestImprAspiration.h b/mo/src/memory/moBestImprAspiration.h index 7187ef666..b83c5d527 100644 --- a/mo/src/memory/moBestImprAspiration.h +++ b/mo/src/memory/moBestImprAspiration.h @@ -56,7 +56,7 @@ public: * @param _sol a solution * @param _neighbor a neighbor */ - void update(EOT & _sol, Neighbor & _neighbor) { + void update(EOT & _sol, Neighbor & /*_neighbor*/) { if (bestFoundSoFar.fitness() < _sol.fitness()) bestFoundSoFar = _sol; } @@ -68,7 +68,7 @@ public: * @param _neighbor a neighbor * @return true if _neighbor fitness is better than the "bestFoundSoFar" */ - bool operator()(EOT & _sol, Neighbor & _neighbor) { + bool operator()(EOT & /*_sol*/, Neighbor & _neighbor) { return (bestFoundSoFar.fitness() < _neighbor.fitness()); } diff --git a/mo/src/memory/moCountMoveMemory.h b/mo/src/memory/moCountMoveMemory.h index 22cbba5fd..eb6ae6825 100644 --- a/mo/src/memory/moCountMoveMemory.h +++ b/mo/src/memory/moCountMoveMemory.h @@ -45,7 +45,7 @@ public: * Init all the counters * @param _sol unused solution */ - void init(EOT & _sol) { + void init(EOT & /*_sol*/) { nbMove=0; nbNoMove=0; counter=0; @@ -55,7 +55,7 @@ public: * @param _sol unused solution * @param _neighbor unused neighbor */ - void add(EOT & _sol, Neighbor & _neighbor) { + void add(EOT & /*_sol*/, Neighbor & /*_neighbor*/) { nbMove++; counter=0; } @@ -64,7 +64,7 @@ public: * @param _sol unused solution * @param _neighbor unused neighbor */ - void update(EOT & _sol, Neighbor & _neighbor) { + void update(EOT & /*_sol*/, Neighbor & /*_neighbor*/) { nbNoMove++; counter++; } diff --git a/mo/src/memory/moDummyMemory.h b/mo/src/memory/moDummyMemory.h index c927a30f0..f176cb1bc 100644 --- a/mo/src/memory/moDummyMemory.h +++ b/mo/src/memory/moDummyMemory.h @@ -44,17 +44,17 @@ public: /** * Init : NOTHIING TO DO */ - void init(EOT & _sol) {} + void init(EOT & /*_sol*/) {} /** * Add : NOTHIING TO DO */ - void add(EOT & _sol, Neighbor & _neighbor) {} + void add(EOT & /*_sol*/, Neighbor & /*_neighbor*/) {} /** * Update : NOTHIING TO DO */ - void update(EOT & _sol, Neighbor & _neighbor) {} + void update(EOT & /*_sol*/, Neighbor & /*_neighbor*/) {} /** * ClearMemory : NOTHIING TO DO diff --git a/mo/src/memory/moIndexedVectorTabuList.h b/mo/src/memory/moIndexedVectorTabuList.h index e1ea94492..b56742602 100644 --- a/mo/src/memory/moIndexedVectorTabuList.h +++ b/mo/src/memory/moIndexedVectorTabuList.h @@ -73,7 +73,7 @@ public: * init the tabuList by clearing the memory * @param _sol the current solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { clearMemory(); } @@ -83,7 +83,7 @@ public: * @param _sol unused solution * @param _neighbor the current neighbor */ - virtual void add(EOT & _sol, Neighbor & _neighbor) { + virtual void add(EOT & /*_sol*/, Neighbor & _neighbor) { if (_neighbor.index() < maxSize) { if (robust) // random value between min and max @@ -98,7 +98,7 @@ public: * @param _sol unused solution * @param _neighbor unused neighbor */ - virtual void update(EOT & _sol, Neighbor & _neighbor) { + virtual void update(EOT & /*_sol*/, Neighbor & /*_neighbor*/) { for (unsigned int i = 0; i < maxSize; i++) if (tabuList[i] > 0) tabuList[i]--; @@ -110,7 +110,7 @@ public: * @param _neighbor the current neighbor * @return true if tabuList contains _sol */ - virtual bool check(EOT & _sol, Neighbor & _neighbor) { + virtual bool check(EOT & /*_sol*/, Neighbor & _neighbor) { return (tabuList[_neighbor.index()] > 0); } diff --git a/mo/src/memory/moNeighborVectorTabuList.h b/mo/src/memory/moNeighborVectorTabuList.h index dbf8edb0f..5e8f8eec7 100644 --- a/mo/src/memory/moNeighborVectorTabuList.h +++ b/mo/src/memory/moNeighborVectorTabuList.h @@ -57,7 +57,7 @@ public: * init the tabuList by clearing the memory * @param _sol the current solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { clearMemory(); } @@ -67,7 +67,7 @@ public: * @param _sol unused solution * @param _neighbor the current neighbor */ - virtual void add(EOT & _sol, Neighbor & _neighbor) { + virtual void add(EOT & /*_sol*/, Neighbor & _neighbor) { if (tabuList.size() < maxSize) { std::pair tmp; @@ -87,7 +87,7 @@ public: * @param _sol unused solution * @param _neighbor unused neighbor */ - virtual void update(EOT & _sol, Neighbor & _neighbor) { + virtual void update(EOT & /*_sol*/, Neighbor & /*_neighbor*/) { if (howlong > 0) for (unsigned int i=0; i 0) @@ -100,7 +100,7 @@ public: * @param _neighbor the current neighbor * @return true if tabuList contains _sol */ - virtual bool check(EOT & _sol, Neighbor & _neighbor) { + virtual bool check(EOT & /*_sol*/, Neighbor & _neighbor) { for (unsigned int i=0; i 0 && tabuList[i].second > 0 && tabuList[i].first.equals(_neighbor)) || (howlong==0 && tabuList[i].first.equals(_neighbor))) return true; diff --git a/mo/src/memory/moRndIndexedVectorTabuList.h b/mo/src/memory/moRndIndexedVectorTabuList.h index 82ffc0e04..dd6f11765 100644 --- a/mo/src/memory/moRndIndexedVectorTabuList.h +++ b/mo/src/memory/moRndIndexedVectorTabuList.h @@ -67,7 +67,7 @@ public: * @param _sol unused solution * @param _neighbor the current neighbor */ - virtual void add(EOT & _sol, Neighbor & _neighbor) { + virtual void add(EOT & /*_sol*/, Neighbor & _neighbor) { if (_neighbor.index() < maxSize) tabuList[_neighbor.index()] = howlong + rng.uniform(howlongRnd) ; } diff --git a/mo/src/memory/moSolVectorTabuList.h b/mo/src/memory/moSolVectorTabuList.h index ba72ccc43..31c57c0f6 100644 --- a/mo/src/memory/moSolVectorTabuList.h +++ b/mo/src/memory/moSolVectorTabuList.h @@ -57,7 +57,7 @@ public: * init the tabuList by clearing the memory * @param _sol the current solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { clearMemory(); } @@ -67,7 +67,7 @@ public: * @param _sol the current solution * @param _neighbor unused neighbor */ - virtual void add(EOT & _sol, Neighbor & _neighbor) { + virtual void add(EOT & _sol, Neighbor & /*_neighbor*/) { if (tabuList.size() < maxSize) { std::pair tmp; @@ -87,7 +87,7 @@ public: * @param _sol the current solution * @param _neighbor the current neighbor (unused) */ - virtual void update(EOT & _sol, Neighbor & _neighbor) { + virtual void update(EOT & /*_sol*/, Neighbor & /*_neighbor*/) { if (howlong > 0) for (unsigned int i=0; i 0) diff --git a/mo/src/neighborhood/moBackwardVectorVNSelection.h b/mo/src/neighborhood/moBackwardVectorVNSelection.h index b3050c439..a47b31e30 100644 --- a/mo/src/neighborhood/moBackwardVectorVNSelection.h +++ b/mo/src/neighborhood/moBackwardVectorVNSelection.h @@ -69,7 +69,7 @@ public: * @param _solution the current solution * @return true if there is some heuristics */ - virtual bool cont(EOT& _solution){ + virtual bool cont(EOT& /*_solution*/){ return (cycle || (current > 0)); } @@ -78,7 +78,7 @@ public: * * @param _solution the current solution */ - virtual void init(EOT& _solution){ + virtual void init(EOT& /*_solution*/){ current = LSvector.size() - 1; } @@ -87,7 +87,7 @@ public: * * @param _solution the current solution */ - virtual void next(EOT& _solution){ + virtual void next(EOT& /*_solution*/){ current = (current + LSvector.size() -1) % LSvector.size(); } diff --git a/mo/src/neighborhood/moDummyNeighbor.h b/mo/src/neighborhood/moDummyNeighbor.h index a8cd01087..e68b2b079 100644 --- a/mo/src/neighborhood/moDummyNeighbor.h +++ b/mo/src/neighborhood/moDummyNeighbor.h @@ -43,6 +43,6 @@ public: * NOTHING TO DO * @param _solution the related solution */ - virtual void move(EOT& _solution) {} + virtual void move(EOT& /*_solution*/) {} }; #endif diff --git a/mo/src/neighborhood/moDummyNeighborhood.h b/mo/src/neighborhood/moDummyNeighborhood.h index 26c62163c..eda0ae490 100644 --- a/mo/src/neighborhood/moDummyNeighborhood.h +++ b/mo/src/neighborhood/moDummyNeighborhood.h @@ -46,7 +46,7 @@ public: * @param _solution unused solution * @return always false */ - virtual bool hasNeighbor(EOT & _solution) { + virtual bool hasNeighbor(EOT & /*_solution*/) { return false; } @@ -55,21 +55,21 @@ public: * @param _solution unused solution * @param _current unused neighbor */ - virtual void init(EOT & _solution, Neighbor & _current) {} + virtual void init(EOT & /*_solution*/, Neighbor & /*_current*/) {} /** * NOTHING TO DO * @param _solution unused solution * @param _current unused neighbor */ - virtual void next(EOT & _solution, Neighbor & _current) {} + virtual void next(EOT & /*_solution*/, Neighbor & /*_current*/) {} /** * NOTHING TO DO * @param _solution unused solution * @return always false */ - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { return false; } diff --git a/mo/src/neighborhood/moForwardVectorVNSelection.h b/mo/src/neighborhood/moForwardVectorVNSelection.h index d7d3546cb..d469cf6be 100644 --- a/mo/src/neighborhood/moForwardVectorVNSelection.h +++ b/mo/src/neighborhood/moForwardVectorVNSelection.h @@ -69,7 +69,7 @@ public: * @param _solution the current solution * @return true if there is some heuristics */ - virtual bool cont(EOT& _solution){ + virtual bool cont(EOT& /*_solution*/){ return (cycle || (current <= (LSvector.size() - 2))); } @@ -78,7 +78,7 @@ public: * * @param _solution the current solution */ - virtual void init(EOT& _solution){ + virtual void init(EOT& /*_solution*/){ current = 0; } @@ -87,7 +87,7 @@ public: * * @param _solution the current solution */ - virtual void next(EOT& _solution){ + virtual void next(EOT& /*_solution*/){ current = (current + 1) % LSvector.size(); } diff --git a/mo/src/neighborhood/moIndexNeighbor.h b/mo/src/neighborhood/moIndexNeighbor.h index eaf302966..880c08812 100644 --- a/mo/src/neighborhood/moIndexNeighbor.h +++ b/mo/src/neighborhood/moIndexNeighbor.h @@ -109,7 +109,7 @@ public: * @param _solution solution from which the neighborhood is visited * @param _key index of the IndexNeighbor */ - virtual void index(EOT & _solution, unsigned int _key) { + virtual void index(EOT & /*_solution*/, unsigned int _key) { key = _key; } diff --git a/mo/src/neighborhood/moNeighbor.h b/mo/src/neighborhood/moNeighbor.h index 889dd6817..8186c2435 100644 --- a/mo/src/neighborhood/moNeighbor.h +++ b/mo/src/neighborhood/moNeighbor.h @@ -93,7 +93,7 @@ public: * @param _neighbor a neighbor * @return if _neighbor and this one are equals */ - virtual bool equals(moNeighbor & _neighbor) { + virtual bool equals(moNeighbor & /*_neighbor*/) { return false; } diff --git a/mo/src/neighborhood/moOrderNeighborhood.h b/mo/src/neighborhood/moOrderNeighborhood.h index 384d0dda7..316ba8cba 100644 --- a/mo/src/neighborhood/moOrderNeighborhood.h +++ b/mo/src/neighborhood/moOrderNeighborhood.h @@ -71,7 +71,7 @@ public: * @param _solution the solution to explore * @return true if the neighborhood was not empty */ - virtual bool hasNeighbor(EOT& _solution) { + virtual bool hasNeighbor(EOT& /*_solution*/) { return getNeighborhoodSize() > 0; } @@ -102,7 +102,7 @@ public: * @param _solution the solution to explore * @return true if there is again a neighbor to explore */ - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { return (currentIndex < getNeighborhoodSize() - 1); } diff --git a/mo/src/neighborhood/moRndVectorVNSelection.h b/mo/src/neighborhood/moRndVectorVNSelection.h index a460f2d45..af4ab22dd 100644 --- a/mo/src/neighborhood/moRndVectorVNSelection.h +++ b/mo/src/neighborhood/moRndVectorVNSelection.h @@ -72,7 +72,7 @@ public: * @param _solution the current solution * @return true if there is some heuristics */ - virtual bool cont(EOT& _solution){ + virtual bool cont(EOT& /*_solution*/){ return ( cycle || (currentOrder <= (order.size() - 2)) ); } @@ -81,7 +81,7 @@ public: * * @param _solution the current solution */ - virtual void init(EOT& _solution) { + virtual void init(EOT& /*_solution*/) { if(order.size() == 0) for(unsigned int i = 0; i < LSvector.size(); i++) order.push_back(i); @@ -98,7 +98,7 @@ public: * * @param _solution the current solution */ - virtual void next(EOT& _solution){ + virtual void next(EOT& /*_solution*/){ currentOrder = (currentOrder + 1) % order.size(); current = order[currentOrder]; diff --git a/mo/src/neighborhood/moRndWithReplNeighborhood.h b/mo/src/neighborhood/moRndWithReplNeighborhood.h index 89537bf09..d66b72ac8 100644 --- a/mo/src/neighborhood/moRndWithReplNeighborhood.h +++ b/mo/src/neighborhood/moRndWithReplNeighborhood.h @@ -68,7 +68,7 @@ public: * @param _solution the solution to explore * @return true if the neighborhood was not empty */ - virtual bool hasNeighbor(EOT& _solution) { + virtual bool hasNeighbor(EOT& /*_solution*/) { return neighborhoodSize > 0; } @@ -97,7 +97,7 @@ public: * @param _solution the solution to explore * @return true if there is again a neighbor to explore */ - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { if (maxNeighbors == 0) return neighborhoodSize > 0; else diff --git a/mo/src/neighborhood/moRndWithoutReplNeighborhood.h b/mo/src/neighborhood/moRndWithoutReplNeighborhood.h index e51c6d6e7..dfa057a28 100644 --- a/mo/src/neighborhood/moRndWithoutReplNeighborhood.h +++ b/mo/src/neighborhood/moRndWithoutReplNeighborhood.h @@ -69,7 +69,7 @@ public: * @param _solution the solution to explore * @return true if the neighborhood was not empty */ - virtual bool hasNeighbor(EOT& _solution) { + virtual bool hasNeighbor(EOT& /*_solution*/) { return neighborhoodSize > 0; } @@ -110,7 +110,7 @@ public: * @param _solution the solution to explore * @return true if there is again a neighbor to explore */ - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { return (maxIndex > 0) ; } diff --git a/mo/src/perturb/moNeighborhoodPerturb.h b/mo/src/perturb/moNeighborhoodPerturb.h index 676f5a828..fe66bdbb9 100644 --- a/mo/src/perturb/moNeighborhoodPerturb.h +++ b/mo/src/perturb/moNeighborhoodPerturb.h @@ -79,7 +79,7 @@ public: * @param _sol the current solution * @param _neighbor unused neighbor (always empty) */ - virtual void add(EOT & _sol, Neighbor & _neighbor) { + virtual void add(EOT & _sol, Neighbor & /*_neighbor*/) { (*this).init(_sol); } @@ -88,7 +88,7 @@ public: * @param _sol the current solution * @param _neighbor unused neighbor (always empty) */ - virtual void update(EOT & _sol, Neighbor & _neighbor) { + virtual void update(EOT & _sol, Neighbor & /*_neighbor*/) { if (otherNeighborhood.cont(_sol)) otherNeighborhood.next(_sol, current); else diff --git a/mo/src/problems/bitString/moBitsWithReplNeighborhood.h b/mo/src/problems/bitString/moBitsWithReplNeighborhood.h index 8c833f1a2..34d2a9623 100644 --- a/mo/src/problems/bitString/moBitsWithReplNeighborhood.h +++ b/mo/src/problems/bitString/moBitsWithReplNeighborhood.h @@ -98,13 +98,13 @@ public: * @param _neighbor the first neighbor * @param _n Hamming distance of the neighbor */ - virtual void randomNeighbor(EOT & _solution, Neighbor & _neighbor, unsigned _n) { + virtual void randomNeighbor(EOT & /*_solution*/, Neighbor & _neighbor, unsigned _n) { _neighbor.bits.resize(_n); _neighbor.nBits = _n; unsigned i; unsigned b; - unsigned tmp; + // unsigned tmp; for(unsigned k = 0; k < _n; k++) { i = rng.random(length - k); @@ -167,7 +167,7 @@ public: * @param _solution the solution to explore * @return true if there is again a neighbor to explore: population size larger or equals than 1 */ - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { return nNeighbors < sampleSize ; } diff --git a/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h b/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h index 4584a791a..34dad414f 100644 --- a/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h +++ b/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h @@ -142,7 +142,7 @@ public: * @param _solution the solution to explore * @param _neighbor the first neighbor */ - virtual void init(EOT & _solution, Neighbor & _neighbor) { + virtual void init(EOT & /*_solution*/, Neighbor & _neighbor) { maxIndex = neighborhoodSize ; unsigned i = rng.random(maxIndex); @@ -163,7 +163,7 @@ public: * @param _solution the solution to explore (population of solutions) * @param _neighbor the next neighbor which in order of distance */ - virtual void next(EOT & _solution, Neighbor & _neighbor) { + virtual void next(EOT & /*_solution*/, Neighbor & _neighbor) { unsigned i = rng.random(maxIndex); key = indexVector[i]; @@ -180,7 +180,7 @@ public: * @param _solution the solution to explore * @return true if there is again a neighbor to explore: population size larger or equals than 1 */ - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { return neighborhoodSize - maxIndex < sampleSize ; } diff --git a/mo/src/problems/permutation/moSwapNeighborhood.h b/mo/src/problems/permutation/moSwapNeighborhood.h index 8354337e6..0ad0f1a2f 100644 --- a/mo/src/problems/permutation/moSwapNeighborhood.h +++ b/mo/src/problems/permutation/moSwapNeighborhood.h @@ -54,7 +54,7 @@ public: * @param _solution the solution to explore * @param _current the first neighbor */ - virtual void init(EOT& _solution, Neighbor& _current) { + virtual void init(EOT& /*_solution*/, Neighbor& _current) { indices.first=0; indices.second=1; _current.setIndices(0,1); diff --git a/mo/src/problems/permutation/moTwoOptExNeighborhood.h b/mo/src/problems/permutation/moTwoOptExNeighborhood.h index 9723946bb..886fbc3de 100755 --- a/mo/src/problems/permutation/moTwoOptExNeighborhood.h +++ b/mo/src/problems/permutation/moTwoOptExNeighborhood.h @@ -57,7 +57,7 @@ public: * @param _solution the solution to explore * @param _current the first neighbor */ - virtual void init(EOT& _solution, Neighbor& _current) { + virtual void init(EOT& /*_solution*/, Neighbor& _current) { indices.first=0; indices.second=1; _current.setIndices(0,1); From 5e0e6fcd792d6c74c4179136f469e648f3ae79e8 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 06/69] 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 bad5d6cbb85a1267a878e625f8b2d508b3aff0b4 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 07/69] 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 5a7fdf7ed34102621e5b45348169af43f9b60feb Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 09:47:58 +0100 Subject: [PATCH 08/69] 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 9cb60e4b10d132530907dad4f738fd4b6fab78c8 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 09:51:56 +0100 Subject: [PATCH 09/69] 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 ff744aea7c6494476ad5ca36fd6ac7f07357ebe1 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:51:29 +0100 Subject: [PATCH 10/69] 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 f30240cb44dcc0c18f0086999a5a43858c2ff2c3 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:54:18 +0100 Subject: [PATCH 11/69] 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 e643468de8816858eb0948672f8066770b52c587 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:54:45 +0100 Subject: [PATCH 12/69] 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; From 55b2f57d19db2b6095ce1d664eb14fff5fd71fc9 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 19 Aug 2024 09:49:08 +0200 Subject: [PATCH 13/69] fix!(eoBit): defaults to `char` for scalar type Since STL's vector of bool is not a vector of bool, `swap`ing bool elements in an eoBit can lead to errors. Using `char` is a saner default. Potential BREAKING CHANGE. --- eo/contrib/MGE/eoInitVirus.h | 8 ++++---- eo/src/ga/eoBit.h | 4 ++-- eo/src/ga/make_genotype_ga.h | 2 +- eo/src/utils/eoRndGenerators.h | 2 +- mo/test/t-moNKlandscapesIncrEval.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eo/contrib/MGE/eoInitVirus.h b/eo/contrib/MGE/eoInitVirus.h index f4cb53072..f114f1a3b 100644 --- a/eo/contrib/MGE/eoInitVirus.h +++ b/eo/contrib/MGE/eoInitVirus.h @@ -41,7 +41,7 @@ template class eoInitVirus: public eoInit< eoVirus > { public: - eoInitVirus(unsigned _combien, eoRndGenerator& _generator ) + eoInitVirus(unsigned _combien, eoRndGenerator& _generator ) : combien(_combien), generator(_generator) {} virtual void operator()( eoVirus& chrom) @@ -58,7 +58,7 @@ public: private : unsigned combien; /// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics - eoSTLF generator; + eoSTLF generator; }; /// Inits the virus with one bit to the left set to one @@ -66,7 +66,7 @@ template class eoInitVirus1bit: public eoInit< eoVirus > { public: - eoInitVirus1bit(unsigned _combien, eoRndGenerator& _generator ) + eoInitVirus1bit(unsigned _combien, eoRndGenerator& _generator ) : combien(_combien), generator(_generator) {} virtual void operator()( eoVirus& chrom) @@ -81,6 +81,6 @@ public: private : unsigned combien; /// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics - eoSTLF generator; + eoSTLF generator; }; #endif diff --git a/eo/src/ga/eoBit.h b/eo/src/ga/eoBit.h index 320a5b7d1..3333099b4 100644 --- a/eo/src/ga/eoBit.h +++ b/eo/src/ga/eoBit.h @@ -60,12 +60,12 @@ Example of a complete test program that use various bitstrings operators: Based on STL's std::vector specialization. */ -template +template class eoBit: public eoVector { public: - using ScalarType = ScalarT; + using ScalarType = ScalarT; using eoVector< FitT, ScalarType >::begin; using eoVector< FitT, ScalarType >::end; diff --git a/eo/src/ga/make_genotype_ga.h b/eo/src/ga/make_genotype_ga.h index 3a1afaa84..fd877f02d 100644 --- a/eo/src/ga/make_genotype_ga.h +++ b/eo/src/ga/make_genotype_ga.h @@ -68,7 +68,7 @@ eoInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT, float _b // Then we can built a bitstring random initializer // based on boolean_generator class (see utils/rnd_generator.h) - eoBooleanGenerator * gen = new eoBooleanGenerator(_bias); + eoBooleanGenerator * gen = new eoBooleanGenerator(_bias); _state.storeFunctor(gen); eoInitFixedLength* init = new eoInitFixedLength(theSize, *gen); // store in state diff --git a/eo/src/utils/eoRndGenerators.h b/eo/src/utils/eoRndGenerators.h index e1168dcd2..48cd82af1 100644 --- a/eo/src/utils/eoRndGenerators.h +++ b/eo/src/utils/eoRndGenerators.h @@ -115,7 +115,7 @@ inline bool eoUniformGenerator::operator()(void) to easily generate random booleans with a specified bias \ingroup bitstring */ -template +template class eoBooleanGenerator : public eoRndGenerator { public : diff --git a/mo/test/t-moNKlandscapesIncrEval.cpp b/mo/test/t-moNKlandscapesIncrEval.cpp index cf9df9de1..f9a76662b 100644 --- a/mo/test/t-moNKlandscapesIncrEval.cpp +++ b/mo/test/t-moNKlandscapesIncrEval.cpp @@ -56,7 +56,7 @@ int main() { nkLandscapesEval eval(N, K); // init - eoUniformGenerator uGen; + eoUniformGenerator uGen; eoInitFixedLength init(N, uGen); // verif constructor From 6f7d505a2aa876004bad6353395a039924ffd548 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 19 Aug 2024 11:02:15 +0200 Subject: [PATCH 14/69] fix(rnd): use STL's rand gen for shuffles Previous implementation used Paradiseo's own random generator system, now superseeded by the STL's one. --- eo/src/eoInit.h | 6 +++-- eo/src/eoPop.h | 2 +- eo/src/utils/rnd_generators.h | 9 ++++--- .../src/selection/moeoNumberUnvisitedSelect.h | 27 ++++++++++--------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index 58eef63e0..5230b2982 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -29,11 +29,12 @@ #include #include +#include #include "eoOp.h" #include "eoSTLFunctor.h" #include "utils/eoRndGenerators.h" -#include "utils/rnd_generators.h" // for shuffle method +// #include "utils/rnd_generators.h" // for shuffle method #include "eoExceptions.h" @@ -197,7 +198,8 @@ class eoInitPermutation: public eoInit // FIXME inherit from eoInitWithDim chrom[idx] = idx+startFrom; } - UF_random_generator gen(chrom.size()); + std::random_device rd; + std::mt19937 gen(rd()); std::shuffle(chrom.begin(), chrom.end(), gen); chrom.invalidate(); } diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index fe84aa365..fe91102b3 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -45,7 +45,7 @@ Authors: #include "eoOp.h" // for eoInit #include "eoPersistent.h" #include "eoInit.h" -#include "utils/rnd_generators.h" // for shuffle method +// #include "utils/rnd_generators.h" // for shuffle method #include "eoExceptions.h" /** A std::vector of EO object, to be used in all algorithms diff --git a/eo/src/utils/rnd_generators.h b/eo/src/utils/rnd_generators.h index 01b682b67..aae3e0000 100644 --- a/eo/src/utils/rnd_generators.h +++ b/eo/src/utils/rnd_generators.h @@ -124,6 +124,7 @@ inline bool random_generator::operator()(void) function (see eoPop::shuffle): its operator() takes an unsigned argument m and must return an unsigned uniformly distributed in [0,m} */ +// FIXME this is probably deprecated by the new STL way of managing random generators. template class UF_random_generator { @@ -134,11 +135,11 @@ class UF_random_generator : _max(max), _random(_rng) {} - T operator()() { return _random.random(_max); } - T operator()(T m) { return _random.random(m); } + T operator()() const { return _random.random(_max); } + T operator()(T m) const { return _random.random(m); } - T min() { return 0; } - T max() { return _max; } + T min() const { return 0; } + T max() const { return _max; } private : T _max; diff --git a/moeo/src/selection/moeoNumberUnvisitedSelect.h b/moeo/src/selection/moeoNumberUnvisitedSelect.h index d31fb2ef2..5a23843f7 100644 --- a/moeo/src/selection/moeoNumberUnvisitedSelect.h +++ b/moeo/src/selection/moeoNumberUnvisitedSelect.h @@ -39,6 +39,8 @@ #ifndef _MOEONUMBERUNVISITEDSELECT_H #define _MOEONUMBERUNVISITEDSELECT_H +#include + #include #include @@ -51,10 +53,10 @@ class moeoNumberUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > public: - /** - * Constructor - * @param _number the number of individuals to select - */ + /** + * Constructor + * @param _number the number of individuals to select + */ moeoNumberUnvisitedSelect(unsigned int _number): number(_number){} /** @@ -64,24 +66,25 @@ public: */ std::vector operator()(eoPop < MOEOT > & _src) { - std::vector res; - res.resize(0); + std::vector res; + res.resize(0); for (unsigned int i=0; i<_src.size(); i++) { if (_src[i].flag() == 0) - res.push_back(i); + res.push_back(i); } if(number < res.size()){ - UF_random_generator rndGen(res.size()); - std::random_shuffle(res.begin(), res.end(), rndGen); - res.resize(number); + std::random_device rd; + std::mt19937 gen(rd()); + std::shuffle(res.begin(), res.end(), gen); + res.resize(number); } return res; } private: - /** number of individuals to select */ - unsigned int number; + /** number of individuals to select */ + unsigned int number; }; From ec1a0f0c629eba300437c4114f8be5f21bd998ae Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 22 Aug 2024 22:21:57 +0200 Subject: [PATCH 15/69] fix(eoForgeVector): use shared_ptr insteadof raw ones + adds instantiate_ptr interface --- eo/src/eoForge.h | 76 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/eo/src/eoForge.h b/eo/src/eoForge.h index 6fcccf811..a9507e9c7 100644 --- a/eo/src/eoForge.h +++ b/eo/src/eoForge.h @@ -74,6 +74,7 @@ class eoForgeInterface { public: virtual Itf& instantiate(bool no_cache = true) = 0; + virtual std::shared_ptr instantiate_ptr(bool no_cache = true) = 0; virtual ~eoForgeInterface() {} }; @@ -123,20 +124,33 @@ class eoForgeOperator : public eoForgeInterface * * @param no_cache If false, will enable caching previous instances. */ - Itf& instantiate(bool no_cache = true) + Itf& instantiate(bool no_cache = true) override { if(no_cache or not _instantiated) { - if(_instantiated) { - delete _instantiated; - } + // if(_instantiated) { + // delete _instantiated; + // } _instantiated = op_constructor(_args); + // _instantiated = op_constructor(_args); } return *_instantiated; } - virtual ~eoForgeOperator() + std::shared_ptr instantiate_ptr(bool no_cache = true) override { - delete _instantiated; + if(no_cache or not _instantiated) { + if(_instantiated) { + // delete _instantiated; + } + _instantiated = op_constructor(_args); + // _instantiated = op_constructor(_args); + } + return _instantiated; + } + + virtual ~eoForgeOperator() override + { + // delete _instantiated; } protected: @@ -145,15 +159,18 @@ class eoForgeOperator : public eoForgeInterface private: /** Metaprogramming machinery which deals with arguments lists @{ */ template - Op* op_constructor(T& args) + std::shared_ptr op_constructor(T& args) + // Op* op_constructor(T& args) { // FIXME double-check that the copy-constructor is a good idea to make_from_tuple with dynamic storage duration. - return new Op(std::make_from_tuple(args)); + return std::make_shared(std::make_from_tuple(args)); + // return new Op(std::make_from_tuple(args)); } /** @} */ protected: - Itf* _instantiated; + std::shared_ptr _instantiated; + // Itf* _instantiated; }; /** Partial specialization for constructors without any argument. @@ -166,24 +183,38 @@ class eoForgeOperator : public eoForgeInterface _instantiated(nullptr) { } - Itf& instantiate( bool no_cache = true ) + Itf& instantiate( bool no_cache = true ) override { if(no_cache or not _instantiated) { - if(_instantiated) { - delete _instantiated; - } - _instantiated = new Op; + // if(_instantiated) { + // delete _instantiated; + // } + _instantiated = std::shared_ptr(); + // _instantiated = new Op; } return *_instantiated; } - virtual ~eoForgeOperator() + std::shared_ptr instantiate_ptr( bool no_cache = true ) override { - delete _instantiated; + if(no_cache or not _instantiated) { + // if(_instantiated) { + // delete _instantiated; + // } + _instantiated = std::shared_ptr(); + // _instantiated = new Op; + } + return _instantiated; + } + + virtual ~eoForgeOperator() override + { + // delete _instantiated; } protected: - Itf* _instantiated; + std::shared_ptr _instantiated; + // Itf* _instantiated; }; /** A vector holding an operator (with deferred instantiation) at a given index. @@ -252,6 +283,17 @@ class eoForgeVector : public std::vector*> return this->at(static_cast(index))->instantiate(_no_cache); } + std::shared_ptr instantiate_ptr(double index) + { + double frac_part, int_part; + frac_part = std::modf(index, &int_part); + if(frac_part != 0) { + eo::log << eo::errors << "there is a fractional part in the given index (" << index << ")" << std::endl; + assert(frac_part != 0); + } + return this->at(static_cast(index))->instantiate_ptr(_no_cache); + } + /** Add an operator to the list. * * @warning When passing a reference (as it is often the case within ParadisEO), From 93e89828b8ee4137ee78e1adc0019e31da2c1080 Mon Sep 17 00:00:00 2001 From: Jxtopher <39927513+Jxtopher@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:08:30 +0200 Subject: [PATCH 16/69] Fix CI: random class issue, t-eoRoulette and update the workflow --- .github/workflows/build_ubuntu_debug.yml | 7 +------ eo/src/eoProportionalSelect.h | 8 ++------ eo/src/ga/eoBitOp.h | 8 ++++---- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_ubuntu_debug.yml b/.github/workflows/build_ubuntu_debug.yml index d6d5cad4b..b68744cb2 100644 --- a/.github/workflows/build_ubuntu_debug.yml +++ b/.github/workflows/build_ubuntu_debug.yml @@ -1,10 +1,5 @@ name: Build Debug (Ubuntu) - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [push, pull_request] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) diff --git a/eo/src/eoProportionalSelect.h b/eo/src/eoProportionalSelect.h index 65188bfe4..7329724ad 100644 --- a/eo/src/eoProportionalSelect.h +++ b/eo/src/eoProportionalSelect.h @@ -68,16 +68,12 @@ public: } assert(not _pop[0].invalid()); - const typename EOT::Fitness min_fit - = std::min_element( std::begin(_pop), std::end(_pop) ) - ->fitness(); - cumulative.clear(); - cumulative.push_back(_pop[0].fitness() - min_fit); + cumulative.push_back(_pop[0].fitness() ); for (unsigned i = 1; i < _pop.size(); ++i) { assert(not _pop[i].invalid()); - cumulative.push_back(cumulative.back() + _pop[i].fitness() - min_fit); + cumulative.push_back(cumulative.back() + _pop[i].fitness()); } assert(cumulative.size() == _pop.size()); } diff --git a/eo/src/ga/eoBitOp.h b/eo/src/ga/eoBitOp.h index b3e33efec..50e23207d 100644 --- a/eo/src/ga/eoBitOp.h +++ b/eo/src/ga/eoBitOp.h @@ -361,10 +361,10 @@ template class eoUBitXover: public eoQuadOp { if (chrom1[i] != chrom2[i] && eo::rng.flip(preference)) { - // bool tmp = chrom1[i]; - // chrom1[i]=chrom2[i]; - // chrom2[i] = tmp; - std::swap(chrom1[i], chrom2[i]); + bool tmp = chrom1[i]; + chrom1[i]=chrom2[i]; + chrom2[i] = tmp; + // std::swap(chrom1[i], chrom2[i]); changed = true; } } From c442d8a0a2bded5c1088be3f9cc231e447bb4107 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 08:57:38 +0200 Subject: [PATCH 17/69] Revert "fix!(eoBit): defaults to `char` for scalar type" This reverts commit 06e0cc0162b6f753d92076c510d7124d82a3def1. --- eo/contrib/MGE/eoInitVirus.h | 8 ++++---- eo/src/ga/eoBit.h | 4 ++-- eo/src/ga/make_genotype_ga.h | 2 +- eo/src/utils/eoRndGenerators.h | 2 +- mo/test/t-moNKlandscapesIncrEval.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eo/contrib/MGE/eoInitVirus.h b/eo/contrib/MGE/eoInitVirus.h index f114f1a3b..f4cb53072 100644 --- a/eo/contrib/MGE/eoInitVirus.h +++ b/eo/contrib/MGE/eoInitVirus.h @@ -41,7 +41,7 @@ template class eoInitVirus: public eoInit< eoVirus > { public: - eoInitVirus(unsigned _combien, eoRndGenerator& _generator ) + eoInitVirus(unsigned _combien, eoRndGenerator& _generator ) : combien(_combien), generator(_generator) {} virtual void operator()( eoVirus& chrom) @@ -58,7 +58,7 @@ public: private : unsigned combien; /// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics - eoSTLF generator; + eoSTLF generator; }; /// Inits the virus with one bit to the left set to one @@ -66,7 +66,7 @@ template class eoInitVirus1bit: public eoInit< eoVirus > { public: - eoInitVirus1bit(unsigned _combien, eoRndGenerator& _generator ) + eoInitVirus1bit(unsigned _combien, eoRndGenerator& _generator ) : combien(_combien), generator(_generator) {} virtual void operator()( eoVirus& chrom) @@ -81,6 +81,6 @@ public: private : unsigned combien; /// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics - eoSTLF generator; + eoSTLF generator; }; #endif diff --git a/eo/src/ga/eoBit.h b/eo/src/ga/eoBit.h index 3333099b4..320a5b7d1 100644 --- a/eo/src/ga/eoBit.h +++ b/eo/src/ga/eoBit.h @@ -60,12 +60,12 @@ Example of a complete test program that use various bitstrings operators: Based on STL's std::vector specialization. */ -template +template class eoBit: public eoVector { public: - using ScalarType = ScalarT; + using ScalarType = ScalarT; using eoVector< FitT, ScalarType >::begin; using eoVector< FitT, ScalarType >::end; diff --git a/eo/src/ga/make_genotype_ga.h b/eo/src/ga/make_genotype_ga.h index fd877f02d..3a1afaa84 100644 --- a/eo/src/ga/make_genotype_ga.h +++ b/eo/src/ga/make_genotype_ga.h @@ -68,7 +68,7 @@ eoInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT, float _b // Then we can built a bitstring random initializer // based on boolean_generator class (see utils/rnd_generator.h) - eoBooleanGenerator * gen = new eoBooleanGenerator(_bias); + eoBooleanGenerator * gen = new eoBooleanGenerator(_bias); _state.storeFunctor(gen); eoInitFixedLength* init = new eoInitFixedLength(theSize, *gen); // store in state diff --git a/eo/src/utils/eoRndGenerators.h b/eo/src/utils/eoRndGenerators.h index 48cd82af1..e1168dcd2 100644 --- a/eo/src/utils/eoRndGenerators.h +++ b/eo/src/utils/eoRndGenerators.h @@ -115,7 +115,7 @@ inline bool eoUniformGenerator::operator()(void) to easily generate random booleans with a specified bias \ingroup bitstring */ -template +template class eoBooleanGenerator : public eoRndGenerator { public : diff --git a/mo/test/t-moNKlandscapesIncrEval.cpp b/mo/test/t-moNKlandscapesIncrEval.cpp index f9a76662b..cf9df9de1 100644 --- a/mo/test/t-moNKlandscapesIncrEval.cpp +++ b/mo/test/t-moNKlandscapesIncrEval.cpp @@ -56,7 +56,7 @@ int main() { nkLandscapesEval eval(N, K); // init - eoUniformGenerator uGen; + eoUniformGenerator uGen; eoInitFixedLength init(N, uGen); // verif constructor From 4bbb4a595e87ff829e9dc901157de83ff10c986e Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 10:02:22 +0200 Subject: [PATCH 18/69] fix(mpi): fix some namespaces issues with mpi --- eo/src/mpi/eoMpi.h | 9 +++++---- eo/src/mpi/eoMpiNode.cpp | 6 +++--- eo/src/mpi/eoMpiNode.h | 6 +++--- eo/src/mpi/eoMultiStart.h | 4 ++-- eo/src/mpi/eoParallelApply.h | 2 +- eo/src/mpi/implMpi.cpp | 5 ++++- eo/src/mpi/implMpi.h | 12 +++++++++++- eo/test/mpi/t-mpi-distrib-exp.cpp | 2 +- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/eo/src/mpi/eoMpi.h b/eo/src/mpi/eoMpi.h index 0bef5fea8..1038078ee 100644 --- a/eo/src/mpi/eoMpi.h +++ b/eo/src/mpi/eoMpi.h @@ -29,6 +29,7 @@ Authors: # include "../eoFunctor.h" # include "../eoExceptions.h" +# include "mpi/implMpi.h" # include "eoMpiNode.h" # include "eoMpiAssignmentAlgorithm.h" @@ -669,7 +670,7 @@ namespace eo timerStat.start("master_wait_for_all_responses"); while( assignmentAlgo.availableWorkers() != totalWorkers ) { - bmpi::status status = comm.probe( bmpi::any_source, eo::mpi::Channel::Messages ); + eo::mpi::status status = comm.probe( eo::mpi::any_source, eo::mpi::Channel::Messages ); int wrkRank = status.source(); that.handleResponse( wrkRank ); comm.send( wrkRank, Channel::Commands, Message::Finish ); @@ -686,7 +687,7 @@ namespace eo AssignmentAlgorithm& assignmentAlgo; Job< JobData > & that; - bmpi::communicator & comm; + eo::mpi::communicator & comm; }; /** @@ -713,7 +714,7 @@ namespace eo { eo::log << eo::debug << "[M" << comm.rank() << "] Waitin' for node..." << std::endl; - bmpi::status status = comm.probe( bmpi::any_source, eo::mpi::Channel::Messages ); + eo::mpi::status status = comm.probe( eo::mpi::any_source, eo::mpi::Channel::Messages ); int wrkRank = status.source(); eo::log << eo::debug << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl; @@ -797,7 +798,7 @@ namespace eo AssignmentAlgorithm& assignmentAlgo; int masterRank; const int workerStopCondition; - bmpi::communicator& comm; + eo::mpi::communicator& comm; JobStore& store; SendTaskFunction & sendTask; diff --git a/eo/src/mpi/eoMpiNode.cpp b/eo/src/mpi/eoMpiNode.cpp index ba6424bc4..d2ed436a3 100644 --- a/eo/src/mpi/eoMpiNode.cpp +++ b/eo/src/mpi/eoMpiNode.cpp @@ -27,14 +27,14 @@ namespace eo { void Node::init( int argc, char** argv ) { - static bmpi::environment env( argc, argv ); + static eo::mpi::environment env( argc, argv ); } - bmpi::communicator& Node::comm() + eo::mpi::communicator& Node::comm() { return _comm; } - bmpi::communicator Node::_comm; + eo::mpi::communicator Node::_comm; } } diff --git a/eo/src/mpi/eoMpiNode.h b/eo/src/mpi/eoMpiNode.h index c370e1c0b..268d89690 100644 --- a/eo/src/mpi/eoMpiNode.h +++ b/eo/src/mpi/eoMpiNode.h @@ -23,7 +23,7 @@ Authors: # define __MPI_NODE_H__ # include "implMpi.h" -namespace bmpi = mpi; +// namespace bmpi = mpi; namespace eo { @@ -54,10 +54,10 @@ namespace eo /** * @brief Returns the global mpi::communicator */ - static bmpi::communicator& comm(); + static eo::mpi::communicator& comm(); protected: - static bmpi::communicator _comm; + static eo::mpi::communicator _comm; }; } } diff --git a/eo/src/mpi/eoMultiStart.h b/eo/src/mpi/eoMultiStart.h index 71e084bb4..dd8c1fa29 100644 --- a/eo/src/mpi/eoMultiStart.h +++ b/eo/src/mpi/eoMultiStart.h @@ -54,7 +54,7 @@ namespace eo typedef eoUF< eoPop&, void> ResetAlgo; MultiStartData( - bmpi::communicator& _comm, + eo::mpi::communicator& _comm, eoAlgo& _algo, int _masterRank, ResetAlgo & _resetAlgo ) @@ -87,7 +87,7 @@ namespace eo /** * @brief Communicator, used to send and retrieve messages. */ - bmpi::communicator& comm; + eo::mpi::communicator& comm; /** * @brief Algorithm which will be performed by the worker. diff --git a/eo/src/mpi/eoParallelApply.h b/eo/src/mpi/eoParallelApply.h index c85e5f7a8..6ee01c81d 100644 --- a/eo/src/mpi/eoParallelApply.h +++ b/eo/src/mpi/eoParallelApply.h @@ -137,7 +137,7 @@ namespace eo std::vector tempArray; int masterRank; - bmpi::communicator& comm; + eo::mpi::communicator& comm; }; /** diff --git a/eo/src/mpi/implMpi.cpp b/eo/src/mpi/implMpi.cpp index 16b9ea2ce..2dd1ca0d5 100644 --- a/eo/src/mpi/implMpi.cpp +++ b/eo/src/mpi/implMpi.cpp @@ -21,6 +21,8 @@ Authors: */ #include "implMpi.h" +namespace eo +{ namespace mpi { const int any_source = MPI_ANY_SOURCE; @@ -163,4 +165,5 @@ namespace mpi { MPI_Bcast( &value, 1, MPI_INT, root, MPI_COMM_WORLD ); } -} +} // namespace mpi +} // namespace eo diff --git a/eo/src/mpi/implMpi.h b/eo/src/mpi/implMpi.h index c55cff6f8..d52b84b26 100644 --- a/eo/src/mpi/implMpi.h +++ b/eo/src/mpi/implMpi.h @@ -41,7 +41,8 @@ Authors: * The entities are here shortly described, if you need further details, don't hesitate * to visit the boost URL. */ - +namespace eo +{ namespace mpi { /** @@ -83,6 +84,14 @@ namespace mpi ~environment(); }; + struct MPI_Status { + int count; + int cancelled; + int MPI_SOURCE; + int MPI_TAG; + int MPI_ERROR; + }; + /** * @brief Wrapper class for MPI_Status * @@ -318,5 +327,6 @@ namespace mpi * @} */ } // namespace mpi +} // namespace eo # endif //__EO_IMPL_MPI_HPP__ diff --git a/eo/test/mpi/t-mpi-distrib-exp.cpp b/eo/test/mpi/t-mpi-distrib-exp.cpp index d3278fcad..905b8702c 100644 --- a/eo/test/mpi/t-mpi-distrib-exp.cpp +++ b/eo/test/mpi/t-mpi-distrib-exp.cpp @@ -382,7 +382,7 @@ class Experiment : public eoserial::Persistent void run() { - mpi::communicator& comm = eo::mpi::Node::comm(); + communicator& comm = eo::mpi::Node::comm(); // reinits every objects eo::rng.reseed( _seed ); eo::rng.clearCache(); // trick for repeatable sequences of normal numbers, cf eo::rng From 09a26fdc621d1353b0bc655aa51b446bbb0e9884 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 10:02:52 +0200 Subject: [PATCH 19/69] fix(eoForge): missing header --- eo/src/eoForge.h | 1 + 1 file changed, 1 insertion(+) diff --git a/eo/src/eoForge.h b/eo/src/eoForge.h index a9507e9c7..c7cf912ea 100644 --- a/eo/src/eoForge.h +++ b/eo/src/eoForge.h @@ -27,6 +27,7 @@ #include #include #include +#include // In case you want to debug arguments captured in tuples: // template From b4e89d8f51f141846488f6bc9f4e9ef7781f128d Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 14:28:34 +0200 Subject: [PATCH 20/69] fix(deprecated): guard from bind and *_function Deprecated since C++11, removed in C++17. --- eo/contrib/MGE/eoVirus.h | 5 +++++ eo/src/eoFunctor.h | 10 ++++++++++ eo/src/eoSTLFunctor.h | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/eo/contrib/MGE/eoVirus.h b/eo/contrib/MGE/eoVirus.h index a7c6aaeea..37b1daf4d 100644 --- a/eo/contrib/MGE/eoVirus.h +++ b/eo/contrib/MGE/eoVirus.h @@ -108,7 +108,12 @@ public: if (is) { virus.resize(bits.size()); std::transform(bits.begin(), bits.end(), virus.begin(), +#if __cplusplus >= 201103L + std::bind(std::equal_to(), std::placeholders::_1, '1')); +#else + // Deprecated since C++11. std::bind2nd(std::equal_to(), '1')); +#endif } } diff --git a/eo/src/eoFunctor.h b/eo/src/eoFunctor.h index 5ccf2e676..7a81252f1 100644 --- a/eo/src/eoFunctor.h +++ b/eo/src/eoFunctor.h @@ -114,7 +114,12 @@ eoFunctorBase::procedure_tag functor_category(const eoF&) result_type **/ template +#if __cplusplus >= 201103L +class eoUF : public eoFunctorBase, public std::function +#else +// Deprecated in C++11 class eoUF : public eoFunctorBase, public std::unary_function +#endif { public : @@ -151,7 +156,12 @@ eoFunctorBase::unary_function_tag functor_category(const eoUF&) result_type **/ template +#if __cplusplus >= 201103L +class eoBF : public eoFunctorBase, public std::function +#else +// Deprecated in C++11 class eoBF : public eoFunctorBase, public std::binary_function +#endif { public : /// virtual dtor here so there is no need to define it in derived classes diff --git a/eo/src/eoSTLFunctor.h b/eo/src/eoSTLFunctor.h index 04f96f9ca..856fd2bfb 100644 --- a/eo/src/eoSTLFunctor.h +++ b/eo/src/eoSTLFunctor.h @@ -79,7 +79,12 @@ void eoSTLF::operator()(void) respectively */ template +#if __cplusplus >= 201103L +class eoSTLUF : public std::function +#else +// Deprecated since C++11 class eoSTLUF : public std::unary_function +#endif { public: eoSTLUF(eoUF& _f) : f(_f) {} @@ -102,7 +107,12 @@ class eoSTLUF : public std::unary_function respectively */ template +#if __cplusplus >= 201103L +class eoSTLBF : public std::function +#else +// Deprecated since C++11 class eoSTLBF : public std::binary_function +#endif { public: eoSTLBF(eoUF& _f) : f(_f) {} From 3cc374ce5c192a60eddf12b53fd7361cf9fefa8a Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 14:30:25 +0200 Subject: [PATCH 21/69] fix(warnings): do not ignore return from system --- eo/test/t-eoSelect.cpp | 2 +- eo/test/t-eoSharing.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eo/test/t-eoSelect.cpp b/eo/test/t-eoSelect.cpp index 400f6725d..cab2f89e3 100644 --- a/eo/test/t-eoSelect.cpp +++ b/eo/test/t-eoSelect.cpp @@ -126,7 +126,7 @@ eoValueParam tournamentSizeParam = parser.createParam(unsigned(2), "to } // hard-coded directory name ... - system("mkdir ResSelect"); + const int ignored = system("mkdir ResSelect"); std::cout << "Testing the Selections\nParents size = " << pSize << ", offspring rate = " << oRate; std::cout << " and putting rsulting files in dir ResSelect" << std::endl; diff --git a/eo/test/t-eoSharing.cpp b/eo/test/t-eoSharing.cpp index fee072b75..8f3155fc9 100644 --- a/eo/test/t-eoSharing.cpp +++ b/eo/test/t-eoSharing.cpp @@ -193,7 +193,7 @@ int the_main(int argc, char **argv) std::cout << "The resulting file (in dir ResSelect), contains \n"; std::cout << " the empirical proba. for each indi to be selected." << std::endl; - system("mkdir ResSelect"); + const int ignored = system("mkdir ResSelect"); // initialize parent population parentsOrg.resize(pSize); From fefb2af4dd08c7ddf3edad7806749ae23c8251e1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 14:31:01 +0200 Subject: [PATCH 22/69] REFACTOR!eoForge*): separate raw pointres from shared ones - Move the instantiate(double) interfaces of eoForgeVector as instantiate_from. - Adds two separated sets members for instantiation. BREAKING CHANGE --- eo/src/eoForge.h | 95 +++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/eo/src/eoForge.h b/eo/src/eoForge.h index c7cf912ea..394071565 100644 --- a/eo/src/eoForge.h +++ b/eo/src/eoForge.h @@ -114,6 +114,7 @@ class eoForgeOperator : public eoForgeInterface template eoForgeOperator(Args2... args) : _args(std::forward(args)...), + _instantiated_ptr(nullptr), _instantiated(nullptr) { } @@ -127,31 +128,30 @@ class eoForgeOperator : public eoForgeInterface */ Itf& instantiate(bool no_cache = true) override { - if(no_cache or not _instantiated) { - // if(_instantiated) { - // delete _instantiated; - // } + if(no_cache or _instantiated == nullptr) { + if(_instantiated) { + delete _instantiated; + } _instantiated = op_constructor(_args); - // _instantiated = op_constructor(_args); } return *_instantiated; } std::shared_ptr instantiate_ptr(bool no_cache = true) override { - if(no_cache or not _instantiated) { - if(_instantiated) { + if(no_cache or _instantiated == nullptr) { + // if(_instantiated) { // delete _instantiated; - } - _instantiated = op_constructor(_args); + // } + _instantiated_ptr = op_constructor_ptr(_args); // _instantiated = op_constructor(_args); } - return _instantiated; + return _instantiated_ptr; } virtual ~eoForgeOperator() override { - // delete _instantiated; + delete _instantiated; } protected: @@ -160,18 +160,22 @@ class eoForgeOperator : public eoForgeInterface private: /** Metaprogramming machinery which deals with arguments lists @{ */ template - std::shared_ptr op_constructor(T& args) - // Op* op_constructor(T& args) + Op* op_constructor(T& args) { // FIXME double-check that the copy-constructor is a good idea to make_from_tuple with dynamic storage duration. - return std::make_shared(std::make_from_tuple(args)); - // return new Op(std::make_from_tuple(args)); + return new Op(std::make_from_tuple(args)); + } + + template + std::shared_ptr op_constructor_ptr(T& args) + { + return std::make_shared( std::make_from_tuple(args) ); } /** @} */ protected: - std::shared_ptr _instantiated; - // Itf* _instantiated; + std::shared_ptr _instantiated_ptr; + Itf* _instantiated; }; /** Partial specialization for constructors without any argument. @@ -181,41 +185,37 @@ class eoForgeOperator : public eoForgeInterface { public: eoForgeOperator() : + _instantiated_ptr(nullptr), _instantiated(nullptr) { } Itf& instantiate( bool no_cache = true ) override { - if(no_cache or not _instantiated) { - // if(_instantiated) { - // delete _instantiated; - // } - _instantiated = std::shared_ptr(); - // _instantiated = new Op; + if(no_cache or _instantiated == nullptr) { + if(_instantiated) { + delete _instantiated; + } + _instantiated = new Op; } return *_instantiated; } std::shared_ptr instantiate_ptr( bool no_cache = true ) override { - if(no_cache or not _instantiated) { - // if(_instantiated) { - // delete _instantiated; - // } - _instantiated = std::shared_ptr(); - // _instantiated = new Op; + if(no_cache or _instantiated == nullptr) { + _instantiated_ptr = std::shared_ptr(); } - return _instantiated; + return _instantiated_ptr; } virtual ~eoForgeOperator() override { - // delete _instantiated; + delete _instantiated; } protected: - std::shared_ptr _instantiated; - // Itf* _instantiated; + std::shared_ptr _instantiated_ptr; + Itf* _instantiated; }; /** A vector holding an operator (with deferred instantiation) at a given index. @@ -273,7 +273,7 @@ class eoForgeVector : public std::vector*> /** instantiate the operator managed at the given index. */ - Itf& instantiate(double index) + Itf& instantiate_from(double index) { double frac_part, int_part; frac_part = std::modf(index, &int_part); @@ -281,20 +281,33 @@ class eoForgeVector : public std::vector*> eo::log << eo::errors << "there is a fractional part in the given index (" << index << ")" << std::endl; assert(frac_part != 0); } + return instantiate(index); + } + + std::shared_ptr instantiate_ptr_from(double index) + { + double frac_part, int_part; + frac_part = std::modf(index, &int_part); + if(frac_part != 0) { + eo::log << eo::errors << "there is a fractional part in the given index (" << index << ")" << std::endl; + assert(frac_part != 0); + } + return instantiate_ptr(index); + } + + /** instantiate the operator managed at the given index. + */ + Itf& instantiate(size_t index) + { return this->at(static_cast(index))->instantiate(_no_cache); } - std::shared_ptr instantiate_ptr(double index) + std::shared_ptr instantiate_ptr(size_t index) { - double frac_part, int_part; - frac_part = std::modf(index, &int_part); - if(frac_part != 0) { - eo::log << eo::errors << "there is a fractional part in the given index (" << index << ")" << std::endl; - assert(frac_part != 0); - } return this->at(static_cast(index))->instantiate_ptr(_no_cache); } + /** Add an operator to the list. * * @warning When passing a reference (as it is often the case within ParadisEO), From 22b74e9c076d4e630499f90e5c5e7074129ca196 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 14:33:35 +0200 Subject: [PATCH 23/69] fix(eoEvalFoundryEA): reorder members to avoid warning --- eo/src/eoEvalFoundryEA.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eo/src/eoEvalFoundryEA.h b/eo/src/eoEvalFoundryEA.h index e28645b73..355d0efaa 100644 --- a/eo/src/eoEvalFoundryEA.h +++ b/eo/src/eoEvalFoundryEA.h @@ -71,13 +71,6 @@ public: i_repl(foundry.replacements.index()) { } -protected: - const size_t i_cont; - const size_t i_cros; - const size_t i_muta; - const size_t i_sele; - const size_t i_repl; - public: /** Decode the high-level problem encoding as an array of indices. @@ -156,6 +149,13 @@ protected: eoAlgoFoundryEA& _foundry; const typename EOT::Fitness _penalization; const size_t _pop_size; + + const size_t i_cont; + const size_t i_cros; + const size_t i_muta; + const size_t i_sele; + const size_t i_repl; + }; /** Helper function to instanciate an eoEvalFoundryEA without having to indicate the template for the sub-problem encoding. From a5d3bf86014df535ddd11ec0845e5ac872528f3d Mon Sep 17 00:00:00 2001 From: Eremey Valetov Date: Sun, 11 Aug 2024 11:29:02 -0400 Subject: [PATCH 24/69] docs: add accelerator physics paper to publications list --- docs/index.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/index.html b/docs/index.html index f64f8b94a..ab5ee5cd8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -998,6 +998,11 @@ undiscovered knowledge.
  • Johann Dreo, Using Performance Fronts for Parameter Setting of Stochastic Metaheuristics, Genetic and Evolutionary Computation Conference, (2009).
  • +

    Accelerator Physics

    + + From dde057b12b7aa5ebec589ef462396efe99e0d766 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 15:22:17 +0200 Subject: [PATCH 25/69] feat(doc): mention partial evaluation for combinatorics --- docs/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index ab5ee5cd8..7654ac870 100644 --- a/docs/index.html +++ b/docs/index.html @@ -302,7 +302,7 @@

    Efficient

    -

    is the fastest framework on the market, which is a crucial feature for modern and robust approach to solver design and validation.

    +

    is the fastest framework on the market, which is a crucial feature for modern and robust approach to solver design and validation (especially on combinatorial problems).

    @@ -311,6 +311,7 @@

    Another classical criticism against is that C++ is hard and that a fast language is useless because speed is not a concern when your objective function is dominating all the runtime.

    However, we argue that:

    -

    Metaheuristics Design

    - - -

    Accelerator Physics

    - -
    From 84148824e08e0fd289c696eeb53f32111d5578dd Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 23 Aug 2024 17:59:49 +0200 Subject: [PATCH 27/69] fix: remove a lot of trivial warnings --- edo/src/utils/edoFileSnapshot.cpp | 3 +- eo/src/eoPartiallyMappedXover.h | 8 ++-- eo/src/gp/eoParseTreeDepthInit.h | 4 ++ eo/test/t-eoCheckpointing.cpp | 2 - eo/test/t-eoSelect.cpp | 2 +- eo/test/t-eoSharing.cpp | 2 +- eo/test/t-eoStateAndParser.cpp | 2 - mo/src/continuator/moFullEvalContinuator.h | 6 ++- mo/src/continuator/moNeighborhoodStat.h | 2 +- mo/src/continuator/moQuartilesNeighborStat.h | 4 +- mo/src/neighborhood/moNeighbor.h | 4 +- mo/src/problems/eval/moNKlandscapesIncrEval.h | 2 +- mo/src/sampling/moAdaptiveWalkSampling.h | 26 ++++++------ mo/src/sampling/moNeutralWalkSampling.h | 2 +- mo/test/moTestClass.h | 16 +++---- moeo/src/archive/moeoEpsilonHyperboxArchive.h | 4 +- moeo/src/core/moeoBitVector.h | 4 ++ moeo/src/distance/moeoDistance.h | 6 +-- .../moeoCrowdingDiversityAssignment.h | 2 +- ...oFrontByFrontCrowdingDiversityAssignment.h | 2 +- ...eoFrontByFrontSharingDiversityAssignment.h | 2 +- .../moeoNearestNeighborDiversityAssignment.h | 2 +- .../moeoSharingDiversityAssignment.h | 2 +- .../moeoAggregationFitnessAssignment.h | 4 +- .../fitness/moeoConstraintFitnessAssignment.h | 4 +- .../moeoDominanceCountFitnessAssignment.h | 2 +- ...eoDominanceCountRankingFitnessAssignment.h | 2 +- .../moeoDominanceRankFitnessAssignment.h | 2 +- moeo/src/fitness/moeoDummyFitnessAssignment.h | 2 +- moeo/src/hybridization/moeoDMLSMonOp.h | 4 +- moeo/src/metric/moeoHyperVolumeMetric.h | 4 +- .../archive/moeoQuickUnboundedArchiveIndex.h | 12 ++++++ .../moeoAchievementFitnessAssignment.h | 2 +- ...alarizingFunctionMetricFitnessAssignment.h | 4 +- ...alarizingFunctionMetricFitnessAssignment.h | 4 +- ...WeightedChebychevMetricFitnessAssignment.h | 4 +- ...WeightedChebychevMetricFitnessAssignment.h | 4 +- moeo/src/selection/moeoDetArchiveSelect.h | 9 ++-- moeo/test/moeoTestClass.h | 4 +- moeo/test/t-moeo.cpp | 4 +- moeo/test/t-moeoASEEA.cpp | 4 +- moeo/test/t-moeoASFAMetric.cpp | 6 +-- moeo/test/t-moeoASFAOrMetric.cpp | 6 +-- .../t-moeoAchievementFitnessAssignment.cpp | 4 +- .../t-moeoAggregationFitnessAssignment.cpp | 4 +- moeo/test/t-moeoBitVector.cpp | 4 +- moeo/test/t-moeoChebyshevMetric.cpp | 6 +-- moeo/test/t-moeoChebyshevOrientedMetric.cpp | 6 +-- .../t-moeoConstraintFitnessAssignment.cpp | 6 +-- .../t-moeoCrowdingDiversityAssignment.cpp | 4 +- moeo/test/t-moeoDetArchiveSelect.cpp | 4 +- .../t-moeoDominanceCountFitnessAssignment.cpp | 4 +- ...DominanceCountRankingFitnessAssignment.cpp | 4 +- .../t-moeoDominanceDepthFitnessAssignment.cpp | 4 +- moeo/test/t-moeoDominanceMatrix.cpp | 4 +- .../t-moeoDominanceRankFitnessAssignment.cpp | 4 +- moeo/test/t-moeoEasyEA.cpp | 4 +- moeo/test/t-moeoEpsilonHyperboxArchive.cpp | 10 ++--- ...t-moeoEpsilonObjectiveVectorComparator.cpp | 4 +- ...pBinaryIndicatorBasedFitnessAssignment.cpp | 4 +- moeo/test/t-moeoFitDivBoundedArchive.cpp | 4 +- .../t-moeoHyperVolumeDifferenceMetric.cpp | 8 ++-- moeo/test/t-moeoHyperVolumeMetric.cpp | 8 ++-- moeo/test/t-moeoHypervolumeBinaryMetric.cpp | 4 +- moeo/test/t-moeoIBEA.cpp | 4 +- moeo/test/t-moeoImprOnlyBoundedArchive.cpp | 4 +- moeo/test/t-moeoIntVector.cpp | 4 +- moeo/test/t-moeoMax3Obj.cpp | 4 +- moeo/test/t-moeoNSGA.cpp | 4 +- moeo/test/t-moeoNSGAII.cpp | 4 +- ...moeoNearestNeighborDiversityAssignment.cpp | 4 +- .../t-moeoParetoObjectiveVectorComparator.cpp | 4 +- moeo/test/t-moeoRealVector.cpp | 4 +- moeo/test/t-moeoSEEA.cpp | 4 +- moeo/test/t-moeoSPEA2.cpp | 4 +- moeo/test/t-moeoSPEA2Archive.cpp | 4 +- .../test/t-moeoSharingDiversityAssignment.cpp | 4 +- .../t-moeoStrictObjectiveVectorComparator.cpp | 4 +- moeo/test/t-moeoUnboundedArchive.cpp | 4 +- ...oeoVecVsVecAdditiveEpsilonBinaryMetric.cpp | 4 +- ...VsVecMultiplicativeEpsilonBinaryMetric.cpp | 4 +- .../t-moeoWeakObjectiveVectorComparator.cpp | 4 +- problems/eval/nkLandscapesEval.h | 42 +++++++++---------- 83 files changed, 218 insertions(+), 196 deletions(-) diff --git a/edo/src/utils/edoFileSnapshot.cpp b/edo/src/utils/edoFileSnapshot.cpp index 32107b409..7628f934c 100644 --- a/edo/src/utils/edoFileSnapshot.cpp +++ b/edo/src/utils/edoFileSnapshot.cpp @@ -76,8 +76,7 @@ edoFileSnapshot::edoFileSnapshot(std::string dirname, s = " "; } - int dummy; - dummy = system(s.c_str()); + (void)/*ignore returned*/ system(s.c_str()); // all done _descOfFiles = new std::ofstream( std::string(dirname + "/list_of_files.txt").c_str() ); diff --git a/eo/src/eoPartiallyMappedXover.h b/eo/src/eoPartiallyMappedXover.h index 992fbcf77..b10a03ca3 100644 --- a/eo/src/eoPartiallyMappedXover.h +++ b/eo/src/eoPartiallyMappedXover.h @@ -82,9 +82,9 @@ public: // replace if necessary for(i = 0; i < i1; i++) { - while (p1[ _solution1[i] ] != -1) + while (p1[ _solution1[i] ] != -1) // FIXME as an unsigned int, p1 cannot hold negative values! _solution1[i] = p1[_solution1[i]]; - while (p2[ _solution2[i] ] != -1) + while (p2[ _solution2[i] ] != -1) // FIXME as an unsigned int, p2 cannot hold negative values! _solution2[i] = p2[_solution2[i]]; } @@ -96,9 +96,9 @@ public: // replace if necessary for(i = i2 + 1; i < _solution1.size(); i++) { - while (p1[ _solution1[i] ] != -1) + while (p1[ _solution1[i] ] != -1) // FIXME as an unsigned int, p1 cannot hold negative values! _solution1[i] = p1[_solution1[i]]; - while (p2[ _solution2[i] ] != -1) + while (p2[ _solution2[i] ] != -1) // FIXME as an unsigned int, p2 cannot hold negative values! _solution2[i] = p2[_solution2[i]]; } diff --git a/eo/src/gp/eoParseTreeDepthInit.h b/eo/src/gp/eoParseTreeDepthInit.h index ba1cf1f5a..8eaa8c3a9 100644 --- a/eo/src/gp/eoParseTreeDepthInit.h +++ b/eo/src/gp/eoParseTreeDepthInit.h @@ -50,7 +50,11 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > protected: // a binary predicate for sorting // hopefully this will work with M$VC++ 6.0 +#if __cplusplus >= 201103L + struct lt_arity:public std::function +#else struct lt_arity:public std::binary_function +#endif { bool operator()(const Node &_node1, const Node &_node2) { return (_node1.arity() < _node2.arity());}; }; diff --git a/eo/test/t-eoCheckpointing.cpp b/eo/test/t-eoCheckpointing.cpp index 134b05cc4..84c8e7fd9 100644 --- a/eo/test/t-eoCheckpointing.cpp +++ b/eo/test/t-eoCheckpointing.cpp @@ -31,8 +31,6 @@ public : int the_main(int argc, char **argv) { // ok, we have a command line parser and a state - typedef eoBit Chrom; - eoParser parser(argc, argv); // Define Parameters diff --git a/eo/test/t-eoSelect.cpp b/eo/test/t-eoSelect.cpp index cab2f89e3..1e37f785c 100644 --- a/eo/test/t-eoSelect.cpp +++ b/eo/test/t-eoSelect.cpp @@ -126,7 +126,7 @@ eoValueParam tournamentSizeParam = parser.createParam(unsigned(2), "to } // hard-coded directory name ... - const int ignored = system("mkdir ResSelect"); + (void) system("mkdir ResSelect"); std::cout << "Testing the Selections\nParents size = " << pSize << ", offspring rate = " << oRate; std::cout << " and putting rsulting files in dir ResSelect" << std::endl; diff --git a/eo/test/t-eoSharing.cpp b/eo/test/t-eoSharing.cpp index 8f3155fc9..f074e1031 100644 --- a/eo/test/t-eoSharing.cpp +++ b/eo/test/t-eoSharing.cpp @@ -193,7 +193,7 @@ int the_main(int argc, char **argv) std::cout << "The resulting file (in dir ResSelect), contains \n"; std::cout << " the empirical proba. for each indi to be selected." << std::endl; - const int ignored = system("mkdir ResSelect"); + (void) system("mkdir ResSelect"); // initialize parent population parentsOrg.resize(pSize); diff --git a/eo/test/t-eoStateAndParser.cpp b/eo/test/t-eoStateAndParser.cpp index a851cb595..09bd3cbda 100644 --- a/eo/test/t-eoStateAndParser.cpp +++ b/eo/test/t-eoStateAndParser.cpp @@ -37,8 +37,6 @@ struct Dummy : public EO int the_main(int argc, char **argv) { // ok, we have a command line parser and a state - typedef eoBit Chrom; - eoParser parser(argc, argv); // Define Parameters diff --git a/mo/src/continuator/moFullEvalContinuator.h b/mo/src/continuator/moFullEvalContinuator.h index bf9a9ea96..168eb5bc1 100644 --- a/mo/src/continuator/moFullEvalContinuator.h +++ b/mo/src/continuator/moFullEvalContinuator.h @@ -54,7 +54,11 @@ public: * @param _maxFullEval number maximum of iterations * @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative */ - moFullEvalContinuator(eoEvalFuncCounter & _eval, unsigned int _maxFullEval, bool _restartCounter = true): eval(_eval), maxFullEval(_maxFullEval), restartCounter(_restartCounter) { + moFullEvalContinuator(eoEvalFuncCounter & _eval, unsigned int _maxFullEval, bool _restartCounter = true): + eval(_eval), + restartCounter(_restartCounter), + maxFullEval(_maxFullEval) + { nbEval_start = eval.value(); } diff --git a/mo/src/continuator/moNeighborhoodStat.h b/mo/src/continuator/moNeighborhoodStat.h index 3ce7d3757..6a6e506cc 100644 --- a/mo/src/continuator/moNeighborhoodStat.h +++ b/mo/src/continuator/moNeighborhoodStat.h @@ -167,7 +167,7 @@ public : if (nb > 1) { sd = 0; - for(int i = 0; i < nb; i++) + for(unsigned i = 0; i < nb; i++) sd += (neighborFitness[i] - mean) * (neighborFitness[i] - mean) ; sd = sqrt( sd / (nb - 1.0) ); // becareful: could be infinite when large values //sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) ); // becareful: could be negative due to approximation of large values diff --git a/mo/src/continuator/moQuartilesNeighborStat.h b/mo/src/continuator/moQuartilesNeighborStat.h index 69f6af68a..77ba3e3b7 100644 --- a/mo/src/continuator/moQuartilesNeighborStat.h +++ b/mo/src/continuator/moQuartilesNeighborStat.h @@ -62,7 +62,7 @@ public : * Set the first and the third quartile of fitness in the neighborhood * @param _sol the first solution */ - virtual void init(EOT & _sol) { + virtual void init(EOT & /*_sol*/) { value().first = nhStat.getQ1(); value().second = nhStat.getQ3(); } @@ -71,7 +71,7 @@ public : * Set the first and the third quartile fitness in the neighborhood * @param _sol the corresponding solution */ - virtual void operator()(EOT & _sol) { + virtual void operator()(EOT & /*_sol*/) { value().first = nhStat.getQ1(); value().second = nhStat.getQ3(); } diff --git a/mo/src/neighborhood/moNeighbor.h b/mo/src/neighborhood/moNeighbor.h index 8186c2435..707a6a126 100644 --- a/mo/src/neighborhood/moNeighbor.h +++ b/mo/src/neighborhood/moNeighbor.h @@ -72,7 +72,7 @@ public: * @param _neighbor the neighbor to assign * @return a neighbor equal to the other */ - virtual moNeighbor& operator=( + moNeighbor& operator=( const moNeighbor& _neighbor) { if (!(_neighbor.invalid())) fitness(_neighbor.fitness()); @@ -93,7 +93,7 @@ public: * @param _neighbor a neighbor * @return if _neighbor and this one are equals */ - virtual bool equals(moNeighbor & /*_neighbor*/) { + bool equals(moNeighbor & /*_neighbor*/) { return false; } diff --git a/mo/src/problems/eval/moNKlandscapesIncrEval.h b/mo/src/problems/eval/moNKlandscapesIncrEval.h index 6635c0de0..a253c7c14 100644 --- a/mo/src/problems/eval/moNKlandscapesIncrEval.h +++ b/mo/src/problems/eval/moNKlandscapesIncrEval.h @@ -112,7 +112,7 @@ private: nonSig = 0; unsigned int n = 1; - for(int j = 0; j < nk.K + 1; j++) { + for(unsigned j = 0; j < nk.K + 1; j++) { if (_solution[ nk.links[i][j] ] == 1) sig = sig | n; diff --git a/mo/src/sampling/moAdaptiveWalkSampling.h b/mo/src/sampling/moAdaptiveWalkSampling.h index 04dafe876..b87b36f49 100644 --- a/mo/src/sampling/moAdaptiveWalkSampling.h +++ b/mo/src/sampling/moAdaptiveWalkSampling.h @@ -84,10 +84,10 @@ public: moEval& _eval, unsigned int _nbAdaptWalk) : moSampling(initHC, * new moRandomSearch(initHC, _fullEval, _nbAdaptWalk), copyStat), - neighborEvalCount(_eval), - nEvalStat(neighborEvalCount, true), - copyStat(lengthStat), // copy is used to report the statistic of the first walk + neighborEvalCount(_eval), + nEvalStat(neighborEvalCount, true), copyEvalStat(nEvalStat), + copyStat(lengthStat), // copy is used to report the statistic of the first walk checkpoint(trueCont), hc(_neighborhood, _fullEval, neighborEvalCount, checkpoint), initHC(_init, hc) @@ -95,15 +95,15 @@ public: // to count the number of step in the HC checkpoint.add(lengthStat); - // set the long name of this statistic which is the length of the walk - copyStat.setLongName("length"); + // set the long name of this statistic which is the length of the walk + copyStat.setLongName("length"); - // to count the number of evaluations + // to count the number of evaluations checkpoint.add(nEvalStat); - // set the long name of this statistic which is the number of neighbor evaluation - copyEvalStat.setLongName("ngheval"); - + // set the long name of this statistic which is the number of neighbor evaluation + copyEvalStat.setLongName("ngheval"); + // add the solution into statistics this->add(copyEvalStat); this->add(solStat); @@ -118,10 +118,10 @@ public: } protected: - /* count the number of evaluations */ - moEvalCounter neighborEvalCount; - moValueStat nEvalStat; - moStatFromStat copyEvalStat; + /* count the number of evaluations */ + moEvalCounter neighborEvalCount; + moValueStat nEvalStat; + moStatFromStat copyEvalStat; moSolutionStat solStat; moMinusOneCounterStat lengthStat; diff --git a/mo/src/sampling/moNeutralWalkSampling.h b/mo/src/sampling/moNeutralWalkSampling.h index 0db5f6c06..73eddbb9c 100644 --- a/mo/src/sampling/moNeutralWalkSampling.h +++ b/mo/src/sampling/moNeutralWalkSampling.h @@ -192,9 +192,9 @@ protected: moSolutionStat solutionStat; moDistanceStat distStat; moNeighborhoodStat< Neighbor > neighborhoodStat; - moMinNeighborStat< Neighbor > minStat; moAverageFitnessNeighborStat< Neighbor > averageStat; moStdFitnessNeighborStat< Neighbor > stdStat; + moMinNeighborStat< Neighbor > minStat; moMaxNeighborStat< Neighbor > maxStat; moNbSupNeighborStat< Neighbor > nbSupStat; moNbInfNeighborStat< Neighbor > nbInfStat; diff --git a/mo/test/moTestClass.h b/mo/test/moTestClass.h index a04a42272..8e79f174f 100644 --- a/mo/test/moTestClass.h +++ b/mo/test/moTestClass.h @@ -71,15 +71,15 @@ typedef EO Solution; class moDummyNeighborTest: public moNeighbor { public: - virtual void move(Solution & _solution) { + virtual void move(Solution & /*_solution*/) { } }; class moDummyBackableNeighbor: public moBackableNeighbor { public: - virtual void move(Solution & _solution) { + virtual void move(Solution & /*_solution*/) { } - virtual void moveBack(Solution & _solution) { + virtual void moveBack(Solution & /*_solution*/) { } }; @@ -91,7 +91,7 @@ public: i(0), j(0) { } - virtual bool hasNeighbor(EOT & _solution) { + virtual bool hasNeighbor(EOT & /*_solution*/) { bool res; if (i % 3 == 0 || i == 1) res = false; @@ -100,11 +100,11 @@ public: i++; return res; } - virtual void init(EOT & _solution, Neighbor & _current) { + virtual void init(EOT & /*_solution*/, Neighbor & /*_current*/) { } - virtual void next(EOT & _solution, Neighbor & _current) { + virtual void next(EOT & /*_solution*/, Neighbor & /*_current*/) { } - virtual bool cont(EOT & _solution) { + virtual bool cont(EOT & /*_solution*/) { j++; return (j % 10 != 0); } @@ -227,7 +227,7 @@ private: class dummyInit: public eoInit { public: - void operator()(bitVector& sol) { + void operator()(bitVector& /*sol*/) { } }; diff --git a/moeo/src/archive/moeoEpsilonHyperboxArchive.h b/moeo/src/archive/moeoEpsilonHyperboxArchive.h index 7a773e0c8..7ea2e1f42 100644 --- a/moeo/src/archive/moeoEpsilonHyperboxArchive.h +++ b/moeo/src/archive/moeoEpsilonHyperboxArchive.h @@ -258,9 +258,9 @@ public: void filtre(){ eoPop pop; - for(int i=0; i= 201103L + std::transform(bits.begin(), bits.end(), begin(), std::bind(std::equal_to(), std::placeholders::_1, '1')); +#else std::transform(bits.begin(), bits.end(), begin(), std::bind2nd(std::equal_to(), '1')); +#endif } } diff --git a/moeo/src/distance/moeoDistance.h b/moeo/src/distance/moeoDistance.h index d5cf75c75..a78593c64 100644 --- a/moeo/src/distance/moeoDistance.h +++ b/moeo/src/distance/moeoDistance.h @@ -52,7 +52,7 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type > * Nothing to do * @param _pop the population */ - virtual void setup(const eoPop < MOEOT > & _pop) + virtual void setup(const eoPop < MOEOT > & /*_pop*/) {} @@ -62,7 +62,7 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type > * @param _max upper bound * @param _obj the objective index */ - virtual void setup(double _min, double _max, unsigned int _obj) + virtual void setup(double /*_min*/, double /*_max*/, unsigned int /*_obj*/) {} @@ -71,7 +71,7 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type > * @param _realInterval the eoRealInterval object * @param _obj the objective index */ - virtual void setup(eoRealInterval _realInterval, unsigned int _obj) + virtual void setup(eoRealInterval /*_realInterval*/, unsigned int /*_obj*/) {} }; diff --git a/moeo/src/diversity/moeoCrowdingDiversityAssignment.h b/moeo/src/diversity/moeoCrowdingDiversityAssignment.h index 3a37f2db9..8f9b55417 100644 --- a/moeo/src/diversity/moeoCrowdingDiversityAssignment.h +++ b/moeo/src/diversity/moeoCrowdingDiversityAssignment.h @@ -100,7 +100,7 @@ class moeoCrowdingDiversityAssignment : public moeoDiversityAssignment < MOEOT > * @param _objVec the objective vector * @warning NOT IMPLEMENTED, DO NOTHING ! */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoCrowdingDiversityAssignment" << std::endl; } diff --git a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h index c90a7ac91..7f85876cc 100644 --- a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h +++ b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h @@ -66,7 +66,7 @@ public: * @param _objVec the objective vector * @warning NOT IMPLEMENTED, DO NOTHING ! */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << std::endl; } diff --git a/moeo/src/diversity/moeoFrontByFrontSharingDiversityAssignment.h b/moeo/src/diversity/moeoFrontByFrontSharingDiversityAssignment.h index 56b4cedca..62e3b65c8 100644 --- a/moeo/src/diversity/moeoFrontByFrontSharingDiversityAssignment.h +++ b/moeo/src/diversity/moeoFrontByFrontSharingDiversityAssignment.h @@ -78,7 +78,7 @@ class moeoFrontByFrontSharingDiversityAssignment : public moeoSharingDiversityAs * @param _objVec the objective vector * @warning NOT IMPLEMENTED, DO NOTHING ! */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl; } diff --git a/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h b/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h index 5b5680eef..434bb0b15 100644 --- a/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h +++ b/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h @@ -143,7 +143,7 @@ public: * @param _objVec the objective vector * @warning NOT IMPLEMENTED, DOES NOTHING ! */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoNearestNeighborDiversityAssignment" << std::endl; } diff --git a/moeo/src/diversity/moeoSharingDiversityAssignment.h b/moeo/src/diversity/moeoSharingDiversityAssignment.h index 6fa66193a..4a0142e70 100644 --- a/moeo/src/diversity/moeoSharingDiversityAssignment.h +++ b/moeo/src/diversity/moeoSharingDiversityAssignment.h @@ -102,7 +102,7 @@ class moeoSharingDiversityAssignment : public moeoDiversityAssignment < MOEOT > * @param _objVec the objective vector * @warning NOT IMPLEMENTED, DO NOTHING ! */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl; } diff --git a/moeo/src/fitness/moeoAggregationFitnessAssignment.h b/moeo/src/fitness/moeoAggregationFitnessAssignment.h index 7b9c809e4..deb5d9043 100644 --- a/moeo/src/fitness/moeoAggregationFitnessAssignment.h +++ b/moeo/src/fitness/moeoAggregationFitnessAssignment.h @@ -113,12 +113,12 @@ class moeoAggregationFitnessAssignment : public moeoSingleObjectivization < MOEO * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec){} + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/){} private: class DummyEval: public eoEvalFunc{ - void operator()(MOEOT &moeo){} + void operator()(MOEOT &/*moeo*/){} }defaultEval; //the vector of weight diff --git a/moeo/src/fitness/moeoConstraintFitnessAssignment.h b/moeo/src/fitness/moeoConstraintFitnessAssignment.h index c87ee3514..daaada5e9 100644 --- a/moeo/src/fitness/moeoConstraintFitnessAssignment.h +++ b/moeo/src/fitness/moeoConstraintFitnessAssignment.h @@ -135,7 +135,7 @@ class moeoConstraintFitnessAssignment : public moeoSingleObjectivization < MOEOT * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { //std::cout << "WARNING : updateByDeleting not implemented in moeoAssignmentFitnessAssignment" << std::endl; } @@ -144,7 +144,7 @@ class moeoConstraintFitnessAssignment : public moeoSingleObjectivization < MOEOT //dummy evaluation function class DummyEval: public eoEvalFunc{ - void operator()(MOEOT &moeo){ + void operator()(MOEOT &/*moeo*/){ } } defaultEval; diff --git a/moeo/src/fitness/moeoDominanceCountFitnessAssignment.h b/moeo/src/fitness/moeoDominanceCountFitnessAssignment.h index 2de727d7e..a991d34d9 100644 --- a/moeo/src/fitness/moeoDominanceCountFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceCountFitnessAssignment.h @@ -119,7 +119,7 @@ public: * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountFitnessAssignment" << std::endl; } diff --git a/moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h b/moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h index 562823703..1129f2c1c 100644 --- a/moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h @@ -123,7 +123,7 @@ public: * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountRankingFitnessAssignment" << std::endl; } diff --git a/moeo/src/fitness/moeoDominanceRankFitnessAssignment.h b/moeo/src/fitness/moeoDominanceRankFitnessAssignment.h index e265b94c1..de3272411 100644 --- a/moeo/src/fitness/moeoDominanceRankFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceRankFitnessAssignment.h @@ -123,7 +123,7 @@ public: * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceRankFitnessAssignment" << std::endl; } diff --git a/moeo/src/fitness/moeoDummyFitnessAssignment.h b/moeo/src/fitness/moeoDummyFitnessAssignment.h index be80edb57..fbe506740 100644 --- a/moeo/src/fitness/moeoDummyFitnessAssignment.h +++ b/moeo/src/fitness/moeoDummyFitnessAssignment.h @@ -74,7 +74,7 @@ class moeoDummyFitnessAssignment : public moeoFitnessAssignment < MOEOT > * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { // nothing to do... ;-) } diff --git a/moeo/src/hybridization/moeoDMLSMonOp.h b/moeo/src/hybridization/moeoDMLSMonOp.h index a9c52d4c8..7840e8a8c 100644 --- a/moeo/src/hybridization/moeoDMLSMonOp.h +++ b/moeo/src/hybridization/moeoDMLSMonOp.h @@ -108,8 +108,8 @@ class moeoDMLSMonOp : public eoMonOp < typename Neighbor::EOT > tmp = rng.random(dmlsArchive.size()); _moeo = dmlsArchive[tmp]; defaultContinuator.totalGenerations(defaultContinuator.totalGenerations()); - if(verbose) - std::cout << "moeoDMLSMonOp: dmls stop" << std::endl << std::endl; + if(verbose) { + std::cout << "moeoDMLSMonOp: dmls stop" << std::endl << std::endl; } return false; } diff --git a/moeo/src/metric/moeoHyperVolumeMetric.h b/moeo/src/metric/moeoHyperVolumeMetric.h index b79dbc558..dc65ac4c9 100644 --- a/moeo/src/metric/moeoHyperVolumeMetric.h +++ b/moeo/src/metric/moeoHyperVolumeMetric.h @@ -318,8 +318,8 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d //if there are less than 3 objectifs take the fisrt objectif of the first point of front to begin computation of hypervolume if(_no_objectives < 3){ - if(_no_objectives < 1) - throw("Error in moeoHyperVolumeUnaryMetric::calc_hypervolume -> argument3: _no_objectives must be greater than 0"); + if(_no_objectives < 1) { + throw("Error in moeoHyperVolumeUnaryMetric::calc_hypervolume -> argument3: _no_objectives must be greater than 0"); } temp_vol=_front[0][0]; } //else if there at least 3 objectives, a recursive computation of hypervolume starts with _no_objectives -1 on the filter_nondominated_set calculating previously. diff --git a/moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h b/moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h index a40add6ae..22694d2af 100644 --- a/moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h +++ b/moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h @@ -54,7 +54,11 @@ class moeoQuickUnboundedArchiveIndex : public moeoArchiveIndex < MOEOT > * equivalent to "number one element should be on top of number two element" in the list by looking to the first obj */ struct CompareByFirst +#if __cplusplus >= 201103L + : std::function< bool(entree, entree) > { +#else : std::binary_function< bool, entree, entree > { +#endif bool operator ()( const entree& elem1, const entree& elem2 @@ -71,7 +75,11 @@ class moeoQuickUnboundedArchiveIndex : public moeoArchiveIndex < MOEOT > * equivalent to "number one element should be on top of number two element" in the list by looking to the 2nd obj */ struct CompareByLast +#if __cplusplus >= 201103L + : std::function< bool(entree, entree) > { +#else : std::binary_function< bool, entree, entree > { +#endif bool operator ()( const entree& elem1, const entree& elem2 @@ -87,7 +95,11 @@ class moeoQuickUnboundedArchiveIndex : public moeoArchiveIndex < MOEOT > struct CompareByLast2 +#if __cplusplus >= 201103L + : std::function< bool(MOEOT, MOEOT) > { +#else : std::binary_function< bool, MOEOT, MOEOT > { +#endif bool operator ()( const MOEOT& elem1, const MOEOT& elem2 diff --git a/moeo/src/scalarStuffs/fitness/moeoAchievementFitnessAssignment.h b/moeo/src/scalarStuffs/fitness/moeoAchievementFitnessAssignment.h index b77355bb1..2c8b873fb 100644 --- a/moeo/src/scalarStuffs/fitness/moeoAchievementFitnessAssignment.h +++ b/moeo/src/scalarStuffs/fitness/moeoAchievementFitnessAssignment.h @@ -111,7 +111,7 @@ class moeoAchievementFitnessAssignment : public moeoScalarFitnessAssignment < MO * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { // nothing to do ;-) } diff --git a/moeo/src/scalarStuffs/fitness/moeoAchievementScalarizingFunctionMetricFitnessAssignment.h b/moeo/src/scalarStuffs/fitness/moeoAchievementScalarizingFunctionMetricFitnessAssignment.h index e396a798b..7546092a7 100644 --- a/moeo/src/scalarStuffs/fitness/moeoAchievementScalarizingFunctionMetricFitnessAssignment.h +++ b/moeo/src/scalarStuffs/fitness/moeoAchievementScalarizingFunctionMetricFitnessAssignment.h @@ -127,12 +127,12 @@ class moeoAchievementScalarizingFunctionMetricFitnessAssignment : public moeoSin * @param _pop the populing * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec){} + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/){} private: class DummyEval: public eoEvalFunc{ - void operator()(MOEOT &moeo){ + void operator()(MOEOT &/*moeo*/){ } } defaultEval; diff --git a/moeo/src/scalarStuffs/fitness/moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment.h b/moeo/src/scalarStuffs/fitness/moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment.h index b0a1499bd..02a1c8293 100644 --- a/moeo/src/scalarStuffs/fitness/moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment.h +++ b/moeo/src/scalarStuffs/fitness/moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment.h @@ -138,7 +138,7 @@ class moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment : publi * @param _pop the populing * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { } @@ -146,7 +146,7 @@ class moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment : publi private: class DummyEval: public eoEvalFunc{ - void operator()(MOEOT &moeo){ + void operator()(MOEOT &/*moeo*/){ } } defaultEval; diff --git a/moeo/src/scalarStuffs/fitness/moeoAugmentedWeightedChebychevMetricFitnessAssignment.h b/moeo/src/scalarStuffs/fitness/moeoAugmentedWeightedChebychevMetricFitnessAssignment.h index 356ac2144..4f6a27fb6 100644 --- a/moeo/src/scalarStuffs/fitness/moeoAugmentedWeightedChebychevMetricFitnessAssignment.h +++ b/moeo/src/scalarStuffs/fitness/moeoAugmentedWeightedChebychevMetricFitnessAssignment.h @@ -124,12 +124,12 @@ class moeoAugmentedWeightedChebychevMetricFitnessAssignment : public moeoSingleO * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec){} + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/){} private: class DummyEval: public eoEvalFunc{ - void operator()(MOEOT &moeo){ + void operator()(MOEOT &/*moeo*/){ } } defaultEval; diff --git a/moeo/src/scalarStuffs/fitness/moeoWeightedChebychevMetricFitnessAssignment.h b/moeo/src/scalarStuffs/fitness/moeoWeightedChebychevMetricFitnessAssignment.h index 382d4e2ef..da7b3e56a 100644 --- a/moeo/src/scalarStuffs/fitness/moeoWeightedChebychevMetricFitnessAssignment.h +++ b/moeo/src/scalarStuffs/fitness/moeoWeightedChebychevMetricFitnessAssignment.h @@ -129,12 +129,12 @@ class moeoWeightedChebychevMetricFitnessAssignment : public moeoSingleObjectiviz * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec){} + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/){} private: class DummyEval: public eoEvalFunc{ - void operator()(MOEOT &moeo){ + void operator()(MOEOT &/*moeo*/){ } } defaultEval; diff --git a/moeo/src/selection/moeoDetArchiveSelect.h b/moeo/src/selection/moeoDetArchiveSelect.h index 78b69a06e..c3f94d018 100644 --- a/moeo/src/selection/moeoDetArchiveSelect.h +++ b/moeo/src/selection/moeoDetArchiveSelect.h @@ -57,7 +57,7 @@ class moeoDetArchiveSelect : public eoSelect * @param _source compatibility parameter, not used * @param _dest destination population, selected from archive */ - void operator()(const eoPop < MOEOT > & _source, eoPop < MOEOT > & _dest) + void operator()(const eoPop < MOEOT > & /*_source*/, eoPop < MOEOT > & _dest) { if(max < min){ std::cout << "Warning! moeoDetArchiveSelect: min value > max value!!! Nothing is done." << std::endl; @@ -74,8 +74,11 @@ class moeoDetArchiveSelect : public eoSelect std::vector permutation; for(unsigned int i=0; i < archive_size; i++) permutation.push_back(i); - UF_random_generator rndGen(permutation.size()); - random_shuffle(permutation.begin(), permutation.end(), rndGen); + // UF_random_generator rndGen(permutation.size()); + // random_shuffle(permutation.begin(), permutation.end(), rndGen); + std::random_device rd; + std::mt19937 gen(rd()); + std::shuffle(permutation.begin(), permutation.end(), gen); for (unsigned int i=0; i ObjectiveVector; typedef MOEO < ObjectiveVector, double, double > Solution; class DummyEval: public eoEvalFunc{ - void operator()(Solution &moeo){ + void operator()(Solution &/*moeo*/){ } } eval; //----------------------------------------------------------------------------- diff --git a/moeo/test/t-moeoASFAOrMetric.cpp b/moeo/test/t-moeoASFAOrMetric.cpp index 9ca8d2e67..d0dca6dde 100644 --- a/moeo/test/t-moeoASFAOrMetric.cpp +++ b/moeo/test/t-moeoASFAOrMetric.cpp @@ -48,11 +48,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } @@ -67,7 +67,7 @@ typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; typedef MOEO < ObjectiveVector, double, double > Solution; class DummyEval: public eoEvalFunc{ - void operator()(Solution &moeo){ + void operator()(Solution &/*moeo*/){ } } eval; //----------------------------------------------------------------------------- diff --git a/moeo/test/t-moeoAchievementFitnessAssignment.cpp b/moeo/test/t-moeoAchievementFitnessAssignment.cpp index 2bf553350..c8a7c3060 100644 --- a/moeo/test/t-moeoAchievementFitnessAssignment.cpp +++ b/moeo/test/t-moeoAchievementFitnessAssignment.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoAggregationFitnessAssignment.cpp b/moeo/test/t-moeoAggregationFitnessAssignment.cpp index 93990e1c5..294397aed 100644 --- a/moeo/test/t-moeoAggregationFitnessAssignment.cpp +++ b/moeo/test/t-moeoAggregationFitnessAssignment.cpp @@ -48,11 +48,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return false; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return true; } diff --git a/moeo/test/t-moeoBitVector.cpp b/moeo/test/t-moeoBitVector.cpp index 5420efdb1..0673f68cc 100644 --- a/moeo/test/t-moeoBitVector.cpp +++ b/moeo/test/t-moeoBitVector.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoChebyshevMetric.cpp b/moeo/test/t-moeoChebyshevMetric.cpp index 5037847ea..583043bb6 100644 --- a/moeo/test/t-moeoChebyshevMetric.cpp +++ b/moeo/test/t-moeoChebyshevMetric.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return false; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return true; } @@ -66,7 +66,7 @@ typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; typedef MOEO < ObjectiveVector, double, double > Solution; class DummyEval: public eoEvalFunc{ - void operator()(Solution &moeo){ + void operator()(Solution &/*moeo*/){ } } eval; //----------------------------------------------------------------------------- diff --git a/moeo/test/t-moeoChebyshevOrientedMetric.cpp b/moeo/test/t-moeoChebyshevOrientedMetric.cpp index 9d82d18da..28f372619 100644 --- a/moeo/test/t-moeoChebyshevOrientedMetric.cpp +++ b/moeo/test/t-moeoChebyshevOrientedMetric.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } @@ -66,7 +66,7 @@ typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; typedef MOEO < ObjectiveVector, double, double > Solution; class DummyEval: public eoEvalFunc{ - void operator()(Solution &moeo){ + void operator()(Solution &/*moeo*/){ } } eval; //----------------------------------------------------------------------------- diff --git a/moeo/test/t-moeoConstraintFitnessAssignment.cpp b/moeo/test/t-moeoConstraintFitnessAssignment.cpp index 8a0e0a573..3df48532b 100644 --- a/moeo/test/t-moeoConstraintFitnessAssignment.cpp +++ b/moeo/test/t-moeoConstraintFitnessAssignment.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } @@ -66,7 +66,7 @@ typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; typedef MOEO < ObjectiveVector, double, double > Solution; class DummyEval: public eoEvalFunc{ - void operator()(Solution &moeo){ + void operator()(Solution &/*moeo*/){ } } defaultEval; //----------------------------------------------------------------------------- diff --git a/moeo/test/t-moeoCrowdingDiversityAssignment.cpp b/moeo/test/t-moeoCrowdingDiversityAssignment.cpp index 5aa17bcad..c126fe2ae 100644 --- a/moeo/test/t-moeoCrowdingDiversityAssignment.cpp +++ b/moeo/test/t-moeoCrowdingDiversityAssignment.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoDetArchiveSelect.cpp b/moeo/test/t-moeoDetArchiveSelect.cpp index b85085d58..4bbbf8fa4 100644 --- a/moeo/test/t-moeoDetArchiveSelect.cpp +++ b/moeo/test/t-moeoDetArchiveSelect.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoDominanceCountFitnessAssignment.cpp b/moeo/test/t-moeoDominanceCountFitnessAssignment.cpp index e71c70bf1..d4ff9d6d5 100644 --- a/moeo/test/t-moeoDominanceCountFitnessAssignment.cpp +++ b/moeo/test/t-moeoDominanceCountFitnessAssignment.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoDominanceCountRankingFitnessAssignment.cpp b/moeo/test/t-moeoDominanceCountRankingFitnessAssignment.cpp index 265aaf0dc..09bf7eef0 100644 --- a/moeo/test/t-moeoDominanceCountRankingFitnessAssignment.cpp +++ b/moeo/test/t-moeoDominanceCountRankingFitnessAssignment.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp b/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp index 71fae12dc..1282bcdc8 100644 --- a/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp +++ b/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoDominanceMatrix.cpp b/moeo/test/t-moeoDominanceMatrix.cpp index cf533d645..0c837fd97 100644 --- a/moeo/test/t-moeoDominanceMatrix.cpp +++ b/moeo/test/t-moeoDominanceMatrix.cpp @@ -48,11 +48,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoDominanceRankFitnessAssignment.cpp b/moeo/test/t-moeoDominanceRankFitnessAssignment.cpp index c59c9510c..f392f82ed 100644 --- a/moeo/test/t-moeoDominanceRankFitnessAssignment.cpp +++ b/moeo/test/t-moeoDominanceRankFitnessAssignment.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoEasyEA.cpp b/moeo/test/t-moeoEasyEA.cpp index b378f9f9a..0210cb5de 100644 --- a/moeo/test/t-moeoEasyEA.cpp +++ b/moeo/test/t-moeoEasyEA.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoEpsilonHyperboxArchive.cpp b/moeo/test/t-moeoEpsilonHyperboxArchive.cpp index 071f278a4..2106e76fc 100644 --- a/moeo/test/t-moeoEpsilonHyperboxArchive.cpp +++ b/moeo/test/t-moeoEpsilonHyperboxArchive.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } @@ -88,7 +88,7 @@ int main() - for(int i=0; i< pop.size()/2; i++){ + for(unsigned i=0; i< pop.size()/2; i++){ // tmp=rng.uniform()*100; obj[0]=o1; obj[1]=o2; @@ -132,10 +132,10 @@ int main() std::cout << "nadir: " << nadir << std::endl; std::cout << "ideal: " << ideal << std::endl; - for(int i=0; i ObjectiveVector; class ObjectiveVectorTraits2 : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoHyperVolumeMetric.cpp b/moeo/test/t-moeoHyperVolumeMetric.cpp index 1ff7cb9d5..455af0f6c 100644 --- a/moeo/test/t-moeoHyperVolumeMetric.cpp +++ b/moeo/test/t-moeoHyperVolumeMetric.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } @@ -66,11 +66,11 @@ typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; class ObjectiveVectorTraits2 : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoHypervolumeBinaryMetric.cpp b/moeo/test/t-moeoHypervolumeBinaryMetric.cpp index 083804537..605affe6b 100644 --- a/moeo/test/t-moeoHypervolumeBinaryMetric.cpp +++ b/moeo/test/t-moeoHypervolumeBinaryMetric.cpp @@ -44,11 +44,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoIBEA.cpp b/moeo/test/t-moeoIBEA.cpp index 89b05fc4f..564157c5d 100644 --- a/moeo/test/t-moeoIBEA.cpp +++ b/moeo/test/t-moeoIBEA.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoImprOnlyBoundedArchive.cpp b/moeo/test/t-moeoImprOnlyBoundedArchive.cpp index 449166cac..483e3eaa3 100644 --- a/moeo/test/t-moeoImprOnlyBoundedArchive.cpp +++ b/moeo/test/t-moeoImprOnlyBoundedArchive.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoIntVector.cpp b/moeo/test/t-moeoIntVector.cpp index 70e580529..51f3f105a 100644 --- a/moeo/test/t-moeoIntVector.cpp +++ b/moeo/test/t-moeoIntVector.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoMax3Obj.cpp b/moeo/test/t-moeoMax3Obj.cpp index f0ff1471e..c638d0ed6 100644 --- a/moeo/test/t-moeoMax3Obj.cpp +++ b/moeo/test/t-moeoMax3Obj.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return false; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return true; } diff --git a/moeo/test/t-moeoNSGA.cpp b/moeo/test/t-moeoNSGA.cpp index 16b994712..779681e24 100644 --- a/moeo/test/t-moeoNSGA.cpp +++ b/moeo/test/t-moeoNSGA.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoNSGAII.cpp b/moeo/test/t-moeoNSGAII.cpp index d1139468e..3827e2800 100644 --- a/moeo/test/t-moeoNSGAII.cpp +++ b/moeo/test/t-moeoNSGAII.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoNearestNeighborDiversityAssignment.cpp b/moeo/test/t-moeoNearestNeighborDiversityAssignment.cpp index d4e0e5ed5..58969730b 100644 --- a/moeo/test/t-moeoNearestNeighborDiversityAssignment.cpp +++ b/moeo/test/t-moeoNearestNeighborDiversityAssignment.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoParetoObjectiveVectorComparator.cpp b/moeo/test/t-moeoParetoObjectiveVectorComparator.cpp index 143e3b70e..a37b3eb8c 100644 --- a/moeo/test/t-moeoParetoObjectiveVectorComparator.cpp +++ b/moeo/test/t-moeoParetoObjectiveVectorComparator.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoRealVector.cpp b/moeo/test/t-moeoRealVector.cpp index 1d17853f6..58d29a491 100644 --- a/moeo/test/t-moeoRealVector.cpp +++ b/moeo/test/t-moeoRealVector.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoSEEA.cpp b/moeo/test/t-moeoSEEA.cpp index 1e58ba972..648ca0585 100644 --- a/moeo/test/t-moeoSEEA.cpp +++ b/moeo/test/t-moeoSEEA.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoSPEA2.cpp b/moeo/test/t-moeoSPEA2.cpp index 3e2a27183..861977c55 100644 --- a/moeo/test/t-moeoSPEA2.cpp +++ b/moeo/test/t-moeoSPEA2.cpp @@ -48,11 +48,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoSPEA2Archive.cpp b/moeo/test/t-moeoSPEA2Archive.cpp index 8fb094510..df3af2d3a 100644 --- a/moeo/test/t-moeoSPEA2Archive.cpp +++ b/moeo/test/t-moeoSPEA2Archive.cpp @@ -46,11 +46,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoSharingDiversityAssignment.cpp b/moeo/test/t-moeoSharingDiversityAssignment.cpp index 1dd3973fa..81232617a 100644 --- a/moeo/test/t-moeoSharingDiversityAssignment.cpp +++ b/moeo/test/t-moeoSharingDiversityAssignment.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoStrictObjectiveVectorComparator.cpp b/moeo/test/t-moeoStrictObjectiveVectorComparator.cpp index b36302f80..f23ac84f2 100644 --- a/moeo/test/t-moeoStrictObjectiveVectorComparator.cpp +++ b/moeo/test/t-moeoStrictObjectiveVectorComparator.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoUnboundedArchive.cpp b/moeo/test/t-moeoUnboundedArchive.cpp index 5c4d8f180..1193b5f23 100644 --- a/moeo/test/t-moeoUnboundedArchive.cpp +++ b/moeo/test/t-moeoUnboundedArchive.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp b/moeo/test/t-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp index db2500f97..99901beb2 100644 --- a/moeo/test/t-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp +++ b/moeo/test/t-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp b/moeo/test/t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp index cd22abfcd..880794e01 100644 --- a/moeo/test/t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp +++ b/moeo/test/t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp @@ -47,11 +47,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/moeo/test/t-moeoWeakObjectiveVectorComparator.cpp b/moeo/test/t-moeoWeakObjectiveVectorComparator.cpp index 9ff0f89ab..f193b1ee7 100644 --- a/moeo/test/t-moeoWeakObjectiveVectorComparator.cpp +++ b/moeo/test/t-moeoWeakObjectiveVectorComparator.cpp @@ -45,11 +45,11 @@ class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { public: - static bool minimizing (int i) + static bool minimizing (int /*i*/) { return true; } - static bool maximizing (int i) + static bool maximizing (int /*i*/) { return false; } diff --git a/problems/eval/nkLandscapesEval.h b/problems/eval/nkLandscapesEval.h index cfdaab60a..73d490876 100644 --- a/problems/eval/nkLandscapesEval.h +++ b/problems/eval/nkLandscapesEval.h @@ -114,7 +114,7 @@ public: void deleteTables() { if (links != NULL) { - for(int i = 0; i < N; i++) { + for(unsigned i = 0; i < N; i++) { delete [] (links[i]); } delete [] links; @@ -122,7 +122,7 @@ public: } if (tables != NULL) { - for(int i = 0; i < N; i++) { + for(unsigned i = 0; i < N; i++) { delete [] (tables[i]); } delete [] tables; @@ -210,8 +210,8 @@ public: * @param file the file to read */ void loadLinks(std::fstream & file) { - for(int j = 0; j < K+1; j++) - for(int i = 0; i < N; i++) { + for(unsigned j = 0; j < K+1; j++) + for(unsigned i = 0; i < N; i++) { file >> links[i][j]; } } @@ -222,8 +222,8 @@ public: * @param file the file to read */ void loadTables(std::fstream & file) { - for(int j = 0; j < (1<<(K+1)); j++) - for(int i = 0; i < N; i++) + for(unsigned j = 0; j < (1<<(K+1)); j++) + for(unsigned i = 0; i < N; i++) file >> tables[i][j]; } @@ -241,13 +241,13 @@ public: file << "p NK " << N << " " << K < Date: Wed, 4 Sep 2024 08:55:48 +0200 Subject: [PATCH 28/69] fix(doc): use current source dir and not the root one. Allow Paradiseo to be built as a Git submodule of another project. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abe421bb6..5bec9ae43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ set(MPI "false" CACHE BOOL "Build the MPI module") ## EO Module set(MODULE_NAME "Paradiseo") -set(DOXYGEN_CONFIG_DIR ${CMAKE_SOURCE_DIR}/doxygen) +set(DOXYGEN_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doxygen) # set(EO_MODULE_NAME "Evolving Objects") set(CMAKE_SOURCE_DIR ${EO_SRC_DIR}) add_subdirectory(${EO_SRC_DIR}) From 51be7e324b07c90d9b1b4b93c7fa9f8d668f76b5 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 5 Sep 2024 14:42:40 +0200 Subject: [PATCH 29/69] fix(moRndVectorVNSelection): use shuffle for modern compilers --- mo/src/neighborhood/moRndVectorVNSelection.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mo/src/neighborhood/moRndVectorVNSelection.h b/mo/src/neighborhood/moRndVectorVNSelection.h index af4ab22dd..86a9d00b7 100644 --- a/mo/src/neighborhood/moRndVectorVNSelection.h +++ b/mo/src/neighborhood/moRndVectorVNSelection.h @@ -52,7 +52,7 @@ public: /** * Default constructor with first search heuristics * - * @param _firstLS first local search + * @param _firstLS first local search * @param _firstShake first heuristic which perturbs the solution * @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop. */ @@ -67,7 +67,7 @@ public: } /** - * test if there is still some heuristics + * test if there is still some heuristics * * @param _solution the current solution * @return true if there is some heuristics @@ -83,11 +83,17 @@ public: */ virtual void init(EOT& /*_solution*/) { if(order.size() == 0) - for(unsigned int i = 0; i < LSvector.size(); i++) - order.push_back(i); - + for(unsigned int i = 0; i < LSvector.size(); i++) { + order.push_back(i); } + +#if __cplusplus >= 201103L + std::random_device rd; + std::mt19937 gen(rd()); + std::shuffle(order.begin(), order.end(), gen); +#else UF_random_generator gen(order.size()); std::random_shuffle(order.begin(), order.end(), gen); +#endif currentOrder = 0; current = order[currentOrder]; From 8dd4f529f27147d216cafb311e1d82537373e2d2 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 09:21:15 +0200 Subject: [PATCH 30/69] fix(eoExceptions): do not return a ref from a temp --- eo/src/eoExceptions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/src/eoExceptions.h b/eo/src/eoExceptions.h index b91bd6207..a41a7e4a9 100644 --- a/eo/src/eoExceptions.h +++ b/eo/src/eoExceptions.h @@ -45,7 +45,7 @@ public: const char* what() const throw() { - return message().c_str(); + return _msg.c_str(); } ~eoException() throw() {} From 1a61cd1f1c5346977148c0616c518527139ef64c Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 09:21:51 +0200 Subject: [PATCH 31/69] fix(eoGnuplot): get rid of warnings about unused variables --- eo/src/utils/eoGnuplot.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/eo/src/utils/eoGnuplot.cpp b/eo/src/utils/eoGnuplot.cpp index 2a7fe5229..ae34e6c79 100644 --- a/eo/src/utils/eoGnuplot.cpp +++ b/eo/src/utils/eoGnuplot.cpp @@ -56,22 +56,24 @@ eoGnuplot::~eoGnuplot() } - +#ifdef HAVE_GNUPLOT void eoGnuplot::gnuplotCommand(const char *_command) { -#ifdef HAVE_GNUPLOT if(gpCom) { PipeComSend( gpCom, _command ); PipeComSend( gpCom, "\n" ); } -#endif } +#else +void eoGnuplot::gnuplotCommand(const char *) +{ } +#endif +#ifdef HAVE_GNUPLOT void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) { -#ifdef HAVE_GNUPLOT std::ostringstream os; os << "250x150-0+" << 170 * numWindow++; char *args[6]; @@ -89,8 +91,12 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) PipeComSend( gpCom, _extra.c_str() ); PipeComSend( gpCom, "\n" ); } -#endif + } +#else +void eoGnuplot::initGnuPlot(std::string, std::string) +{ } +#endif From c23b9c160a8dbf3227ced2538a572e1235661940 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 09:22:16 +0200 Subject: [PATCH 32/69] fix(selectors): correctly initialize rawTotal --- eo/src/utils/selectors.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eo/src/utils/selectors.h b/eo/src/utils/selectors.h index 7f0f571ed..b97a08fbf 100644 --- a/eo/src/utils/selectors.h +++ b/eo/src/utils/selectors.h @@ -179,7 +179,8 @@ double sum_fitness(const eoPop& _pop) template double sum_fitness(const eoPop& _pop, std::pair& _minmax) { - double rawTotal, scaledTotal; + double rawTotal = 0; + double scaledTotal; typename eoPop::const_iterator it = _pop.begin(); From 32195a480b1792de8502bebb2f2dd386563a1fc3 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 09:26:00 +0200 Subject: [PATCH 33/69] fix(selectors): comment out unused variable --- eo/src/utils/selectors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo/src/utils/selectors.h b/eo/src/utils/selectors.h index b97a08fbf..fda0633ca 100644 --- a/eo/src/utils/selectors.h +++ b/eo/src/utils/selectors.h @@ -179,7 +179,7 @@ double sum_fitness(const eoPop& _pop) template double sum_fitness(const eoPop& _pop, std::pair& _minmax) { - double rawTotal = 0; + // double rawTotal = 0; double scaledTotal; typename eoPop::const_iterator it = _pop.begin(); @@ -194,7 +194,7 @@ double sum_fitness(const eoPop& _pop, std::pair& _minmax) _minmax.first = std::min(_minmax.first, v); _minmax.second = std::max(_minmax.second, v); - rawTotal += v; + // rawTotal += v; } if (minimizing_fitness()) From 867b1c289b85f123cc543723c65592b888cf3d66 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 09:28:55 +0200 Subject: [PATCH 34/69] fix(eoEvalUserTimeThrowException): preprocessor test for POSIX and UNIX --- eo/src/eoEvalUserTimeThrowException.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eo/src/eoEvalUserTimeThrowException.h b/eo/src/eoEvalUserTimeThrowException.h index 1e2edda6f..a11748491 100644 --- a/eo/src/eoEvalUserTimeThrowException.h +++ b/eo/src/eoEvalUserTimeThrowException.h @@ -21,9 +21,9 @@ Authors: Johann Dréo */ -#if !defined(__unix__) && !defined(_WINDOWS) +#if !defined(_POSIX_VERSION) && !defined(__unix__) && !defined(_WINDOWS) #warning "Warning: class 'eoEvalUserTimeThrowException' is only available under UNIX (defining 'rusage' in 'sys/resource.h') or Win32 (defining 'GetProcessTimes' in 'WinBase.h') systems, contributions for other systems are welcomed." -#else //!defined(__unix__) && !defined(_WINDOWS) +#else // defined(_POSIX_VERSION) || defined(__unix__) || defined(_WINDOWS) #ifndef __EOEVALUSERTIMETHROWEXCEPTION_H__ #define __EOEVALUSERTIMETHROWEXCEPTION_H__ @@ -40,7 +40,7 @@ Johann Dréo #include "eoExceptions.h" -#ifdef __unix__ +#if defined(_POSIX_VERSION) || defined(__unix__) #include #include @@ -106,6 +106,6 @@ protected: }; #endif // _WINDOWS -#endif //__unix__ +#endif // defined(_POSIX_VERSION) || defined(__unix__) #endif // __EOEVALUSERTIMETHROWEXCEPTION_H__ -#endif //!defined(__unix__) && !defined(_WINDOWS) +#endif //!defined(_POSIX_VERSION) && !defined(__unix__) && !defined(_WINDOWS) From df8c457f7588581610f0c57213ec90bb934467c1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 10:45:18 +0200 Subject: [PATCH 35/69] fix(moeoSPEA2Archive): correct members init order --- moeo/src/archive/moeoSPEA2Archive.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/moeo/src/archive/moeoSPEA2Archive.h b/moeo/src/archive/moeoSPEA2Archive.h index f5b60e63f..d2c64b83a 100644 --- a/moeo/src/archive/moeoSPEA2Archive.h +++ b/moeo/src/archive/moeoSPEA2Archive.h @@ -81,7 +81,7 @@ public: * Default ctor. * @param _maxSize the size of archive (must be smaller or equal to the population size) */ - moeoSPEA2Archive(unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(defaultDistance) + moeoSPEA2Archive(unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(defaultComparator), defaultDistance(), distance(defaultDistance) {} @@ -90,7 +90,7 @@ public: * @param _dist the distance used * @param _maxSize the size of archive (must be smaller or egal to the population size) */ - moeoSPEA2Archive(moeoDistance & _dist, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(_dist) + moeoSPEA2Archive(moeoDistance & _dist, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(defaultComparator), distance(_dist) {} @@ -99,7 +99,7 @@ public: * @param _comparator the functor used to compare objective vectors * @param _maxSize the size of archive (must be smaller or egal to the population size) */ - moeoSPEA2Archive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(defaultDistance) + moeoSPEA2Archive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(defaultComparator), defaultDistance(), distance(defaultDistance) {} @@ -108,7 +108,7 @@ public: * @param _indiComparator the functor used to compare MOEOT * @param _maxSize the size of archive (must be smaller or egal to the population size) */ - moeoSPEA2Archive(moeoComparator & _indiComparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(_indiComparator), distance(defaultDistance) + moeoSPEA2Archive(moeoComparator & _indiComparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(_indiComparator), defaultDistance(), distance(defaultDistance) {} @@ -119,7 +119,7 @@ public: * @param _comparator the functor used to compare objective vectors * @param _maxSize the size of archive (must be smaller or egal to the population size) */ - moeoSPEA2Archive(moeoComparator & _indiComparator, moeoDistance & _dist, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), indiComparator(_indiComparator), distance(_dist) + moeoSPEA2Archive(moeoComparator & _indiComparator, moeoDistance & _dist, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), defaultComparator(), indiComparator(_indiComparator), distance(_dist) {} @@ -283,11 +283,12 @@ public: private: - /** archive max size */ unsigned int maxSize; /** archive size */ unsigned int borne; + /** default moeoComparator*/ + moeoFitnessThenDiversityComparator < MOEOT > defaultComparator; /** * Wrapper which allow to used an moeoComparator in std::sort * @param _comp the comparator to used @@ -314,12 +315,10 @@ private: moeoComparator < MOEOT > & comp; } indiComparator; - /** default moeoComparator*/ - moeoFitnessThenDiversityComparator < MOEOT > defaultComparator; - /** distance */ - moeoDistance & distance; /** default distance */ moeoEuclideanDistance < MOEOT > defaultDistance; + /** distance */ + moeoDistance & distance; /** From a6a3f799e77a874849fac500db4921da23c030d0 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 10:57:50 +0200 Subject: [PATCH 36/69] fix(eoParallel): declutch _t_start under _OPENMP --- eo/src/utils/eoParallel.cpp | 6 ++++-- eo/src/utils/eoParallel.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/eo/src/utils/eoParallel.cpp b/eo/src/utils/eoParallel.cpp index cae5e8c41..41704c54b 100644 --- a/eo/src/utils/eoParallel.cpp +++ b/eo/src/utils/eoParallel.cpp @@ -39,8 +39,10 @@ eoParallel::eoParallel() : _nthreads( 0, "parallelize-nthreads", "Define the number of threads you want to use, nthreads = 0 means you want to use all threads available", '\0' ), _enableResults( false, "parallelize-enable-results", "Enable the generation of results", '\0' ), _doMeasure( false, "parallelize-do-measure", "Do some measures during execution", '\0' ), - _packetSize( 1U, "parallelize-packet-size", "Number of elements which should be sent in a single message during a parallel evaluation based on message passing.", '\0'), - _t_start(0) + _packetSize( 1U, "parallelize-packet-size", "Number of elements which should be sent in a single message during a parallel evaluation based on message passing.", '\0') +#ifdef _OPENMP + , _t_start(0) +#endif { } diff --git a/eo/src/utils/eoParallel.h b/eo/src/utils/eoParallel.h index 6608706dc..929d955d6 100644 --- a/eo/src/utils/eoParallel.h +++ b/eo/src/utils/eoParallel.h @@ -71,7 +71,9 @@ private: eoValueParam _enableResults; eoValueParam _doMeasure; eoValueParam _packetSize; +#ifdef _OPENMP double _t_start; +#endif }; void make_parallel(eoParser&); From 11f49e58d77afc3cd9cbf46fa57bc25d6872918a Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 12 Sep 2022 15:20:05 +0200 Subject: [PATCH 37/69] feat: prepare the use of binary partitions for signatures --- mo/src/problems/partition/moBinaryPartition.h | 107 +++++++++++++++++ .../partition/moBinaryPartitionSwapNeighbor.h | 89 +++++++++++++++ .../moBinaryPartitionSwapNeighborhood.h | 108 ++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 mo/src/problems/partition/moBinaryPartition.h create mode 100644 mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h create mode 100644 mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h new file mode 100644 index 000000000..2fedb50ef --- /dev/null +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -0,0 +1,107 @@ +#pragma once + +#include + +#include + +template +class moBinaryPartition : public EO +{ + public: + using AtomType = size_t; + using ContainerType = std::set; + + ContainerType selected; + ContainerType rejected; + + /** Constructor + * + * @param total_nb_genes Total number of possible genes from whith to select. + */ + moBinaryPartition( const size_t total_nb_genes ) + { + // Fill the rejected list with all possible gene indices, + // starting from zero. + for(size_t i = 0; i < total_nb_genes; ++i) { + rejected.insert(i); + } + // No selected. + } + + void select(const size_t atom) { + assert(not selected.contains(atom)); + + #ifndef NDEBUG + size_t has_erased = + #endif + this->rejected.erase(atom); + assert(has_erased == 1); + + #ifndef NDEBUG + auto [where, has_inserted] = + #endif + this->selected.insert(atom); + assert(has_inserted); + } + + void reject(const size_t atom) { + assert(not rejected.contains(atom)); + + #ifndef NDEBUG + size_t has_erased = + #endif + this->selected.erase(atom); + assert(has_erased == 1); + + #ifndef NDEBUG + auto [where, has_inserted] = + #endif + this->rejected.insert(atom); + assert(has_inserted); + } + + /** Serialization of the `selected` atoms. */ + virtual void printOn(std::ostream& out) const + { + EO::printOn(out); // Fitness. + // Trailing space already inserted. + out << selected.size() << " "; // Size. + std::copy(std::begin(selected), std::end(selected), + std::ostream_iterator(out, " ")); // Values. + out << " "; + out << rejected.size() << " "; // Size. + std::copy(std::begin(rejected), std::end(rejected), + std::ostream_iterator(out, " ")); // Values. + } + + /** Deserialization of the `selected` atoms. */ + virtual void readFrom(std::istream& in) + { + EO::readFrom(in); // Fitness. + unsigned size; + in >> size; // Size. + for(size_t i = 0; i < size; ++i) { + AtomType atom; + in >> atom; // Value. + selected.insert(atom); + } + assert(selected.size() == size); + in >> size; // Size. + for(size_t i = 0; i < size; ++i) { + AtomType atom; + in >> atom; // Value. + rejected.insert(atom); + } + assert(rejected.size() == size); + } + + bool operator==(const moBinaryPartition& other) { + return this->selected == other.selected + and this->rejected == other.rejected; + } + + virtual std::string className() const + { + return "moBinaryPartition"; + } +}; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h new file mode 100644 index 000000000..86e97a74d --- /dev/null +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -0,0 +1,89 @@ +#pragma once + +#include + +#include + +#include "moBinaryPartition.h" + +template +class moBinaryPartitionSwapNeighbor : + public moBackableNeighbor//, + // public moIndexNeighbor +{ + public: + using AtomType = typename EOT::AtomType; + using ContainerType = typename EOT::ContainerType; + using moBackableNeighbor::fitness; + // using moIndexNeighbor::key; + // using moIndexNeighbor::index; + + moBinaryPartitionSwapNeighbor( const size_t _selected_nb ) : + selected_nb(_selected_nb), + is_set(false) + { + assert(selected_nb > 0); + } + + virtual void move(EOT& solution) override { + assert(is_set); + // Swap the two atoms. + solution.reject(this->reject); + solution.select(this->select); + assert(solution.selected.size() == this->selected_nb); + + solution.invalidate(); + } + + virtual void moveBack(EOT& solution) override { + assert(is_set); + solution.reject(this->select); + solution.select(this->reject); + assert(solution.selected.size() == this->selected_nb); + + solution.invalidate(); + } + + void set(AtomType in, AtomType out) { + this->select = in; + this->reject = out; + #ifndef NDEBUG + is_set = true; + #endif + } + + std::pair get() { + assert(is_set); + return std::make_pair(select, reject); + } + + virtual bool equals(moBinaryPartitionSwapNeighbor& neighbor) { + auto [in, out] = neighbor.get(); + return this->select == in and this->reject == out; + } + + virtual std::string className() const override { + return "moBinaryPartitionSwapNeighbor"; + } + + virtual void printOn(std::ostream& out) const override { + assert(is_set); + out << selected_nb + << " -" << reject + << " +" << select; + } + +#ifndef NDEBUG + public: +#else + protected: +#endif + const size_t selected_nb; + AtomType select; + AtomType reject; + #ifndef NDEBUG + bool is_set; + #endif +}; + + diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h new file mode 100644 index 000000000..e92382357 --- /dev/null +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -0,0 +1,108 @@ +#pragma once + +#include + +#include +#include "moBinaryPartition.h" + +template +class moBinaryPartitionSwapNeighborhood : public moNeighborhood > +{ + public: + using Neighbor = moBinaryPartitionSwapNeighbor; + using AtomType = typename EOT::AtomType; + + AtomType selected(EOT& from, const size_t i_select) { + typename EOT::ContainerType::iterator + it = std::begin(from.rejected); + std::advance(it, i_select); + return *it; + } + + AtomType rejected(EOT& from, const size_t j_reject) { + typename EOT::ContainerType::iterator + it = std::begin(from.selected); + std::advance(it, j_reject); + return *it; + } + + virtual void init(EOT& from, Neighbor& to) override { + i_select = 0; + j_reject = 0; + + // std::clog << "Init neighborhood:" + // << " -" << rejected(from, j_reject) + // << " +" << selected(from, i_select) + // << std::endl; + + // First item in both lists. + AtomType in = selected(from, i_select); + AtomType out = rejected(from, j_reject); + to.set(in, out); + } + + virtual void next(EOT& from, Neighbor& to) override { + // If last item of the inner loop. + if( i_select == from.rejected.size()-1 ) { + i_select = 0; // Reset inner loop. + j_reject++; // Next outer loop. + } else { + i_select++; // Next inner loop. + } + + // std::clog << "Next in neighborhood:" + // << " -" << rejected(from, j_reject) + // << " +" << selected(from, i_select) + // << std::endl; + + assert( from.rejected.contains(selected(from,i_select)) ); + assert( from.selected.contains(rejected(from,j_reject)) ); + assert( selected(from,i_select) != rejected(from,j_reject) ); + + // Implant this move in the neighbor. + to.set( + selected(from, i_select), + rejected(from, j_reject) + ); + } + + virtual bool cont(EOT& from) override { + // Outer loop on selected, + // inner loop on rejected. + // std::clog << "cont neighborhood?" + // << " " << j_reject << "(-" << rejected(from, j_reject) << ")/" << from.selected.size() + // << " " << i_select << "(-" << selected(from, i_select) << ")/" << from.rejected.size() + // << std::endl; + + // If reached the last item of the outer loop. + if( i_select == from.rejected.size()-1 + and j_reject == from.selected.size()-1) { + // We should also have reached the end of the inner loop, + // and have set the inner loop to zero. + // std::clog << "\tnope" << std::endl; + return false; + + } else { // There is still some items in the outer loop. + // and thus also in the inner loop. + // std::clog << "\tyes" << std::endl; + assert( j_reject < from.selected.size() ); + return true; + } + } + + virtual bool hasNeighbor(EOT& solution) override { + return solution.rejected.size() > 0; + } + + virtual std::string className() const override { + return "moBinaryPartitionSwapNeighborhood"; + } + +#ifndef NDEBUG + public: +#else + protected: +#endif + size_t i_select; + size_t j_reject; +}; From 2accb17599025618c4be9a18884e2d77640742a2 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 13 Sep 2022 15:25:33 +0200 Subject: [PATCH 38/69] document everything and remove dead code --- mo/src/problems/partition/moBinaryPartition.h | 64 +++++++++++++++++-- .../partition/moBinaryPartitionSwapNeighbor.h | 60 ++++++++++++++++- .../moBinaryPartitionSwapNeighborhood.h | 36 ++++++++++- 3 files changed, 150 insertions(+), 10 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 2fedb50ef..7fd53bce0 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -4,30 +4,76 @@ #include +/** A partition of a binary space. + * + * This data structure defines a grouping of the elements of a multi-dimensional + * set in a space of boolean numbers. + * \f[ + * \mathrm{1}^n = \bigcup_{i=1}^n \{0,1\}_i + * \f] + * Elements of the set may be either "selected" (in the set S) or "rejected" (in the set R). + * \f[ + * (S \in \mathrm{1}^m) \cup (R \in \mathrm{1}^k) \in \mathrm{1}^n,\; n=m+k + * \f] + * Elements are referred to by their index in the set (hereby named "atoms"). + * + * This representation is useful if your problem can be defined has selecting + * a subset of elements that optimize some objective function. + * + * The core data structures are two ordered sets of unique atoms, + * the union of which is guaranteed to have the correct dimension. + */ template class moBinaryPartition : public EO { public: + /** The type for indices. */ using AtomType = size_t; + + /** The data structures holding the indices. */ using ContainerType = std::set; + /** The set of selected atoms. */ ContainerType selected; + + /** The set of not-selected atoms. */ ContainerType rejected; - /** Constructor + /** Consistent constructor * - * @param total_nb_genes Total number of possible genes from whith to select. + * Put all `total_nb_atoms` indices in the @ref rejected set. + * Indices starts at zero and fill the set in increasing order. + * + * @param total_nb_atoms Total number of possible atoms from whith to select. */ - moBinaryPartition( const size_t total_nb_genes ) + moBinaryPartition( const size_t total_nb_atoms ) { // Fill the rejected list with all possible gene indices, // starting from zero. - for(size_t i = 0; i < total_nb_genes; ++i) { + for(size_t i = 0; i < total_nb_atoms; ++i) { rejected.insert(i); } - // No selected. + // None selected. } + /** Empty constructor + * + * Do not fill the @ref rejected set. + * You are responsible for making it consistent after instantiation. + * + * @warning If you do not fill at least the @ref rejected set, + * errors will be raised whe trying to @ref select or @ref reject. + */ + moBinaryPartition() + { } + + /** Move one atom in the @ref selected set. + * + * That is: erase the atom from @ref rejected, + * insert it in @ref selected. + * + * @note In debug mode, double check that elements were actually moved. + */ void select(const size_t atom) { assert(not selected.contains(atom)); @@ -44,6 +90,13 @@ class moBinaryPartition : public EO assert(has_inserted); } + /** Move one atom in the @ref rejected set. + * + * That is: insert the atom in @ref rejected, + * erase it from @ref selected. + * + * @note In debug mode, double check that elements were actually moved. + */ void reject(const size_t atom) { assert(not rejected.contains(atom)); @@ -95,6 +148,7 @@ class moBinaryPartition : public EO assert(rejected.size() == size); } + /** Returns true if all sets are equals. */ bool operator==(const moBinaryPartition& other) { return this->selected == other.selected and this->rejected == other.rejected; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index 86e97a74d..af7449398 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -6,25 +6,53 @@ #include "moBinaryPartition.h" +/** Stable neighbor for a binary partition. + * + * Models how to move from a solution to a neighbor, + * by swaping one selected atom for one rejected atom. + * The number of selected atoms is thus guaranteed to be stable. + * + * The core data structure is two atoms: + * - the selected one, + * - the rejected one. + */ template class moBinaryPartitionSwapNeighbor : public moBackableNeighbor//, - // public moIndexNeighbor + // public moIndexNeighbor // FIXME see if we can model that. { public: + /** Shortcut for Atom’s type. */ using AtomType = typename EOT::AtomType; + + /** Shortcut for container’s type. */ using ContainerType = typename EOT::ContainerType; + + /** Shortcut for fitness. */ using moBackableNeighbor::fitness; + // using moIndexNeighbor::key; // using moIndexNeighbor::index; + /** Consistent constructor. + * + * Will ensure that the dimension of the partition does not change. + * + * @param _selected_nb Number of selected atoms to maintain. + */ moBinaryPartitionSwapNeighbor( const size_t _selected_nb ) : - selected_nb(_selected_nb), - is_set(false) + selected_nb(_selected_nb) + #ifndef NDEBUG + , is_set(false) + #endif { assert(selected_nb > 0); } + /** Apply the currently stored move. + * + * That is: reject one atom and select one other. + */ virtual void move(EOT& solution) override { assert(is_set); // Swap the two atoms. @@ -35,6 +63,10 @@ class moBinaryPartitionSwapNeighbor : solution.invalidate(); } + /** Apply the opposite of the currently stored move. + * + * That is: reject the selected atom, and select the rejected one. + */ virtual void moveBack(EOT& solution) override { assert(is_set); solution.reject(this->select); @@ -44,6 +76,11 @@ class moBinaryPartitionSwapNeighbor : solution.invalidate(); } + /** Set the considered atoms. + * + * @param in The selected atom. + * @param out The rejected atom. + */ void set(AtomType in, AtomType out) { this->select = in; this->reject = out; @@ -52,11 +89,16 @@ class moBinaryPartitionSwapNeighbor : #endif } + /** Get the considered atom. + * + * @returns A pair of atoms, the first being the selected atom, the second being the rejected one. + */ std::pair get() { assert(is_set); return std::make_pair(select, reject); } + /** Returns true if this neighbor has the same selected & rejected atoms than the given neighbor. */ virtual bool equals(moBinaryPartitionSwapNeighbor& neighbor) { auto [in, out] = neighbor.get(); return this->select == in and this->reject == out; @@ -66,6 +108,7 @@ class moBinaryPartitionSwapNeighbor : return "moBinaryPartitionSwapNeighbor"; } + /** Fancy print. */ virtual void printOn(std::ostream& out) const override { assert(is_set); out << selected_nb @@ -78,10 +121,21 @@ class moBinaryPartitionSwapNeighbor : #else protected: #endif + /** Fixed dimension of the handled solutions. */ const size_t selected_nb; + + /** Selected atom. */ AtomType select; + + /** Rejected atom. */ AtomType reject; + #ifndef NDEBUG + /** Sanity flag. + * + * Used in debug builds to ensure that the neighbor + * have been set before being used. + */ bool is_set; #endif }; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index e92382357..694576732 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -5,13 +5,32 @@ #include #include "moBinaryPartition.h" +/** Stable neighborhood for binary partitions. + * + * This generates all neighbors of a binary partition + * that have the same dimension than the considered solution. + * I.e. it enumerates all the swaps of two atoms + * between the selected and rejected sets. + * + * The core data structure is two indices: + * - one for the position within the selected set of a binary partition, + * - the other for the position within the rejected set. + * + * The neighborhood is defined as enumerating the neighbors, + * first by going over the rejected atoms (outer loop), + * then by iterating over the selected atoms (inner loop). + */ template class moBinaryPartitionSwapNeighborhood : public moNeighborhood > { public: + /** Shortcut for neighbor's type. */ using Neighbor = moBinaryPartitionSwapNeighbor; + + /** Shortcut for Atom’s type. */ using AtomType = typename EOT::AtomType; + /** Get the currently pointed selected atom. */ AtomType selected(EOT& from, const size_t i_select) { typename EOT::ContainerType::iterator it = std::begin(from.rejected); @@ -19,6 +38,7 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood 0; } @@ -103,6 +132,9 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood Date: Mon, 3 Oct 2022 16:11:37 +0200 Subject: [PATCH 39/69] feat: adds partial eval and tests --- mo/src/problems/partition/moBinaryPartition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 7fd53bce0..e74d0ea64 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -118,7 +118,7 @@ class moBinaryPartition : public EO { EO::printOn(out); // Fitness. // Trailing space already inserted. - out << selected.size() << " "; // Size. + out << selected.size() << " "; // Size. std::copy(std::begin(selected), std::end(selected), std::ostream_iterator(out, " ")); // Values. out << " "; From bfce997ce800fec9d565a79f05481779afd976a1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 18 Oct 2022 11:12:38 +0200 Subject: [PATCH 40/69] first part of partial signature evaluation --- .../partition/moBinaryPartitionSwapNeighbor.h | 56 ++++++++++++++++++- .../moBinaryPartitionSwapNeighborhood.h | 2 + 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index af7449398..dd65b9c0d 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -49,6 +49,43 @@ class moBinaryPartitionSwapNeighbor : assert(selected_nb > 0); } + /** Default constructor. + * + * Will NOT ensure that the dimension of the partition does not change. + */ + moBinaryPartitionSwapNeighbor() : + selected_nb(0) + #ifndef NDEBUG + , is_set(false) + #endif + { + // Invalid fitness by default. + } + + /** Copy constructor. + */ + moBinaryPartitionSwapNeighbor( const moBinaryPartitionSwapNeighbor& other) : + selected_nb(other.selected_nb ) + #ifndef NDEBUG + , is_set(other.is_set) + #endif + { + this->fitness(other.fitness()); + } + + /** Default assignment operator. + */ + moBinaryPartitionSwapNeighbor& operator=( + const moBinaryPartitionSwapNeighbor& other) + { + this->fitness(other.fitness()); + this->selected_nb = other.selected_nb; + #ifndef NDEBUG + this->is_set = other.is_set; + #endif + return *this; + } + /** Apply the currently stored move. * * That is: reject one atom and select one other. @@ -58,7 +95,9 @@ class moBinaryPartitionSwapNeighbor : // Swap the two atoms. solution.reject(this->reject); solution.select(this->select); - assert(solution.selected.size() == this->selected_nb); + #ifndef NDEBUG + assert(solution.selected.size() == this->selected_nb); + #endif solution.invalidate(); } @@ -71,7 +110,9 @@ class moBinaryPartitionSwapNeighbor : assert(is_set); solution.reject(this->select); solution.select(this->reject); - assert(solution.selected.size() == this->selected_nb); + #ifndef NDEBUG + assert(solution.selected.size() == this->selected_nb); + #endif solution.invalidate(); } @@ -116,13 +157,22 @@ class moBinaryPartitionSwapNeighbor : << " +" << select; } + void size(size_t _selected_nb) { + assert(_selected_nb > 0); + this->selected_nb = _selected_nb; + } + + size_t size() const { + return this->selected_nb; + } + #ifndef NDEBUG public: #else protected: #endif /** Fixed dimension of the handled solutions. */ - const size_t selected_nb; + size_t selected_nb; /** Selected atom. */ AtomType select; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index 694576732..cf4845478 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -64,6 +64,7 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood Date: Wed, 18 Jan 2023 11:14:13 +0100 Subject: [PATCH 41/69] more doc --- mo/src/problems/partition/moBinaryPartition.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index e74d0ea64..c91c2848b 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -113,12 +113,16 @@ class moBinaryPartition : public EO assert(has_inserted); } - /** Serialization of the `selected` atoms. */ + /** Serialization of the `selected` and `rejected` atoms. + * + * Output a string of the form (spaces replaced with period here, to show their count): + * `.........` + */ virtual void printOn(std::ostream& out) const { EO::printOn(out); // Fitness. // Trailing space already inserted. - out << selected.size() << " "; // Size. + out << " " << selected.size() << " "; // Size. std::copy(std::begin(selected), std::end(selected), std::ostream_iterator(out, " ")); // Values. out << " "; @@ -127,7 +131,11 @@ class moBinaryPartition : public EO std::ostream_iterator(out, " ")); // Values. } - /** Deserialization of the `selected` atoms. */ + /** Deserialization of the `selected` and `rejected` atoms. + * + * Expects a string of the form (spaces replaced with period here, to show their count): + * `.........` + */ virtual void readFrom(std::istream& in) { EO::readFrom(in); // Fitness. From 36fe6e6f7d8be2aa95c65c5ce68faf2ea80ca1b5 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 18 Jan 2023 11:28:50 +0100 Subject: [PATCH 42/69] fix a warning --- mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index dd65b9c0d..8dca43d53 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -144,6 +144,11 @@ class moBinaryPartitionSwapNeighbor : auto [in, out] = neighbor.get(); return this->select == in and this->reject == out; } + private: + // Disable access to `equals(moNeighbor<…>&)` (removes the related overloaded-virtual warning). + using moBackableNeighbor::equals; + + public: virtual std::string className() const override { return "moBinaryPartitionSwapNeighbor"; From 237426a6b40a049617eb1106bc9736ce262cfa54 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 26 Jan 2023 11:48:44 +0100 Subject: [PATCH 43/69] refactor while hunting a bug --- mo/src/problems/partition/moBinaryPartition.h | 9 ++++ .../partition/moBinaryPartitionSwapNeighbor.h | 41 ++++++++++++++----- .../moBinaryPartitionSwapNeighborhood.h | 37 ++++++++++------- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index c91c2848b..768cf3bd1 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -166,4 +166,13 @@ class moBinaryPartition : public EO { return "moBinaryPartition"; } + + void fitness(const FitT& fit) { + CLUTCHLOG(debug, "Fitness assignment -- solution: " << *this << " gets fitness: " << fit); + EO::fitness(fit); + } + + FitT fitness() const { + return EO::fitness(); + } }; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index 8dca43d53..dd9a93a3a 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -65,7 +65,9 @@ class moBinaryPartitionSwapNeighbor : /** Copy constructor. */ moBinaryPartitionSwapNeighbor( const moBinaryPartitionSwapNeighbor& other) : - selected_nb(other.selected_nb ) + selected_nb(other.selected_nb), + select(other.select), + reject(other.reject) #ifndef NDEBUG , is_set(other.is_set) #endif @@ -78,11 +80,13 @@ class moBinaryPartitionSwapNeighbor : moBinaryPartitionSwapNeighbor& operator=( const moBinaryPartitionSwapNeighbor& other) { - this->fitness(other.fitness()); this->selected_nb = other.selected_nb; + this->select = other.select; + this->reject = other.reject; #ifndef NDEBUG this->is_set = other.is_set; #endif + this->fitness(other.fitness()); return *this; } @@ -95,10 +99,7 @@ class moBinaryPartitionSwapNeighbor : // Swap the two atoms. solution.reject(this->reject); solution.select(this->select); - #ifndef NDEBUG - assert(solution.selected.size() == this->selected_nb); - #endif - + assert(solution.selected.size() == this->selected_nb); solution.invalidate(); } @@ -110,10 +111,7 @@ class moBinaryPartitionSwapNeighbor : assert(is_set); solution.reject(this->select); solution.select(this->reject); - #ifndef NDEBUG - assert(solution.selected.size() == this->selected_nb); - #endif - + assert(solution.selected.size() == this->selected_nb); solution.invalidate(); } @@ -128,6 +126,15 @@ class moBinaryPartitionSwapNeighbor : #ifndef NDEBUG is_set = true; #endif + this->invalidate(); + } + + /** Set the considered atoms. + * + * @param in_out A pair of {selected,rejected} atoms. + */ + void set(std::pair in_out) { + this->set(in_out.first, in_out.second); } /** Get the considered atom. @@ -157,7 +164,9 @@ class moBinaryPartitionSwapNeighbor : /** Fancy print. */ virtual void printOn(std::ostream& out) const override { assert(is_set); - out << selected_nb + EO::printOn(out); // Fitness. + out << " " + << selected_nb << " -" << reject << " +" << select; } @@ -165,12 +174,22 @@ class moBinaryPartitionSwapNeighbor : void size(size_t _selected_nb) { assert(_selected_nb > 0); this->selected_nb = _selected_nb; + this->invalidate(); } size_t size() const { return this->selected_nb; } + void fitness(const Fitness& fit) { + CLUTCHLOG(debug, "Fitness assignment -- neighbor: " << *this << " gets fitness: " << fit); + EO::fitness(fit); + } + + Fitness fitness() const { + return EO::fitness(); + } + #ifndef NDEBUG public: #else diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index cf4845478..50702be9a 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -55,16 +55,20 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood Date: Thu, 2 Feb 2023 14:48:02 +0100 Subject: [PATCH 44/69] refactor(fitness): store cache with the fitness to allow rollback with minimal mem footprint --- mo/src/problems/partition/moBinaryPartition.h | 20 ++++++--- .../partition/moBinaryPartitionSwapNeighbor.h | 14 ++++--- .../moBinaryPartitionSwapNeighborhood.h | 42 +++++++++---------- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 768cf3bd1..b1b698ab8 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -118,7 +118,7 @@ class moBinaryPartition : public EO * Output a string of the form (spaces replaced with period here, to show their count): * `.........` */ - virtual void printOn(std::ostream& out) const + virtual void printOn(std::ostream& out) const override { EO::printOn(out); // Fitness. // Trailing space already inserted. @@ -136,7 +136,7 @@ class moBinaryPartition : public EO * Expects a string of the form (spaces replaced with period here, to show their count): * `.........` */ - virtual void readFrom(std::istream& in) + virtual void readFrom(std::istream& in) override { EO::readFrom(in); // Fitness. unsigned size; @@ -162,17 +162,25 @@ class moBinaryPartition : public EO and this->rejected == other.rejected; } - virtual std::string className() const + virtual std::string className() const override { return "moBinaryPartition"; } - void fitness(const FitT& fit) { - CLUTCHLOG(debug, "Fitness assignment -- solution: " << *this << " gets fitness: " << fit); + virtual void fitness(const FitT& fit) override + { + // std::clog << "Fitness assignment -- solution: " << *this << " gets fitness: " << fit << std::endl; EO::fitness(fit); } - FitT fitness() const { + virtual const FitT& fitness() const override + { return EO::fitness(); } + + virtual void invalidate() override + { + // this->fitness().clear(); + EO::invalidate(); + } }; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index dd9a93a3a..2fe5d3a55 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -18,7 +18,7 @@ */ template class moBinaryPartitionSwapNeighbor : - public moBackableNeighbor//, + public moBackableNeighbor//, // public moIndexNeighbor // FIXME see if we can model that. { public: @@ -100,6 +100,7 @@ class moBinaryPartitionSwapNeighbor : solution.reject(this->reject); solution.select(this->select); assert(solution.selected.size() == this->selected_nb); + // this->fitness( Fitness(solution.fitness()) ); // For the cache. solution.invalidate(); } @@ -112,6 +113,7 @@ class moBinaryPartitionSwapNeighbor : solution.reject(this->select); solution.select(this->reject); assert(solution.selected.size() == this->selected_nb); + // this->fitness( Fitness(solution.fitness()) ); // For the cache. solution.invalidate(); } @@ -153,7 +155,7 @@ class moBinaryPartitionSwapNeighbor : } private: // Disable access to `equals(moNeighbor<…>&)` (removes the related overloaded-virtual warning). - using moBackableNeighbor::equals; + using moBackableNeighbor::equals; public: @@ -181,12 +183,14 @@ class moBinaryPartitionSwapNeighbor : return this->selected_nb; } - void fitness(const Fitness& fit) { - CLUTCHLOG(debug, "Fitness assignment -- neighbor: " << *this << " gets fitness: " << fit); + virtual void fitness(const Fitness& fit) override + { + // std::clog << "Fitness assignment -- neighbor: " << *this << " gets fitness: " << fit << std::endl; EO::fitness(fit); } - Fitness fitness() const { + virtual const Fitness& fitness() const override + { return EO::fitness(); } diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index 50702be9a..ca40fa551 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -55,13 +55,13 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood Date: Fri, 3 Feb 2023 10:35:10 +0100 Subject: [PATCH 45/69] refactor(app): separate main exe and datatester better log --- mo/src/problems/partition/moBinaryPartition.h | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index b1b698ab8..598de79c6 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -113,6 +113,27 @@ class moBinaryPartition : public EO assert(has_inserted); } + /** Serialization of the `selected`. + * + * Output a string of the form (spaces replaced with period here, to show their count): + * `....` + */ + virtual void printSelectedOn(std::ostream& out) const + { + EO::printOn(out); // Fitness. + // Trailing space already inserted. + out << " " << selected.size() << " "; // Size. + std::copy(std::begin(selected), std::end(selected), + std::ostream_iterator(out, " ")); // Values. + } + + std::string str() const + { + std::ostringstream msg; + this->printSelectedOn(msg); + return msg.str(); + } + /** Serialization of the `selected` and `rejected` atoms. * * Output a string of the form (spaces replaced with period here, to show their count): @@ -120,11 +141,7 @@ class moBinaryPartition : public EO */ virtual void printOn(std::ostream& out) const override { - EO::printOn(out); // Fitness. - // Trailing space already inserted. - out << " " << selected.size() << " "; // Size. - std::copy(std::begin(selected), std::end(selected), - std::ostream_iterator(out, " ")); // Values. + this->printSelectedOn(out); out << " "; out << rejected.size() << " "; // Size. std::copy(std::begin(rejected), std::end(rejected), From e57b504cd693d2490b859ddc0de44e61cdd7d468 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 3 Feb 2023 11:46:17 +0100 Subject: [PATCH 46/69] refactor(app): usable output --- mo/src/problems/partition/moBinaryPartition.h | 1 + 1 file changed, 1 insertion(+) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 598de79c6..36d1136fa 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -127,6 +127,7 @@ class moBinaryPartition : public EO std::ostream_iterator(out, " ")); // Values. } + //! Convenience function to only render the fitess and the selected atoms (and not the rejected ones). std::string str() const { std::ostringstream msg; From d64f2b38ed1294709e26fcfae89e44dcb7dc0df0 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 6 Feb 2023 23:12:36 +0100 Subject: [PATCH 47/69] refactor: put cache in lib + clean doc --- mo/src/problems/partition/moBinaryPartition.h | 32 +++++++++++-------- .../partition/moBinaryPartitionSwapNeighbor.h | 21 ++++++------ .../moBinaryPartitionSwapNeighborhood.h | 1 + 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 36d1136fa..253c838c6 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -180,25 +180,29 @@ class moBinaryPartition : public EO and this->rejected == other.rejected; } + //! Class name for state management. virtual std::string className() const override { return "moBinaryPartition"; } - virtual void fitness(const FitT& fit) override - { - // std::clog << "Fitness assignment -- solution: " << *this << " gets fitness: " << fit << std::endl; - EO::fitness(fit); - } + // //! Accessor to set fitness. + // virtual void fitness(const FitT& fit) override + // { + // // std::clog << "Fitness assignment -- solution: " << *this << " gets fitness: " << fit << std::endl; + // EO::fitness(fit); + // } - virtual const FitT& fitness() const override - { - return EO::fitness(); - } + // //! Accessor to get fitness. + // virtual const FitT& fitness() const override + // { + // return EO::fitness(); + // } - virtual void invalidate() override - { - // this->fitness().clear(); - EO::invalidate(); - } + // //! Accessor to invalidate fitness. + // virtual void invalidate() override + // { + // // this->fitness().clear(); + // EO::invalidate(); + // } }; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index 2fe5d3a55..915831122 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -159,6 +159,7 @@ class moBinaryPartitionSwapNeighbor : public: + //! Class name for state management. virtual std::string className() const override { return "moBinaryPartitionSwapNeighbor"; } @@ -173,26 +174,28 @@ class moBinaryPartitionSwapNeighbor : << " +" << select; } + //! Accessor to set the size. void size(size_t _selected_nb) { assert(_selected_nb > 0); this->selected_nb = _selected_nb; this->invalidate(); } + //! Accessor to get the size. size_t size() const { return this->selected_nb; } - virtual void fitness(const Fitness& fit) override - { - // std::clog << "Fitness assignment -- neighbor: " << *this << " gets fitness: " << fit << std::endl; - EO::fitness(fit); - } + // virtual void fitness(const Fitness& fit) override + // { + // // std::clog << "Fitness assignment -- neighbor: " << *this << " gets fitness: " << fit << std::endl; + // EO::fitness(fit); + // } - virtual const Fitness& fitness() const override - { - return EO::fitness(); - } + // virtual const Fitness& fitness() const override + // { + // return EO::fitness(); + // } #ifndef NDEBUG public: diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index ca40fa551..be677d0e2 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -134,6 +134,7 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood 0; } + //! Class name for state management. virtual std::string className() const override { return "moBinaryPartitionSwapNeighborhood"; } From a376921f075d88861a1b19d59fa23bbff57d5cf8 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 28 Mar 2023 18:58:51 +0200 Subject: [PATCH 48/69] add save-sol to output all solutions to a file --- mo/src/problems/partition/moBinaryPartition.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 253c838c6..3b3f478e9 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -143,10 +143,12 @@ class moBinaryPartition : public EO virtual void printOn(std::ostream& out) const override { this->printSelectedOn(out); - out << " "; - out << rejected.size() << " "; // Size. - std::copy(std::begin(rejected), std::end(rejected), - std::ostream_iterator(out, " ")); // Values. + // Printing the rejected atom should not be necessary, + // as this is the complementary set of the selected. + // out << " "; + // out << rejected.size() << " "; // Size. + // std::copy(std::begin(rejected), std::end(rejected), + // std::ostream_iterator(out, " ")); // Values. } /** Deserialization of the `selected` and `rejected` atoms. From b96b537ed137c4c6b291c3e71ea0c064d6e00ed3 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 10 Sep 2024 16:47:28 +0200 Subject: [PATCH 49/69] fix(nbhood): make accessors const --- mo/src/problems/partition/moBinaryPartition.h | 4 ++-- mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index 3b3f478e9..df5fed9fa 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -62,7 +62,7 @@ class moBinaryPartition : public EO * You are responsible for making it consistent after instantiation. * * @warning If you do not fill at least the @ref rejected set, - * errors will be raised whe trying to @ref select or @ref reject. + * errors will be raised when trying to @ref select or @ref reject. */ moBinaryPartition() { } @@ -127,7 +127,7 @@ class moBinaryPartition : public EO std::ostream_iterator(out, " ")); // Values. } - //! Convenience function to only render the fitess and the selected atoms (and not the rejected ones). + //! Convenience function to only render the fitness and the selected atoms (and not the rejected ones). std::string str() const { std::ostringstream msg; diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index be677d0e2..f91b252da 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -31,7 +31,7 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood Date: Mon, 12 Sep 2022 15:20:05 +0200 Subject: [PATCH 50/69] feat: prepare the use of binary partitions for signatures --- mo/test/t-moBinaryPartition.cpp | 90 +++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 mo/test/t-moBinaryPartition.cpp diff --git a/mo/test/t-moBinaryPartition.cpp b/mo/test/t-moBinaryPartition.cpp new file mode 100644 index 000000000..873d245bb --- /dev/null +++ b/mo/test/t-moBinaryPartition.cpp @@ -0,0 +1,90 @@ + +#include +#include +#include + +int main() +{ + using Signature = moBinaryPartition; + const size_t genes_nb = 4; + + /********************************************** + * Test if neighborhood has all neighbors. + **********************************************/ + Signature geneset(genes_nb); + std::clog << "Available genes:"; + for(size_t g : geneset.rejected) { + std::clog << " " << g; + } + std::clog << std::endl; + + const size_t n = 2; + for(size_t i=0; i < n; ++i) { + geneset.select(i); + } + + std::clog << "Init geneset: " << geneset << std::endl; + std::clog << std::endl; + + moBinaryPartitionSwapNeighborhood neighborhood; + + // Save generated solutions for testing. + std::vector solutions; + + // Follows the framework's workflow (see moRandomBestHCexplorer): + // 1) if hasNeighbor() + // 2) neighborhood.init(…) + // 3) [eval] + // 4) while neighborhood.cont(…) + // 5) neighborhood.next(…) + // 6) [eval] + // … loop. + if(neighborhood.hasNeighbor(geneset)) { + + moBinaryPartitionSwapNeighbor neighbor(n); + neighborhood.init(geneset, neighbor); + std::clog << "Init neighbor: " << neighbor << std::endl; + + // Print what it looks like. + std::clog << "Current geneset: " << geneset << std::endl; + Signature new_geneset = geneset; + neighbor.move(new_geneset); + std::clog << "Moved to solution: " << new_geneset << std::endl; + solutions.push_back(new_geneset); + std::clog << std::endl; + + while(neighborhood.cont(geneset)) { + // Generate next neighbor. + neighborhood.next(geneset, neighbor); + std::clog << "New neighbor: " << neighbor << std::endl; + + // Print what it looks like. + std::clog << "Current geneset: " << geneset << std::endl; + Signature new_geneset = geneset; + neighbor.move(new_geneset); + std::clog << "Moved to solution: " << new_geneset << std::endl; + solutions.push_back(new_geneset); + + // Double check that one can moveBack and get the same solution. + neighbor.moveBack(new_geneset); + assert(new_geneset == geneset); + std::clog << std::endl; + } + } + + std::clog << "Generated " << solutions.size() << " neighbors of: " << geneset << std::endl; + for(Signature s : solutions) { + std::clog << "\t" << s << std::endl; + } + assert(solutions.size() == 4); + + /********************************************** + * Test if a full solution does not have neighbor. + **********************************************/ + Signature full(genes_nb); + for(size_t i=0; i < genes_nb; ++i) { + full.select(i); + } + assert(not neighborhood.hasNeighbor(full)); + +} From cf086ea9b9ed235b9703cb870bc7dad2fa38d1fe Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Sep 2024 20:26:36 +0200 Subject: [PATCH 51/69] fix(moBinaryPartition): finalize integration in --- mo/src/mo.h | 5 ++++- mo/src/problems/partition/moBinaryPartition.h | 12 ++++++++++-- .../partition/moBinaryPartitionSwapNeighbor.h | 1 - .../partition/moBinaryPartitionSwapNeighborhood.h | 9 +++++++-- mo/test/CMakeLists.txt | 1 + mo/test/t-moBinaryPartition.cpp | 4 +--- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mo/src/mo.h b/mo/src/mo.h index 3f44d2df7..f936b646d 100755 --- a/mo/src/mo.h +++ b/mo/src/mo.h @@ -184,6 +184,10 @@ #include #include +#include +#include +#include + //#include //#include //#include @@ -193,7 +197,6 @@ //#include //#include - #include #include #include diff --git a/mo/src/problems/partition/moBinaryPartition.h b/mo/src/problems/partition/moBinaryPartition.h index df5fed9fa..7feaef0b3 100644 --- a/mo/src/problems/partition/moBinaryPartition.h +++ b/mo/src/problems/partition/moBinaryPartition.h @@ -75,7 +75,11 @@ class moBinaryPartition : public EO * @note In debug mode, double check that elements were actually moved. */ void select(const size_t atom) { - assert(not selected.contains(atom)); + #if __cplusplus >= 202002L + assert(not selected.contains(atom)); + #else + assert(selected.count(atom) == 0); + #endif #ifndef NDEBUG size_t has_erased = @@ -98,7 +102,11 @@ class moBinaryPartition : public EO * @note In debug mode, double check that elements were actually moved. */ void reject(const size_t atom) { - assert(not rejected.contains(atom)); + #if __cplusplus >= 202002L + assert(not rejected.contains(atom)); + #else + assert(rejected.count(atom) == 0); + #endif #ifndef NDEBUG size_t has_erased = diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h index 915831122..8f6bc601c 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h @@ -3,7 +3,6 @@ #include #include - #include "moBinaryPartition.h" /** Stable neighbor for a binary partition. diff --git a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h index f91b252da..d51325b26 100644 --- a/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h +++ b/mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h @@ -87,8 +87,13 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood= 202002L + assert( from.rejected.contains(selected(from,i_select)) ); + assert( from.selected.contains(rejected(from,j_reject)) ); + #else + assert( from.rejected.count(selected(from,i_select)) > 0 ); + assert( from.selected.count(rejected(from,j_reject)) > 0 ); + #endif assert( selected(from,i_select) != rejected(from,j_reject) ); // Implant this move in the neighbor. diff --git a/mo/test/CMakeLists.txt b/mo/test/CMakeLists.txt index a27f97db9..184cdb651 100644 --- a/mo/test/CMakeLists.txt +++ b/mo/test/CMakeLists.txt @@ -96,6 +96,7 @@ set (TEST_LIST t-moIndexedVectorTabuList # t-moRndIndexedVectorTabuList t-moDynSpanCoolingSchedule + t-moBinaryPartition ) ###################################################################################### diff --git a/mo/test/t-moBinaryPartition.cpp b/mo/test/t-moBinaryPartition.cpp index 873d245bb..3300c83bf 100644 --- a/mo/test/t-moBinaryPartition.cpp +++ b/mo/test/t-moBinaryPartition.cpp @@ -1,7 +1,5 @@ -#include -#include -#include +#include int main() { From db24e611b776c3c21fea23475039da1779d7e738 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 11 Sep 2024 11:03:38 +0200 Subject: [PATCH 52/69] refactor(tests): reduce runtime for foundry tests --- eo/test/t-eoAlgoFoundryFastGA.cpp | 18 +++++++++--------- eo/test/t-forge-FastGA.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eo/test/t-eoAlgoFoundryFastGA.cpp b/eo/test/t-eoAlgoFoundryFastGA.cpp index fa97ca1b8..4513cdf6f 100644 --- a/eo/test/t-eoAlgoFoundryFastGA.cpp +++ b/eo/test/t-eoAlgoFoundryFastGA.cpp @@ -25,7 +25,7 @@ int main(int /*argc*/, char** /*argv*/) /***** Crossovers ****/ foundry.crossovers.add< eo1PtBitXover >(); - foundry.crossovers.add< eoUBitXover >(0.5); // preference over 1 + // foundry.crossovers.add< eoUBitXover >(0.5); // preference over 1 for(size_t i=1; i < 11; i+=4) { foundry.crossovers.add< eoNPtsBitXover >(i); // nb of points } @@ -43,9 +43,9 @@ int main(int /*argc*/, char** /*argv*/) std::ref(foundry.mutation_selectors) }) { ops.add< eoRandomSelect >(); - ops.add< eoStochTournamentSelect >(0.5); - ops.add< eoSequentialSelect >(); - ops.add< eoProportionalSelect >(); + // ops.add< eoStochTournamentSelect >(0.5); + // ops.add< eoSequentialSelect >(); + // ops.add< eoProportionalSelect >(); for(size_t i=2; i < 10; i+=4) { ops.add< eoDetTournamentSelect >(i); } @@ -53,16 +53,16 @@ int main(int /*argc*/, char** /*argv*/) /***** Replacements ****/ foundry.replacements.add< eoCommaReplacement >(); - foundry.replacements.add< eoPlusReplacement >(); - foundry.replacements.add< eoSSGAWorseReplacement >(); - foundry.replacements.add< eoSSGAStochTournamentReplacement >(0.51); + // foundry.replacements.add< eoPlusReplacement >(); + // foundry.replacements.add< eoSSGAWorseReplacement >(); + // foundry.replacements.add< eoSSGAStochTournamentReplacement >(0.51); for(size_t i=2; i < 10; i+=4) { foundry.replacements.add< eoSSGADetTournamentReplacement >(i); } /***** Continuators ****/ - for(size_t i=10; i < 30; i+=10 ) { - foundry.continuators.add< eoSteadyFitContinue >(10,i); + for(size_t i=3; i < 5; i+=1 ) { + foundry.continuators.add< eoGenContinue >(i); } diff --git a/eo/test/t-forge-FastGA.cpp b/eo/test/t-forge-FastGA.cpp index e4f713cff..52af1129f 100644 --- a/eo/test/t-forge-FastGA.cpp +++ b/eo/test/t-forge-FastGA.cpp @@ -19,7 +19,7 @@ int main(int /*argc*/, char** /*argv*/) eoBooleanGenerator gen(0.5); eoInitFixedLength init(dim, gen); - eoGenContinue common_cont(100); + eoGenContinue common_cont(5); eoForgeVector< eoContinue > continuators; continuators.add< eoSteadyFitContinue >(10,10); From 846006c613478e00550ef192fd76dc549c41fac1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Sat, 21 Sep 2024 10:22:47 +0200 Subject: [PATCH 53/69] feat(moSA): adds a constructor without cool but with cont --- mo/src/algo/moSA.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mo/src/algo/moSA.h b/mo/src/algo/moSA.h index c126f31fc..5748f020a 100644 --- a/mo/src/algo/moSA.h +++ b/mo/src/algo/moSA.h @@ -79,6 +79,20 @@ public: explorer(_neighborhood, _eval, defaultSolNeighborComp, _cool) {} + /** + * Constructor without cooling schedule, but with a continuator. + * + * @param _neighborhood the neighborhood + * @param _fullEval the full evaluation function + * @param _eval neighbor's evaluation function + * @param _cont an external continuator + */ + moSA(Neighborhood& _neighborhood, eoEvalFunc& _fullEval, moEval& _eval, moContinuator& _cont): + moLocalSearch(explorer, _cont, _fullEval), + defaultCool(0, 0, 0, 0), + explorer(_neighborhood, _eval, defaultSolNeighborComp, defaultCool) + {} + /** * General constructor for a simulated annealing * @param _neighborhood the neighborhood From 19ec4c4ff760b5470163f0e940d1148449b6f3ad Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 26 Sep 2024 13:24:10 +0200 Subject: [PATCH 54/69] feat(eo): wrap ops on float vecs into ops on int vecs Adds wrapper classes to make any MonOp or QuadOp that operates on eoReal embbedable in any operator needing an eoInt. --- eo/src/eo | 4 ++ eo/src/eoInt.h | 5 +- eo/src/eoRealToIntMonOp.h | 73 +++++++++++++++++++++++++ eo/src/eoRealToIntQuadOp.h | 94 +++++++++++++++++++++++++++++++++ eo/src/es/eoReal.h | 1 + eo/test/CMakeLists.txt | 2 + eo/test/t-eoRealToIntMonOp.cpp | 28 ++++++++++ eo/test/t-eoRealToIntQuadOp.cpp | 35 ++++++++++++ 8 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 eo/src/eoRealToIntMonOp.h create mode 100644 eo/src/eoRealToIntQuadOp.h create mode 100644 eo/test/t-eoRealToIntMonOp.cpp create mode 100644 eo/test/t-eoRealToIntQuadOp.cpp diff --git a/eo/src/eo b/eo/src/eo index 55c070857..77a65e249 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -224,6 +224,10 @@ #include "utils/eoLogger.h" #include "utils/eoParallel.h" +#include "eoInt.h" +#include "eoRealToIntMonOp.h" +#include "eoRealToIntQuadOp.h" + #endif // Local Variables: diff --git a/eo/src/eoInt.h b/eo/src/eoInt.h index 0f0feb3e1..efeba4a62 100644 --- a/eo/src/eoInt.h +++ b/eo/src/eoInt.h @@ -36,9 +36,12 @@ * * @ingroup Representations */ -template class eoInt: public eoVector +template +class eoInt: public eoVector { public: + using AtomType = size_t; + using FitnessType = FitT; /** * (Default) Constructor. diff --git a/eo/src/eoRealToIntMonOp.h b/eo/src/eoRealToIntMonOp.h new file mode 100644 index 000000000..47207a185 --- /dev/null +++ b/eo/src/eoRealToIntMonOp.h @@ -0,0 +1,73 @@ +#ifndef eoRealToIntMonOp_h_INCLUDED +#define eoRealToIntMonOp_h_INCLUDED + +#include "es/eoReal.h" +#include "utils/eoIntBounds.h" + +template> +class eoRealToIntMonOp : public eoMonOp +{ +public: + + using EOTreal = EOTREAL; + + enum Repair { + folds, + truncate + }; + + eoRealToIntMonOp( eoMonOp& monop ) : + _whenout(Repair::truncate), + _nobounds(), + _bounds(_nobounds), + _monop(monop) + { } + + eoRealToIntMonOp( eoMonOp& monop, eoIntBounds& bounds, Repair whenout = Repair::truncate ) : + _whenout(whenout), + _nobounds(), + _bounds(bounds), + _monop(monop) + { } + + bool operator()(EOTINT& intsol) + { + #ifndef NDEBUG + for(size_t i=0; i < intsol.size(); ++i) { + assert(_bounds.isInBounds(intsol[i])); + } + #endif + + EOTreal floatsol; + std::copy( std::begin(intsol), std::end(intsol), std::back_inserter(floatsol) ); + + bool changed = _monop(floatsol); + + if(changed) { + for(size_t i=0; i < floatsol.size(); ++i) { + typename EOTreal::AtomType rounded = std::round(floatsol[i]); + if( not _bounds.isInBounds(rounded) ) { + switch(_whenout) { + case Repair::truncate: + _bounds.truncate(rounded); + break; + case Repair::folds: + _bounds.foldsInBounds(rounded); + break; + } + } + intsol[i] = static_cast(rounded); + } + } + return changed; + } + +protected: + Repair _whenout; + eoIntNoBounds _nobounds; + + eoIntBounds& _bounds; + eoMonOp& _monop; +}; + +#endif // eoRealToIntMonOp_h_INCLUDED diff --git a/eo/src/eoRealToIntQuadOp.h b/eo/src/eoRealToIntQuadOp.h new file mode 100644 index 000000000..7a5e02044 --- /dev/null +++ b/eo/src/eoRealToIntQuadOp.h @@ -0,0 +1,94 @@ +#ifndef eoRealToIntQuadOp_h_INCLUDED +#define eoRealToIntQuadOp_h_INCLUDED + +#include "es/eoReal.h" +#include "utils/eoIntBounds.h" + +template> +class eoRealToIntQuadOp : public eoQuadOp +{ +public: + + using EOTreal = EOTREAL; + + enum Repair { + folds, + truncate + }; + + eoRealToIntQuadOp( eoQuadOp& quadop ) : + _whenout(Repair::truncate), + _nobounds(), + _bounds(_nobounds), + _quadop(quadop) + { } + + eoRealToIntQuadOp( eoQuadOp& quadop, eoIntBounds& bounds, Repair whenout = Repair::truncate ) : + _whenout(whenout), + _nobounds(), + _bounds(bounds), + _quadop(quadop) + { } + + bool operator()(EOTINT& intsol1, EOTINT& intsol2) + { + #ifndef NDEBUG + for(size_t i=0; i < intsol1.size(); ++i) { + assert(_bounds.isInBounds(intsol1[i])); + } + for(size_t i=0; i < intsol2.size(); ++i) { + assert(_bounds.isInBounds(intsol2[i])); + } + #endif + + EOTreal floatsol1; + std::copy( std::begin(intsol1), std::end(intsol1), std::back_inserter(floatsol1) ); + + EOTreal floatsol2; + std::copy( std::begin(intsol2), std::end(intsol2), std::back_inserter(floatsol2) ); + + bool changed = _quadop(floatsol1, floatsol2); + + if(changed) { + for(size_t i=0; i < floatsol1.size(); ++i) { + typename EOTreal::AtomType rounded = std::round(floatsol1[i]); + if( not _bounds.isInBounds(rounded) ) { + switch(_whenout) { + case Repair::truncate: + _bounds.truncate(rounded); + break; + case Repair::folds: + _bounds.foldsInBounds(rounded); + break; + } + } + intsol1[i] = static_cast(rounded); + } + for(size_t i=0; i < floatsol2.size(); ++i) { + typename EOTreal::AtomType rounded = std::round(floatsol2[i]); + if( not _bounds.isInBounds(rounded) ) { + switch(_whenout) { + case Repair::truncate: + _bounds.truncate(rounded); + break; + case Repair::folds: + _bounds.foldsInBounds(rounded); + break; + } + } + intsol2[i] = static_cast(rounded); + } + } + return changed; + } + +protected: + Repair _whenout; + eoIntNoBounds _nobounds; + + eoIntBounds& _bounds; + eoQuadOp& _quadop; +}; + + +#endif // eoRealToIntQuadOp_h_INCLUDED diff --git a/eo/src/es/eoReal.h b/eo/src/es/eoReal.h index 440234f60..a611df3b6 100644 --- a/eo/src/es/eoReal.h +++ b/eo/src/es/eoReal.h @@ -39,6 +39,7 @@ template class eoReal: public eoVector { public: + using AtomType = double; using FitnessType = FitT; /** diff --git a/eo/test/CMakeLists.txt b/eo/test/CMakeLists.txt index b6b9afee6..8f8000890 100644 --- a/eo/test/CMakeLists.txt +++ b/eo/test/CMakeLists.txt @@ -80,6 +80,8 @@ set (TEST_LIST t-forge-FastGA t-eoFoundryFastGA t-eoAlgoFoundryFastGA + t-eoRealToIntMonOp + t-eoRealToIntQuadOp ) diff --git a/eo/test/t-eoRealToIntMonOp.cpp b/eo/test/t-eoRealToIntMonOp.cpp new file mode 100644 index 000000000..0aee0481a --- /dev/null +++ b/eo/test/t-eoRealToIntMonOp.cpp @@ -0,0 +1,28 @@ +#include + +#include +#include + +using namespace std; + +int main(int, char**) +{ + eoIntInterval bounds(1,5); + + using Chrom = eoInt; + using MutWrapper = eoRealToIntMonOp; + + eoDetUniformMutation< typename MutWrapper::EOTreal > mutreal(/*range*/6, /*nb*/5); + + MutWrapper mutint(mutreal, bounds); + + Chrom sol({1,2,3,4,5}); + + bool changed = mutint(sol); + assert(changed); + + for(auto& x : sol) { + assert(bounds.isInBounds(x)); + } +} + diff --git a/eo/test/t-eoRealToIntQuadOp.cpp b/eo/test/t-eoRealToIntQuadOp.cpp new file mode 100644 index 000000000..0ddfe7846 --- /dev/null +++ b/eo/test/t-eoRealToIntQuadOp.cpp @@ -0,0 +1,35 @@ +#include + +#include +#include + +using namespace std; + +int main(int, char**) +{ + eoIntInterval intbounds(1,5); + eoRealInterval rb(1,5); + eoRealVectorBounds realbounds(5, rb); + + using Chrom = eoInt; + using CrossWrapper = eoRealToIntQuadOp; + + eoSegmentCrossover< typename CrossWrapper::EOTreal > crossreal(realbounds, /*alpha*/0); + + CrossWrapper crossint(crossreal, intbounds); + + Chrom sol1({1,2,3,4,5}); + Chrom sol2({1,2,3,4,5}); + + bool changed = crossint(sol1, sol2); + assert(changed); + + for(auto& x : sol1) { + assert(intbounds.isInBounds(x)); + } + for(auto& x : sol2) { + assert(intbounds.isInBounds(x)); + } +} + + From 8ea6e2b680d00f82655584fcc199f90803f00fa2 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 27 Sep 2024 12:20:10 +0200 Subject: [PATCH 55/69] feat(eo): adds eoRealToIntInit --- eo/src/eo | 1 + eo/src/eoRealToIntInit.h | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 eo/src/eoRealToIntInit.h diff --git a/eo/src/eo b/eo/src/eo index 77a65e249..0f6f133d3 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -227,6 +227,7 @@ #include "eoInt.h" #include "eoRealToIntMonOp.h" #include "eoRealToIntQuadOp.h" +#include "eoRealToIntInit.h" #endif diff --git a/eo/src/eoRealToIntInit.h b/eo/src/eoRealToIntInit.h new file mode 100644 index 000000000..4b79ca641 --- /dev/null +++ b/eo/src/eoRealToIntInit.h @@ -0,0 +1,74 @@ +#ifndef eoRealToIntInit_h_INCLUDED +#define eoRealToIntInit_h_INCLUDED + +#include "es/eoReal.h" +#include "utils/eoIntBounds.h" + +template> +class eoRealToIntInit : public eoInit +{ +public: + + using EOTreal = EOTREAL; + + enum Repair { + folds, + truncate + }; + + eoRealToIntInit( eoInit& init ) : + _whenout(Repair::truncate), + _nobounds(), + _bounds(_nobounds), + _init(init) + { } + + eoRealToIntInit( eoInit& init, eoIntBounds& bounds, Repair whenout = Repair::truncate ) : + _whenout(whenout), + _nobounds(), + _bounds(bounds), + _init(init) + { } + + virtual void operator()(EOTINT& intsol) override + { + #ifndef NDEBUG + for(size_t i=0; i < intsol.size(); ++i) { + assert(_bounds.isInBounds(intsol[i])); + } + #endif + + EOTreal floatsol; + std::copy( std::begin(intsol), std::end(intsol), std::back_inserter(floatsol) ); + + _init(floatsol); + + intsol.resize(floatsol.size()); + + for(size_t i=0; i < floatsol.size(); ++i) { + typename EOTreal::AtomType rounded = std::round(floatsol[i]); + if( not _bounds.isInBounds(rounded) ) { + switch(_whenout) { + case Repair::truncate: + _bounds.truncate(rounded); + break; + case Repair::folds: + _bounds.foldsInBounds(rounded); + break; + } + } + intsol[i] = static_cast(rounded); + } + } + +protected: + Repair _whenout; + eoIntNoBounds _nobounds; + + eoIntBounds& _bounds; + eoInit& _init; +}; + + + +#endif // eoRealToIntInit_h_INCLUDED From 190a30495e2d9af10a6b4a4f70bc51c68847ad1a Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 30 Sep 2024 20:42:20 +0200 Subject: [PATCH 56/69] fix(EO): allow readFrom to work on std::cin + invalidTag - std::cin does not allow seekg/tellg, so instead one wrap the read string in a istringstream, and then read from it. This allows to read from any istream, with or without seekg. - Adds an EO::invalidTag member, in case someone would need to use it (for instance as a regexp to sanitize inputs). --- eo/src/EO.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index a2c3b490a..09bb2d20d 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -64,6 +64,8 @@ template class EO: public eoObject, public eoPersistent public: typedef F Fitness; + static constexpr const char* invalidTag = "INVALID"; + /** Default constructor. */ EO(): repFitness(Fitness()), invalidFitness(true) { } @@ -124,25 +126,21 @@ public: * The read and print methods should be compatible and have the same format. * In principle, format is "plain": they just print a number * @param _is a std::istream. - * @throw eoInvalidFitnessError If a valid object can't be read. */ - virtual void readFrom(std::istream& _is) { - - // the new version of the reafFrom function. - // It can distinguish between valid and invalid fitness values. + virtual void readFrom(std::istream& _is) + { std::string fitness_str; - int pos = _is.tellg(); _is >> fitness_str; - if (fitness_str == "INVALID") + if (fitness_str == invalidTag) { invalidFitness = true; } else { invalidFitness = false; - _is.seekg(pos); // rewind - _is >> repFitness; + std::istringstream iss(fitness_str); + iss >> repFitness; } } @@ -150,12 +148,11 @@ public: * Write object. Called printOn since it prints the object _on_ a stream. * @param _os A std::ostream. */ - virtual void printOn(std::ostream& _os) const { - - - // the latest version of the code. Very similar to the old code - if (invalid()) { - _os << "INVALID "; + virtual void printOn(std::ostream& _os) const + { + if (invalid()) + { + _os << invalidTag << ' '; } else { From d3a2ab5e843c22c864c6ed25119ca057c300240e Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 3 Oct 2024 10:08:00 +0200 Subject: [PATCH 57/69] fix(EDO): constructor declarations without templates --- edo/src/edoEstimatorAdaptive.h | 2 +- edo/src/edoEstimatorAdaptiveReset.h | 4 ++-- edo/src/edoEstimatorCombined.h | 8 ++++---- edo/src/edoRepairerModulo.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/edo/src/edoEstimatorAdaptive.h b/edo/src/edoEstimatorAdaptive.h index dfd9eb53a..01bb9c83c 100644 --- a/edo/src/edoEstimatorAdaptive.h +++ b/edo/src/edoEstimatorAdaptive.h @@ -45,7 +45,7 @@ class edoEstimatorAdaptive : public edoEstimator public: typedef typename D::EOType EOType; - edoEstimatorAdaptive( D& distrib ) : _distrib(distrib) {} + edoEstimatorAdaptive( D& distrib ) : _distrib(distrib) {} // virtual D operator() ( eoPop< EOT >& )=0 (provided by eoUF< A1, R >) diff --git a/edo/src/edoEstimatorAdaptiveReset.h b/edo/src/edoEstimatorAdaptiveReset.h index c7dfd4939..b3d518dca 100644 --- a/edo/src/edoEstimatorAdaptiveReset.h +++ b/edo/src/edoEstimatorAdaptiveReset.h @@ -41,12 +41,12 @@ class edoEstimatorAdaptiveReset : public edoEstimatorAdaptive public: typedef typename D::EOType EOType; - edoEstimatorAdaptiveReset( D& distrib ) : + edoEstimatorAdaptiveReset( D& distrib ) : edoEstimatorAdaptive(distrib), _dim(0) { } - edoEstimatorAdaptiveReset( D& distrib, size_t dim ) : + edoEstimatorAdaptiveReset( D& distrib, size_t dim ) : edoEstimatorAdaptive(distrib), _dim(dim) { } diff --git a/edo/src/edoEstimatorCombined.h b/edo/src/edoEstimatorCombined.h index f884f38f1..3c546bd6a 100644 --- a/edo/src/edoEstimatorCombined.h +++ b/edo/src/edoEstimatorCombined.h @@ -43,12 +43,12 @@ class edoEstimatorCombinedAdaptive : public edoEstimatorAdaptive, public std: public: typedef typename D::EOType EOType; - edoEstimatorCombinedAdaptive( D& distrib, edoEstimator& estim) : + edoEstimatorCombinedAdaptive( D& distrib, edoEstimator& estim) : edoEstimatorAdaptive(distrib), std::vector*>(1,&estim) {} - edoEstimatorCombinedAdaptive( D& distrib, std::vector*> estims) : + edoEstimatorCombinedAdaptive( D& distrib, std::vector*> estims) : edoEstimatorAdaptive(distrib), std::vector*>(estims) {} @@ -78,11 +78,11 @@ class edoEstimatorCombinedStateless : public edoEstimatorCombinedAdaptive public: typedef typename D::EOType EOType; - edoEstimatorCombinedStateless( edoEstimator& estim ) : + edoEstimatorCombinedStateless( edoEstimator& estim ) : edoEstimatorCombinedAdaptive(*(new D), estim) {} - edoEstimatorCombinedStateless( std::vector*> estims) : + edoEstimatorCombinedStateless( std::vector*> estims) : edoEstimatorCombinedAdaptive(*(new D), estims) {} diff --git a/edo/src/edoRepairerModulo.h b/edo/src/edoRepairerModulo.h index 1bc7e7682..54b823de7 100644 --- a/edo/src/edoRepairerModulo.h +++ b/edo/src/edoRepairerModulo.h @@ -39,7 +39,7 @@ template < typename EOT > class edoRepairerModulo: public edoRepairerApplyBinary { public: - edoRepairerModulo( double denominator ) : edoRepairerApplyBinary( std::fmod, denominator ) {} + edoRepairerModulo( double denominator ) : edoRepairerApplyBinary( std::fmod, denominator ) {} }; From 77148b5a972fb76cfc66a4ed3cbbc72ce1440d9e Mon Sep 17 00:00:00 2001 From: Alessandro Sidero <75628365+Alessandro624@users.noreply.github.com> Date: Mon, 24 Feb 2025 19:07:10 +0100 Subject: [PATCH 58/69] fix(MPI): resolved cyclic inclusion and MPI issue --- eo/src/mpi/implMpi.h | 474 +++++++++++++++++++++---------------------- 1 file changed, 236 insertions(+), 238 deletions(-) diff --git a/eo/src/mpi/implMpi.h b/eo/src/mpi/implMpi.h index d52b84b26..0efb89a75 100644 --- a/eo/src/mpi/implMpi.h +++ b/eo/src/mpi/implMpi.h @@ -22,7 +22,7 @@ Authors: #ifndef __EO_IMPL_MPI_HPP__ #define __EO_IMPL_MPI_HPP__ -#include "eoMpi.h" +#include #include "../serial/eoSerial.h" /** @@ -43,290 +43,288 @@ Authors: */ namespace eo { -namespace mpi -{ - /** - * @ingroup Parallel - * @{ - */ - - /** - * @brief Constant indicating that a message can come from any process. - */ - extern const int any_source; - - /** - * @brief Constant indicating that a message can come from any tag (channel). - */ - extern const int any_tag; - - /** - * @brief Wrapper class to have a MPI environment. - * - * Instead of calling MPI_Init and MPI_Finalize, it is only necessary to instantiate - * this class once, in the global context. - */ - class environment + namespace mpi { - public: + /** + * @ingroup Parallel + * @{ + */ /** - * @brief Inits MPI context. + * @brief Constant indicating that a message can come from any process. + */ + extern const int any_source; + + /** + * @brief Constant indicating that a message can come from any tag (channel). + */ + extern const int any_tag; + + /** + * @brief Wrapper class to have a MPI environment. * - * @param argc Number of params in command line (same as one in main) - * @param argv Strings containing params (same as one in main) + * Instead of calling MPI_Init and MPI_Finalize, it is only necessary to instantiate + * this class once, in the global context. */ - environment(int argc, char**argv); - - /** - * @brief Closes MPI context. - */ - ~environment(); - }; - - struct MPI_Status { - int count; - int cancelled; - int MPI_SOURCE; - int MPI_TAG; - int MPI_ERROR; - }; - - /** - * @brief Wrapper class for MPI_Status - * - * Consists only in a C++ wrapper class, giving getters on status attributes. - */ - class status - { + class environment + { public: + /** + * @brief Inits MPI context. + * + * @param argc Number of params in command line (same as one in main) + * @param argv Strings containing params (same as one in main) + */ + environment(int argc, char **argv); + + /** + * @brief Closes MPI context. + */ + ~environment(); + }; + + /* struct MPI_Status + { + int count; + int cancelled; + int MPI_SOURCE; + int MPI_TAG; + int MPI_ERROR; + }; */ /** - * @brief Converts a MPI_Status into a status. + * @brief Wrapper class for MPI_Status + * + * Consists only in a C++ wrapper class, giving getters on status attributes. */ - status( const MPI_Status & s ); + class status + { + public: + /** + * @brief Converts a MPI_Status into a status. + */ + status(const MPI_Status &s); - /** - * @brief Returns the tag of the associated communication. - */ - int tag() { return _tag; } + /** + * @brief Returns the tag of the associated communication. + */ + int tag() { return _tag; } - /** - * @brief Indicates which error number we obtained in the associated communication. - */ - int error() { return _error; } + /** + * @brief Indicates which error number we obtained in the associated communication. + */ + int error() { return _error; } - /** - * @brief Returns the MPI rank of the source of the associated communication. - */ - int source() { return _source; } + /** + * @brief Returns the MPI rank of the source of the associated communication. + */ + int source() { return _source; } private: int _source; int _tag; int _error; - }; + }; - /** - * @brief Main object, used to send / receive messages, get informations about the rank and the size of the world, - * etc. - */ - class communicator - { + /** + * @brief Main object, used to send / receive messages, get informations about the rank and the size of the world, + * etc. + */ + class communicator + { public: + /** + * Creates the communicator, using the whole world as a MPI_Comm. + * + * @todo Allow the user to precise which MPI_Comm to use + */ + communicator(); - /** - * Creates the communicator, using the whole world as a MPI_Comm. - * - * @todo Allow the user to precise which MPI_Comm to use - */ - communicator( ); + ~communicator(); - ~communicator(); + /** + * @brief Returns the MPI rank of the current process. + */ + int rank(); - /** - * @brief Returns the MPI rank of the current process. - */ - int rank(); + /** + * @brief Returns the size of the MPI cluster. + */ + int size(); - /** - * @brief Returns the size of the MPI cluster. - */ - int size(); + /* + * SEND / RECV INT + */ - /* - * SEND / RECV INT - */ + /** + * @brief Sends an integer to dest on channel "tag". + * + * @param dest MPI rank of the receiver + * @param tag MPI tag of message + * @param n The integer to send + */ + void send(int dest, int tag, int n); - /** - * @brief Sends an integer to dest on channel "tag". - * - * @param dest MPI rank of the receiver - * @param tag MPI tag of message - * @param n The integer to send - */ - void send( int dest, int tag, int n ); + /* + * @brief Receives an integer from src on channel "tag". + * + * @param src MPI rank of the sender + * @param tag MPI tag of message + * @param n Where to save the received integer + */ + void recv(int src, int tag, int &n); - /* - * @brief Receives an integer from src on channel "tag". - * - * @param src MPI rank of the sender - * @param tag MPI tag of message - * @param n Where to save the received integer - */ - void recv( int src, int tag, int& n ); + /* + * SEND / RECV STRING + */ - /* - * SEND / RECV STRING - */ + /** + * @brief Sends a string to dest on channel "tag". + * + * @param dest MPI rank of the receiver + * @param tag MPI tag of message + * @param str The std::string to send + */ + void send(int dest, int tag, const std::string &str); - /** - * @brief Sends a string to dest on channel "tag". - * - * @param dest MPI rank of the receiver - * @param tag MPI tag of message - * @param str The std::string to send - */ - void send( int dest, int tag, const std::string& str ); + /* + * @brief Receives a string from src on channel "tag". + * + * @param src MPI rank of the sender + * @param tag MPI tag of message + * @param std::string Where to save the received string + */ + void recv(int src, int tag, std::string &str); - /* - * @brief Receives a string from src on channel "tag". - * - * @param src MPI rank of the sender - * @param tag MPI tag of message - * @param std::string Where to save the received string - */ - void recv( int src, int tag, std::string& str ); + /* + * SEND / RECV Objects + */ - /* - * SEND / RECV Objects - */ + /** + * @brief Sends an eoserial::Persistent to dest on channel "tag". + * + * @param dest MPI rank of the receiver + * @param tag MPI tag of message + * @param persistent The object to send (it must absolutely implement eoserial::Persistent) + */ + void send(int dest, int tag, const eoserial::Persistent &persistent); - /** - * @brief Sends an eoserial::Persistent to dest on channel "tag". - * - * @param dest MPI rank of the receiver - * @param tag MPI tag of message - * @param persistent The object to send (it must absolutely implement eoserial::Persistent) - */ - void send( int dest, int tag, const eoserial::Persistent & persistent ); - - /** - * @brief Sends an array of eoserial::Persistent to dest on channel "tag". - * - * @param dest MPI rank of the receiver - * @param tag MPI tag of message - * @param table The array of eoserial::Persistent objects - * @param size The number of elements to send (no check is done, the user has to be sure that the size won't - * overflow!) - */ - template< class T > - void send( int dest, int tag, T* table, int size ) - { - // Puts all the values into an array - eoserial::Array* array = new eoserial::Array; - - for( int i = 0; i < size; ++i ) + /** + * @brief Sends an array of eoserial::Persistent to dest on channel "tag". + * + * @param dest MPI rank of the receiver + * @param tag MPI tag of message + * @param table The array of eoserial::Persistent objects + * @param size The number of elements to send (no check is done, the user has to be sure that the size won't + * overflow!) + */ + template + void send(int dest, int tag, T *table, int size) { - array->push_back( table[i].pack() ); + // Puts all the values into an array + eoserial::Array *array = new eoserial::Array; + + for (int i = 0; i < size; ++i) + { + array->push_back(table[i].pack()); + } + + // Encapsulates the array into an object + eoserial::Object *obj = new eoserial::Object; + obj->add("array", array); + std::stringstream ss; + obj->print(ss); + delete obj; + + // Sends the object as a string + send(dest, tag, ss.str()); } - // Encapsulates the array into an object - eoserial::Object* obj = new eoserial::Object; - obj->add( "array", array ); - std::stringstream ss; - obj->print( ss ); - delete obj; + /* + * @brief Receives an eoserial::Persistent object from src on channel "tag". + * + * @param src MPI rank of the sender + * @param tag MPI tag of message + * @param persistent Where to unpack the serialized object? + */ + void recv(int src, int tag, eoserial::Persistent &persistent); - // Sends the object as a string - send( dest, tag, ss.str() ); - } - - /* - * @brief Receives an eoserial::Persistent object from src on channel "tag". - * - * @param src MPI rank of the sender - * @param tag MPI tag of message - * @param persistent Where to unpack the serialized object? - */ - void recv( int src, int tag, eoserial::Persistent & persistent ); - - /* - * @brief Receives an array of eoserial::Persistent from src on channel "tag". - * - * @param src MPI rank of the sender - * @param tag MPI tag of message - * @param table The table in which we're saving the received objects. It must have been allocated by the user, - * as no allocation is performed here. - * @param size The number of elements to receive (no check is done, the user has to be sure that the size won't - * overflow!) - */ - template< class T > - void recv( int src, int tag, T* table, int size ) - { - // Receives the string which contains the object - std::string asText; - recv( src, tag, asText ); - - // Parses the object and retrieves the table - eoserial::Object* obj = eoserial::Parser::parse( asText ); - eoserial::Array* array = static_cast( (*obj)["array"] ); - - // Retrieves all the values from the array - for( int i = 0; i < size; ++i ) + /* + * @brief Receives an array of eoserial::Persistent from src on channel "tag". + * + * @param src MPI rank of the sender + * @param tag MPI tag of message + * @param table The table in which we're saving the received objects. It must have been allocated by the user, + * as no allocation is performed here. + * @param size The number of elements to receive (no check is done, the user has to be sure that the size won't + * overflow!) + */ + template + void recv(int src, int tag, T *table, int size) { - eoserial::unpackObject( *array, i, table[i] ); + // Receives the string which contains the object + std::string asText; + recv(src, tag, asText); + + // Parses the object and retrieves the table + eoserial::Object *obj = eoserial::Parser::parse(asText); + eoserial::Array *array = static_cast((*obj)["array"]); + + // Retrieves all the values from the array + for (int i = 0; i < size; ++i) + { + eoserial::unpackObject(*array, i, table[i]); + } + delete obj; } - delete obj; - } - /* - * Other methods - */ + /* + * Other methods + */ - /** - * @brief Wrapper for MPI_Probe - * - * Waits for a message to come from process having rank src, on the channel - * tag. - * - * @param src MPI rank of the sender (any_source if it can be any sender) - * @param tag MPI tag of the expected message (any_tag if it can be any tag) - */ - status probe( int src = any_source, int tag = any_tag ); + /** + * @brief Wrapper for MPI_Probe + * + * Waits for a message to come from process having rank src, on the channel + * tag. + * + * @param src MPI rank of the sender (any_source if it can be any sender) + * @param tag MPI tag of the expected message (any_tag if it can be any tag) + */ + status probe(int src = any_source, int tag = any_tag); - /** - * @brief Wrapper for MPI_Barrier - * - * - */ - void barrier(); + /** + * @brief Wrapper for MPI_Barrier + * + * + */ + void barrier(); private: int _rank; int _size; - char* _buf; // temporary buffer for sending and receiving strings. Avoids reallocations + char *_buf; // temporary buffer for sending and receiving strings. Avoids reallocations int _bufsize; // size of the above temporary buffer - }; + }; - /** - * @brief Wrapper for MPI_Bcast - * - * Broadcasts an integer value on the communicator comm, from the process having the MPI rank root. - * - * @param comm The communicator on which to broadcast - * @param value The integer value to send - * @param root The MPI rank of the broadcaster - * - * @todo Actually comm isn't used and broadcast is performed on the whole MPI_COMM_WORLD. TODO: Use comm instead - */ - void broadcast( communicator & comm, int value, int root ); + /** + * @brief Wrapper for MPI_Bcast + * + * Broadcasts an integer value on the communicator comm, from the process having the MPI rank root. + * + * @param comm The communicator on which to broadcast + * @param value The integer value to send + * @param root The MPI rank of the broadcaster + * + * @todo Actually comm isn't used and broadcast is performed on the whole MPI_COMM_WORLD. TODO: Use comm instead + */ + void broadcast(communicator &comm, int value, int root); - /** - * @} - */ -} // namespace mpi + /** + * @} + */ + } // namespace mpi } // namespace eo -# endif //__EO_IMPL_MPI_HPP__ +#endif //__EO_IMPL_MPI_HPP__ From 7c88ec4fa7af22bd485c7e446c7d07ff2838475d Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 09:47:58 +0100 Subject: [PATCH 59/69] feat(EO): allow overriding fitness accessors May be useful for debugging, by tracing when fitness assignement occurs. --- eo/src/EO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index 09bb2d20d..9c29dbbce 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -95,7 +95,7 @@ public: /** 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 172798a637ffa66878fb96f34cc2eefc1369fb57 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 10 Feb 2023 11:54:45 +0100 Subject: [PATCH 60/69] revert 399b22266 (virtual fitness interface temptative) Incompatible with MOEO's change of interface. --- eo/src/EO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index 9c29dbbce..09bb2d20d 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -95,7 +95,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; From cfcd6e22bb2081fa9f730c4ee0e07d04b1c8fe55 Mon Sep 17 00:00:00 2001 From: Jxtopher <39927513+Jxtopher@users.noreply.github.com> Date: Fri, 28 Mar 2025 22:30:30 +0100 Subject: [PATCH 61/69] Ccache setup The goal is to speed up recompilation using ccache. Ccache is a tool that speeds up recompilation of C/C++ code. It does this by caching the results of previous compilations. When you recompile code, ccache checks if it has already compiled the same code with the same compiler flags. If so, it uses the cached result instead of recompiling. --- .github/workflows/build_ubuntu_debug.yml | 9 ++++++++- CMakeLists.txt | 11 +++++++++++ README.md | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_ubuntu_debug.yml b/.github/workflows/build_ubuntu_debug.yml index b68744cb2..58aac6a42 100644 --- a/.github/workflows/build_ubuntu_debug.yml +++ b/.github/workflows/build_ubuntu_debug.yml @@ -16,8 +16,15 @@ jobs: compiler: [g++-10, g++-9, g++-8, g++-7, clang-6, clang-7, clang-8, clang-9, clang-10, clang-11, clang-12] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Caching objects + id: cache-objects + uses: actions/cache@v4 + with: + path: ~/.cache/ccache + key: ${{ runner.os }}-${{env.BUILD_TYPE}}-${{ matrix.compiler }}-objects + - name: Install Dependencies shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bec9ae43..1b364f35f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,17 @@ project("ParadisEO" ## Language set(CMAKE_CXX_STANDARD 17) +## ccache +find_program(CCACHE_PROGRAM ccache) + +if (CCACHE_PROGRAM) + message(NOTICE "-- ccache is enabled (found here: ${CCACHE_PROGRAM})") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "\"${CCACHE_PROGRAM}\"") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "\"${CCACHE_PROGRAM}\"") +else () + message(NOTICE "-- ccache has not been found") +endif () + ###################################################################################### ### 2) Check dependencies diff --git a/README.md b/README.md index 686b08334..ff158606d 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ If you `ENABLE_CMAKE_EXAMPLE`, it will also build the examples. If may want to make build scripts more verbose (especially when building the doc) by enabling `CMAKE_VERBOSE_MAKEFILE`. +If `ccache` installed in your environment, library recompilation times can be significantly reduced. To clear all cached objects, execute `ccache -C`. ## Licenses From 22275e434b078bfb5bc480c77f74685aecb4395b Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 7 Apr 2025 14:16:37 +0200 Subject: [PATCH 62/69] fix several warnings Probably fixes a bug in es/CMA, which has been deprecated for a long time in favor of the EDO module anyway. --- eo/src/eoEasyPSO.h | 16 ++++++------- eo/src/eoSyncEasyPSO.h | 30 ++++++++++++------------- eo/src/es/CMAParams.cpp | 3 +++ eo/src/gp/parse_tree.h | 7 ++++++ eo/src/mpi/implMpi.cpp | 2 +- eo/src/utils/pipecom.cpp | 6 ++--- eo/src/utils/pipecom.h | 4 ++-- moeo/src/do/make_checkpoint_moeo.h | 2 +- moeo/src/do/make_ea_moeo.h | 2 +- moeo/src/metric/moeoHyperVolumeMetric.h | 4 ++-- moeo/tutorial/Lesson1/Sch1.cpp | 4 ++-- smp/src/PPExpander.h | 2 +- smp/src/island.cpp | 4 ++++ smp/src/island.h | 3 ++- smp/tutorial/Lesson1/QAPGA.h | 2 ++ 15 files changed, 53 insertions(+), 38 deletions(-) diff --git a/eo/src/eoEasyPSO.h b/eo/src/eoEasyPSO.h index 87c27cad3..25f030595 100644 --- a/eo/src/eoEasyPSO.h +++ b/eo/src/eoEasyPSO.h @@ -174,18 +174,18 @@ protected: // if the flight does not need to be used, use the dummy flight instance class eoDummyFlight:public eoFlight < POT > { - public: - eoDummyFlight () {} - void operator () (POT &) {} - }dummyFlight; + public: + eoDummyFlight () {} + void operator() (POT &) override {} + } dummyFlight; // if the initializer does not need to be used, use the dummy one instead class eoDummyInitializer:public eoInitializerBase < POT > { - public: - eoDummyInitializer () {} - void operator () (POT &) {} - }dummyInit; + public: + eoDummyInitializer () {} + void operator() () override {} + } dummyInit; }; /** diff --git a/eo/src/eoSyncEasyPSO.h b/eo/src/eoSyncEasyPSO.h index 11640af53..183148896 100644 --- a/eo/src/eoSyncEasyPSO.h +++ b/eo/src/eoSyncEasyPSO.h @@ -230,27 +230,25 @@ protected: // if the eval does not need to be used, use the dummy eval instance class eoDummyEval : public eoEvalFunc - { - public: - void operator()(POT &) - {} - } - dummyEval; - - class eoDummyFlight:public eoFlight < POT > { - public: - eoDummyFlight () {} - void operator () (POT &) {} - }dummyFlight; + public: + void operator()(POT &) override {} + } dummyEval; + + class eoDummyFlight:public eoFlight < POT > + { + public: + eoDummyFlight () {} + void operator() (POT &) override {} + } dummyFlight; // if the initializer does not need to be used, use the dummy one instead class eoDummyInitializer:public eoInitializerBase < POT > { - public: - eoDummyInitializer () {} - void operator () (POT &) {} - }dummyInit; + public: + eoDummyInitializer () {} + void operator() () override {} + } dummyInit; }; /** @example t-eoSyncEasyPSO.cpp diff --git a/eo/src/es/CMAParams.cpp b/eo/src/es/CMAParams.cpp index 2862cdd1a..d27204f97 100644 --- a/eo/src/es/CMAParams.cpp +++ b/eo/src/es/CMAParams.cpp @@ -113,16 +113,19 @@ CMAParams::CMAParams(eoParser& parser, unsigned dimensionality) { for (unsigned i = 0; i < weights.size(); ++i) { weights[i] = mu - i; } + break; } case 2: { weights = 1.; + break; } default : { for (unsigned i = 0; i < weights.size(); ++i) { weights[i] = log(mu+1.)-log(i+1.); } + break; } } diff --git a/eo/src/gp/parse_tree.h b/eo/src/gp/parse_tree.h index 84ec04d35..6b9ab80ae 100644 --- a/eo/src/gp/parse_tree.h +++ b/eo/src/gp/parse_tree.h @@ -468,8 +468,11 @@ private : switch(new_arity) { case 3 : args[2].copy(s.args[2]); args[2].parent = this; // no break! + [[fallthrough]]; case 2 : args[1].copy(s.args[1]); args[1].parent = this; + [[fallthrough]]; case 1 : args[0].copy(s.args[0]); args[0].parent = this; + [[fallthrough]]; case 0 : break; default : { @@ -523,7 +526,9 @@ private : switch(arity()) { case 3 : args[2].parent = 0; // no break! + [[fallthrough]]; case 2 : args[1].parent = 0; + [[fallthrough]]; case 1 : args[0].parent = 0; break; case 0 : break; default : @@ -542,7 +547,9 @@ private : switch(arity()) { case 3 : args[2].parent = this; // no break! + [[fallthrough]]; case 2 : args[1].parent = this; + [[fallthrough]]; case 1 : args[0].parent = this; break; case 0 : break; default : diff --git a/eo/src/mpi/implMpi.cpp b/eo/src/mpi/implMpi.cpp index 2dd1ca0d5..d045da3ac 100644 --- a/eo/src/mpi/implMpi.cpp +++ b/eo/src/mpi/implMpi.cpp @@ -161,7 +161,7 @@ namespace mpi MPI_Barrier( MPI_COMM_WORLD ); } - void broadcast( communicator & comm, int value, int root ) + void broadcast( communicator & /*comm*/, int value, int root ) { MPI_Bcast( &value, 1, MPI_INT, root, MPI_COMM_WORLD ); } diff --git a/eo/src/utils/pipecom.cpp b/eo/src/utils/pipecom.cpp index a175112f9..bef9ae2ce 100644 --- a/eo/src/utils/pipecom.cpp +++ b/eo/src/utils/pipecom.cpp @@ -42,16 +42,16 @@ int Check( PCom *com ) } -PCom * PipeComOpen( char *prog ) +PCom * PipeComOpen( const char *prog ) { char *args[2]; - args[0] = prog; + args[0] = strdup( prog ); args[1] = NULL; return PipeComOpenArgv( prog, args ); } -PCom * PipeComOpenArgv( char *prog, char *argv[] ) +PCom * PipeComOpenArgv( const char *prog, char *argv[] ) { int toFils[2]; int toPere[2]; diff --git a/eo/src/utils/pipecom.h b/eo/src/utils/pipecom.h index 56b031708..16685225c 100644 --- a/eo/src/utils/pipecom.h +++ b/eo/src/utils/pipecom.h @@ -23,8 +23,8 @@ typedef struct PipeCommunication { } PCom; -extern PCom *PipeComOpen( char *prog ); -extern PCom *PipeComOpenArgv( char *prog, char *argv[] ); +extern PCom *PipeComOpen( const char *prog ); +extern PCom *PipeComOpenArgv( const char *prog, char *argv[] ); extern int PipeComSend( PCom *to, const char *line ); extern int PipeComSendn( PCom *to, const char *data, int n ); diff --git a/moeo/src/do/make_checkpoint_moeo.h b/moeo/src/do/make_checkpoint_moeo.h index 188c340ea..98bb1e2a1 100644 --- a/moeo/src/do/make_checkpoint_moeo.h +++ b/moeo/src/do/make_checkpoint_moeo.h @@ -66,7 +66,7 @@ bool testDirRes(std::string _dirName, bool _erase); * @param _archive the archive of non-dominated solutions */ template < class MOEOT > -eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive) +eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & /*_eval*/, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive) { eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue)); /* the objective vector type */ diff --git a/moeo/src/do/make_ea_moeo.h b/moeo/src/do/make_ea_moeo.h index aee4dcd0d..76559e198 100644 --- a/moeo/src/do/make_ea_moeo.h +++ b/moeo/src/do/make_ea_moeo.h @@ -85,7 +85,7 @@ * @param _archive the archive of non-dominated solutions */ template < class MOEOT > -moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive) +moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & /*_archive*/) { /* the objective vector type */ diff --git a/moeo/src/metric/moeoHyperVolumeMetric.h b/moeo/src/metric/moeoHyperVolumeMetric.h index dc65ac4c9..ce1ee0c1c 100644 --- a/moeo/src/metric/moeoHyperVolumeMetric.h +++ b/moeo/src/metric/moeoHyperVolumeMetric.h @@ -55,7 +55,7 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d * @param _normalize allow to normalize data (default true) * @param _rho coefficient to determine the reference point. */ - moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){ + moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho) { bounds.resize(ObjectiveVector::Traits::nObjectives()); // initialize bounds in case someone does not want to use them for (unsigned int i=0; i } template - U& findValueImpl(T& t, Arg&... arg, std::true_type) + U& findValueImpl(T& t, Arg&... /*arg*/, std::true_type) { return t; } diff --git a/smp/src/island.cpp b/smp/src/island.cpp index 783d42d75..eb8fa85ca 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -59,6 +59,10 @@ paradiseo::smp::Island::Island(eoPop& _pop, IntPolicy _pop, _intPolicy, _migPolicy, args...) { } +template