update lesson1 new version

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@268 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-04-17 15:55:58 +00:00
commit 97b9338bef
14 changed files with 454 additions and 689 deletions

View file

@ -2,7 +2,7 @@
//-----------------------------------------------------------------------------
// FlowShopBenchmarkParser.h
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
/*
This library...
@ -10,26 +10,20 @@
*/
//-----------------------------------------------------------------------------
#ifndef _FlowShopBenchmarkParser_h
#define _FlowShopBenchmarkParser_h
// general include
#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/~liefooga/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
{
class FlowShopBenchmarkParser {
public:
@ -37,146 +31,110 @@ public:
* constructor
* @param const string _benchmarkFileName the name of the benchmark file
*/
FlowShopBenchmarkParser (const string _benchmarkFileName)
{
init (_benchmarkFileName);
FlowShopBenchmarkParser(const string _benchmarkFileName) {
init(_benchmarkFileName);
}
/**
* the number of machines
*/
const unsigned
getM ()
{
const unsigned getM() {
return M;
}
/**
* the number of jobs
*/
const unsigned
getN ()
{
const unsigned getN() {
return N;
}
/**
* the processing times
*/
const
std::vector <
std::vector < unsigned > >
getP ()
{
const std::vector< std::vector<unsigned> > getP() {
return p;
}
/**
* the due-dates
*/
const
std::vector < unsigned >
getD ()
{
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;
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] << " ";
}
for (unsigned j=0; j<N; j++) {
_os << d[j] << " ";
}
_os << endl << endl;
}
private:
/** number of machines */
unsigned
M;
unsigned M;
/** number of jobs */
unsigned
N;
unsigned N;
/** p[i][j] = processing time of job j on machine i */
std::vector < std::vector < unsigned > >
p;
std::vector< std::vector<unsigned> > p;
/** d[j] = due-date of the job j */
std::vector < unsigned >
d;
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;
void init(const string _benchmarkFileName) {
string buffer;
string::size_type start, end;
ifstream
inputFile (_benchmarkFileName.data (), ios::in);
ifstream inputFile(_benchmarkFileName.data(), ios::in);
// opening of the benchmark file
if (!inputFile)
cerr << "*** ERROR : Unable to open the benchmark file '" <<
_benchmarkFileName << "'" << endl;
if (! inputFile)
cerr << "*** ERROR : Unable to open the benchmark file '" << _benchmarkFileName << "'" << endl;
// number of jobs (N)
getline (inputFile, buffer, '\n');
N = atoi (buffer.data ());
getline(inputFile, buffer, '\n');
N = atoi(buffer.data());
// number of machines M
getline (inputFile, buffer, '\n');
M = atoi (buffer.data ());
getline(inputFile, buffer, '\n');
M = atoi(buffer.data());
// initial and current seeds (not used)
getline (inputFile, buffer, '\n');
getline(inputFile, buffer, '\n');
// processing times and due-dates
p = std::vector < std::vector < unsigned > > (M, N);
d = std::vector < unsigned >(N);
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);
}
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 ();
inputFile.close();
}
};
#endif
#endif /*FLOWSHOPBENCHMARKPARSER_H_*/