change tutorials to tutorial

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@385 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-06-26 12:17:31 +00:00
commit 2fdf1525fc
30 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1 @@
SUBDIRS=lesson1

View file

@ -0,0 +1,114 @@
// -*- 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 <MOEO.h>
#include <moeoObjectiveVector.h>
#include <moeoObjectiveVectorTraits.h>
/**
* definition of the objective vector for multi-objective flow-shop problems
*/
typedef moeoObjectiveVectorDouble<moeoObjectiveVectorTraits> FlowShopObjectiveVector;
/**
* Structure of the genotype for the flow-shop scheduling problem
*/
class FlowShop: public MOEO<FlowShopObjectiveVector, double, double> {
public:
/**
* default constructor
*/
FlowShop() {}
/**
* destructor
*/
virtual ~FlowShop() {}
/**
* class name
*/
virtual string className() const {
return "FlowShop";
}
/**
* set scheduling vector
* @param vector<unsigned> & _scheduling the new scheduling to set
*/
void setScheduling(vector<unsigned> & _scheduling) {
scheduling = _scheduling;
}
/**
* get scheduling vector
*/
const vector<unsigned> & getScheduling() const {
return scheduling;
}
/**
* printing...
*/
void printOn(ostream& _os) const {
// fitness
MOEO<FlowShopObjectiveVector, double, double>::printOn(_os);
// size
_os << scheduling.size() << "\t" ;
// scheduling
for (unsigned i=0; i<scheduling.size(); i++)
_os << scheduling[i] << ' ' ;
}
/**
* reading...
*/
void readFrom(istream& _is) {
// fitness
MOEO<FlowShopObjectiveVector, double, double>::readFrom(_is);
// size
unsigned size;
_is >> size;
// scheduling
scheduling.resize(size);
bool tmp;
for (unsigned i=0; i<size; i++) {
_is >> tmp;
scheduling[i] = tmp;
}
}
bool operator==(const FlowShop& _other) const { return scheduling == _other.getScheduling(); }
bool operator!=(const FlowShop& _other) const { return scheduling != _other.getScheduling(); }
bool operator< (const FlowShop& _other) const { return scheduling < _other.getScheduling(); }
bool operator> (const FlowShop& _other) const { return scheduling > _other.getScheduling(); }
bool operator<=(const FlowShop& _other) const { return scheduling <= _other.getScheduling(); }
bool operator>=(const FlowShop& _other) const { return scheduling >= _other.getScheduling(); }
private:
/** scheduling (order of operations) */
std::vector<unsigned> scheduling;
};
#endif /*FLOWSHOP_H_*/

View file

@ -0,0 +1,140 @@
// -*- 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 <stdexcept>
#include <fstream>
/** Web site to download benchmarks */
const static std::string BENCHMARKS_WEB_SITE = "www.lifl.fr/~basseur/BenchsUncertain/";
/**
* Class to handle parameters of a flow-shop instance from a benchmark file
* benchmark files are available at www.lifl.fr/~basseur/BenchsUncertain/
*/
class FlowShopBenchmarkParser {
public:
/**
* constructor
* @param const string _benchmarkFileName the name of the benchmark file
*/
FlowShopBenchmarkParser(const string _benchmarkFileName) {
init(_benchmarkFileName);
}
/**
* the number of machines
*/
const unsigned getM() {
return M;
}
/**
* the number of jobs
*/
const unsigned getN() {
return N;
}
/**
* the processing times
*/
const std::vector< std::vector<unsigned> > getP() {
return p;
}
/**
* the due-dates
*/
const std::vector<unsigned> getD() {
return d;
}
/**
* printing...
*/
void printOn(ostream& _os) const {
_os << "M=" << M << " N=" << N << endl;
_os << "*** processing times" << endl;
for (unsigned i=0; i<M; i++) {
for (unsigned j=0; j<N; j++) {
_os << p[i][j] << " ";
}
_os << endl;
}
_os << "*** due-dates" << endl;
for (unsigned j=0; j<N; j++) {
_os << d[j] << " ";
}
_os << endl << endl;
}
private:
/** number of machines */
unsigned M;
/** number of jobs */
unsigned N;
/** p[i][j] = processing time of job j on machine i */
std::vector< std::vector<unsigned> > p;
/** d[j] = due-date of the job j */
std::vector<unsigned> d;
/**
* Initialisation of the parameters with the data contained in the benchmark file
* @param const string _benchmarkFileName the name of the benchmark file
*/
void init(const string _benchmarkFileName) {
string buffer;
string::size_type start, end;
ifstream inputFile(_benchmarkFileName.data(), ios::in);
// opening of the benchmark file
if (! inputFile)
cerr << "*** ERROR : Unable to open the benchmark file '" << _benchmarkFileName << "'" << endl;
// 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> > (M,N);
d = std::vector<unsigned> (N);
// for each job...
for (unsigned 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 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();
}
};
#endif /*FLOWSHOPBENCHMARKPARSER_H_*/

Binary file not shown.

View file

@ -0,0 +1,118 @@
// -*- 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
*/
//-----------------------------------------------------------------------------
// Miscilaneous include and declaration
using namespace std;
/* EO + MOEO */
// 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);
/* FLOW-SHOP */
// definition of representation
#include "FlowShop.h"
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);
pop.sort();
arch.update(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;
}

View file

@ -0,0 +1,48 @@
###### General ######
# --help=0 # -h : Prints this message
# --stopOnUnknownParam=1 # Stop if unkown param entered
# --seed=1176819700 # -S : Random number seed
###### Evolution Engine ######
# --popSize=20 # -P : Population Size
# --updateArch=1 # Update the archive at each gen.
# --fitness=FastNonDominatedSorting # -F : Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased
# --indicator=Epsilon # -i : Binary indicator for IndicatorBased: Epsilon, Hypervolume
# --rho=1.1 # -r : reference point for the hypervolume indicator
# --kappa=0.05 # -k : Scaling factor kappa for IndicatorBased
# --diversity=Dummy # -D : Diversity assignment scheme: Dummy or CrowdingDistance
# --comparator=FitnessThenDiversity # -C : Comparator scheme: FitnessThenDiversity or DiversityThenFitness
# --selection=DetTour(2) # -S : Selection scheme: DetTour(T), StochTour(t) or Random
# --replacement=Elitist # -R : Replacement scheme: Elitist, Environmental or Generational
# --nbOffspring=100% # -O : Number of offspring (percentage or absolute)
###### Output ######
# --resDir=Res # Directory to store DISK outputs
# --eraseDir=1 # erase files in dirName if any
# --printPop=0 # Print sorted pop. every gen.
# --storeArch=0 # Store the archive's objective vectors at each gen.
# --contribution=0 # Store the contribution of the archive at each gen.
# --entropy=0 # Store the entropy of the archive at each gen.
###### Persistence ######
# --Load= # -L : A save file to restart from
# --recomputeFitness=0 # -r : Recompute the fitness after re-loading the pop.?
# --saveFrequency=0 # Save every F generation (0 = only final state, absent = never)
# --saveTimeInterval=0 # Save every T seconds (0 or absent = never)
# --status=./FlowShopEA.status # Status file
###### Representation ######
--BenchmarkFile=benchmarks/020_10_01.txt # -B : Benchmark file name (benchmarks are available at www.lifl.fr/~basseur/BenchsUncertain/) REQUIRED
###### Stopping criterion ######
# --maxGen=100 # -G : Maximum number of generations (0 = none)
# --maxEval=0 # -E : Maximum number of evaluations (0 = none)
# --CtrlC=1 # -C : Terminate current generation upon Ctrl C
###### Variation Operators ######
# --crossRate=1 # Relative rate for the only crossover
# --shiftMutRate=0.5 # Relative rate for shift mutation
# --exchangeMutRate=0.5 # Relative rate for exchange mutation
# --pCross=0.25 # -c : Probability of Crossover
# --pMut=0.35 # -m : Probability of Mutation

View file

