new architecture
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@510 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
ca02604102
commit
b37b5887f6
37 changed files with 130 additions and 146 deletions
|
|
@ -1,16 +1,142 @@
|
|||
|
||||
######################################################################################
|
||||
### 0) Need lesson1 directory
|
||||
### 0) Need flowhsop directory
|
||||
######################################################################################
|
||||
|
||||
SET(TUTORIAL_LESSON1_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
SET(FLOWSHOP_EXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flowshop)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 5) Where should CMake go now ?
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
SUBDIRS(src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
|
||||
INCLUDE_DIRECTORIES(${MOEO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${FLOWSHOP_EXAMPLE_DIR})
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
|
||||
######################################################################################
|
||||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${MOEO_DIR}/build ${TUTORIAL_LESSON1_DIR}/build)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(WIN32)
|
||||
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
|
||||
IF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set (CMAKE_BUILD_TYPE Debug)
|
||||
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
LINK_DIRECTORIES(${TUTORIAL_LESSON1_DIR}\\build\\debug)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
LINK_DIRECTORIES(${TUTORIAL_LESSON1_DIR}\\build\\release)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
ENDIF(UNIX)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(FlowShopEA FlowShopEA.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(FlowShopEA moeo)
|
||||
ADD_DEPENDENCIES(FlowShopEA flowshop)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON1_DIR}/build)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(FLOWSHOPEA_VERSION "1.0.beta")
|
||||
SET_TARGET_PROPERTIES(FlowShopEA PROPERTIES VERSION "${FLOWSHOPEA_VERSION}")
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA moeo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA flowshop)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eoutils)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(WIN32)
|
||||
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
|
||||
IF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set (CMAKE_BUILD_TYPE Debug)
|
||||
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA moeo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA flowshop)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eod)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eoutilsd)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA moeo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA flowshop)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eoutils)
|
||||
ELSE(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE(FATAL_ERROR " Cmake build type can only be \"Debug\" or \"Release\" ")
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
ENDIF(UNIX)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 6) Windows advanced config - especially for Microsoft Visual Studio 8
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_CXX_COMPILER MATCHES cl)
|
||||
IF(NOT WITH_SHARED_LIBS)
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005")
|
||||
SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2")
|
||||
SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
|
||||
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005")
|
||||
ENDIF(NOT WITH_SHARED_LIBS)
|
||||
ENDIF(CMAKE_CXX_COMPILER MATCHES cl)
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 7) Where should CMake go now ?
|
||||
######################################################################################
|
||||
|
||||
SUBDIRS(${FLOWSHOP_EXAMPLE_DIR})
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
107
trunk/paradiseo-moeo/tutorial/Lesson1/FlowShopEA.cpp
Normal file
107
trunk/paradiseo-moeo/tutorial/Lesson1/FlowShopEA.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopEA.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.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
|
||||
moeoArchive<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
|
||||
apply<FlowShop>(eval, pop);
|
||||
|
||||
// printing of the initial population
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
// run the algo
|
||||
do_run(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;
|
||||
}
|
||||
|
|
@ -1,24 +1,12 @@
|
|||
|
||||
######################################################################################
|
||||
### 0) Need flowhsop directory
|
||||
######################################################################################
|
||||
|
||||
SET(FLOWSHOP_EXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flowshop)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
|
||||
INCLUDE_DIRECTORIES(${MOEO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${FLOWSHOP_EXAMPLE_DIR})
|
||||
######################################################################################
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
|
|
@ -27,7 +15,7 @@ INCLUDE_DIRECTORIES(${FLOWSHOP_EXAMPLE_DIR})
|
|||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${MOEO_DIR}/build ${TUTORIAL_LESSON1_DIR}/build)
|
||||
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${MOEO_DIR}/build)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(WIN32)
|
||||
|
|
@ -37,10 +25,10 @@ ELSEIF(WIN32)
|
|||
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
LINK_DIRECTORIES(${TUTORIAL_LESSON1_DIR}\\build\\debug)
|
||||
LINK_DIRECTORIES(${MOEO_DIR}\\build\\debug)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
LINK_DIRECTORIES(${TUTORIAL_LESSON1_DIR}\\build\\release)
|
||||
LINK_DIRECTORIES(${MOEO_DIR}\\build\\release)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
|
|
@ -51,16 +39,34 @@ ENDIF(UNIX)
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
### 3) Define your target(s): just the flowshop lib here
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(FlowShopEA FlowShopEA.cpp)
|
||||
SET(FLOWSHOP_LIB_OUTPUT_PATH ${TUTORIAL_LESSON1_DIR}/build)
|
||||
SET(LIBRARY_OUTPUT_PATH ${FLOWSHOP_LIB_OUTPUT_PATH})
|
||||
|
||||
ADD_DEPENDENCIES(FlowShopEA moeo)
|
||||
ADD_DEPENDENCIES(FlowShopEA flowshop)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON1_DIR}/build)
|
||||
SET (FLOWSHOP_SOURCES FlowShopBenchmarkParser.cpp
|
||||
FlowShopEval.cpp
|
||||
FlowShopInit.cpp
|
||||
FlowShopObjectiveVectorTraits.cpp
|
||||
FlowShopOpCrossoverQuad.cpp
|
||||
FlowShopOpMutationExchange.cpp
|
||||
FlowShopOpMutationShift.cpp
|
||||
FlowShop.cpp)
|
||||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
ADD_LIBRARY(flowshop STATIC ${FLOWSHOP_SOURCES})
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(WIN32)
|
||||
ADD_LIBRARY(flowshop STATIC ${FLOWSHOP_SOURCES})
|
||||
|
||||
|
||||
ADD_DEPENDENCIES(flowshop moeo)
|
||||
|
||||
ENDIF(UNIX)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
|
@ -69,24 +75,21 @@ SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON1_DIR}/build)
|
|||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(FLOWSHOPEA_VERSION "1.0.beta")
|
||||
SET_TARGET_PROPERTIES(FlowShopEA PROPERTIES VERSION "${FLOWSHOPEA_VERSION}")
|
||||
SET(FLOWSHOP_VERSION "1.0.beta")
|
||||
SET_TARGET_PROPERTIES(flowshop PROPERTIES VERSION "${FLOWSHOP_VERSION}")
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA moeo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA flowshop)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eoutils)
|
||||
TARGET_LINK_LIBRARIES(flowshop moeo)
|
||||
TARGET_LINK_LIBRARIES(flowshop eo)
|
||||
|
||||
# --> WIN
|
||||
# --> APPLE AND WIN
|
||||
ELSEIF(WIN32)
|
||||
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
|
||||
IF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
|
|
@ -94,15 +97,11 @@ ELSEIF(WIN32)
|
|||
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA moeo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA flowshop)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eod)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eoutilsd)
|
||||
TARGET_LINK_LIBRARIES(flowshop moeo)
|
||||
TARGET_LINK_LIBRARIES(flowshop eod)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA moeo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA flowshop)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eo)
|
||||
TARGET_LINK_LIBRARIES(FlowShopEA eoutils)
|
||||
TARGET_LINK_LIBRARIES(flowshop moeo)
|
||||
TARGET_LINK_LIBRARIES(flowshop eo)
|
||||
ELSE(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE(FATAL_ERROR " Cmake build type can only be \"Debug\" or \"Release\" ")
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
|
@ -111,7 +110,6 @@ ENDIF(UNIX)
|
|||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 6) Windows advanced config - especially for Microsoft Visual Studio 8
|
||||
######################################################################################
|
||||
|
|
@ -132,11 +130,5 @@ ENDIF(UNIX)
|
|||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 7) Where should CMake go now ?
|
||||
######################################################################################
|
||||
|
||||
SUBDIRS(${FLOWSHOP_EXAMPLE_DIR})
|
||||
|
||||
######################################################################################
|
||||
|
||||
18
trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShop.cpp
Normal file
18
trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShop.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShop.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <FlowShop.h>
|
||||
|
||||
std::string FlowShop::className() const
|
||||
{
|
||||
return "FlowShop";
|
||||
}
|
||||
33
trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShop.h
Normal file
33
trunk/paradiseo-moeo/tutorial/examples/flowshop/FlowShop.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShop.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.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 , double , double , unsigned int >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* class name
|
||||
*/
|
||||
std::string className() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*FLOWSHOP_H_*/
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopBenchmarkParser.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#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);
|
||||
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();
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopBenchmarkParser.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPBENCHMARKPARSER_H_
|
||||
#define FLOWSHOPBENCHMARKPARSER_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_*/
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopEval.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.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(M,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;
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopEval.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPEVAL_H_
|
||||
#define FLOWSHOPEVAL_H_
|
||||
|
||||
#include <vector>
|
||||
#include <core/moeoEvalFunc.h>
|
||||
#include <FlowShop.h>
|
||||
|
||||
/**
|
||||
* Evaluation of the objective vector a (multi-objective) FlowShop object
|
||||
*/
|
||||
class FlowShopEval : public moeoEvalFunc<FlowShop>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _M the number of machines
|
||||
* @param _N the number of jobs to schedule
|
||||
* @param _p the processing times
|
||||
* @param _d the due dates
|
||||
*/
|
||||
FlowShopEval(unsigned int _M, unsigned int _N, const std::vector< std::vector<unsigned int> > & _p, const std::vector<unsigned int> & _d);
|
||||
|
||||
|
||||
/**
|
||||
* computation of the multi-objective evaluation of a FlowShop object
|
||||
* @param _flowshop the FlowShop object to evaluate
|
||||
*/
|
||||
void operator()(FlowShop & _flowshop);
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* computation of the makespan
|
||||
* @param _flowshop the genotype to evaluate
|
||||
*/
|
||||
double makespan(const FlowShop & _flowshop);
|
||||
|
||||
|
||||
/**
|
||||
* computation of the tardiness
|
||||
* @param _flowshop the genotype to evaluate
|
||||
*/
|
||||
double tardiness(const FlowShop & _flowshop);
|
||||
|
||||
|
||||
/**
|
||||
* computation of the completion times of a scheduling (for each job on each machine)
|
||||
* C[i][j] = completion of the jth job of the scheduling on the ith machine
|
||||
* @param _flowshop the genotype to evaluate
|
||||
*/
|
||||
std::vector< std::vector<unsigned int> > completionTime (const FlowShop & _flowshop);
|
||||
|
||||
};
|
||||
|
||||
#endif /*FLOWSHOPEVAL_H_*/
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopInit.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <FlowShopInit.h>
|
||||
|
||||
|
||||
FlowShopInit::FlowShopInit(unsigned int _N) : N(_N)
|
||||
{}
|
||||
|
||||
|
||||
void FlowShopInit::operator()(FlowShop & _flowshop)
|
||||
{
|
||||
// scheduling vector
|
||||
std::vector<unsigned int> scheduling(N);
|
||||
// initialisation of possible values
|
||||
std::vector<unsigned int> possibles(N);
|
||||
for (unsigned int i=0 ; i<N ; i++)
|
||||
possibles[i] = i;
|
||||
// random initialization
|
||||
unsigned int rInd; // random index
|
||||
for (unsigned int i=0; i<N; i++)
|
||||
{
|
||||
rInd = (unsigned int) rng.uniform(N-i);
|
||||
scheduling[i] = possibles[rInd];
|
||||
possibles[rInd] = possibles[N-i-1];
|
||||
}
|
||||
_flowshop.resize(N);
|
||||
_flowshop.value(scheduling);
|
||||
_flowshop.invalidate(); // IMPORTANT in case the _genotype is old
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopInit.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPINIT_H_
|
||||
#define FLOWSHOPINIT_H_
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <FlowShop.h>
|
||||
|
||||
/**
|
||||
* Initialization of a random genotype built by the default constructor of the FlowShop class
|
||||
*/
|
||||
class FlowShopInit : public eoInit<FlowShop>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _N the number of jobs to schedule
|
||||
*/
|
||||
FlowShopInit(unsigned int _N);
|
||||
|
||||
|
||||
/**
|
||||
* builds a random genotype
|
||||
* @param _flowshop a genotype that has been default-constructed
|
||||
*/
|
||||
void operator()(FlowShop & _flowshop);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** the number of jobs (size of a scheduling vector) */
|
||||
unsigned int N;
|
||||
|
||||
};
|
||||
|
||||
#endif /*FLOWSHOPINIT_H_*/
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopObjectiveVector.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPOBJECTIVEVECTOR_H_
|
||||
#define FLOWSHOPOBJECTIVEVECTOR_H_
|
||||
|
||||
#include <core/moeoRealObjectiveVector.h>
|
||||
#include <FlowShopObjectiveVectorTraits.h>
|
||||
|
||||
/**
|
||||
* Definition of the objective vector for multi-objective flow-shop problems: a vector of doubles
|
||||
*/
|
||||
typedef moeoRealObjectiveVector < FlowShopObjectiveVectorTraits > FlowShopObjectiveVector;
|
||||
|
||||
#endif /*FLOWSHOPOBJECTIVEVECTOR_H_*/
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopObjectiveVectorTraits.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <FlowShopObjectiveVectorTraits.h>
|
||||
|
||||
|
||||
bool FlowShopObjectiveVectorTraits::minimizing (int _i)
|
||||
{
|
||||
// minimizing both
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FlowShopObjectiveVectorTraits::nObjectives ()
|
||||
{
|
||||
// 2 objectives
|
||||
return 2;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopObjectiveVectorTraits.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPOBJECTIVEVECTORTRAITS_H_
|
||||
#define FLOWSHOPOBJECTIVEVECTORTRAITS_H_
|
||||
|
||||
#include <core/moeoObjectiveVectorTraits.h>
|
||||
|
||||
/**
|
||||
* Definition of the objective vector traits for multi-objective flow-shop problems
|
||||
*/
|
||||
class FlowShopObjectiveVectorTraits : public moeoObjectiveVectorTraits
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns true if the _ith objective have to be minimzed
|
||||
* @param _i index of the objective
|
||||
*/
|
||||
static bool minimizing (int _i);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of objectives
|
||||
*/
|
||||
static unsigned int nObjectives ();
|
||||
|
||||
};
|
||||
|
||||
#endif /*FLOWSHOPOBJECTIVEVECTORTRAITS_H_*/
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopOpCrossoverQuad.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <FlowShopOpCrossoverQuad.h>
|
||||
|
||||
|
||||
std::string FlowShopOpCrossoverQuad::className() const
|
||||
{
|
||||
return "FlowShopOpCrossoverQuad";
|
||||
}
|
||||
|
||||
|
||||
bool FlowShopOpCrossoverQuad::operator()(FlowShop & _flowshop1, FlowShop & _flowshop2)
|
||||
{
|
||||
bool oneAtLeastIsModified;
|
||||
// computation of the 2 random points
|
||||
unsigned int point1, point2;
|
||||
do
|
||||
{
|
||||
point1 = rng.random(std::min(_flowshop1.size(), _flowshop2.size()));
|
||||
point2 = rng.random(std::min(_flowshop1.size(), _flowshop2.size()));
|
||||
} while (fabs((double) point1-point2) <= 2);
|
||||
// computation of the offspring
|
||||
FlowShop offspring1 = generateOffspring(_flowshop1, _flowshop2, point1, point2);
|
||||
FlowShop offspring2 = generateOffspring(_flowshop2, _flowshop1, point1, point2);
|
||||
// does at least one genotype has been modified ?
|
||||
if ((_flowshop1 != offspring1) || (_flowshop2 != offspring2))
|
||||
{
|
||||
// update
|
||||
_flowshop1.value(offspring1);
|
||||
_flowshop2.value(offspring2);
|
||||
// at least one genotype has been modified
|
||||
oneAtLeastIsModified = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no genotype has been modified
|
||||
oneAtLeastIsModified = false;
|
||||
}
|
||||
// return 'true' if at least one genotype has been modified
|
||||
return oneAtLeastIsModified;
|
||||
}
|
||||
|
||||
|
||||
FlowShop FlowShopOpCrossoverQuad::generateOffspring(const FlowShop & _parent1, const FlowShop & _parent2, unsigned int _point1, unsigned int _point2)
|
||||
{
|
||||
FlowShop result = _parent1;
|
||||
std::vector<bool> taken_values(result.size(), false);
|
||||
if (_point1 > _point2)
|
||||
std::swap(_point1, _point2);
|
||||
/* first parent */
|
||||
for (unsigned int i=0 ; i<=_point1 ; i++)
|
||||
{
|
||||
// result[i] == _parent1[i]
|
||||
taken_values[_parent1[i]] = true;
|
||||
}
|
||||
for (unsigned int i=_point2 ; i<result.size() ; i++)
|
||||
{
|
||||
// result[i] == _parent1[i]
|
||||
taken_values[_parent1[i]] = true;
|
||||
}
|
||||
/* second parent */
|
||||
unsigned int i = _point1+1;
|
||||
unsigned int j = 0;
|
||||
while (i<_point2 && j<_parent2.size())
|
||||
{
|
||||
if (! taken_values[_parent2[j]])
|
||||
{
|
||||
result[i] = _parent2[j];
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopOpCrossoverQuad.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPOPCROSSOVERQUAD_H_
|
||||
#define FLOWSHOPOPCROSSOVERQUAD_H_
|
||||
|
||||
#include <eoOp.h>
|
||||
#include <FlowShop.h>
|
||||
|
||||
/**
|
||||
* Quadratic crossover operator for flow-shop (modify the both genotypes)
|
||||
*/
|
||||
class FlowShopOpCrossoverQuad : public eoQuadOp < FlowShop >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* the class name (used to display statistics)
|
||||
*/
|
||||
std::string className() const;
|
||||
|
||||
|
||||
/**
|
||||
* eoQuad crossover - _flowshop1 and _flowshop2 are the (future) offspring, i.e. _copies_ of the parents
|
||||
* @param _flowshop1 the first parent
|
||||
* @param _flowshop2 the second parent
|
||||
*/
|
||||
bool operator()(FlowShop & _flowshop1, FlowShop & _flowshop2);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* generation of an offspring by a 2 points crossover
|
||||
* @param _parent1 the first parent
|
||||
* @param _parent2 the second parent
|
||||
* @param _point1 the first point
|
||||
* @param _point2 the second point
|
||||
*/
|
||||
FlowShop generateOffspring(const FlowShop & _parent1, const FlowShop & _parent2, unsigned int _point1, unsigned int _point2);
|
||||
|
||||
};
|
||||
|
||||
#endif /*FLOWSHOPOPCROSSOVERQUAD_H_*/
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopOpCrossoverQuad.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <FlowShopOpMutationExchange.h>
|
||||
|
||||
|
||||
std::string FlowShopOpMutationExchange::className() const
|
||||
{
|
||||
return "FlowShopOpMutationExchange";
|
||||
}
|
||||
|
||||
|
||||
bool FlowShopOpMutationExchange::operator()(FlowShop & _flowshop)
|
||||
{
|
||||
bool isModified;
|
||||
FlowShop result = _flowshop;
|
||||
// computation of the 2 random points
|
||||
unsigned int point1, point2;
|
||||
do
|
||||
{
|
||||
point1 = rng.random(result.size());
|
||||
point2 = rng.random(result.size());
|
||||
} while (point1 == point2);
|
||||
// swap
|
||||
std::swap (result[point1], result[point2]);
|
||||
// update (if necessary)
|
||||
if (result != _flowshop)
|
||||
{
|
||||
// update
|
||||
_flowshop.value(result);
|
||||
// the genotype has been modified
|
||||
isModified = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the genotype has not been modified
|
||||
isModified = false;
|
||||
}
|
||||
// return 'true' if the genotype has been modified
|
||||
return isModified;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopOpCrossoverQuad.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef FLOWSHOPOPMUTATIONEXCHANGE_H_
|
||||
#define FLOWSHOPOPMUTATIONEXCHANGE_H_
|
||||
|
||||
#include <eoOp.h>
|
||||
#include <FlowShop.h>
|
||||
|
||||
/**
|
||||
* Exchange mutation operator for the flow-shop
|
||||
*/
|
||||
class FlowShopOpMutationExchange : public eoMonOp<FlowShop>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* the class name (used to display statistics)
|
||||
*/
|
||||
std::string className() const;
|
||||
|
||||
|
||||
/**
|
||||
* modifies the parent with an exchange mutation
|
||||
* @param _flowshop the parent genotype (will be modified)
|
||||
*/
|
||||
bool operator()(FlowShop & _flowshop);
|
||||
|
||||
};
|
||||
|
||||
#endif /*FLOWSHOPOPMUTATIONEXCHANGE_H_*/
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FlowShopOpMutationShift.cpp
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <FlowShopOpMutationShift.h>
|
||||
|
||||
|
||||
std::string FlowShopOpMutationShift::className() const
|
||||
{
|
||||
return "FlowShopOpMutationShift";
|
||||
}
|
||||
|
||||
|
||||
bool FlowShopOpMutationShift::operator()(FlowShop & _flowshop)
|
||||
{
|
||||
bool isModified;
|
||||
int direction;
|
||||
unsigned int tmp;
|
||||
FlowShop result = _flowshop;
|
||||
// computation of the 2 random points
|
||||
unsigned int point1, point2;
|
||||
do
|
||||
{
|
||||
point1 = rng.random(result.size());
|
||||
point2 = rng.random(result.size());
|
||||
} while (point1 == point2);
|
||||
// direction
|
||||
if (point1 < point2)
|
||||
direction = 1;
|
||||
else
|
||||
direction = -1;
|
||||
// mutation
|
||||
tmp = result[point1];
|
||||
for (unsigned int i=point1 ; i!=point2 ; i+=direction)
|
||||
result[i] = result[i+direction];
|
||||
result[point2] = tmp;
|
||||
// update (if necessary)
|
||||
if (result != _flowshop)
|
||||
{
|
||||
// update
|
||||
_flowshop.value(result);
|
||||
// the genotype has been modified
|
||||
isModified = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the genotype has not been modified
|
||||
isModified = false;
|
||||
}
|
||||
// return 'true' if the genotype has been modified
|
||||
return isModified;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue