diff --git a/trunk/paradiseo-mo/src/algo/moLocalSearch.h b/trunk/paradiseo-mo/src/algo/moLocalSearch.h index bb3b75e78..ad7ce5d7c 100644 --- a/trunk/paradiseo-mo/src/algo/moLocalSearch.h +++ b/trunk/paradiseo-mo/src/algo/moLocalSearch.h @@ -50,11 +50,10 @@ public: typedef typename NeighborhoodExplorer::EOT EOT ; typedef typename NeighborhoodExplorer::Neighborhood Neighborhood ; - /** * Constructor of a moLocalSearch needs a NeighborhooExplorer and a Continuator */ - moLocalSearch(NeighborhoodExplorer& _searchExpl, moContinuator & _continuator, eoEvalFunc& _fullEval) : searchExplorer(_searchExpl), continuator(_continuator), fullEval(_fullEval) { } ; + moLocalSearch(moNeighborhoodExplorer& _searchExpl, moContinuator & _continuator, eoEvalFunc& _fullEval) : searchExplorer(_searchExpl), continuator(_continuator), fullEval(_fullEval) { } ; /** * Run the local search on a solution @@ -99,7 +98,7 @@ public: private: // make the exploration of the neighborhood according to a local search heuristic - NeighborhoodExplorer& searchExplorer ; + moNeighborhoodExplorer& searchExplorer ; // external continuator moContinuator& continuator ; diff --git a/trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h index 410caf44f..7f9ec6d36 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h +++ b/trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h @@ -35,23 +35,21 @@ Contact: paradiseo-help@lists.gforge.inria.fr /** * A variable Neighborhood Search (VNS) in the forward manner */ -template< class Neighbor > -class moForwardVariableNeighborhood : public moVariableNeighborhood +template< class EOT, class Fitness > +class moForwardVariableNeighborhood : public moVariableNeighborhood { public: - /** - * Define type of a solution corresponding to Neighbor - */ - typedef typename Neighbor::EOT EOT; - using moVariableNeighborhood::currentNH; - using moVariableNeighborhood::neighborhoodVector; + typedef moNeighbor Neighbor; + + using moVariableNeighborhood::currentNH; + using moVariableNeighborhood::neighborhoodVector; /** * Construction of at least one neighborhood * @param _firstNH first neighborhood in the vector */ - moForwardVariableNeighborhood(moNeighborhood& _firstNH) : moVariableNeighborhood(_firstNH) { } + moForwardVariableNeighborhood(moNeighborhood& _firstNH) : moVariableNeighborhood(_firstNH) { } /** * Return the class id. diff --git a/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h index 82ae82645..4c0016d16 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h +++ b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h @@ -31,25 +31,25 @@ Contact: paradiseo-help@lists.gforge.inria.fr #define _moVariableNeighborhood_h #include +#include +#include +#include /** * A vector of neighborhood for the Variable Neighborhood Search (VNS) */ -template< class Neighbor > -class moVariableNeighborhood : public moNeighborhood +template< class EOT, class Fitness > +class moVariableNeighborhood : public moNeighborhood > { public: - /** - * Define type of a solution corresponding to Neighbor - */ - typedef typename Neighbor::EOT EOT; + typedef moNeighbor Neighbor; /** * Construction of at least one neighborhood * @param _firstNH first neighborhood in the vector */ moVariableNeighborhood(moNeighborhood& _firstNH) { - neighborhoodVector.push_back(_firstNH); + neighborhoodVector.push_back(&_firstNH); // the current neighborhood currentNH = 0; } @@ -58,7 +58,7 @@ public: * @return if the current neighborhood is random */ virtual bool isRandom() { - return neighborhoodVector[currentNH].isRandom(); + return neighborhoodVector[currentNH]->isRandom(); } /** @@ -67,7 +67,7 @@ public: * @return if _solution has a Neighbor in the current neighborhood */ virtual bool hasNeighbor(EOT & _solution) { - return neighborhoodVector[currentNH].hasNeighbor(_solution); + return neighborhoodVector[currentNH]->hasNeighbor(_solution); } /** @@ -76,7 +76,7 @@ public: * @param _current the first neighbor in the current neighborhood */ virtual void init(EOT & _solution, Neighbor & _current) { - neighborhoodVector[currentNH].init(_solution, _current); + neighborhoodVector[currentNH]->init(_solution, _current); } /** @@ -85,7 +85,7 @@ public: * @param _current the next neighbor in the current neighborhood */ virtual void next(EOT & _solution, Neighbor & _current) { - neighborhoodVector[currentNH].next(_solution, _current); + neighborhoodVector[currentNH]->next(_solution, _current); } /** @@ -94,7 +94,7 @@ public: * @return if there is still a neighbor not explored in the current neighborhood */ virtual bool cont(EOT & _solution) { - neighborhoodVector[currentNH].cont(_solution); + return neighborhoodVector[currentNH]->cont(_solution); } /** @@ -110,7 +110,7 @@ public: * @param _nh the neighborhood to add at the end of the vector of neighborhood */ virtual void add(moNeighborhood& _nh) { - neighborhoodVector.push_back(_nh); + neighborhoodVector.push_back(&_nh); } /** @@ -129,9 +129,9 @@ public: */ virtual void nextNeighborhood() = 0; -private: +protected: // the vector of neighborhoods - std::vector& > neighborhoodVector; + std::vector* > neighborhoodVector; // the index of the current neighborhood unsigned int currentNH; diff --git a/trunk/paradiseo-mo/test/CMakeLists.txt b/trunk/paradiseo-mo/test/CMakeLists.txt index 2f78edadf..8cf9df803 100644 --- a/trunk/paradiseo-mo/test/CMakeLists.txt +++ b/trunk/paradiseo-mo/test/CMakeLists.txt @@ -58,6 +58,7 @@ SET (TEST_LIST t-moMetropolisHastingExplorer t-moRandomNeutralWalkExplorer t-moTSExplorer + t-moForwardVariableNeighborhood ) FOREACH (test ${TEST_LIST}) diff --git a/trunk/paradiseo-mo/test/t-moForwardVariableNeighborhood.cpp b/trunk/paradiseo-mo/test/t-moForwardVariableNeighborhood.cpp new file mode 100644 index 000000000..e91380204 --- /dev/null +++ b/trunk/paradiseo-mo/test/t-moForwardVariableNeighborhood.cpp @@ -0,0 +1,55 @@ +/* + +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 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 +*/ + +#include +#include +#include + +#include +#include +#include "moTestClass.h" + + + +int main(){ + + std::cout << "[t-moForwardVariableNeighborhood] => START" << std::endl; + + moRndWithoutReplNeighborhood rndNH(8); + moOrderNeighborhood, eoMinimizingFitness> > orderNH(8); + + + //moForwardVariableNeighborhood, eoMinimizingFitness> test(orderNH); + + + std::cout << "[t-moForwardVariableNeighborhood] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-mo/tutorial/oneMax/application/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/oneMax/application/CMakeLists.txt index 4c6310333..d49acdace 100644 --- a/trunk/paradiseo-mo/tutorial/oneMax/application/CMakeLists.txt +++ b/trunk/paradiseo-mo/tutorial/oneMax/application/CMakeLists.txt @@ -13,7 +13,7 @@ ADD_EXECUTABLE(testMetropolisHasting testMetropolisHasting.cpp) #ADD_EXECUTABLE(testWithMove testWithMove.cpp) ADD_EXECUTABLE(testSimpleTS testSimpleTS.cpp) ADD_EXECUTABLE(testRandomNeutralWalk testRandomNeutralWalk.cpp) -ADD_EXECUTABLE(testILS testILS.cpp) +#ADD_EXECUTABLE(testILS testILS.cpp) ADD_EXECUTABLE(testSimulatedAnnealing testSimulatedAnnealing.cpp) TARGET_LINK_LIBRARIES(testSimpleHC eoutils ga eo) @@ -25,7 +25,7 @@ TARGET_LINK_LIBRARIES(testMetropolisHasting eoutils ga eo) #TARGET_LINK_LIBRARIES(testWithMove eoutils ga eo) TARGET_LINK_LIBRARIES(testSimpleTS eoutils ga eo) TARGET_LINK_LIBRARIES(testRandomNeutralWalk eoutils ga eo) -TARGET_LINK_LIBRARIES(testILS eoutils ga eo) +#TARGET_LINK_LIBRARIES(testILS eoutils ga eo) TARGET_LINK_LIBRARIES(testSimulatedAnnealing eoutils ga eo)