git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1407 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
jhumeau 2009-02-06 09:34:46 +00:00
commit c0e5ffcf0d
42 changed files with 3919 additions and 3 deletions

View file

@ -0,0 +1,33 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_MOEO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
######################################################################################
### 2) Define your target(s): just the flow-shop lib here
######################################################################################
SET(FLOWSHOP_LIB_OUTPUT_PATH ${INSTALL_DIR}/flowshop/lib)
SET(LIBRARY_OUTPUT_PATH ${FLOWSHOP_LIB_OUTPUT_PATH})
SET (FLOWSHOP_SOURCES FlowShopBenchmarkParser.cpp
FlowShopEval.cpp
FlowShopObjectiveVectorTraits.cpp
FlowShopOpCrossoverQuad.cpp
FlowShop.cpp
exchange_move.cpp
exchange_move_init.cpp
exchange_move_next.cpp
)
ADD_LIBRARY(flowshop STATIC ${FLOWSHOP_SOURCES})
######################################################################################

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 , double , double , unsigned int >
{
public:
/**
* class name
*/
std::string className() const;
};
#endif /*FLOWSHOP_H_*/

View file

@ -0,0 +1,131 @@
/*
* <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 <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();
}

View file

@ -0,0 +1,109 @@
/*
* <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 <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,90 @@
/*
* <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(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;
}

View file

@ -0,0 +1,104 @@
/*
* <FlowShopEval.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 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_*/

View file

@ -0,0 +1,64 @@
/*
* <FlowShopInit.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 <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
}

View file

@ -0,0 +1,49 @@
/*
* <FlowShopInit.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 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
*/
typedef eoInitPermutation<FlowShop> FlowShopInit;
#endif /*FLOWSHOPINIT_H_*/

View file

@ -0,0 +1,49 @@
/*
* <FlowShopObjectiveVector.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 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_*/

View file

@ -0,0 +1,57 @@
/*
* <FlowShopObjectiveVectorTraits.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 <FlowShopObjectiveVectorTraits.h>
bool FlowShopObjectiveVectorTraits::minimizing (int _i)
{
// minimizing both
return true;
}
bool FlowShopObjectiveVectorTraits::maximizing (int _i)
{
// minimizing both
return false;
}
unsigned int FlowShopObjectiveVectorTraits::nObjectives ()
{
// 2 objectives
return 2;
}

View file

@ -0,0 +1,71 @@
/*
* <FlowShopObjectiveVectorTraits.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 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 true if the _ith objective have to be maximzed
* @param _i index of the objective
*/
static bool maximizing (int _i);
/**
* Returns the number of objectives
*/
static unsigned int nObjectives ();
};
#endif /*FLOWSHOPOBJECTIVEVECTORTRAITS_H_*/

View file

@ -0,0 +1,110 @@
/*
* <FlowShopOpCrossoverQuad.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 <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;
}

View file

@ -0,0 +1,78 @@
/*
* <FlowShopOpCrossoverQuad.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 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_*/

View file

@ -0,0 +1,49 @@
/*
* <FlowShopOpMutationExchange.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 FLOWSHOPOPMUTATIONEXCHANGE_H_
#define FLOWSHOPOPMUTATIONEXCHANGE_H_
#include <eoSwapMutation.h>
#include <FlowShop.h>
/**
* Exchange mutation operator for the flow-shop
*/
typedef eoSwapMutation<FlowShop> FlowShopOpMutationExchange;
#endif /*FLOWSHOPOPMUTATIONEXCHANGE_H_*/

View file

@ -0,0 +1,49 @@
/*
* <FlowShopOpMutationShift.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 FLOWSHOPOPMUTATIONSHIFT_H_
#define FLOWSHOPOPMUTATIONSHIFT_H_
#include <eoShiftMutation.h>
#include <FlowShop.h>
/**
* Shift mutation operator for flow-shop
*/
typedef eoShiftMutation<FlowShop> FlowShopOpMutationShift;
#endif /*FLOWSHOPOPMUTATIONSHIFT_H_*/

View file

@ -0,0 +1,67 @@
#include "exchange_move.h"
/*ExchangeMove ExchangeMove :: operator ! () const
{
ExchangeMove move = * this ;
FlowShop __flowshop;
//std :: swap (move.first, move.second) ;
__flowshop[move.second] =__flowshop[move.first];
return move ;
}*/
//void ExchangeMove :: operator () (FlowShop & __flowshop)
void ExchangeMove :: operator () (FlowShop& __flowshop)
{
//bool isModified;
//ExchangeMove move;
int direction;
unsigned int tmp;
//FlowShop result = __flowshop;
/*std :: vector <unsigned int> seq_cities ;
for (unsigned int i = second ; i > first ; i --)
{
seq_cities.push_back (__flowshop [i]) ;
}
unsigned int j = 0 ;
for (unsigned int i = first + 1 ; i < second + 1 ; i ++)
{
__flowshop[i] = seq_cities [j ++] ;
}*/
if (first < second)
direction = 1;
else
direction = -1;
// mutation
tmp = __flowshop[first];
for (unsigned int i=first ; i!= second ; i+=direction)
__flowshop[i] = __flowshop[i+direction];
__flowshop[ second] = 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;
}
void ExchangeMove :: readFrom (std :: istream & __is)
{
__is >> first >> second ;
}
void ExchangeMove :: printOn (std :: ostream & __os) const
{
__os << first << ' ' << second ;
}

