Migration from SVN

This commit is contained in:
quemy 2012-08-30 11:30:11 +02:00
commit 8cd56f37db
45 changed files with 0 additions and 4096888 deletions

View file

@ -0,0 +1,22 @@
######################################################################################
### 0) Include MO sources
######################################################################################
include_directories(${MO_SRC_DIR}/src)
######################################################################################
### 1) Define flowshop paths
######################################################################################
set(FLOWSHOP_SRC_DIR ${MOEO_SRC_DIR}/tutorial/examples/flowshop)
set(FLOWSHOP_BINARY_DIR ${MOEO_BIN_DIR}/tutorial/examples/flowshop)
######################################################################################
### 2) Include lessons subdirectories
######################################################################################
add_subdirectory(examples)
add_subdirectory(Lesson1)
add_subdirectory(Lesson2)
add_subdirectory(Lesson3)
add_subdirectory(Lesson4)

View file

@ -0,0 +1,23 @@
# Lesson 1
######################################################################################
### 0) Define files
######################################################################################
set(files Sch1)
######################################################################################
### 1) Create the lesson
######################################################################################
add_lesson(moeo Lesson1 "${files}")
######################################################################################
### 2) Include dependencies
######################################################################################
include_directories(${EO_SRC_DIR}/src
${EO_SRC_DIR}/utils
${MOEO_SRC_DIR}/src)

View file

