From 0c8d0c5f08f2d5e0883338db6a11c89a23aa75f9 Mon Sep 17 00:00:00 2001 From: liefooga Date: Fri, 15 Feb 2008 13:25:56 +0000 Subject: [PATCH] now we use the permutation stuffs from EO git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@959 331e1502-861f-0410-8da2-ba01fb791d7f --- .../tutorial/examples/flowshop/CMakeLists.txt | 11 +-- .../tutorial/examples/flowshop/FlowShopInit.h | 25 +----- .../flowshop/FlowShopOpMutationExchange.cpp | 76 ---------------- .../flowshop/FlowShopOpMutationExchange.h | 20 +---- .../flowshop/FlowShopOpMutationShift.cpp | 86 ------------------- .../flowshop/FlowShopOpMutationShift.h | 20 +---- 6 files changed, 9 insertions(+), 229 deletions(-) delete mode 100644 trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.cpp delete mode 100644 trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.cpp diff --git a/trunk/paradiseo-moeo/tutorial/examples/flowshop/CMakeLists.txt b/trunk/paradiseo-moeo/tutorial/examples/flowshop/CMakeLists.txt index a2dcb1e23..03bc43387 100644 --- a/trunk/paradiseo-moeo/tutorial/examples/flowshop/CMakeLists.txt +++ b/trunk/paradiseo-moeo/tutorial/examples/flowshop/CMakeLists.txt @@ -50,13 +50,10 @@ SET(FLOWSHOP_LIB_OUTPUT_PATH ${FLOWSHOP_BINARY_DIR}/lib) SET(LIBRARY_OUTPUT_PATH ${FLOWSHOP_LIB_OUTPUT_PATH}) SET (FLOWSHOP_SOURCES FlowShopBenchmarkParser.cpp - FlowShopEval.cpp - FlowShopInit.cpp - FlowShopObjectiveVectorTraits.cpp - FlowShopOpCrossoverQuad.cpp - FlowShopOpMutationExchange.cpp - FlowShopOpMutationShift.cpp - FlowShop.cpp) + FlowShopEval.cpp + FlowShopObjectiveVectorTraits.cpp + FlowShopOpCrossoverQuad.cpp + FlowShop.cpp) ADD_LIBRARY(flowshop STATIC ${FLOWSHOP_SOURCES}) ADD_DEPENDENCIES(flowshop moeo) diff --git a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopInit.h b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopInit.h index 99cecc7b0..d21072453 100644 --- a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopInit.h +++ b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopInit.h @@ -44,29 +44,6 @@ /** * Initialization of a random genotype built by the default constructor of the FlowShop class */ -class FlowShopInit : public eoInit - { - public: - - /** - * Ctor - * @param _N the number of jobs to schedule - */ - FlowShopInit(unsigned int _N); - - - /** - * builds a random genotype - * @param _flowshop a genotype that has been default-constructed - */ - void operator()(FlowShop & _flowshop); - - - private: - - /** the number of jobs (size of a scheduling vector) */ - unsigned int N; - - }; +typedef eoInitPermutation FlowShopInit; #endif /*FLOWSHOPINIT_H_*/ diff --git a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.cpp b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.cpp deleted file mode 100644 index a37ae2587..000000000 --- a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Arnaud Liefooghe -* -* 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 -* -*/ -//----------------------------------------------------------------------------- - -#include - - -std::string FlowShopOpMutationExchange::className() const - { - return "FlowShopOpMutationExchange"; - } - - -bool FlowShopOpMutationExchange::operator()(FlowShop & _flowshop) -{ - bool isModified; - FlowShop result = _flowshop; - // computation of the 2 random points - unsigned int point1, point2; - do - { - point1 = rng.random(result.size()); - point2 = rng.random(result.size()); - } - while (point1 == point2); - // swap - std::swap (result[point1], result[point2]); - // update (if necessary) - if (result != _flowshop) - { - // update - _flowshop.value(result); - // the genotype has been modified - isModified = true; - } - else - { - // the genotype has not been modified - isModified = false; - } - // return 'true' if the genotype has been modified - return isModified; -} diff --git a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.h b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.h index c54b8f063..51801d9d9 100644 --- a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.h +++ b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationExchange.h @@ -38,28 +38,12 @@ #ifndef FLOWSHOPOPMUTATIONEXCHANGE_H_ #define FLOWSHOPOPMUTATIONEXCHANGE_H_ -#include +#include #include /** * Exchange mutation operator for the flow-shop */ -class FlowShopOpMutationExchange : public eoMonOp - { - public: - - /** - * the class name (used to display statistics) - */ - std::string className() const; - - - /** - * modifies the parent with an exchange mutation - * @param _flowshop the parent genotype (will be modified) - */ - bool operator()(FlowShop & _flowshop); - - }; +typedef eoSwapMutation FlowShopOpMutationExchange; #endif /*FLOWSHOPOPMUTATIONEXCHANGE_H_*/ diff --git a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.cpp b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.cpp deleted file mode 100644 index 389842bdd..000000000 --- a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Arnaud Liefooghe -* -* 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 -* -*/ -//----------------------------------------------------------------------------- - -#include - - -std::string FlowShopOpMutationShift::className() const - { - return "FlowShopOpMutationShift"; - } - - -bool FlowShopOpMutationShift::operator()(FlowShop & _flowshop) -{ - bool isModified; - int direction; - unsigned int tmp; - FlowShop result = _flowshop; - // computation of the 2 random points - unsigned int point1, point2; - do - { - point1 = rng.random(result.size()); - point2 = rng.random(result.size()); - } - while (point1 == point2); - // direction - if (point1 < point2) - direction = 1; - else - direction = -1; - // mutation - tmp = result[point1]; - for (unsigned int i=point1 ; i!=point2 ; i+=direction) - result[i] = result[i+direction]; - result[point2] = tmp; - // update (if necessary) - if (result != _flowshop) - { - // update - _flowshop.value(result); - // the genotype has been modified - isModified = true; - } - else - { - // the genotype has not been modified - isModified = false; - } - // return 'true' if the genotype has been modified - return isModified; -} diff --git a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.h b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.h index 8e9fb851d..523bb88f0 100644 --- a/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.h +++ b/trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShopOpMutationShift.h @@ -38,28 +38,12 @@ #ifndef FLOWSHOPOPMUTATIONSHIFT_H_ #define FLOWSHOPOPMUTATIONSHIFT_H_ -#include +#include #include /** * Shift mutation operator for flow-shop */ -class FlowShopOpMutationShift : public eoMonOp < FlowShop > - { - public: - - /** - * the class name (used to display statistics) - */ - std::string className() const; - - - /** - * modifies the parent with a shift mutation - * @param _flowshop the parent genotype (will be modified) - */ - bool operator()(FlowShop & _flowshop); - - }; +typedef eoShiftMutation FlowShopOpMutationShift; #endif /*FLOWSHOPOPMUTATIONSHIFT_H_*/