Parallel MOEO
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@849 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
35a6b78f8f
commit
53abc21464
15 changed files with 934 additions and 4 deletions
|
|
@ -9,6 +9,9 @@ SET(EO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-eo/build" CACHE PATH "Paradi
|
||||||
|
|
||||||
SET(MO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-mo" CACHE PATH "ParadisMO-MO source directory" FORCE)
|
SET(MO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-mo" CACHE PATH "ParadisMO-MO source directory" FORCE)
|
||||||
SET(MO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-mo/build" CACHE PATH "ParadisMO-MO binary directory" FORCE)
|
SET(MO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-mo/build" CACHE PATH "ParadisMO-MO binary directory" FORCE)
|
||||||
|
|
||||||
|
SET(MOEO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-moeo" CACHE PATH "ParadisMOEO-MOEO source directory" FORCE)
|
||||||
|
SET(MOEO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-moeo/build" CACHE PATH "ParadisMOEO-MOEO binary directory" FORCE)
|
||||||
|
|
||||||
###########################################################################################################################################
|
###########################################################################################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ ELSE(WIN32)
|
||||||
SET (ABSOLUTE_PATH_REGEX "^/")
|
SET (ABSOLUTE_PATH_REGEX "^/")
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
SET(REQUIRED_PATHS "EO_SRC_DIR" "EO_BIN_DIR" "MO_SRC_DIR" "MO_BIN_DIR")
|
SET(REQUIRED_PATHS "EO_SRC_DIR" "EO_BIN_DIR" "MO_SRC_DIR" "MO_BIN_DIR" "MOEO_SRC_DIR" "MOEO_BIN_DIR")
|
||||||
FOREACH (path ${REQUIRED_PATHS})
|
FOREACH (path ${REQUIRED_PATHS})
|
||||||
IF(EXISTS ${${path}})
|
IF(EXISTS ${${path}})
|
||||||
MESSAGE (STATUS "Using ${path}=${${path}}")
|
MESSAGE (STATUS "Using ${path}=${${path}}")
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
#define __eoVector_mesg_h
|
#define __eoVector_mesg_h
|
||||||
|
|
||||||
#include <eoVector.h>
|
#include <eoVector.h>
|
||||||
|
#include <core/moeoVector.h>
|
||||||
|
|
||||||
#include "messaging.h"
|
#include "messaging.h"
|
||||||
|
|
||||||
|
|
@ -125,4 +126,79 @@ unsigned valid; unpack(valid);
|
||||||
unpack (__v.velocities[i]);
|
unpack (__v.velocities[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class F, class T, class V, class W> void unpack (moeoVector <F,T,V,W> &_v)
|
||||||
|
{
|
||||||
|
unsigned valid;
|
||||||
|
unpack(valid);
|
||||||
|
if (! valid)
|
||||||
|
_v.invalidate();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
T fit;
|
||||||
|
unpack (fit);
|
||||||
|
_v.fitness (fit);
|
||||||
|
}
|
||||||
|
unpack(valid);
|
||||||
|
if (! valid)
|
||||||
|
_v.invalidateDiversity();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
V diver;
|
||||||
|
unpack(diver);
|
||||||
|
_v.diversity(diver);
|
||||||
|
}
|
||||||
|
unsigned len;
|
||||||
|
unpack (len);
|
||||||
|
_v.resize (len);
|
||||||
|
for (unsigned i = 0 ; i < len; i ++)
|
||||||
|
unpack (_v [i]);
|
||||||
|
unpack(valid);
|
||||||
|
if (! valid)
|
||||||
|
_v.invalidateObjectiveVector();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
F object;
|
||||||
|
unpack (len);
|
||||||
|
object.resize(len);
|
||||||
|
for (unsigned i = 0 ; i < len; i ++)
|
||||||
|
unpack (object[i]);
|
||||||
|
_v.objectiveVector(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class F, class T, class V, class W> void pack (moeoVector <F,T,V,W> &_v)
|
||||||
|
{
|
||||||
|
if (_v.invalid())
|
||||||
|
pack((unsigned)0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pack((unsigned)1);
|
||||||
|
pack (_v.fitness ());
|
||||||
|
}
|
||||||
|
if (_v.invalidDiversity())
|
||||||
|
pack((unsigned)0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pack((unsigned)1);
|
||||||
|
pack(_v.diversity());
|
||||||
|
}
|
||||||
|
unsigned len = _v.size ();
|
||||||
|
pack (len);
|
||||||
|
for (unsigned i = 0 ; i < len; i ++)
|
||||||
|
pack (_v[i]);
|
||||||
|
if (_v.invalidObjectiveVector())
|
||||||
|
pack((unsigned)0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pack((unsigned)1);
|
||||||
|
F object;
|
||||||
|
object=_v.objectiveVector();
|
||||||
|
len=object.nObjectives();
|
||||||
|
pack (len);
|
||||||
|
for (unsigned i = 0 ; i < len; i ++)
|
||||||
|
pack (object[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
#include <eo>
|
#include <eo>
|
||||||
#include <mo>
|
#include <mo>
|
||||||
|
#include <moeo>
|
||||||
|
|
||||||
|
|
||||||
//! \mainpage The ParadisEO-PEO Framework
|
//! \mainpage The ParadisEO-PEO Framework
|
||||||
|
|
@ -330,6 +331,8 @@
|
||||||
#include "peoTransform.h"
|
#include "peoTransform.h"
|
||||||
#include "peoEvalFunc.h"
|
#include "peoEvalFunc.h"
|
||||||
#include "peoPopEval.h"
|
#include "peoPopEval.h"
|
||||||
|
#include "peoMoeoPopEval.h"
|
||||||
|
|
||||||
|
|
||||||
/* Cooperative island model */
|
/* Cooperative island model */
|
||||||
#include "core/ring_topo.h"
|
#include "core/ring_topo.h"
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,15 @@
|
||||||
|
|
||||||
SET(TSP_SRC_DIR ${ParadisEO-PEO_SOURCE_DIR}/tutorial/examples/tsp)
|
SET(TSP_SRC_DIR ${ParadisEO-PEO_SOURCE_DIR}/tutorial/examples/tsp)
|
||||||
SET(TSP_BINARY_DIR ${ParadisEO-PEO_BINARY_DIR}/tutorial/examples/tsp)
|
SET(TSP_BINARY_DIR ${ParadisEO-PEO_BINARY_DIR}/tutorial/examples/tsp)
|
||||||
|
SET(FLOWSHOP_SRC_DIR "${MOEO_SRC_DIR}/tutorial/examples/flowshop" CACHE PATH "Flowshop source directory" FORCE)
|
||||||
|
SET(FLOWSHOP_BIN_DIR "${MOEO_BIN_DIR}/tutorial/examples/flowshop" CACHE PATH "Flowshop binary directory" FORCE)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
### 2) Where must cmake go now ?
|
### 2) Where must cmake go now ?
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
SUBDIRS(examples Wrapper)
|
SUBDIRS(examples Wrapper Lesson7)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
81
trunk/paradiseo-peo/tutorial/Lesson7/CMakeLists.txt
Normal file
81
trunk/paradiseo-peo/tutorial/Lesson7/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 0) Set the compiler and define targets to easily run the lessons
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
SET (CMAKE_CXX_COMPILER mpicxx)
|
||||||
|
|
||||||
|
ADD_CUSTOM_TARGET(install DEPENDS ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson7/param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson7/FlowShopEA.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson7/schema.xml)
|
||||||
|
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
TARGET install
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
ARGS -E copy_if_different
|
||||||
|
${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson7/FlowShopEA.param
|
||||||
|
${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson7)
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
TARGET install
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
ARGS -E copy_if_different
|
||||||
|
${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson7/param
|
||||||
|
${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson7)
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
TARGET install
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
ARGS -E copy_if_different
|
||||||
|
${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson7/schema.xml
|
||||||
|
${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson7)
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 1) Include the sources
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MOEO_SRC_DIR}/src ${FLOWSHOP_SRC_DIR} ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR})
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
IF(NOT WIN32 OR CYGWIN)
|
||||||
|
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${MOEO_BIN_DIR}/lib ${FLOWSHOP_BIN_DIR}/lib ${ParadisEO-PEO_BINARY_DIR}/lib ${TSP_BINARY_DIR}/lib)
|
||||||
|
ENDIF(NOT WIN32 OR CYGWIN)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 3) Define your target(s): just an executable here
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(example main.cpp)
|
||||||
|
ADD_DEPENDENCIES(example flowshop moeo peo rmc_mpi)
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 5) Link the librairies
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(example ${XML2_LIBS} flowshop moeo peo rmc_mpi eo eoutils)
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
49
trunk/paradiseo-peo/tutorial/Lesson7/FlowShopEA.param
Normal file
49
trunk/paradiseo-peo/tutorial/Lesson7/FlowShopEA.param
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
###### General ######
|
||||||
|
--help=0 # -h : Prints this message
|
||||||
|
--stopOnUnknownParam=1 # Stop if unkown param entered
|
||||||
|
# --seed=1183379758 # -S : Random number seed
|
||||||
|
|
||||||
|
###### Evolution Engine ######
|
||||||
|
--popSize=20 # -P : Population Size
|
||||||
|
--updateArch=1 # Update the archive at each gen.
|
||||||
|
--fitness=FastNonDominatedSorting # -F : Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased
|
||||||
|
--indicator=Epsilon # -i : Binary indicator for IndicatorBased: Epsilon, Hypervolume
|
||||||
|
--rho=1.1 # -r : reference point for the hypervolume indicator
|
||||||
|
--kappa=0.05 # -k : Scaling factor kappa for IndicatorBased
|
||||||
|
--diversity=Crowding # -D : Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding
|
||||||
|
--comparator=FitnessThenDiversity # -C : Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative
|
||||||
|
--selection=DetTour(2) # -S : Selection scheme: DetTour(T), StochTour(t) or Random
|
||||||
|
--replacement=Elitist # -R : Replacement scheme: Elitist, Environmental or Generational
|
||||||
|
--nbOffspring=100% # -O : Number of offspring (percentage or absolute)
|
||||||
|
|
||||||
|
###### Output ######
|
||||||
|
#--resDir=Res # Directory to store DISK outputs
|
||||||
|
--eraseDir=1 # erase files in dirName if any
|
||||||
|
--printPop=0 # Print sorted pop. every gen.
|
||||||
|
--storeArch=0 # Store the archive's objective vectors at each gen.
|
||||||
|
--contribution=0 # Store the contribution of the archive at each gen.
|
||||||
|
--entropy=0 # Store the entropy of the archive at each gen.
|
||||||
|
|
||||||
|
###### Persistence ######
|
||||||
|
--Load= # -L : A save file to restart from
|
||||||
|
--recomputeFitness=0 # -r : Recompute the fitness after re-loading the pop.?
|
||||||
|
--saveFrequency=0 # Save every F generation (0 = only final state, absent = never)
|
||||||
|
--saveTimeInterval=0 # Save every T seconds (0 or absent = never)
|
||||||
|
--status=./FlowShopEA.status # Status file
|
||||||
|
|
||||||
|
###### Representation ######
|
||||||
|
--BenchmarkFile=../../../../paradiseo-moeo/tutorial/examples/flowshop/benchs/020_10_01.txt # -B : Benchmark file name REQUIRED
|
||||||
|
|
||||||
|
###### Stopping criterion ######
|
||||||
|
--maxGen=100 # -G : Maximum number of generations (0 = none)
|
||||||
|
--maxEval=0 # -E : Maximum number of evaluations (0 = none)
|
||||||
|
--maxTime=0 # -T : Maximum running time in seconds (0 = none)
|
||||||
|
#--CtrlC=1 # -C : Terminate current generation upon Ctrl C (only available on Unix platforms)
|
||||||
|
|
||||||
|
###### Variation Operators ######
|
||||||
|
--crossRate=1 # Relative rate for the only crossover
|
||||||
|
--shiftMutRate=0.5 # Relative rate for shift mutation
|
||||||
|
--exchangeMutRate=0.5 # Relative rate for exchange mutation
|
||||||
|
--pCross=0.25 # -c : Probability of Crossover
|
||||||
|
--pMut=0.35 # -m : Probability of Mutation
|
||||||
|
|
||||||
35
trunk/paradiseo-peo/tutorial/Lesson7/main.cpp
Normal file
35
trunk/paradiseo-peo/tutorial/Lesson7/main.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include <peo>
|
||||||
|
#include <moeo>
|
||||||
|
#include <make_eval_FlowShop.h>
|
||||||
|
#include <make_genotype_FlowShop.h>
|
||||||
|
#include <make_op_FlowShop.h>
|
||||||
|
#include <do/make_pop.h>
|
||||||
|
#include <../tutorial/Lesson7/make_continue_moeo.h>
|
||||||
|
#include <../tutorial/Lesson7/make_checkpoint_moeo.h>
|
||||||
|
#include <../tutorial/Lesson7/make_ea_moeo.h>
|
||||||
|
#include <../tutorial/Lesson7/make_para_eval.h>
|
||||||
|
#include <FlowShop.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
peo :: init( argc,argv );
|
||||||
|
eoParser parser(argc, argv);
|
||||||
|
eoState state;
|
||||||
|
peoMoeoPopEval<FlowShop>& eval = do_make_para_eval(parser, state);
|
||||||
|
eoInit<FlowShop>& init = do_make_genotype(parser, state);
|
||||||
|
eoGenOp<FlowShop>& op = do_make_op(parser, state);
|
||||||
|
eoPop<FlowShop>& pop = do_make_pop(parser, state, init);
|
||||||
|
moeoArchive<FlowShop> arch;
|
||||||
|
eoContinue<FlowShop>& term = do_make_continue_moeo(parser, state, eval);
|
||||||
|
eoCheckPoint<FlowShop>& checkpoint = do_make_checkpoint_moeo(parser, state, eval, term, pop, arch);
|
||||||
|
eoAlgo<FlowShop>& algo = do_make_ea_moeo(parser, state, eval, checkpoint, op, arch);
|
||||||
|
peoWrapper parallelMOEO( algo, pop);
|
||||||
|
eval.setOwner(parallelMOEO);
|
||||||
|
peo :: run();
|
||||||
|
peo :: finalize();
|
||||||
|
if (getNodeRank()==1)
|
||||||
|
std::cout << "Final population :\n" << pop << std::endl;
|
||||||
|
}
|
||||||
201
trunk/paradiseo-peo/tutorial/Lesson7/make_checkpoint_moeo.h
Executable file
201
trunk/paradiseo-peo/tutorial/Lesson7/make_checkpoint_moeo.h
Executable file
|
|
@ -0,0 +1,201 @@
|
||||||
|
/*
|
||||||
|
* <make_checkpoint_moeo.h>
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef MAKE_CHECKPOINT_MOEO_H_
|
||||||
|
#define MAKE_CHECKPOINT_MOEO_H_
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <eoContinue.h>
|
||||||
|
#include <eoEvalFuncCounter.h>
|
||||||
|
#include <utils/checkpointing>
|
||||||
|
#include <utils/selectors.h>
|
||||||
|
#include <utils/eoParser.h>
|
||||||
|
#include <utils/eoState.h>
|
||||||
|
#include <metric/moeoContributionMetric.h>
|
||||||
|
#include <metric/moeoEntropyMetric.h>
|
||||||
|
#include <utils/moeoArchiveUpdater.h>
|
||||||
|
#include <utils/moeoArchiveObjectiveVectorSavingUpdater.h>
|
||||||
|
#include <utils/moeoBinaryMetricSavingUpdater.h>
|
||||||
|
|
||||||
|
bool testDirRes(std::string _dirName, bool _erase);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This functions allows to build an eoCheckPoint for multi-objective optimization from the parser (partly taken from make_checkpoint_pareto.h)
|
||||||
|
* @param _parser the parser
|
||||||
|
* @param _state to store allocated objects
|
||||||
|
* @param _eval the funtions evaluator
|
||||||
|
* @param _continue the stopping crietria
|
||||||
|
* @param _pop the population
|
||||||
|
* @param _archive the archive of non-dominated solutions
|
||||||
|
*/
|
||||||
|
template < class MOEOT >
|
||||||
|
eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoPopEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive)
|
||||||
|
{
|
||||||
|
eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue));
|
||||||
|
/* the objective vector type */
|
||||||
|
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// Counters
|
||||||
|
//////////////////
|
||||||
|
// is nb Eval to be used as counter?
|
||||||
|
//bool useEval = _parser.getORcreateParam(true, "useEval", "Use nb of eval. as counter (vs nb of gen.)", '\0', "Output").value();
|
||||||
|
// Create anyway a generation-counter parameter
|
||||||
|
eoValueParam<unsigned int> *generationCounter = new eoValueParam<unsigned int>(0, "Gen.");
|
||||||
|
// Create an incrementor (sub-class of eoUpdater).
|
||||||
|
eoIncrementor<unsigned int> & increment = _state.storeFunctor( new eoIncrementor<unsigned int>(generationCounter->value()) );
|
||||||
|
// Add it to the checkpoint
|
||||||
|
checkpoint.add(increment);
|
||||||
|
// dir for DISK output
|
||||||
|
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output").value();
|
||||||
|
// shoudl we empty it if exists
|
||||||
|
eoValueParam<bool>& eraseParam = _parser.getORcreateParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output");
|
||||||
|
bool dirOK = false; // not tested yet
|
||||||
|
|
||||||
|
// Dump of the whole population
|
||||||
|
//-----------------------------
|
||||||
|
bool printPop = _parser.getORcreateParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output").value();
|
||||||
|
eoSortedPopStat<MOEOT> * popStat;
|
||||||
|
if ( printPop ) // we do want pop dump
|
||||||
|
{
|
||||||
|
popStat = & _state.storeFunctor(new eoSortedPopStat<MOEOT>);
|
||||||
|
checkpoint.add(*popStat);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// State savers
|
||||||
|
//////////////////////////////
|
||||||
|
// feed the state to state savers
|
||||||
|
// save state every N generation
|
||||||
|
eoValueParam<unsigned int>& saveFrequencyParam = _parser.createParam((unsigned int)(0), "saveFrequency", "Save every F generation (0 = only final state, absent = never)", '\0', "Persistence" );
|
||||||
|
if (_parser.isItThere(saveFrequencyParam))
|
||||||
|
{
|
||||||
|
// first make sure dirName is OK
|
||||||
|
if (! dirOK )
|
||||||
|
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||||
|
unsigned int freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
|
||||||
|
#ifdef _MSVC
|
||||||
|
std::string stmp = dirName + "\generations";
|
||||||
|
#else
|
||||||
|
std::string stmp = dirName + "/generations";
|
||||||
|
#endif
|
||||||
|
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
|
||||||
|
_state.storeFunctor(stateSaver1);
|
||||||
|
checkpoint.add(*stateSaver1);
|
||||||
|
}
|
||||||
|
// save state every T seconds
|
||||||
|
eoValueParam<unsigned int>& saveTimeIntervalParam = _parser.getORcreateParam((unsigned int)(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" );
|
||||||
|
if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
|
||||||
|
{
|
||||||
|
// first make sure dirName is OK
|
||||||
|
if (! dirOK )
|
||||||
|
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||||
|
#ifdef _MSVC
|
||||||
|
std::string stmp = dirName + "\time";
|
||||||
|
#else
|
||||||
|
std::string stmp = dirName + "/time";
|
||||||
|
#endif
|
||||||
|
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
|
||||||
|
_state.storeFunctor(stateSaver2);
|
||||||
|
checkpoint.add(*stateSaver2);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// Archive
|
||||||
|
//////////////////
|
||||||
|
// update the archive every generation
|
||||||
|
bool updateArch = _parser.getORcreateParam(true, "updateArch", "Update the archive at each gen.", '\0', "Evolution Engine").value();
|
||||||
|
if (updateArch)
|
||||||
|
{
|
||||||
|
moeoArchiveUpdater < MOEOT > * updater = new moeoArchiveUpdater < MOEOT > (_archive, _pop);
|
||||||
|
_state.storeFunctor(updater);
|
||||||
|
checkpoint.add(*updater);
|
||||||
|
}
|
||||||
|
// store the objective vectors contained in the archive every generation
|
||||||
|
bool storeArch = _parser.getORcreateParam(false, "storeArch", "Store the archive's objective vectors at each gen.", '\0', "Output").value();
|
||||||
|
if (storeArch)
|
||||||
|
{
|
||||||
|
if (! dirOK )
|
||||||
|
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||||
|
#ifdef _MSVC
|
||||||
|
std::string stmp = dirName + "\arch";
|
||||||
|
#else
|
||||||
|
std::string stmp = dirName + "/arch";
|
||||||
|
#endif
|
||||||
|
moeoArchiveObjectiveVectorSavingUpdater < MOEOT > * save_updater = new moeoArchiveObjectiveVectorSavingUpdater < MOEOT > (_archive, stmp);
|
||||||
|
_state.storeFunctor(save_updater);
|
||||||
|
checkpoint.add(*save_updater);
|
||||||
|
}
|
||||||
|
// store the contribution of the non-dominated solutions
|
||||||
|
bool cont = _parser.getORcreateParam(false, "contribution", "Store the contribution of the archive at each gen.", '\0', "Output").value();
|
||||||
|
if (cont)
|
||||||
|
{
|
||||||
|
if (! dirOK )
|
||||||
|
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||||
|
#ifdef _MSVC
|
||||||
|
std::string stmp = dirName + "\contribution";
|
||||||
|
#else
|
||||||
|
std::string stmp = dirName + "/contribution";
|
||||||
|
#endif
|
||||||
|
moeoContributionMetric < ObjectiveVector > * contribution = new moeoContributionMetric < ObjectiveVector >;
|
||||||
|
moeoBinaryMetricSavingUpdater < MOEOT > * contribution_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*contribution, _archive, stmp);
|
||||||
|
_state.storeFunctor(contribution_updater);
|
||||||
|
checkpoint.add(*contribution_updater);
|
||||||
|
}
|
||||||
|
// store the entropy of the non-dominated solutions
|
||||||
|
bool ent = _parser.getORcreateParam(false, "entropy", "Store the entropy of the archive at each gen.", '\0', "Output").value();
|
||||||
|
if (ent)
|
||||||
|
{
|
||||||
|
if (! dirOK )
|
||||||
|
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||||
|
#ifdef _MSVC
|
||||||
|
std::string stmp = dirName + "\entropy";
|
||||||
|
#else
|
||||||
|
std::string stmp = dirName + "/entropy";
|
||||||
|
#endif
|
||||||
|
moeoEntropyMetric < ObjectiveVector > * entropy = new moeoEntropyMetric < ObjectiveVector >;
|
||||||
|
moeoBinaryMetricSavingUpdater < MOEOT > * entropy_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*entropy, _archive, stmp);
|
||||||
|
_state.storeFunctor(entropy_updater);
|
||||||
|
checkpoint.add(*entropy_updater);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and that's it for the (control and) output
|
||||||
|
return checkpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*MAKE_CHECKPOINT_MOEO_H_*/
|
||||||
130
trunk/paradiseo-peo/tutorial/Lesson7/make_continue_moeo.h
Executable file
130
trunk/paradiseo-peo/tutorial/Lesson7/make_continue_moeo.h
Executable file
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
* <make_continue_moeo.h>
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef MAKE_CONTINUE_MOEO_H_
|
||||||
|
#define MAKE_CONTINUE_MOEO_H_
|
||||||
|
#include <eoCombinedContinue.h>
|
||||||
|
#include <eoGenContinue.h>
|
||||||
|
#include <eoEvalContinue.h>
|
||||||
|
#include <eoFitContinue.h>
|
||||||
|
#include <eoTimeContinue.h>
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
#include <eoCtrlCContinue.h>
|
||||||
|
#endif
|
||||||
|
#include <utils/eoParser.h>
|
||||||
|
#include <utils/eoState.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function
|
||||||
|
* @param _combined the eoCombinedContinue object
|
||||||
|
* @param _cont the eoContinue to add
|
||||||
|
*/
|
||||||
|
template <class MOEOT>
|
||||||
|
eoCombinedContinue<MOEOT> * make_combinedContinue(eoCombinedContinue<MOEOT> *_combined, eoContinue<MOEOT> *_cont)
|
||||||
|
{
|
||||||
|
if (_combined) // already exists
|
||||||
|
_combined->add(*_cont);
|
||||||
|
else
|
||||||
|
_combined = new eoCombinedContinue<MOEOT>(*_cont);
|
||||||
|
return _combined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This functions allows to build a eoContinue for multi-objective optimization from the parser (partly taken from make_continue_pareto.h)
|
||||||
|
* @param _parser the parser
|
||||||
|
* @param _state to store allocated objects
|
||||||
|
* @param _eval the funtions evaluator
|
||||||
|
*/
|
||||||
|
template <class MOEOT>
|
||||||
|
eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoPopEvalFunc<MOEOT> & _eval)
|
||||||
|
{
|
||||||
|
// the combined continue - to be filled
|
||||||
|
eoCombinedContinue<MOEOT> *continuator = NULL;
|
||||||
|
// First the eoGenContinue - need a default value so you can run blind
|
||||||
|
// but we also need to be able to avoid it <--> 0
|
||||||
|
eoValueParam<unsigned int>& maxGenParam = _parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
|
||||||
|
if (maxGenParam.value()) // positive: -> define and store
|
||||||
|
{
|
||||||
|
eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
|
||||||
|
_state.storeFunctor(genCont);
|
||||||
|
// and "add" to combined
|
||||||
|
continuator = make_combinedContinue<MOEOT>(continuator, genCont);
|
||||||
|
}
|
||||||
|
// maxEval
|
||||||
|
eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)(0), "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
|
||||||
|
/* if (maxEvalParam.value())
|
||||||
|
{
|
||||||
|
eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value());
|
||||||
|
_state.storeFunctor(evalCont);
|
||||||
|
// and "add" to combined
|
||||||
|
continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
|
||||||
|
}*/
|
||||||
|
// maxTime
|
||||||
|
eoValueParam<unsigned long>& maxTimeParam = _parser.getORcreateParam((unsigned long)(0), "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion");
|
||||||
|
if (maxTimeParam.value()) // positive: -> define and store
|
||||||
|
{
|
||||||
|
eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());
|
||||||
|
_state.storeFunctor(timeCont);
|
||||||
|
// and "add" to combined
|
||||||
|
continuator = make_combinedContinue<MOEOT>(continuator, timeCont);
|
||||||
|
}
|
||||||
|
// CtrlC
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
// the CtrlC interception (Linux only I'm afraid)
|
||||||
|
eoCtrlCContinue<MOEOT> *ctrlCCont;
|
||||||
|
eoValueParam<bool>& ctrlCParam = _parser.createParam(true, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
|
||||||
|
if (_parser.isItThere(ctrlCParam))
|
||||||
|
{
|
||||||
|
ctrlCCont = new eoCtrlCContinue<MOEOT>;
|
||||||
|
// store
|
||||||
|
_state.storeFunctor(ctrlCCont);
|
||||||
|
// add to combinedContinue
|
||||||
|
continuator = make_combinedContinue<MOEOT>(continuator, ctrlCCont);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// now check that there is at least one!
|
||||||
|
if (!continuator)
|
||||||
|
throw std::runtime_error("You MUST provide a stopping criterion");
|
||||||
|
// OK, it's there: store in the eoState
|
||||||
|
_state.storeFunctor(continuator);
|
||||||
|
// and return
|
||||||
|
return *continuator;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*MAKE_CONTINUE_MOEO_H_*/
|
||||||
297
trunk/paradiseo-peo/tutorial/Lesson7/make_ea_moeo.h
Executable file
297
trunk/paradiseo-peo/tutorial/Lesson7/make_ea_moeo.h
Executable file
|
|
@ -0,0 +1,297 @@
|
||||||
|
/*
|
||||||
|
* <make_ea_moeo.h>
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef MAKE_EA_MOEO_H_
|
||||||
|
#define MAKE_EA_MOEO_H_
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <eoContinue.h>
|
||||||
|
#include <eoEvalFunc.h>
|
||||||
|
#include <eoGeneralBreeder.h>
|
||||||
|
#include <eoGenOp.h>
|
||||||
|
#include <utils/eoParser.h>
|
||||||
|
#include <utils/eoState.h>
|
||||||
|
|
||||||
|
#include <algo/moeoEA.h>
|
||||||
|
#include <algo/moeoEasyEA.h>
|
||||||
|
#include <archive/moeoArchive.h>
|
||||||
|
#include <comparator/moeoAggregativeComparator.h>
|
||||||
|
#include <comparator/moeoComparator.h>
|
||||||
|
#include <comparator/moeoDiversityThenFitnessComparator.h>
|
||||||
|
#include <comparator/moeoFitnessThenDiversityComparator.h>
|
||||||
|
#include <diversity/moeoDiversityAssignment.h>
|
||||||
|
#include <diversity/moeoDummyDiversityAssignment.h>
|
||||||
|
#include <diversity/moeoFrontByFrontCrowdingDiversityAssignment.h>
|
||||||
|
#include <diversity/moeoFrontByFrontSharingDiversityAssignment.h>
|
||||||
|
#include <fitness/moeoDummyFitnessAssignment.h>
|
||||||
|
#include <fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h>
|
||||||
|
#include <fitness/moeoFastNonDominatedSortingFitnessAssignment.h>
|
||||||
|
#include <fitness/moeoFitnessAssignment.h>
|
||||||
|
#include <metric/moeoAdditiveEpsilonBinaryMetric.h>
|
||||||
|
#include <metric/moeoHypervolumeBinaryMetric.h>
|
||||||
|
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
|
||||||
|
#include <replacement/moeoElitistReplacement.h>
|
||||||
|
#include <replacement/moeoEnvironmentalReplacement.h>
|
||||||
|
#include <replacement/moeoGenerationalReplacement.h>
|
||||||
|
#include <replacement/moeoReplacement.h>
|
||||||
|
#include <selection/moeoDetTournamentSelect.h>
|
||||||
|
#include <selection/moeoRandomSelect.h>
|
||||||
|
#include <selection/moeoStochTournamentSelect.h>
|
||||||
|
#include <selection/moeoSelectOne.h>
|
||||||
|
#include <selection/moeoSelectors.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This functions allows to build a moeoEA from the parser
|
||||||
|
* @param _parser the parser
|
||||||
|
* @param _state to store allocated objects
|
||||||
|
* @param _eval the funtions evaluator
|
||||||
|
* @param _continue the stopping crietria
|
||||||
|
* @param _op the variation operators
|
||||||
|
* @param _archive the archive of non-dominated solutions
|
||||||
|
*/
|
||||||
|
template < class MOEOT >
|
||||||
|
moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoPopEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* the objective vector type */
|
||||||
|
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||||
|
|
||||||
|
|
||||||
|
/* the fitness assignment strategy */
|
||||||
|
std::string & fitnessParam = _parser.createParam(std::string("FastNonDominatedSorting"), "fitness",
|
||||||
|
"Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased", 'F',
|
||||||
|
"Evolution Engine").value();
|
||||||
|
std::string & indicatorParam = _parser.createParam(std::string("Epsilon"), "indicator",
|
||||||
|
"Binary indicator for IndicatorBased: Epsilon, Hypervolume", 'i',
|
||||||
|
"Evolution Engine").value();
|
||||||
|
double rho = _parser.createParam(1.1, "rho", "reference point for the hypervolume indicator", 'r',
|
||||||
|
"Evolution Engine").value();
|
||||||
|
double kappa = _parser.createParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased", 'k',
|
||||||
|
"Evolution Engine").value();
|
||||||
|
moeoFitnessAssignment < MOEOT > * fitnessAssignment;
|
||||||
|
if (fitnessParam == std::string("Dummy"))
|
||||||
|
{
|
||||||
|
fitnessAssignment = new moeoDummyFitnessAssignment < MOEOT> ();
|
||||||
|
}
|
||||||
|
else if (fitnessParam == std::string("FastNonDominatedSorting"))
|
||||||
|
{
|
||||||
|
fitnessAssignment = new moeoFastNonDominatedSortingFitnessAssignment < MOEOT> ();
|
||||||
|
}
|
||||||
|
else if (fitnessParam == std::string("IndicatorBased"))
|
||||||
|
{
|
||||||
|
// metric
|
||||||
|
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
|
||||||
|
if (indicatorParam == std::string("Epsilon"))
|
||||||
|
{
|
||||||
|
metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
|
||||||
|
}
|
||||||
|
else if (indicatorParam == std::string("Hypervolume"))
|
||||||
|
{
|
||||||
|
metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam;
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
fitnessAssignment = new moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > (*metric, kappa);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
_state.storeFunctor(fitnessAssignment);
|
||||||
|
|
||||||
|
|
||||||
|
/* the diversity assignment strategy */
|
||||||
|
eoValueParam<eoParamParamType> & diversityParam = _parser.createParam(eoParamParamType("Dummy"), "diversity",
|
||||||
|
"Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding", 'D', "Evolution Engine");
|
||||||
|
eoParamParamType & diversityParamValue = diversityParam.value();
|
||||||
|
moeoDiversityAssignment < MOEOT > * diversityAssignment;
|
||||||
|
if (diversityParamValue.first == std::string("Dummy"))
|
||||||
|
{
|
||||||
|
diversityAssignment = new moeoDummyDiversityAssignment < MOEOT> ();
|
||||||
|
}
|
||||||
|
else if (diversityParamValue.first == std::string("Sharing"))
|
||||||
|
{
|
||||||
|
double nicheSize;
|
||||||
|
if (!diversityParamValue.second.size()) // no parameter added
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING, no niche size given for Sharing, using 0.5" << std::endl;
|
||||||
|
nicheSize = 0.5;
|
||||||
|
diversityParamValue.second.push_back(std::string("0.5"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nicheSize = atoi(diversityParamValue.second[0].c_str());
|
||||||
|
}
|
||||||
|
diversityAssignment = new moeoFrontByFrontSharingDiversityAssignment < MOEOT> (nicheSize);
|
||||||
|
}
|
||||||
|
else if (diversityParamValue.first == std::string("Crowding"))
|
||||||
|
{
|
||||||
|
diversityAssignment = new moeoFrontByFrontCrowdingDiversityAssignment < MOEOT> ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string stmp = std::string("Invalid diversity assignment strategy: ") + diversityParamValue.first;
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
_state.storeFunctor(diversityAssignment);
|
||||||
|
|
||||||
|
|
||||||
|
/* the comparator strategy */
|
||||||
|
std::string & comparatorParam = _parser.createParam(std::string("FitnessThenDiversity"), "comparator",
|
||||||
|
"Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative", 'C', "Evolution Engine").value();
|
||||||
|
moeoComparator < MOEOT > * comparator;
|
||||||
|
if (comparatorParam == std::string("FitnessThenDiversity"))
|
||||||
|
{
|
||||||
|
comparator = new moeoFitnessThenDiversityComparator < MOEOT> ();
|
||||||
|
}
|
||||||
|
else if (comparatorParam == std::string("DiversityThenFitness"))
|
||||||
|
{
|
||||||
|
comparator = new moeoDiversityThenFitnessComparator < MOEOT> ();
|
||||||
|
}
|
||||||
|
else if (comparatorParam == std::string("Aggregative"))
|
||||||
|
{
|
||||||
|
comparator = new moeoAggregativeComparator < MOEOT> ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string stmp = std::string("Invalid comparator strategy: ") + comparatorParam;
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
_state.storeFunctor(comparator);
|
||||||
|
|
||||||
|
|
||||||
|
/* the selection strategy */
|
||||||
|
eoValueParam < eoParamParamType > & selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection",
|
||||||
|
"Selection scheme: DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine");
|
||||||
|
eoParamParamType & ppSelect = selectionParam.value();
|
||||||
|
moeoSelectOne < MOEOT > * select;
|
||||||
|
if (ppSelect.first == std::string("DetTour"))
|
||||||
|
{
|
||||||
|
unsigned int tSize;
|
||||||
|
if (!ppSelect.second.size()) // no parameter added
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
|
||||||
|
tSize = 2;
|
||||||
|
// put back 2 in parameter for consistency (and status file)
|
||||||
|
ppSelect.second.push_back(std::string("2"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as DetTour(T)
|
||||||
|
{
|
||||||
|
tSize = atoi(ppSelect.second[0].c_str());
|
||||||
|
}
|
||||||
|
select = new moeoDetTournamentSelect < MOEOT > (*comparator, tSize);
|
||||||
|
}
|
||||||
|
else if (ppSelect.first == std::string("StochTour"))
|
||||||
|
{
|
||||||
|
double tRate;
|
||||||
|
if (!ppSelect.second.size()) // no parameter added
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
|
||||||
|
tRate = 1;
|
||||||
|
// put back 1 in parameter for consistency (and status file)
|
||||||
|
ppSelect.second.push_back(std::string("1"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as StochTour(T)
|
||||||
|
{
|
||||||
|
tRate = atof(ppSelect.second[0].c_str());
|
||||||
|
}
|
||||||
|
select = new moeoStochTournamentSelect < MOEOT > (*comparator, tRate);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else if (ppSelect.first == string("Roulette"))
|
||||||
|
{
|
||||||
|
// TO DO !
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
else if (ppSelect.first == std::string("Random"))
|
||||||
|
{
|
||||||
|
select = new moeoRandomSelect <MOEOT > ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string stmp = std::string("Invalid selection strategy: ") + ppSelect.first;
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
_state.storeFunctor(select);
|
||||||
|
|
||||||
|
|
||||||
|
/* the replacement strategy */
|
||||||
|
std::string & replacementParam = _parser.createParam(std::string("Elitist"), "replacement",
|
||||||
|
"Replacement scheme: Elitist, Environmental or Generational", 'R', "Evolution Engine").value();
|
||||||
|
moeoReplacement < MOEOT > * replace;
|
||||||
|
if (replacementParam == std::string("Elitist"))
|
||||||
|
{
|
||||||
|
replace = new moeoElitistReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
|
||||||
|
}
|
||||||
|
else if (replacementParam == std::string("Environmental"))
|
||||||
|
{
|
||||||
|
replace = new moeoEnvironmentalReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
|
||||||
|
}
|
||||||
|
else if (replacementParam == std::string("Generational"))
|
||||||
|
{
|
||||||
|
replace = new moeoGenerationalReplacement < MOEOT> ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string stmp = std::string("Invalid replacement strategy: ") + replacementParam;
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
_state.storeFunctor(replace);
|
||||||
|
|
||||||
|
|
||||||
|
/* the number of offspring */
|
||||||
|
eoValueParam < eoHowMany > & offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring",
|
||||||
|
"Number of offspring (percentage or absolute)", 'O', "Evolution Engine");
|
||||||
|
|
||||||
|
|
||||||
|
// the general breeder
|
||||||
|
eoGeneralBreeder < MOEOT > * breed = new eoGeneralBreeder < MOEOT > (*select, _op, offspringRateParam.value());
|
||||||
|
_state.storeFunctor(breed);
|
||||||
|
// the eoEasyEA
|
||||||
|
moeoEA < MOEOT > * algo = new moeoEasyEA < MOEOT > (_continue, _eval, *breed, *replace, *fitnessAssignment, *diversityAssignment);
|
||||||
|
_state.storeFunctor(algo);
|
||||||
|
return *algo;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*MAKE_EA_MOEO_H_*/
|
||||||
25
trunk/paradiseo-peo/tutorial/Lesson7/make_para_eval.h
Normal file
25
trunk/paradiseo-peo/tutorial/Lesson7/make_para_eval.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <peo>
|
||||||
|
#include <es.h>
|
||||||
|
#include <moeo>
|
||||||
|
|
||||||
|
peoMoeoPopEval<FlowShop> & do_make_para_eval(eoParser& _parser, eoState& _state)
|
||||||
|
{
|
||||||
|
std::string benchmarkFileName = _parser.getORcreateParam(std::string(), "BenchmarkFile", "Benchmark file name (benchmarks are available at www.lifl.fr/~liefooga/benchmarks)", 'B',"Representation", true).value();
|
||||||
|
if (benchmarkFileName == "")
|
||||||
|
{
|
||||||
|
std::string stmp = "*** Missing name of the benchmark file\n";
|
||||||
|
stmp += " Type '-B=the_benchmark_file_name' or '--BenchmarkFile=the_benchmark_file_name'\n";
|
||||||
|
stmp += " Benchmarks files are available at www.lifl.fr/~liefooga/benchmarks";
|
||||||
|
throw std::runtime_error(stmp.c_str());
|
||||||
|
}
|
||||||
|
FlowShopBenchmarkParser fParser(benchmarkFileName);
|
||||||
|
unsigned int M = fParser.getM();
|
||||||
|
unsigned int N = fParser.getN();
|
||||||
|
std::vector< std::vector<unsigned int> > p = fParser.getP();
|
||||||
|
std::vector<unsigned int> d = fParser.getD();
|
||||||
|
|
||||||
|
FlowShopEval* plainEval = new FlowShopEval(M, N, p, d);
|
||||||
|
peoMoeoPopEval<FlowShop>* eval = new peoMoeoPopEval<FlowShop> (* plainEval);
|
||||||
|
_state.storeFunctor(eval);
|
||||||
|
return *eval;
|
||||||
|
}
|
||||||
12
trunk/paradiseo-peo/tutorial/Lesson7/param
Normal file
12
trunk/paradiseo-peo/tutorial/Lesson7/param
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
## miscallenous parameters
|
||||||
|
|
||||||
|
--debug=false
|
||||||
|
|
||||||
|
## deployment schema
|
||||||
|
|
||||||
|
--schema=schema.xml
|
||||||
|
|
||||||
|
## parameters
|
||||||
|
|
||||||
|
--inst=../examples/tsp/benchs/eil101.tsp
|
||||||
|
|
||||||
15
trunk/paradiseo-peo/tutorial/Lesson7/schema.xml
Normal file
15
trunk/paradiseo-peo/tutorial/Lesson7/schema.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<schema>
|
||||||
|
<group scheduler="0">
|
||||||
|
<node name="0" num_workers="0">
|
||||||
|
</node>
|
||||||
|
<node name="1" num_workers="0">
|
||||||
|
<runner>1</runner>
|
||||||
|
</node>
|
||||||
|
<node name="2" num_workers="1">
|
||||||
|
</node>
|
||||||
|
<node name="3" num_workers="1">
|
||||||
|
</node>
|
||||||
|
</group>
|
||||||
|
</schema>
|
||||||
|
|
@ -29,7 +29,7 @@ ADD_CUSTOM_COMMAND(
|
||||||
### 1) Include the sources
|
### 1) Include the sources
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR})
|
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MOEO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR})
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_D
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
IF(NOT WIN32 OR CYGWIN)
|
IF(NOT WIN32 OR CYGWIN)
|
||||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-PEO_BINARY_DIR}/lib ${TSP_BINARY_DIR}/lib)
|
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${MOEO_BIN_DIR}/lib ${ParadisEO-PEO_BINARY_DIR}/lib ${TSP_BINARY_DIR}/lib)
|
||||||
ENDIF(NOT WIN32 OR CYGWIN)
|
ENDIF(NOT WIN32 OR CYGWIN)
|
||||||
|
|
||||||
# especially for Visual Studio
|
# especially for Visual Studio
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue