40 #include "GeneratorConfig.h"
48 EXIT_WITH_SUCCESS = 0,
49 INVALID_PARAMETER = 1,
50 INSUFFICIENT_PARAMETERS = 2,
51 INPUT_OUTPUT_ERROR = 4,
58 cout<<
"Generator of instances for energy optimisation of robotics lines."<<endl;
59 cout<<
"Author: Libor Bukata and Premysl Sucha"<<endl;
60 cout<<
"Licence: GNU General Public License"<<endl;
61 cout<<
"Version: "<<PROGRAM_VERSION<<endl<<endl;
71 cout<<
"\t"<<progName<<
" [options+parameters]"<<endl;
72 cout<<
"Options:"<<endl;
73 cout<<
"\t--project-configuration-file ARG, -pcf ARG, ARG=FILE"<<endl;
74 cout<<
"\t\tIt reads the desired parameters of the project from the file."<<endl;
75 cout<<
"\t--number-of-instances ARG, -noi ARG, ARG=POSITIVE_INTEGER"<<endl;
76 cout<<
"\t\tThe number of generated instances for the project."<<endl;
77 cout<<
"\t--output-file ARG, -of ARG, ARG=FILE"<<endl;
78 cout<<
"\t\tOutput xml file to which the generated instances will be written."<<endl;
79 cout<<
"\t--set-dataset-title ARG, -sdt ARG, ARG=STRING"<<endl;
80 cout<<
"\t\tSet short title (<name>ARG</name>) of the dataset."<<endl;
81 cout<<
"\t--help, -h"<<endl;
82 cout<<
"\t\tIt prints this program help."<<endl;
83 cout<<
"\t--verbose"<<endl;
84 cout<<
"\t\tIt also prints additional information (program header, progress bar, and runtime)."<<endl<<endl;
85 cout<<
"Default settings can be modified at \"DefaultSettings.h\" file."<<endl;
93 int main(
int argc,
char* argv[]) {
95 for (
int i = 1; i < argc; ++i) {
99 if (arg ==
"--project-configuration-file" || arg ==
"-pcf") {
101 Settings::PROJECT_CONFIGURATION_FILE = argv[++i];
103 cerr<<
"Project configuration file was not specified!"<<endl;
104 return INVALID_PARAMETER;
110 if (arg ==
"--number-of-instances" || arg ==
"-noi") {
112 string number = argv[++i];
113 istringstream istr(number, istringstream::in);
114 istr>>Settings::NUMBER_OF_INSTANCES;
115 if (any_of(number.cbegin(), number.cend(), [](
char c) {
return (c < '0' || c >
'9') ?
true :
false; }) || istr.fail()) {
116 cerr<<
"Cannot parse '"<<number<<
"' to number!"<<endl;
117 cout<<
"\"--number-of-instances\" invalid parameter!"<<endl;
118 return INVALID_PARAMETER;
121 cout<<
"\"--number-of-instances\" requires the parameter!"<<endl;
127 if (arg ==
"--output-file" || arg ==
"-of") {
129 Settings::OUTPUT_FILE = argv[++i];
131 cerr<<
"\"--output-file\" requires the parameter!"<<endl;
132 return INVALID_PARAMETER;
138 if (arg ==
"--set-dataset-title" || arg ==
"-sdt") {
140 Settings::DATASET_TITLE = argv[++i];
142 cerr<<
"\"--set-dataset-title\" requires the parameter!"<<endl;
143 return INVALID_PARAMETER;
149 if (arg ==
"--verbose" || arg ==
"-v") {
150 Settings::VERBOSE =
true;
154 if (arg ==
"--help" || arg ==
"-h") {
156 return EXIT_WITH_SUCCESS;
159 cerr<<
"Unknown argument \""<<arg<<
"\"!"<<endl;
160 cerr<<
"Check help by using \"-h\" or \"--help\" arguments."<<endl;
161 return INVALID_PARAMETER;
164 if (Settings::OUTPUT_FILE.empty()) {
165 cerr<<
"Insufficient parameters, at least the output file has to be specified!"<<endl;
166 cerr<<
"See the following program help..."<<endl<<endl;
168 return INSUFFICIENT_PARAMETERS;
172 if (Settings::VERBOSE ==
true)
178 generator.setParameters(parameters);
180 }
catch (invalid_argument e) {
181 cerr<<e.what()<<endl;
182 return INPUT_OUTPUT_ERROR;
183 }
catch (runtime_error e) {
184 cerr<<e.what()<<endl;
185 return RUNTIME_ERROR;
186 }
catch (exception& e) {
187 cerr<<e.what()<<endl;
188 return UNKNOWN_ERROR;
191 return EXIT_WITH_SUCCESS;
ProgramReturnedCodes
Return codes of the program.
The structure with desired properties for the generated instances.
void printProgramHelp(const string &progName)
It prints the program header and help.
int main(int argc, char *argv[])
It handles the program command line arguments, reads desired properties of instances, generates and writes them to the xml file.
The file contains the Generator class.
It reads the desired properties of instances from the text file.
void generateProblems(uint32_t numberOfProblems=Settings::NUMBER_OF_INSTANCES)
It generates the specified number of instances and writes them to the xml file.
void printProgramHeader()
It prints the program header to the standard output.
It declares the class for parsing the desired properties of project instances.
The file declares the structure for storing the properties of generated instances.
It declares the namespace for program settings.
It encapsulates the RoboticLine and XmlWriter classes and adds the additional features.