change lesson1 to Lesson1
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@386 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
2fdf1525fc
commit
c496c12f40
27 changed files with 0 additions and 0 deletions
|
|
@ -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_*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue