// -*- 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 #include /** 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 > getP() { return p; } /** * the due-dates */ const std::vector getD() { return d; } /** * printing... */ void printOn(ostream& _os) const { _os << "M=" << M << " N=" << N << endl; _os << "*** processing times" << endl; for (unsigned i=0; i > p; /** d[j] = due-date of the job j */ std::vector 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 > (M,N); d = std::vector (N); // for each job... for (unsigned j=0 ; j 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