@ -0,0 +1,129 @@
// -*- 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 "FlowShop.h"
#include <moeoEvalFunc.h>
/**
* Functor
* Computation of the multi-objective evaluation of a FlowShop object
*/
class FlowShopEval : public moeoEvalFunc<FlowShop> {
public:
/**
* constructor
* @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(const unsigned _M, const unsigned _N, const vector< vector<unsigned> > & _p, const vector<unsigned> & _d) :
M(_M), N (_N), p(_p), d(_d){
unsigned nObjs = 2;
std::vector<bool> bObjs(nObjs, true);
moeoObjectiveVectorTraits::setup(nObjs, bObjs);
}
/**
* computation of the multi-objective evaluation of an eoFlowShop object
* @param FlowShop & _eo the FlowShop object to evaluate
*/
void operator()(FlowShop & _eo) {
FlowShopObjectiveVector objVector;
objVector[0] = tardiness(_eo);
objVector[1] = makespan(_eo);
_eo.objectiveVector(objVector);
}
private:
/** number of machines */
unsigned M;
/** number of jobs */
unsigned N;
/** p[i][j] = processing time of job j on machine i */
std::vector< std::vector<unsigned> > p;
/** d[j] = due-date of the job j */
std::vector<unsigned> d;
/**
* computation of the makespan
* @param FlowShop _eo the FlowShop object to evaluate
*/
double makespan(FlowShop _eo) {
// the scheduling to evaluate
vector<unsigned> scheduling = _eo.getScheduling();
// 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> > C = completionTime(_eo);
// fitness == C[M-1][scheduling[N-1]];
return C[M-1][scheduling[N-1]];
}
/**
* computation of the tardiness
* @param _eo the FlowShop object to evaluate
*/
double tardiness(FlowShop _eo) {
// the scheduling to evaluate
vector<unsigned> scheduling = _eo.getScheduling();
// 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> > C = completionTime(_eo);
// tardiness computation
unsigned long sum = 0;
for (unsigned j=0 ; j<N ; j++)
sum += (unsigned) std::max (0, (int) (C[M-1][scheduling[j]] - d[scheduling[j]]));
// fitness == sum
return sum;
}
/**
* 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 const FlowShop _eo the genotype to evaluate
*/
std::vector< std::vector<unsigned> > completionTime(FlowShop _eo) {
vector<unsigned> scheduling = _eo.getScheduling();
std::vector< std::vector<unsigned> > C(M,N);
C[0][scheduling[0]] = p[0][scheduling[0]];
for (unsigned j=1; j<N; j++)
C[0][scheduling[j]] = C[0][scheduling[j-1]] + p[0][scheduling[j]];
for (unsigned i=1; i<M; i++)
C[i][scheduling[0]] = C[i-1][scheduling[0]] + p[i][scheduling[0]];
for (unsigned i=1; i<M; i++)
for (unsigned j=1; j<N; j++)
C[i][scheduling[j]] = std::max(C[i][scheduling[j-1]], C[i-1][scheduling[j]]) + p[i][scheduling[j]];
return C;
}
};
#endif /*FLOWSHOPEVAL_H_*/

View file

@ -0,0 +1,64 @@
// -*- 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"
/**
* Functor
* Initialisation of a random genotype built by the default constructor of the eoFlowShop class
*/
class FlowShopInit: public eoInit<FlowShop> {
public:
/**
* constructor
* @param const unsigned _N the number of jobs to schedule
*/
FlowShopInit(const unsigned _N) {
N = _N;
}
/**
* randomize a genotype
* @param FlowShop & _genotype a genotype that has been default-constructed
*/
void operator()(FlowShop & _genotype) {
// scheduling vector
vector<unsigned> scheduling(N);
// initialisation of possible values
vector<unsigned> possibles(N);
for (unsigned i=0 ; i<N ; i++)
possibles[i] = i;
// random initialization
unsigned rInd; // random index
for (unsigned i=0; i<N; i++) {
rInd = (unsigned) rng.uniform(N-i);
scheduling[i] = possibles[rInd];
possibles[rInd] = possibles[N-i-1];
}
_genotype.setScheduling(scheduling);
_genotype.invalidate(); // IMPORTANT in case the _genotype is old
}
private:
/** the number of jobs (size of a scheduling vector) */
unsigned N;
};
#endif /*FLOWSHOPINIT_H_*/

View file

@ -0,0 +1,120 @@
// -*- 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"
/**
* Functor
* Quadratic crossover operator for flow-shop (modify the both genotypes)
*/
class FlowShopOpCrossoverQuad: public eoQuadOp<FlowShop> {
public:
/**
* default constructor
*/
FlowShopOpCrossoverQuad() {}
/**
* the class name (used to display statistics)
*/
string className() const {
return "FlowShopOpCrossoverQuad";
}
/**
* eoQuad crossover - _genotype1 and _genotype2 are the (future) offspring, i.e. _copies_ of the parents
* @param FlowShop & _genotype1 the first parent
* @param FlowShop & _genotype2 the second parent
*/
bool operator()(FlowShop & _genotype1, FlowShop & _genotype2) {
bool oneAtLeastIsModified;
// parents
vector<unsigned> parent1 = _genotype1.getScheduling();
vector<unsigned> parent2 = _genotype2.getScheduling();
// computation of the 2 random points
unsigned point1, point2;
do {
point1 = rng.random(min(parent1.size(), parent2.size()));
point2 = rng.random(min(parent1.size(), parent2.size()));
} while (fabs((double) point1-point2) <= 2);
// computation of the offspring
vector<unsigned> offspring1 = generateOffspring(parent1, parent2, point1, point2);
vector<unsigned> offspring2 = generateOffspring(parent2, parent1, point1, point2);
// does at least one genotype has been modified ?
if ((parent1 != offspring1) || (parent2 != offspring2)) {
// update
_genotype1.setScheduling(offspring1);
_genotype2.setScheduling(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;
}
private:
/**
* generation of an offspring by a 2 points crossover
* @param vector<unsigned> _parent1 the first parent
* @param vector<unsigned> _parent2 the second parent
* @param unsigned_point1 the first point
* @param unsigned_point2 the second point
*/
vector<unsigned> generateOffspring(vector<unsigned> _parent1, vector<unsigned> _parent2, unsigned _point1, unsigned _point2) {
vector<unsigned> result = _parent1;
vector<bool> taken_values(result.size(), false);
if (_point1 > _point2) swap(_point1, _point2);
/* first parent */
for (unsigned i=0 ; i<=_point1 ; i++) {
// result[i] == _parent1[i]
taken_values[_parent1[i]] = true;
}
for (unsigned i=_point2 ; i<result.size() ; i++) {
// result[i] == _parent1[i]
taken_values[_parent1[i]] = true;
}
/* second parent */
unsigned i = _point1+1;
unsigned j = 0;
while (i<_point2 && j<_parent2.size()) {
if (! taken_values[_parent2[j]]) {
result[i] = _parent2[j];
i++;
}
j++;
}
return result;
}
};
#endif /*FLOWSHOPOPCROSSOVERQUAD_H_*/

View file

@ -0,0 +1,78 @@
// -*- 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"
/**
* Functor
* Exchange mutation operator for flow-shop
*/
class FlowShopOpMutationExchange: public eoMonOp<FlowShop> {
public:
/**
* default constructor
*/
FlowShopOpMutationExchange() {}
/**
* the class name (used to display statistics)
*/
string className() const {
return "FlowShopOpMutationExchange";
}
/**
* modifies the parent with an exchange mutation
* @param FlowShop & _genotype the parent genotype (will be modified)
*/
bool operator()(FlowShop & _genotype) {
bool isModified;
// schedulings
vector<unsigned> initScheduling = _genotype.getScheduling();
vector<unsigned> resultScheduling = _genotype.getScheduling();
// computation of the 2 random points
unsigned point1, point2;
do {
point1 = rng.random(resultScheduling.size());
point2 = rng.random(resultScheduling.size());
} while (point1 == point2);
// swap
swap (resultScheduling[point1], resultScheduling[point2]);
// update (if necessary)
if (resultScheduling != initScheduling) {
// update
_genotype.setScheduling(resultScheduling);
// 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;
}
};
#endif /*FLOWSHOPOPMUTATIONEXCHANGE_H_*/

View file

@ -0,0 +1,86 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// FlowShopOpMutationShift.h
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
/*
This library...
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
*/
//-----------------------------------------------------------------------------
#ifndef FLOWSHOPOPMUTATIONSHIFT_H_
#define FLOWSHOPOPMUTATIONSHIFT_H_
#include <eoOp.h>
#include "FlowShop.h"
/**
* Functor
* Shift mutation operator for flow-shop
*/
class FlowShopOpMutationShift: public eoMonOp<FlowShop> {
public:
/**
* default constructor
*/
FlowShopOpMutationShift() {}
/**
* the class name (used to display statistics)
*/
string className() const {
return "FlowShopOpMutationShift";
}
/**
* modifies the parent with a shift mutation
* @param FlowShop & _genotype the parent genotype (will be modified)
*/
bool operator()(FlowShop & _genotype) {
bool isModified;
int direction;
unsigned tmp;
// schedulings
vector<unsigned> initScheduling = _genotype.getScheduling();
vector<unsigned> resultScheduling = initScheduling;
// computation of the 2 random points
unsigned point1, point2;
do {
point1 = rng.random(resultScheduling.size());
point2 = rng.random(resultScheduling.size());
} while (point1 == point2);
// direction
if (point1 < point2) direction = 1;
else direction = -1;
// mutation
tmp = resultScheduling[point1];
for (unsigned i=point1 ; i!=point2 ; i+=direction)
resultScheduling[i] = resultScheduling[i+direction];
resultScheduling[point2] = tmp;
// update (if necessary)
if (resultScheduling != initScheduling) {
// update
_genotype.setScheduling(resultScheduling);
// 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;
}
};
#endif /*FLOWSHOPOPMUTATIONSHIFT_H_*/

View file

@ -0,0 +1,9 @@
noinst_PROGRAMS = FlowShopEA
FlowShopEA_SOURCES = FlowShopEA.cpp
LDADD = -L$(top_builddir)/src ${EO_DIR}/src/libeo.a ${EO_DIR}/src/utils/libeoutils.a
INCLUDES = -I${EO_DIR}/src/ -I${MO_DIR}/src/ -I$(top_srcdir)/src

View file

@ -0,0 +1,63 @@
20
5
873654221
0
468
54 79 16 66 58
1
325
83 3 89 58 56
2
923
15 11 49 31 20
3
513
71 99 15 68 85
4
1070
77 56 89 78 53
5
690
36 70 45 91 35
6
602
53 99 60 13 53
7
289
38 60 23 59 41
8
873
27 5 57 49 69
9
342
87 56 64 85 13
10
764
76 3 7 85 86
11
268
91 61 1 9 72
12
1158
14 73 63 39 8
13
646
29 75 41 41 49
14
1111
12 47 63 56 47
15
965
77 14 47 40 87
16
703
32 21 26 54 58
17
1205
87 86 75 77 18
18
334
68 5 77 51 68
19
1111
94 77 40 31 28

View file

@ -0,0 +1,63 @@
20
5
379008056
0
517
26 59 78 88 69
1
461
38 62 90 54 30
2
832
27 44 64 47 61
3
653
88 10 49 83 35
4
933
95 23 47 84 53
5
811
55 64 20 9 98
6
966
54 47 61 30 94
7
448
63 68 93 11 33
8
577
23 54 36 92 77
9
1122
45 9 47 63 31
10
666
86 30 70 62 54
11
1189
43 31 54 75 71
12
470
43 92 87 48 78
13
475
40 7 13 23 9
14
462
37 14 40 85 79
15
866
54 95 34 23 51
16
392
35 76 55 4 76
17
310
59 82 13 31 56
18
719
43 91 11 13 80
19
1221
50 37 5 98 72

View file

@ -0,0 +1,63 @@
20
10
587595453
0
1250
74 28 89 60 54 92 9 4 25 15
1
1371
21 3 52 88 66 11 8 18 15 84
2
637
58 27 56 26 12 54 88 25 91 8
3
616
4 61 13 58 57 97 72 28 49 30
4
917
21 34 7 76 70 57 27 95 56 95
5
937
28 76 32 98 82 53 22 51 10 79
6
1435
58 64 32 29 99 65 50 84 62 9
7
1197
83 87 98 47 84 77 2 18 70 91
8
1301
31 54 46 79 16 51 49 6 76 76
9
637
61 98 60 26 41 36 82 90 99 26
10
749
94 76 23 19 23 53 93 69 58 42
11
1223
44 41 87 48 11 19 96 61 83 66
12
887
97 70 7 95 68 54 43 57 84 70
13
1316
94 43 36 78 58 86 13 5 64 91
14
1330
66 42 26 77 30 40 60 75 74 67
15
1380
6 79 85 90 5 56 11 4 14 3
16
767
37 88 7 24 5 79 37 38 18 98
17
574
22 15 34 10 39 74 91 28 48 4
18
1398
99 49 36 85 58 24 84 4 96 71
19
1179
83 72 48 55 31 3 67 80 86 62

View file

@ -0,0 +1,63 @@
20
10
1401007982
0
1279
80 59 59 31 30 53 93 90 65 64
1
1481
13 83 70 64 88 19 79 92 97 38
2
1157
64 85 76 11 14 99 88 35 27 44
3
1391
77 85 10 9 22 62 77 13 25 46
4
763
17 70 65 32 93 88 94 75 61 66
5
1456
78 35 19 58 48 93 39 55 24 31
6
900
82 2 77 98 10 34 74 80 97 48
7
1047
4 76 86 95 7 72 46 67 61 27
8
1355
72 46 21 25 14 42 17 3 75 82
9
1262
93 72 75 4 91 65 30 93 92 51
10
1329
68 69 96 45 5 39 62 54 73 90
11
562
25 46 3 60 43 79 77 67 21 63
12
684
67 3 50 87 30 9 43 25 29 85
13
567
80 57 57 31 79 26 98 77 3 36
14
765
43 71 66 1 39 72 48 38 96 69
15
808
93 77 84 96 34 29 14 98 51 67
16
999
21 33 98 22 77 36 45 96 26 81
17
548
33 49 55 95 81 48 25 20 44 18
18
577
14 59 70 73 11 57 98 15 56 81
19
704
30 82 32 77 10 95 30 36 31 72

View file

@ -0,0 +1,63 @@
20
20
479340445
0
1696
50 78 36 85 9 75 46 73 71 7 49 3 60 12 75 31 70 20 88 9
1
1273
90 56 43 88 92 64 94 3 49 40 49 53 88 47 19 61 78 78 30 41
2
1546
39 9 10 60 98 96 6 56 36 33 15 59 15 46 60 47 41 38 34 22
3
1882
34 43 19 98 44 95 19 73 87 64 18 7 26 17 87 32 9 26 33 34
4
1117
66 84 55 4 51 22 20 80 8 5 65 65 11 43 27 34 47 64 21 83
5
1181
81 73 48 99 8 41 51 82 25 25 55 58 16 16 48 69 94 62 7 55
6
1416
27 66 85 53 31 26 85 36 76 89 1 24 55 91 72 32 26 11 94 3
7
1635
48 38 70 21 15 33 92 98 73 95 79 55 59 94 88 1 65 38 10 8
8
1723
46 83 82 33 47 68 43 90 80 58 10 26 81 73 48 1 17 68 73 75
9
1932
68 57 39 53 31 9 75 46 6 83 37 40 53 89 59 80 42 37 85 30
10
1219
48 97 91 63 80 81 70 10 6 28 77 89 92 12 74 19 59 74 82 57
11
1521
92 52 82 18 83 28 70 46 33 35 80 94 23 58 86 57 80 9 62 65
12
1322
78 77 85 45 20 61 36 65 79 74 79 51 55 25 49 98 7 65 99 89
13
1057
84 13 17 29 84 69 31 83 10 5 84 74 79 24 94 37 75 16 67 60
14
1922
93 12 6 43 69 37 76 75 93 6 93 54 13 55 15 31 63 38 61 90
15
1130
39 2 54 41 49 57 63 47 65 9 21 86 89 1 95 51 96 85 10 84
16
1411
43 65 87 80 93 36 89 61 26 3 85 22 2 67 41 66 7 50 4 74
17
1840
1 93 85 4 39 80 46 28 73 2 64 83 17 3 94 38 10 62 70 17
18
1741
65 39 4 31 13 96 25 59 42 35 46 19 97 1 15 62 47 39 31 2
19
1377
87 1 72 19 88 74 88 22 18 41 35 44 41 71 71 72 38 97 49 19

View file

@ -0,0 +1,153 @@
50
5
1328042058
0
1290
75 26 48 26 77
1
2352
87 37 4 67 94
2
362
13 25 92 4 9
3
305
11 95 92 14 57
4
262
41 49 72 93 29
5
1250
43 12 45 54 79
6
2170
93 59 5 21 55
7
1601
69 17 98 20 73
8
2039
80 46 93 6 65
9
1628
13 20 17 18 86
10
483
24 52 79 75 25
11
285
72 44 11 25 39
12
1092
38 92 16 16 76
13
936
81 75 89 77 24
14
2349
83 95 81 28 38
15
473
88 33 92 24 5
16
2325
26 10 45 15 91
17
747
6 45 61 77 29
18
970
89 2 39 36 22
19
434
67 62 28 16 27
20
1258
70 62 94 32 39
21
2405
30 82 87 46 31
22
862
89 29 23 21 46
23
298
30 29 1 81 18
24
2014
68 94 55 28 93
25
2608
21 20 91 70 58
26
1737
78 42 67 89 85
27
2214
46 80 91 54 58
28
1910
99 94 4 96 97
29
2245
10 35 60 62 10
30
2211
17 8 38 46 79
31
547
23 41 25 60 93
32
2237
83 65 90 19 2
33
1327
47 4 93 97 87
34
700
86 71 13 13 17
35
1011
18 30 65 7 18
36
2001
67 14 25 44 10
37
1230
46 32 34 7 50
38
1020
4 50 47 73 8
39
1918
14 30 98 15 26
40
1001
4 27 91 66 14
41
1383
20 98 11 70 21
42
1229
88 39 46 97 15
43
2594
50 84 50 33 10
44
403
84 65 77 97 85
45
1515
58 12 5 64 46
46
431
93 58 14 73 42
47
1971
76 45 47 28 18
48
939
50 49 80 4 36
49
2028
30 15 45 87 2

View file

@ -0,0 +1,153 @@
50
10
1958948863
0
793
46 61 3 51 37 79 83 22 27 24
1
2280
52 87 1 24 16 93 87 29 92 47
2
939
79 51 58 21 42 68 38 99 75 39
3
2591
45 25 85 57 47 75 38 25 94 66
4
1540
97 73 33 69 94 37 86 98 18 41
5
2386
10 93 71 51 14 44 67 55 41 46
6
812
44 28 58 50 94 34 23 80 37 24
7
2524
24 90 56 51 34 39 19 82 58 23
8
1370
85 94 64 21 72 76 97 33 56 68
9
1319
75 59 43 19 36 62 78 68 20 50
10
2388
66 64 48 63 88 74 66 47 2 93
11
961
49 2 69 91 51 28 67 74 39 22
12
2831
95 16 96 11 41 78 7 26 91 64
13
2790
61 35 35 6 71 43 23 61 81 81
14
2076
19 53 82 31 94 98 67 95 33 94
15
2519
47 40 53 63 99 83 8 55 14 97
16
1981
84 81 64 36 11 91 77 11 88 54
17
695
13 26 11 39 97 27 71 42 22 82
18
2133
11 85 61 57 44 6 85 72 36 11
19
1871
19 4 36 47 77 82 29 14 65 91
20
1495
98 4 53 56 69 60 49 8 79 23
21
754
2 10 87 65 91 44 3 98 23 32
22
783
85 63 88 59 38 43 94 90 66 26
23
984
44 96 10 4 25 76 76 36 5 22
24
2004
7 55 32 10 87 99 95 75 15 12
25
2269
73 71 38 12 7 66 48 69 51 23
26
1771
19 66 25 62 66 11 4 26 2 34
27
2030
69 94 24 43 54 35 37 24 81 87
28
2603
12 7 90 49 86 52 82 55 12 59
29
2150
73 15 7 54 49 8 57 98 40 2
30
2157
85 11 11 87 3 40 61 86 59 38
31
2187
23 99 49 29 48 62 6 30 32 84
32
937
53 37 2 2 44 25 97 92 16 62
33
728
16 50 76 18 93 24 5 94 87 10
34
510
88 56 17 75 37 30 27 66 78 11
35
2786
8 69 32 39 82 1 95 47 41 93
36
2134
26 22 39 77 31 73 46 3 43 57
37
1046
42 56 9 69 59 27 92 41 94 81
38
2849
58 67 83 15 78 16 46 41 1 10
39
1956
63 63 69 78 33 91 52 47 93 40
40
2456
7 96 67 68 36 33 8 89 22 62
41
1105
2 74 28 37 3 11 11 28 93 49
42
1560
44 4 88 22 58 99 7 39 62 90
43
1745
38 42 23 41 10 2 54 80 53 34
44
2216
24 40 91 92 98 60 72 47 30 11
45
1157
76 30 71 67 6 90 57 57 34 81
46
1317
85 93 3 24 44 36 85 74 27 51
47
2372
61 36 26 87 62 62 22 38 30 21
48
777
32 25 41 91 24 15 87 59 54 39
49
972
90 87 96 31 94 3 65 5 77 27

View file

@ -0,0 +1,153 @@
50
20
1539989115
0
2509
52 63 82 16 63 94 79 22 80 96 53 54 71 27 95 3 92 80 61 74
1
2039
95 99 21 26 55 34 21 6 13 3 19 67 90 93 53 80 62 38 86 38
2
3096
42 69 79 46 59 89 93 24 64 50 99 25 59 49 54 78 11 55 16 4
3
2950
75 70 95 66 35 62 32 55 77 57 62 77 82 63 22 32 83 34 42 31
4
1249
44 53 46 76 21 47 8 48 17 66 88 38 22 65 84 53 87 85 14 62
5
2481
57 21 23 31 59 66 45 57 78 84 93 98 88 34 54 43 66 44 92 39
6
3193
89 10 40 36 78 76 37 78 82 98 34 96 35 10 2 85 98 47 67 97
7
3253
53 31 95 8 25 15 78 5 4 55 72 20 49 56 80 19 42 66 77 57
8
2123
84 80 87 37 30 18 26 50 72 70 42 15 78 51 84 48 23 19 46 9
9
2390
62 18 37 21 38 54 98 83 93 32 65 36 69 97 66 49 45 66 41 54
10
1764
91 5 24 3 78 24 17 70 68 31 39 65 76 52 25 66 52 61 78 13
11
2940
14 18 24 76 79 55 25 21 25 64 79 97 2 46 16 22 6 60 3 47
12
1635
95 17 65 67 58 96 21 71 67 11 9 27 14 16 79 37 3 98 72 6
13
3171
89 71 62 5 44 10 28 58 80 9 26 25 3 50 90 51 64 82 95 70
14
2670
4 90 19 47 38 12 68 36 43 32 72 61 22 96 51 82 55 79 53 19
15
2932
95 93 67 72 76 96 24 50 93 58 29 24 26 85 29 59 97 71 59 97
16
2054
2 14 66 66 70 53 62 31 21 98 36 97 44 61 29 88 83 28 34 41
17
3238
97 49 6 56 72 92 89 86 33 95 48 61 1 76 90 77 42 74 66 1
18
2466
68 52 65 95 85 77 60 29 14 25 57 75 4 30 83 19 81 27 42 57
19
2384
20 7 59 49 8 6 64 30 30 4 95 92 16 90 83 32 92 33 63 60
20
3473
33 78 2 47 10 91 38 93 59 45 93 73 55 42 19 52 68 13 27 62
21
3290
51 57 67 26 84 14 90 49 83 60 79 21 43 88 95 9 46 9 92 14
22
2086
98 41 82 81 42 41 87 83 85 87 88 29 87 37 87 96 56 12 8 90
23
2560
8 75 90 56 67 30 1 89 85 31 77 3 35 43 12 23 88 51 65 76
24
3253
85 98 30 76 20 85 99 44 70 1 94 96 76 88 34 64 50 16 34 12
25
3205
86 93 63 66 24 17 34 38 35 96 39 51 98 91 23 22 13 49 6 89
26
2534
73 33 5 36 75 23 9 62 2 22 74 26 78 14 44 37 23 83 42 37
27
2039
4 75 93 53 23 60 22 45 76 95 46 44 81 63 30 3 13 48 39 35
28
2273
40 68 53 26 33 76 74 22 46 73 17 56 48 65 82 52 49 13 2 91
29
2062
98 33 85 52 60 39 14 85 72 77 30 31 25 74 83 44 18 78 7 69
30
1909
12 60 81 29 20 85 14 39 69 30 62 64 81 71 42 11 50 96 85 55
31
2432
59 82 73 36 75 10 84 98 46 88 77 38 27 8 56 21 94 77 32 48
32
2624
44 24 34 68 83 65 75 56 3 14 43 44 84 39 89 85 71 68 14 56
33
3325
46 99 74 21 26 15 37 68 57 22 98 46 59 95 38 6 64 88 74 84
34
3427
2 4 13 71 92 55 32 84 71 93 48 66 98 82 96 40 31 77 59 22
35
1318
41 97 78 61 29 41 29 77 77 48 14 31 14 17 10 68 21 76 95 51
36
1539
28 24 35 71 39 28 32 67 33 10 45 48 32 38 3 30 2 73 48 43
37
3223
83 50 20 69 14 93 89 53 49 7 25 27 95 69 53 35 63 92 37 50
38
1703
28 55 16 28 74 88 12 46 59 14 98 82 30 17 97 58 58 72 59 62
39
1051
21 91 48 86 66 27 47 24 82 91 30 51 13 24 11 31 36 87 4 61
40
1512
80 46 12 27 86 77 19 52 59 5 90 90 68 66 65 11 64 66 42 10
41
2589
71 58 11 41 10 81 97 96 70 43 92 63 19 75 47 11 52 98 93 87
42
3248
4 17 80 86 27 19 7 2 76 30 35 85 57 52 76 6 8 40 32 99
43
2047
60 47 9 55 8 76 12 88 10 79 13 36 65 59 22 59 94 31 30 40
44
3333
34 82 24 17 7 55 43 33 65 39 75 69 13 4 17 64 51 75 16 91
45
1760
55 6 76 62 97 67 89 27 19 34 55 67 63 73 14 65 36 45 95 64
46
2333
53 15 32 96 84 65 14 49 77 77 80 81 26 56 11 23 82 98 58 62
47
2400
96 91 35 59 56 8 33 78 86 81 67 18 96 19 69 80 30 90 12 53
48
2142
37 74 66 53 61 18 56 82 21 11 3 81 53 39 91 75 17 4 95 33
49
1231
37 42 48 93 9 56 57 65 75 10 93 72 94 51 53 63 21 23 21 16

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