Ajout d'une Lesson sur les DMLS
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1840 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
b5008fbda7
commit
ff7b15fe22
6 changed files with 241 additions and 15 deletions
|
|
@ -18,10 +18,10 @@ PROJECT(ParadisEO-MOEO)
|
|||
|
||||
SET(PACKAGE_BUGREPORT "paradiseo-help@lists.gforge.inria.fr" CACHE STRING "Package bug report" FORCE)
|
||||
SET(PACKAGE_NAME "ParadisEO-MOEO - Multi Objective Evolving Objects" CACHE STRING "Package name" FORCE)
|
||||
SET(PACKAGE_STRING "ParadisEO-MOEO 1.2" CACHE STRING "MOEO Package string full name" FORCE)
|
||||
SET(PACKAGE_VERSION "1.2" CACHE STRING "Package version" FORCE)
|
||||
SET(GLOBAL_VERSION "1.2" CACHE STRING "Global version" FORCE)
|
||||
SET(VERSION "1.2" CACHE STRING "Version" FORCE)
|
||||
SET(PACKAGE_STRING "ParadisEO-MOEO 1.3" CACHE STRING "MOEO Package string full name" FORCE)
|
||||
SET(PACKAGE_VERSION "1.3" CACHE STRING "Package version" FORCE)
|
||||
SET(GLOBAL_VERSION "1.3" CACHE STRING "Global version" FORCE)
|
||||
SET(VERSION "1.3" CACHE STRING "Version" FORCE)
|
||||
##########################################################################################################################################
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ private:
|
|||
_dest.back().objectiveVector(neighbor.fitness());
|
||||
//fix its flag to 0 (unvisited solution)
|
||||
_dest.back().flag(0);
|
||||
_dest.back().fitness(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
48
trunk/paradiseo-moeo/src/utils/moeoFullEvalByCopy.h
Normal file
48
trunk/paradiseo-moeo/src/utils/moeoFullEvalByCopy.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef moeoFullEvalByCopy_H
|
||||
#define moeoFullEvalByCopy_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <eval/moEval.h>
|
||||
|
||||
/**
|
||||
* Evaluation by copy
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moeoFullEvalByCopy : public moEval<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename moEval<Neighbor>::EOT EOT;
|
||||
typedef typename moEval<Neighbor>::Fitness Fitness;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _eval the full evaluation object
|
||||
*/
|
||||
moeoFullEvalByCopy(eoEvalFunc<EOT> & _eval) : eval(_eval) {}
|
||||
|
||||
/**
|
||||
* Full evaluation of the neighbor by copy
|
||||
* @param _sol current solution
|
||||
* @param _neighbor the neighbor to be evaluated
|
||||
*/
|
||||
void operator()(EOT & _sol, Neighbor & _neighbor)
|
||||
{
|
||||
// tmp solution
|
||||
EOT tmp(_sol);
|
||||
// move tmp solution wrt _neighbor
|
||||
_neighbor.move(tmp);
|
||||
// eval copy
|
||||
tmp.invalidate();
|
||||
eval(tmp);
|
||||
// set the fitness value to the neighbor
|
||||
_neighbor.fitness(tmp.objectiveVector());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
eoEvalFunc<EOT> & eval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -47,6 +47,9 @@ IF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CM
|
|||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${ParadisEO-MOEO_SOURCE_DIR}/tutorial/Lesson3/FlowShopEA2.param
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson3/FlowShopEA2.param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${ParadisEO-MOEO_SOURCE_DIR}/tutorial/Lesson4/FlowShopDMLS.param
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson4/FlowShopDMLS.param
|
||||
)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
|
|
@ -127,6 +130,13 @@ MACRO(ADD_COMMANDS_MOEO)
|
|||
${ParadisEO-MOEO_SOURCE_DIR}/tutorial/Lesson3/FlowShopEA2.param
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson3
|
||||
)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson4/FlowShopDMLS.param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${ParadisEO-MOEO_SOURCE_DIR}/tutorial/Lesson4/FlowShopDMLS.param
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson4
|
||||
)
|
||||
ENDMACRO(ADD_COMMANDS_MOEO)
|
||||
|
||||
MACRO(ADD_TARGET_MOEO n)
|
||||
|
|
@ -169,6 +179,23 @@ MACRO(ADD_TARGET_MOEO n)
|
|||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/100_20_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/200_10_01.txt
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson4")
|
||||
ADD_CUSTOM_TARGET(lesson4 DEPENDS
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson4/FlowShopDMLS
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson4/FlowShopDMLS.param
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_05_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_05_02.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_10_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_10_02.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_20_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/050_05_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/050_10_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/050_20_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/100_05_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/100_10_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/100_20_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/200_10_01.txt
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "install")
|
||||
ADD_CUSTOM_TARGET(install DEPENDS
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson1/Sch1.param
|
||||
|
|
@ -215,6 +242,7 @@ ADD_SUBDIRECTORY(examples)
|
|||
ADD_SUBDIRECTORY(Lesson1)
|
||||
ADD_SUBDIRECTORY(Lesson2)
|
||||
ADD_SUBDIRECTORY(Lesson3)
|
||||
ADD_SUBDIRECTORY(Lesson4)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-MOEO_BINARY_DIR}/lib ${FLOWSHOP_B
|
|||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES FlowShopEA2.cpp)
|
||||
SOURCE_GROUP(src FILES FlowShopDMLS.cpp)
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_05_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_05_02.txt
|
||||
|
|
@ -32,9 +32,9 @@ IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "
|
|||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/100_20_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/200_10_01.txt
|
||||
)
|
||||
ADD_EXECUTABLE(FlowShopEA2
|
||||
FlowShopEA2.cpp
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson3/FlowShopEA2.param
|
||||
ADD_EXECUTABLE(FlowShopDMLS
|
||||
FlowShopDMLS.cpp
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/Lesson4/FlowShopDMLS.param
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_05_01.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_05_02.txt
|
||||
${ParadisEO-MOEO_BINARY_DIR}/tutorial/examples/flowshop/benchs/020_10_01.txt
|
||||
|
|
@ -50,27 +50,27 @@ IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "
|
|||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MOEO()
|
||||
ADD_TARGET_MOEO(lesson3)
|
||||
ADD_TARGET_MOEO(lesson4)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(FlowShopEA2 FlowShopEA2.cpp)
|
||||
ADD_EXECUTABLE(FlowShopDMLS FlowShopDMLS.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(FlowShopEA2 EXCLUDE_FROM_ALL FlowShopEA2.cpp)
|
||||
ADD_EXECUTABLE(FlowShopDMLS EXCLUDE_FROM_ALL FlowShopDMLS.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(FlowShopEA2 flowshop moeo)
|
||||
ADD_DEPENDENCIES(FlowShopDMLS flowshop moeo)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(FlowShopEA2_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(FlowShopEA2 PROPERTIES VERSION "${FlowShopEA2_VERSION}")
|
||||
SET(FlowShopDMLS_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(FlowShopDMLS PROPERTIES VERSION "${FlowShopDMLS_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA2 moeo flowshop eo eoutils)
|
||||
TARGET_LINK_LIBRARIES(FlowShopDMLS moeo flowshop eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
149
trunk/paradiseo-moeo/tutorial/Lesson4/FlowShopDMLS.cpp
Normal file
149
trunk/paradiseo-moeo/tutorial/Lesson4/FlowShopDMLS.cpp
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* <FlowShopDMLS.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// moeo general include
|
||||
#include <moeo>
|
||||
// for the creation of an evaluator
|
||||
#include <make_eval_FlowShop.h>
|
||||
// for the creation of an initializer
|
||||
#include <make_genotype_FlowShop.h>
|
||||
// for the creation of the variation operators
|
||||
#include <make_op_FlowShop.h>
|
||||
// how to initialize the population
|
||||
#include <do/make_pop.h>
|
||||
// checks for help demand, and writes the status file and make_help; in libutils
|
||||
void make_help(eoParser & _parser);
|
||||
// definition of the representation
|
||||
#include <FlowShop.h>
|
||||
|
||||
#include <problems/permutation/moShiftNeighbor.h>
|
||||
#include <neighborhood/moOrderNeighborhood.h>
|
||||
#include <utils/moeoFullEvalByCopy.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//define a neighbor
|
||||
typedef moShiftNeighbor<FlowShop, FlowShopObjectiveVector> Neighbor;
|
||||
|
||||
|
||||
eoParser parser(argc, argv); // for user-parameter reading
|
||||
eoState state; // to keep all things allocated
|
||||
|
||||
|
||||
/*** the representation-dependent things ***/
|
||||
|
||||
// The fitness evaluation
|
||||
eoEvalFuncCounter<FlowShop>& eval = do_make_eval(parser, state);
|
||||
// the genotype (through a genotype initializer)
|
||||
eoInit<FlowShop>& init = do_make_genotype(parser, state);
|
||||
// the variation operators
|
||||
eoGenOp<FlowShop>& op = do_make_op(parser, state);
|
||||
|
||||
|
||||
/*** the representation-independent things ***/
|
||||
|
||||
// initialization of the population
|
||||
eoPop<FlowShop>& pop = do_make_pop(parser, state, init);
|
||||
// definition of the archive
|
||||
moeoUnboundedArchive<FlowShop> arch;
|
||||
// stopping criteria
|
||||
unsigned int maxGen = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of gen.",'G',"Stopping criterion").value();
|
||||
eoGenContinue<FlowShop> term(maxGen);
|
||||
unsigned int nhSize = parser.createParam((unsigned int)(20), "nhSize", "neighborhood size",'G',"Evolution Engine").value();
|
||||
// checkpointing
|
||||
eoCheckPoint<FlowShop> checkpoint(term);
|
||||
moeoArchiveUpdater < FlowShop > updater(arch, pop);
|
||||
checkpoint.add(updater);
|
||||
|
||||
//neighborhood
|
||||
moOrderNeighborhood<Neighbor> neighborhood((nhSize-1) * (nhSize-1)); //!!!!!!!!!!!!!!!CHANGER CET VALEUR PAR RAPPORT AU PARAM
|
||||
//neighbor Evaluation function
|
||||
moeoFullEvalByCopy<Neighbor> moEval(eval);
|
||||
//Selection in the archive
|
||||
moeoNumberUnvisitedSelect<FlowShop> select(1);
|
||||
//explorer
|
||||
moeoFirstImprovingNeighborhoodExplorer<Neighbor> explor(neighborhood, moEval);
|
||||
|
||||
moeoUnifiedDominanceBasedLS<Neighbor> algo(checkpoint, eval, arch, explor, select);
|
||||
|
||||
|
||||
/*** Go ! ***/
|
||||
|
||||
// help ?
|
||||
make_help(parser);
|
||||
|
||||
// first evalution (for printing)
|
||||
apply<FlowShop>(eval, pop);
|
||||
for(int i=0; i<pop.size(); i++)
|
||||
pop[i].fitness(0);
|
||||
|
||||
//arch(pop);
|
||||
|
||||
// printing of the initial population
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
// run the algo
|
||||
algo(pop);
|
||||
|
||||
// printing of the final population
|
||||
cout << "Final Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
// printing of the final archive
|
||||
cout << "Final Archive\n";
|
||||
arch.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue