generator  1.2
Generator.cpp
1 /*
2  This file is part of the GeneratorOfDatasets program.
3 
4  GeneratorOfDatasets is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  GeneratorOfDatasets is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with GeneratorOfDatasets. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include <chrono>
18 #include <ctime>
19 #include <iomanip>
20 #include <iostream>
21 #include <string>
22 #include <stdexcept>
23 #include <stdint.h>
24 #include "Generator.h"
25 #include "XmlWriter.h"
26 
27 using namespace std;
28 using namespace std::chrono;
29 
30 void Generator::generateProblems(uint32_t numberOfProblems) {
31 
32  high_resolution_clock::time_point start = high_resolution_clock::now();
33 
34  vector<RoboticLine*> lines;
35  if (Settings::VERBOSE && numberOfProblems > 0)
36  cout<<"Generation of instances: "<<endl;
37 
38  for (uint32_t pn = 0; pn < numberOfProblems; ++pn) {
39  lines.push_back(new RoboticLine(mParameters));
40  if (Settings::VERBOSE) {
41  cout<<" 0 % ["<<setfill('#')<<setw(50)<<string(50*(numberOfProblems-pn-1)/numberOfProblems,' ')<<"] ";
42  cout<<setprecision(2)<<fixed<<100.0*(pn+1)/numberOfProblems<<" %"<<'\r';
43  cout.flush();
44  }
45  }
46 
47  if (Settings::VERBOSE && numberOfProblems > 0)
48  cout<<endl<<endl;
49 
50  XmlWriter writer(lines);
51  writer.writeXmlFile();
52 
53  for (uint32_t pn = 0; pn < numberOfProblems; ++pn) {
54  if (!lines[pn]->warnings().empty()) {
55  if (Settings::VERBOSE)
56  clog<<endl;
57  clog<<"Warnings for instance "<<pn<<":"<<endl;
58  for (const string& warn : lines[pn]->warnings())
59  clog<<warn<<endl;
60  }
61  }
62 
63  for (RoboticLine *r : lines)
64  delete r;
65 
66  duration<double> runtime = duration_cast<duration<double>>(high_resolution_clock::now()-start);
67  if (Settings::VERBOSE)
68  cout<<endl<<setprecision(10)<<"Total running time: "<<runtime.count()<<" s"<<endl;
69 }
70 
It primarily defines XmlWriter class for writing the generated instances to the file.
STL namespace.
void writeXmlFile(std::string filename=Settings::OUTPUT_FILE)
It transforms the instances of the robotic cells to the form of the xml file.
Definition: XmlWriter.cpp:31
The file contains the Generator class.
void generateProblems(uint32_t numberOfProblems=Settings::NUMBER_OF_INSTANCES)
It generates the specified number of instances and writes them to the xml file.
Definition: Generator.cpp:30
It writes problem instances to the xml file.
Definition: XmlWriter.h:55
The robotic cell corresponds to an instance of this class.
Definition: RoboticLine.h:553