View file

@ -0,0 +1,28 @@
#ifndef exchange_move_h
#define exchange_move_h
#include <eoPersistent.h>
#include <utility>
#include <moMove.h>
//#include <moeo>
#include <FlowShop.h>
class ExchangeMove : public moMove <FlowShop>, public std :: pair <unsigned, unsigned>, public eoPersistent
{
public :
ExchangeMove operator ! () const ;
//void operator () (FlowShop & __FlowShop) ;
void operator () (FlowShop & __FlowShop) ;
void readFrom (std :: istream & __is) ;
void printOn (std :: ostream & __os) const ;
} ;
#endif

View file

@ -0,0 +1,13 @@
#include <exchange_move_init.h>
#include <utils/eoRNG.h>
void ExchangeMoveInit :: operator () (ExchangeMove & _move, const FlowShop & _flowshop)
{
FlowShop flowshop=_flowshop;
//eoRNG rng;
do
{
_move.first = rng.random(flowshop.size()) ;
_move.second = rng.random(flowshop.size()) ;
}while(_move.first == _move.second);
}

View file

@ -0,0 +1,20 @@
#ifndef exchange_move_init_h
#define exchange_move_init_h
#include <moMoveInit.h>
//#include <moeo>
#include "exchange_move.h"
/** It sets the first couple of edges */
class ExchangeMoveInit : public moMoveInit <ExchangeMove>
{
public :
void operator () (ExchangeMove & _move, const FlowShop & _flowshop) ;
} ;
#endif

View file

@ -0,0 +1,30 @@
#include "exchange_move_next.h"
//#include "graph.h"
//int ExchangeMoveNext ::init(static int i)
bool ExchangeMoveNext :: operator () (ExchangeMove & _move, const FlowShop & _flowshop)
{
FlowShop flowshop =_flowshop;
if (_move.first >= (flowshop.size() - 4))// && _move.second == _move.first + 2)
//if (_move.second == flowshop.size ()-2)
{
return false ;
}
else
{
//std::cout<<_move.second<<" "<<_move.first<<" "<<flowshop.size()<<std::endl;
_move.second ++ ;
if (_move.second >= flowshop.size () - 1)
{
_move.first ++ ;
_move.second = _move.first + 2 ;
}
return true ;
}
}

View file

@ -0,0 +1,22 @@
#ifndef exchange_move_next_h
#define exchange_move_next_h
#include <moNextMove.h>
#include "exchange_move.h"
//#include <moeo>
/** It updates a couple of edges */
class ExchangeMoveNext : public moNextMove <ExchangeMove>
{
public :
bool operator () (ExchangeMove & _move, const FlowShop & _flowshop) ;
} ;
#endif

View file

@ -0,0 +1,81 @@
/*
* <make_eval_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 MAKE_EVAL_FLOWSHOP_H_
#define MAKE_EVAL_FLOWSHOP_H_
#include <utils/eoParser.h>
#include <utils/eoState.h>
#include <eoEvalFuncCounter.h>
#include <FlowShop.h>
#include <FlowShopBenchmarkParser.h>
#include <FlowShopEval.h>
/*
* This function creates an eoEvalFuncCounter<eoFlowShop> that can later be used to evaluate an individual.
* @param eoParser& _parser to get user parameters
* @param eoState& _state to store the memory
*/
eoEvalFuncCounter<FlowShop> & do_make_eval(eoParser& _parser, eoState& _state)
{
// benchmark file name
std::string benchmarkFileName = _parser.getORcreateParam(std::string("../flowshop/benchs/020_20_01.txt"), "BenchmarkFile", "Benchmark file name (benchmarks are available at www.lifl.fr/~liefooga/benchmarks)", 'B',"Representation", false).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());
// }
// reading of the parameters contained in the benchmark file
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();
// build of the initializer (a pointer, stored in the eoState)
FlowShopEval* plainEval = new FlowShopEval(M, N, p, d);
// turn that object into an evaluation counter
eoEvalFuncCounter<FlowShop>* eval = new eoEvalFuncCounter<FlowShop> (* plainEval);
// store in state
_state.storeFunctor(eval);
// and return a reference
return *eval;
}
#endif /*MAKE_EVAL_FLOWSHOP_H_*/

View file

