diff --git a/trunk/paradiseo-mo/src/algo/moDummyLS.h b/trunk/paradiseo-mo/src/algo/moDummyLS.h new file mode 100644 index 000000000..09846110b --- /dev/null +++ b/trunk/paradiseo-mo/src/algo/moDummyLS.h @@ -0,0 +1,71 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moDummyLS_h +#define _moDummyLS_h + +#include +#include +#include + +/******************************************************** + * Dummy Local Search: + * + * To do nothing, only the full evaluation of the solution if necessary ;-) + ********************************************************/ +template +class moDummyLS: public moLocalSearch +{ +public: + typedef typename Neighbor::EOT EOT; + typedef moNeighborhood Neighborhood ; + + /** + * Simple constructor + * @param _fullEval the full evaluation function + */ + moDummyLS(eoEvalFunc& _fullEval): + moLocalSearch(explorer, trueCont, _fullEval) + {} + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moDummyLS"; + } + +private: + // always true continuator + moTrueContinuator trueCont; + // the explorer of the simple HC + moDummyExplorer explorer; +}; + +#endif diff --git a/trunk/paradiseo-mo/src/algo/moRandomSearch.h b/trunk/paradiseo-mo/src/algo/moRandomSearch.h index ba5beff67..53e7b0730 100644 --- a/trunk/paradiseo-mo/src/algo/moRandomSearch.h +++ b/trunk/paradiseo-mo/src/algo/moRandomSearch.h @@ -72,6 +72,13 @@ public: explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0) {} + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moRandomSearch"; + } + private: // always true continuator moTrueContinuator trueCont; diff --git a/trunk/paradiseo-mo/src/explorer/moDummyExplorer.h b/trunk/paradiseo-mo/src/explorer/moDummyExplorer.h new file mode 100644 index 000000000..5e6b6eca7 --- /dev/null +++ b/trunk/paradiseo-mo/src/explorer/moDummyExplorer.h @@ -0,0 +1,107 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moDummyExplorer_h +#define _moDummyExplorer_h + +#include + +/** + * Dummy Explorer the neighborhood: nothing is explored + */ +template< class Neighbor > +class moDummyExplorer : public moNeighborhoodExplorer +{ +public: + typedef moNeighborhood Neighborhood; + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness ; + + moDummyExplorer(): moNeighborhoodExplorer() { } + + /** + * Init Search parameters + * @param _solution the solution to explore + */ + void initParam (EOT& _solution) { } ; + + /** + * Update Search parameters + * @param _solution the solution to explore + */ + void updateParam (EOT& _solution) { } ; + + /** + * Test if the exploration continue or not + * @param _solution the solution to explore + * @return true if the exploration continue, else return false + */ + bool isContinue(EOT& _solution) { return false; } ; + + /** + * Move a solution + * @param _solution the solution to explore + */ + void move(EOT& _solution) { } ; + + /** + * Test if a solution is accepted + * @param _solution the solution to explore + * @return true if the solution is accepted, else return false + */ + virtual bool accept(EOT& _solution) { return false; } ; + + /** + * Terminate the search + * @param _solution the solution to explore + */ + virtual void terminate(EOT& _solution) { } ; + + /** + * Explore the neighborhood of a solution + * @param _solution + */ + void operator()(EOT & _solution) { } + + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moDummyExplorer"; + } + +}; + +#endif diff --git a/trunk/paradiseo-mo/src/mo.h b/trunk/paradiseo-mo/src/mo.h index 2cd5c4600..a12401ce2 100755 --- a/trunk/paradiseo-mo/src/mo.h +++ b/trunk/paradiseo-mo/src/mo.h @@ -36,6 +36,7 @@ #define _newmo_h #include +#include #include #include #include @@ -90,6 +91,7 @@ #include #include #include +#include #include #include #include diff --git a/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h b/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h index 4061a8052..3b2d2c615 100644 --- a/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moAutocorrelationSampling.h @@ -78,7 +78,7 @@ public: */ ~moAutocorrelationSampling() { // delete the pointer on the local search which has been constructed in the constructor - delete &localSearch; + delete localSearch; } protected: diff --git a/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h b/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h index 817edd115..2e18c6eb2 100644 --- a/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h @@ -73,7 +73,7 @@ public: */ ~moDensityOfStatesSampling() { // delete the pointer on the local search which has been constructed in the constructor - delete &localSearch; + delete localSearch; } protected: diff --git a/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h b/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h index b00d515c1..7fbc02e39 100644 --- a/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moHillClimberSampling.h @@ -90,7 +90,7 @@ public: */ ~moHillClimberSampling() { // delete the pointer on the local search which has been constructed in the constructor - delete &localSearch; + delete localSearch; } protected: diff --git a/trunk/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h b/trunk/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h index 7b08da84c..b4a3173df 100644 --- a/trunk/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h @@ -111,7 +111,7 @@ public: */ ~moNeutralDegreeSampling() { // delete the pointer on the local search which has been constructed in the constructor - delete &localSearch; + delete localSearch; } protected: diff --git a/trunk/paradiseo-mo/src/sampling/moRndRndFitnessCloudSampling.h b/trunk/paradiseo-mo/src/sampling/moRndRndFitnessCloudSampling.h new file mode 100644 index 000000000..61da261c6 --- /dev/null +++ b/trunk/paradiseo-mo/src/sampling/moRndRndFitnessCloudSampling.h @@ -0,0 +1,96 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef moRndRndFitnessCloudSampling_h +#define moRndRndFitnessCloudSampling_h + +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute an estimation of the fitness cloud, + * i.e. the scatter plot of solution fitness versus neighbor fitness: + * + * Sample the fitness of random solution in the search space + * and the fitness of one random neighbor + * + * The values are collected during the random search + * + */ +template +class moRndRndFitnessCloudSampling : public moFitnessCloudSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Default Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood) + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbSol Number of solutions in the sample + */ + moRndRndFitnessCloudSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbSol) : + moFitnessCloudSampling(_init, _neighborhood, _fullEval, _eval, _nbSol), + neighborFitnessStat(_neighborhood, _eval) + { + // delete the dummy local search + delete localSearch; + + // random sampling + localSearch = new moRandomSearch(_init, _fullEval, _nbSol); + + // one random neighbor + add(neighborFitnessStat); + } + +protected: + moNeighborFitnessStat< Neighbor > neighborFitnessStat; + +}; + + +#endif diff --git a/trunk/paradiseo-mo/src/sampling/moSampling.h b/trunk/paradiseo-mo/src/sampling/moSampling.h index 61f418813..4afe19c03 100644 --- a/trunk/paradiseo-mo/src/sampling/moSampling.h +++ b/trunk/paradiseo-mo/src/sampling/moSampling.h @@ -65,7 +65,7 @@ public: * @param _monitoring the statistic is saved into the monitor if true */ template - moSampling(eoInit & _init, moLocalSearch & _localSearch, moStat & _stat, bool _monitoring = true) : init(_init), localSearch(_localSearch), continuator(_localSearch.getContinuator()) + moSampling(eoInit & _init, moLocalSearch & _localSearch, moStat & _stat, bool _monitoring = true) : init(_init), localSearch(&_localSearch), continuator(_localSearch.getContinuator()) { checkpoint = new moCheckpoint(*continuator); add(_stat, _monitoring); @@ -93,7 +93,7 @@ public: checkpoint->add(_stat); if (_monitoring) { - moVectorMonitor * monitor = new moVectorMonitor(_stat); + moVectorMonitor * monitor = new moVectorMonitor(_stat); // attention fuite memoire a la descruction ! monitorVec.push_back(monitor); checkpoint->add(*monitor); } @@ -109,7 +109,7 @@ public: monitorVec[i]->clear(); // change the checkpoint to compute the statistics - localSearch.setContinuator(*checkpoint); + localSearch->setContinuator(*checkpoint); // the initial solution EOT solution; @@ -117,11 +117,13 @@ public: // initialisation of the solution init(solution); + std::cout << localSearch->className() << std::endl; + // compute the sampling - localSearch(solution); + (*localSearch)(solution); // set back to initial continuator - localSearch.setContinuator(*continuator); + localSearch->setContinuator(*continuator); } /** @@ -180,7 +182,7 @@ public: protected: eoInit & init; - moLocalSearch & localSearch; + moLocalSearch * localSearch; moContinuator * continuator; moCheckpoint * checkpoint; diff --git a/trunk/paradiseo-mo/tutorial/Lesson6/fitnessCloud.cpp b/trunk/paradiseo-mo/tutorial/Lesson6/fitnessCloud.cpp index 028ba5735..bb476ed5e 100644 --- a/trunk/paradiseo-mo/tutorial/Lesson6/fitnessCloud.cpp +++ b/trunk/paradiseo-mo/tutorial/Lesson6/fitnessCloud.cpp @@ -37,8 +37,8 @@ using namespace std; //----------------------------------------------------------------------------- // the sampling class -#include -#include +#include +//#include // Declaration of types //----------------------------------------------------------------------------- @@ -165,8 +165,8 @@ void main_function(int argc, char **argv) // - neighbor evaluation // - number of solutions to sample - //moFitnessCloudSampling sampling(random, neighborhood, fullEval, neighborEval, nbSol); - moMHFitnessCloudSampling sampling(random, neighborhood, fullEval, neighborEval, nbSol); + moRndRndFitnessCloudSampling sampling(random, neighborhood, fullEval, neighborEval, nbSol); + //moMHFitnessCloudSampling sampling(random, neighborhood, fullEval, neighborEval, nbSol); /* ========================================================= *