@ -0,0 +1,140 @@
/*
* <Sch1.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Abdelhakim Deneche, 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 <stdio.h>
#include <moeo>
#include <es/eoRealInitBounded.h>
#include <es/eoRealOp.h>
using namespace std;
// the moeoObjectiveVectorTraits : minimizing 2 objectives
class Sch1ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
// objective vector of real values
typedef moeoRealObjectiveVector < Sch1ObjectiveVectorTraits > Sch1ObjectiveVector;
// multi-objective evolving object for the Sch1 problem
class Sch1 : public moeoRealVector < Sch1ObjectiveVector >
{
public:
Sch1() : moeoRealVector < Sch1ObjectiveVector > (1)
{}
};
// evaluation of objective functions
class Sch1Eval : public moeoEvalFunc < Sch1 >
{
public:
void operator () (Sch1 & _sch1)
{
if (_sch1.invalidObjectiveVector())
{
Sch1ObjectiveVector objVec;
double x = _sch1[0];
objVec[0] = x * x;
objVec[1] = (x - 2.0) * (x - 2.0);
_sch1.objectiveVector(objVec);
}
}
};
// main
int main (int argc, char *argv[])
{
eoParser parser(argc, argv); // for user-parameter reading
eoState state; // to keep all things allocated
// parameters
unsigned int POP_SIZE = parser.createParam((unsigned int)(100), "popSize", "Population size",'P',"Param").value();
unsigned int MAX_GEN = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations",'G',"Param").value();
double M_EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value();
double P_CROSS = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value();
double P_MUT = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value();
// objective functions evaluation
Sch1Eval eval;
// crossover and mutation
eoQuadCloneOp < Sch1 > xover;
eoUniformMutation < Sch1 > mutation (M_EPSILON);
// generate initial population
eoRealVectorBounds bounds (1, 0.0, 2.0); // [0, 2]
eoRealInitBounded < Sch1 > init (bounds);
eoPop < Sch1 > pop (POP_SIZE, init);
// build NSGA-II
moeoNSGAII < Sch1 > nsgaII (MAX_GEN, eval, xover, P_CROSS, mutation, P_MUT);
// help ?
make_help(parser);
// run the algo
nsgaII (pop);
// extract first front of the final population using an moeoArchive (this is the output of nsgaII)
moeoUnboundedArchive < Sch1 > arch;
arch(pop);
// printing of the final archive
cout << "Final Archive" << endl;
arch.sortedPrintOn (cout);
cout << endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,14 @@
###### General ######
# --help=0 # -h : Prints this message
# --stopOnUnknownParam=1 # Stop if unkown param entered
###### Param ######
--popSize=100 # -P : Population size
--maxGen=100 # -G : Maximum number of generations
--mutEpsilon=0.01 # -e : epsilon for mutation
--pCross=0.25 # -C : Crossover probability
--pMut=0.35 # -M : Mutation probability
###### Persistence ######
# --status=./Sch1.status # Status file

View file

@ -0,0 +1,23 @@
# Lesson 2
######################################################################################
### 0) Define files
######################################################################################
set(files FlowShopEA)
######################################################################################
### 1) Create the lesson
######################################################################################
add_lesson(moeo Lesson2 "${files}")
######################################################################################
### 2) Include dependencies
######################################################################################
include_directories(${EO_SRC_DIR}/src)
include_directories(${MOEO_SRC_DIR}/src)
include_directories(${FLOWSHOP_SRC_DIR})
target_link_libraries(FlowShopEA moeo flowshop eo eoutils)

View file

@ -0,0 +1,139 @@
/*
* <FlowShopEA.cpp>
* 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
*
*/
//-----------------------------------------------------------------------------
// 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>
using namespace std;
int main(int argc, char* argv[])
{
try
{
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);
// checkpointing
eoCheckPoint<FlowShop> checkpoint(term);
moeoArchiveUpdater < FlowShop > updater(arch, pop);
checkpoint.add(updater);
// fitness assignment
moeoDominanceDepthFitnessAssignment <FlowShop> fitnessAssignment;
// diversity preservation
moeoFrontByFrontCrowdingDiversityAssignment <FlowShop> diversityAssignment;
// comparator
moeoFitnessThenDiversityComparator <FlowShop> comparator;
// selection scheme
moeoDetTournamentSelect <FlowShop> select(comparator, 2);
// replacement scheme
moeoElitistReplacement <FlowShop> replace(fitnessAssignment, diversityAssignment, comparator);
// breeder
eoGeneralBreeder <FlowShop> breed(select, op);
// algorithm
moeoEasyEA <FlowShop> algo (checkpoint, eval, breed, replace, fitnessAssignment, diversityAssignment);
/*** Go ! ***/
// help ?
make_help(parser);
// first evalution (for printing)
apply<FlowShop>(eval, 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;
}

View file

@ -0,0 +1,21 @@
###### General ######
--help=0 # -h : Prints this message
--stopOnUnknownParam=1 # Stop if unkown param entered
# --seed=1203083493 # -S : Random number seed
###### Evolution Engine ######
--popSize=100 # -P : Population Size
###### Representation ######
--BenchmarkFile=../examples/flowshop/benchs/020_10_01.txt # -B : Benchmark file name REQUIRED
###### Stopping criterion ######
--maxGen=100 # -G : Maximum number of generations
###### 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

View file

@ -0,0 +1,23 @@
# Lesson 3
######################################################################################
### 0) Define files
######################################################################################
set(files FlowShopEA2)
######################################################################################
### 1) Create the lesson
######################################################################################
add_lesson(moeo Lesson3 "${files}")
######################################################################################
### 2) Include dependencies
######################################################################################
include_directories(${EO_SRC_DIR}/src)
include_directories(${MOEO_SRC_DIR}/src)
include_directories(${FLOWSHOP_SRC_DIR})
target_link_libraries(FlowShopEA2 moeo flowshop eo eoutils)

View file

@ -0,0 +1,132 @@
/*
* <FlowShopEA.cpp>
* 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
*
*/
//-----------------------------------------------------------------------------
// 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>
// the stopping criterion
#include <do/make_continue_moeo.h>
// outputs (stats, population dumps, ...)
#include <do/make_checkpoint_moeo.h>
// evolution engine (selection and replacement)
#include <do/make_ea_moeo.h>
// simple call to the algo
#include <do/make_run.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>
using namespace std;
int main(int argc, char* argv[])
{
try
{
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
eoContinue<FlowShop>& term = do_make_continue_moeo(parser, state, eval);
// output
eoCheckPoint<FlowShop>& checkpoint = do_make_checkpoint_moeo(parser, state, eval, term, pop, arch);
// algorithm
eoAlgo<FlowShop>& algo = do_make_ea_moeo(parser, state, eval, checkpoint, op, arch);
/*** Go ! ***/
// help ?
make_help(parser);
// first evalution (for printing)
apply<FlowShop>(eval, 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;
}

View 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=100 # -P : Population Size
--updateArch=1 # Update the archive at each gen.
--fitness=IndicatorBased # -F : Fitness assignment scheme: Dummy, DomDepth 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=../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

View file

@ -0,0 +1,23 @@
# Lesson 4
######################################################################################
### 0) Define files
######################################################################################
set(files FlowShopDMLS)
######################################################################################
### 1) Create the lesson
######################################################################################
add_lesson(moeo Lesson4 "${files}")
include_directories(${EO_SRC_DIR}/src)
include_directories(${MOEO_SRC_DIR}/src)
include_directories(${FLOWSHOP_SRC_DIR})
######################################################################################
### 2) Include dependencies
######################################################################################
target_link_libraries(FlowShopDMLS moeo flowshop eo eoutils)

View file

@ -0,0 +1,144 @@
/*
* <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
unsigned int maxGen = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of gen.",'G',"Stopping criterion").value();
unsigned int nhSize = parser.createParam((unsigned int)(20), "nhSize", "neighborhood size",'G',"Evolution Engine").value();
/*** 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 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
//Continuator
eoGenContinue<FlowShop> term(maxGen);
// checkpointing
eoCheckPoint<FlowShop> checkpoint(term);
moeoArchiveUpdater < FlowShop > updater(arch, pop);
checkpoint.add(updater);
//neighborhood
moOrderNeighborhood<Neighbor> neighborhood((nhSize-1) * (nhSize-1));
//neighbor Evaluation function
moeoFullEvalByCopy<Neighbor> moEval(eval);
//Selection in the archive
moeoNumberUnvisitedSelect<FlowShop> select(1);
//explorer
moeoFirstImprovingNeighborhoodExplorer<Neighbor> explor(neighborhood, moEval);
//DMLS(1.1>)
moeoUnifiedDominanceBasedLS<Neighbor> algo(checkpoint, eval, arch, explor, select);
/*** Go ! ***/
// help ?
make_help(parser);
// first evalution (for printing)
apply<FlowShop>(eval, pop);
for(unsigned int i=0; i<pop.size(); i++)
pop[i].fitness(0);
// printing of the initial population
cout << "Initial Population\n";
pop.sortedPrintOn(cout);
cout << endl;
// run the algo
algo(pop);
// printing of the final archive
cout << "Final Archive\n";
arch.sortedPrintOn(cout);
cout << endl;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,20 @@
###### General ######
# --help=0 # -h : Prints this message
# --stopOnUnknownParam=1 # Stop if unkown param entered
# --seed=1275660123 # -S : Random number seed
###### Evolution Engine ######
# --nhSize=20 # -G : neighborhood size
# --popSize=20 # -P : Population Size
###### Persistence ######
# --Load= # -L : A save file to restart from
# --recomputeFitness=0 # -r : Recompute the fitness after re-loading the pop.?
# --status=./FlowShopDMLS.status # Status file
###### Representation ######
# --BenchmarkFile=../examples/flowshop/benchs/020_20_01.txt # -B : Benchmark file name
###### Stopping criterion ######
# --maxGen=100 # -G : Maximum number of gen.

View file

@ -0,0 +1,6 @@
######################################################################################
### 0) Include subdirectories
######################################################################################
add_subdirectory(flowshop)

View file

@ -0,0 +1,49 @@
######################################################################################
### 0) Include lessons subdirectories
######################################################################################
include_directories(${EO_SRC_DIR}/src)
include_directories(${MOEO_SRC_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
### 2) Define output paths
######################################################################################
set(FLOWSHOP_LIB_OUTPUT_PATH ${FLOWSHOP_BINARY_DIR}/lib)
set(LIBRARY_OUTPUT_PATH ${FLOWSHOP_LIB_OUTPUT_PATH})
######################################################################################
### 3) Set flowshop sources
######################################################################################
set(FLOWSHOP_SOURCES
FlowShopBenchmarkParser.cpp
FlowShopEval.cpp
FlowShopObjectiveVectorTraits.cpp
FlowShopOpCrossoverQuad.cpp
FlowShop.cpp)
######################################################################################
### 4) Create flowshop library
######################################################################################
add_library(flowshop STATIC ${FLOWSHOP_SOURCES})
add_dependencies(flowshop moeo)
target_link_libraries(flowshop eo)
install(TARGETS flowshop ARCHIVE DESTINATION local/${LIB} COMPONENT libraries)
######################################################################################
### 5) Installing benchs
######################################################################################
install(DIRECTORY benchs DESTINATION local/include${INSTALL_SUB_DIR}/moeo/tutorial/flowshop COMPONENT tutorial)
######################################################################################
### 6) Look for headers
######################################################################################
file(GLOB HDRS *.h)
install(FILES ${HDRS} DESTINATION local/include${INSTALL_SUB_DIR}/moeo/tutorial/examples/flowshop COMPONENT headers)

View file

@ -0,0 +1,43 @@
/*
* <FlowShop.cpp>
* 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 <FlowShop.h>
std::string FlowShop::className() const
{
return "FlowShop";
}

View file

@ -0,0 +1,58 @@
/*
* <FlowShop.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 FLOWSHOP_H_
#define FLOWSHOP_H_
#include <core/moeoVector.h>
#include <FlowShopObjectiveVector.h>
/**
* Structure of the genotype for the flow-shop scheduling problem: a vector of unsigned int int.
*/
class FlowShop: public moeoVector < FlowShopObjectiveVector , unsigned int >
{
public:
/**
* class name
*/
std::string className() const;
};
#endif /*FLOWSHOP_H_*/

View file

@ -0,0 +1,136 @@
/*
* <FlowShopBenchmarkParser.cpp>
* 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 <iostream>
#include <stdexcept>
#include "FlowShopBenchmarkParser.h"
FlowShopBenchmarkParser::FlowShopBenchmarkParser(const std::string _benchmarkFileName)
{
init(_benchmarkFileName);
}
const unsigned int FlowShopBenchmarkParser::getM()
{
return M;
}
const unsigned int FlowShopBenchmarkParser::getN()
{
return N;
}
const std::vector< std::vector<unsigned int> > FlowShopBenchmarkParser::getP()
{
return p;
}
const std::vector<unsigned int> FlowShopBenchmarkParser::getD()
{
return d;
}
void FlowShopBenchmarkParser::printOn(std::ostream & _os) const
{
_os << "M=" << M << " N=" << N << std::endl;
_os << "*** processing times" << std::endl;
for (unsigned int i=0; i<M; i++)
{
for (unsigned int j=0; j<N; j++)
{
_os << p[i][j] << " ";
}
_os << std::endl;
}
_os << "*** due-dates" << std::endl;
for (unsigned int j=0; j<N; j++)
{
_os << d[j] << " ";
}
_os << std::endl << std::endl;
}
void FlowShopBenchmarkParser::init(const std::string _benchmarkFileName)
{
std::string buffer;
std::string::size_type start, end;
std::ifstream inputFile(_benchmarkFileName.data(), std::ios::in);
// opening of the benchmark file
if (! inputFile)
throw std::runtime_error("*** ERROR : Unable to open the benchmark file");
// number of jobs (N)
getline(inputFile, buffer, '\n');
N = atoi(buffer.data());
// number of machines M
getline(inputFile, buffer, '\n');
M = atoi(buffer.data());
// initial and current seeds (not used)
getline(inputFile, buffer, '\n');
// processing times and due-dates
// p = std::vector< std::vector<unsigned int> > (M,N);
p.resize(M);
for (unsigned int j=0 ; j<M ; j++)
{
p[j].resize(N);
}
d = std::vector<unsigned int> (N);
// for each job...
for (unsigned int j=0 ; j<N ; j++)
{
// index of the job (<=> j)
getline(inputFile, buffer, '\n');
// due-date of the job j
getline(inputFile, buffer, '\n');
d[j] = atoi(buffer.data());
// processing times of the job j on each machine
getline(inputFile, buffer, '\n');
start = buffer.find_first_not_of(" ");
for (unsigned int i=0 ; i<M ; i++)
{
end = buffer.find_first_of(" ", start);
p[i][j] = atoi(buffer.substr(start, end-start).data());
start = buffer.find_first_not_of(" ", end);
}
}
// closing of the input file
inputFile.close();
}

View file

@ -0,0 +1,110 @@
/*
* <FlowShopBenchmarkParser.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 FLOWSHOPBENCHMARKPARSER_H_
#define FLOWSHOPBENCHMARKPARSER_H_
#include <stdlib.h>
#include <fstream>
#include <string>
#include <vector>
/**
* Class to handle parameters of a flow-shop instance from a benchmark file
*/
class FlowShopBenchmarkParser
{
public:
/**
* Ctor
* @param _benchmarkFileName the name of the benchmark file
*/
FlowShopBenchmarkParser(const std::string _benchmarkFileName);
/**
* the number of machines
*/
const unsigned int getM();
/**
* the number of jobs
*/
const unsigned int getN();
/**
* the processing times
*/
const std::vector < std::vector < unsigned int > > getP();
/**
* the due-dates
*/
const std::vector < unsigned int > getD();
/**
* printing...
*/
void printOn(std::ostream & _os) const;
private:
/** number of machines */
unsigned int M;
/** number of jobs */
unsigned int N;
/** p[i][j] = processing time of job j on machine i */
std::vector < std::vector < unsigned int > > p;
/** d[j] = due-date of the job j */
std::vector < unsigned int > d;
/**
* Initialisation of the parameters with the data contained in the benchmark file
* @param _benchmarkFileName the name of the benchmark file
*/
void init(const std::string _benchmarkFileName);
};
#endif /*FLOWSHOPBENCHMARKPARSER_H_*/

View file

@ -0,0 +1,95 @@
/*
* <FlowShopEval.cpp>
* 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 <FlowShopEval.h>
FlowShopEval::FlowShopEval(unsigned int _M, unsigned int _N, const std::vector< std::vector<unsigned int> > & _p, const std::vector<unsigned int> & _d) :
M(_M), N (_N), p(_p), d(_d)
{}
void FlowShopEval::operator()(FlowShop & _flowshop)
{
FlowShopObjectiveVector objVector;
objVector[0] = makespan(_flowshop);
objVector[1] = tardiness(_flowshop);
_flowshop.objectiveVector(objVector);
}
double FlowShopEval::makespan(const FlowShop & _flowshop)
{
// completion times computation for each job on each machine
// C[i][j] = completion of the jth job of the scheduling on the ith machine
std::vector< std::vector<unsigned int> > C = completionTime(_flowshop);
return C[M-1][_flowshop[N-1]];
}
double FlowShopEval::tardiness(const FlowShop & _flowshop)
{
// completion times computation for each job on each machine
// C[i][j] = completion of the jth job of the scheduling on the ith machine
std::vector< std::vector<unsigned int> > C = completionTime(_flowshop);
// tardiness computation
unsigned int long sum = 0;
for (unsigned int j=0 ; j<N ; j++)
sum += (unsigned int) std::max (0, (int) (C[M-1][_flowshop[j]] - d[_flowshop[j]]));
return sum;
}
std::vector< std::vector<unsigned int> > FlowShopEval::completionTime(const FlowShop & _flowshop)
{
std::vector< std::vector<unsigned int> > C;
C.resize(M);
for (unsigned int i=0;i<M;i++)
{
C[i].resize(N);
}
C[0][_flowshop[0]] = p[0][_flowshop[0]];
for (unsigned int j=1; j<N; j++)
C[0][_flowshop[j]] = C[0][_flowshop[j-1]] + p[0][_flowshop[j]];
for (unsigned int i=1; i<M; i++)
C[i][_flowshop[0]] = C[i-1][_flowshop[0]] + p[i][_flowshop[0]];
for (unsigned int i=1; i<M; i++)
for (unsigned int j=1; j<N; j++)
C[i][_flowshop[j]] = std::max(C[i][_flowshop[j-1]], C[i-1][_flowshop[j]]) + p[i][_flowshop[j]];
return C;
}

Some files were not shown because too many files have changed in this diff Show more