@ -0,0 +1,74 @@
/*
* <make_genotype_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 MAKE_GENOTYPE_FLOWSHOP_H_
#define MAKE_GENOTYPE_FLOWSHOP_H_
#include <utils/eoParser.h>
#include <utils/eoState.h>
#include <FlowShop.h>
#include <FlowShopInit.h>
#include <FlowShopBenchmarkParser.h>
/*
* This function creates an eoInit<eoFlowShop> that can later be used to initialize the population (see make_pop.h).
* @param eoParser& _parser to get user parameters
* @param eoState& _state to store the memory
*/
eoInit<FlowShop> & do_make_genotype(eoParser& _parser, eoState& _state)
{
// benchmark file name
std::string benchmarkFileName = _parser.getORcreateParam(std::string("../flowshop/benchs/020_20_01.txt"), "BenchmarkFile", "Benchmark file name (benchmarks are available at www.lifl.fr/~liefooga/benchmarks/)", 'B',"Representation", false).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());
// }
// reading of number of jobs to schedule contained in the benchmark file
FlowShopBenchmarkParser fParser(benchmarkFileName);
unsigned int N = fParser.getN();
// build of the initializer (a pointer, stored in the eoState)
eoInit<FlowShop>* init = new FlowShopInit(N);
// store in state
_state.storeFunctor(init);
// and return a reference
return *init;
}
#endif /*MAKE_GENOTYPE_FLOWSHOP_H_*/

View file

@ -0,0 +1,132 @@
/*
* <make_op_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 MAKE_OP_FLOWSHOP_H_
#define MAKE_OP_FLOWSHOP_H_
#include <utils/eoParser.h>
#include <utils/eoState.h>
#include <eoOp.h>
#include <eoGenOp.h>
#include <eoCloneOps.h>
#include <eoOpContainer.h>
#include <eoProportionalCombinedOp.h>
#include <FlowShopOpCrossoverQuad.h>
#include <FlowShopOpMutationShift.h>
#include <FlowShopOpMutationExchange.h>
/*
* This function builds the operators that will be applied to the eoFlowShop
* @param eoParameterLoader& _parser to get user parameters
* @param eoState& _state to store the memory
*/
eoGenOp<FlowShop> & do_make_op(eoParameterLoader& _parser, eoState& _state)
{
/////////////////////////////
// Variation operators
////////////////////////////
// the crossover
////////////////
// a first crossover
eoQuadOp<FlowShop> *cross = new FlowShopOpCrossoverQuad;
// store in the state
_state.storeFunctor(cross);
// relative rate in the combination
double cross1Rate = _parser.createParam(1.0, "crossRate", "Relative rate for the only crossover", 0, "Variation Operators").value();
// creation of the combined operator with this one
eoPropCombinedQuadOp<FlowShop> *propXover = new eoPropCombinedQuadOp<FlowShop>(*cross, cross1Rate);
// store in the state
_state.storeFunctor(propXover);
// the mutation
///////////////
// a first mutation : the shift mutation
eoMonOp<FlowShop> *mut = new FlowShopOpMutationShift;
_state.storeFunctor(mut);
// its relative rate in the combination
double mut1Rate = _parser.createParam(0.5, "shiftMutRate", "Relative rate for shift mutation", 0, "Variation Operators").value();
// creation of the combined operator with this one
eoPropCombinedMonOp<FlowShop> *propMutation = new eoPropCombinedMonOp<FlowShop>(*mut, mut1Rate);
_state.storeFunctor(propMutation);
// a second mutation : the exchange mutation
mut = new FlowShopOpMutationExchange;
_state.storeFunctor(mut);
// its relative rate in the combination
double mut2Rate = _parser.createParam(0.5, "exchangeMutRate", "Relative rate for exchange mutation", 0, "Variation Operators").value();
// addition of this one to the combined operator
propMutation -> add(*mut, mut2Rate);
// end of crossover and mutation definitions
////////////////////////////////////////////
// First read the individual level parameters
eoValueParam<double>& pCrossParam = _parser.createParam(0.25, "pCross", "Probability of Crossover", 'c', "Variation Operators" );
// minimum check
if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
throw std::runtime_error("Invalid pCross");
eoValueParam<double>& pMutParam = _parser.createParam(0.35, "pMut", "Probability of Mutation", 'm', "Variation Operators" );
// minimum check
if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
throw std::runtime_error("Invalid pMut");
// the crossover - with probability pCross
eoProportionalOp<FlowShop> * propOp = new eoProportionalOp<FlowShop> ;
_state.storeFunctor(propOp);
eoQuadOp<FlowShop> *ptQuad = new eoQuadCloneOp<FlowShop>;
_state.storeFunctor(ptQuad);
propOp -> add(*propXover, pCrossParam.value()); // crossover, with proba pcross
propOp -> add(*ptQuad, 1-pCrossParam.value()); // nothing, with proba 1-pcross
// now the sequential
eoSequentialOp<FlowShop> *op = new eoSequentialOp<FlowShop>;
_state.storeFunctor(op);
op -> add(*propOp, 1.0); // always do combined crossover
op -> add(*propMutation, pMutParam.value()); // then mutation, with proba pmut
// return a reference
return *op;
}
#endif /*MAKE_OP_FLOWSHOP_H_*/