My Project
OSCommandLine.cpp
Go to the documentation of this file.
1/* $Id: OSCommandLine.cpp 4340 2011-10-15 20:08:33Z Gassmann $ */
21#include <cstdio>
22#include <sstream>
23
24#include "OSConfig.h"
25#include "OSInstance.h"
26#include "OSOption.h"
27#include "OSOutput.h"
28#include "OSCommandLine.h"
29
30using std::string;
31
33
35{
36#ifndef NDEBUG
37 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Reset command line options\n");
38#endif
39 if (osinstance != NULL) delete osinstance;
40 osinstance = NULL;
41 if (osoption != NULL) delete osoption;
42 osoption = NULL;
43 serviceLocation = "";
44 serviceMethod = "";
45 solverName = "";
46 configFile = "";
47 osilFile = "";
48 osil = "";
49 osilOutputFile = "";
50 osolFile = "";
51 osol = "";
52 osolOutputFile = "";
53 osrlFile = "";
54 insListFile = "";
55 insList = "";
56 osplInputFile = "";
57 osplInput = "";
58 osplOutputFile = "";
59 mpsFile = "";
60 mps = "";
61 nlFile = "";
62 nl = "";
63 datFile = "";
64 dat = "";
65 gamsControlFile = "";
66 browser = "";
68 logFile = "";
70 jobID = "";
71 invokeHelp = false;
72 listOptions = false;
73 writeVersion = false;
74 printModel = false;
76 quit = false;
77#ifndef NDEBUG
78 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Done resetting command line options\n");
79#endif
80}// reset_options
81
83 osinstance(NULL),
84 osoption(NULL)
85{
86#ifndef NDEBUG
87 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Inside command line constructor\n");
88#endif
90}
91
93{
94#ifndef NDEBUG
95 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Inside command line destructor\n");
96#endif
97 if (osinstance != NULL) delete osinstance;
98 osinstance = NULL;
99 if (osoption != NULL) delete osoption;
100 osoption = NULL;
101}
102
104{
105 unsigned int k;
106 for (k = 0; k < solverName.length(); k++)
107 {
108 solverName[k] = (char)tolower(solverName[k]);
109 }
110}
111
113{
114 unsigned int k;
115 for (k = 0; k < solverName.length(); k++)
116 {
117 solverName[k] = (char)toupper(solverName[k]);
118 }
119}
120
122{
123 std::ostringstream outStr;
124 outStr << "The following command line options and values have been read:"
125 << std::endl;
126 if (serviceLocation != "")
127 outStr << "Service Location = "
129 << std::endl;
130 if (serviceMethod != "")
131 outStr << "Service Method = "
133 << std::endl;
134 if ( solverName != "")
135 outStr << "Selected Solver = "
136 << solverName
137 << std::endl;
138
139 if (configFile != "")
140 outStr << "Config file = "
141 << configFile
142 << std::endl;
143 if (osilFile != "")
144 outStr << "OSiL file = "
145 << osilFile
146 << std::endl;
147 if (osilOutputFile != "")
148 outStr << "OSiL output file = "
150 << std::endl;
151 if (osolFile != "")
152 outStr << "OSoL file = "
153 << osolFile
154 << std::endl;
155 if (osolOutputFile != "")
156 outStr << "OSoL output file = "
158 << std::endl;
159 if (osrlFile != "")
160 outStr << "OSrL file = "
161 << osrlFile
162 << std::endl;
163 if (insListFile != "")
164 outStr << "Instruction List file = "
165 << insListFile
166 << std::endl;
167 if (osplInputFile != "")
168 outStr << "OSpL Input file = "
170 << std::endl;
171 if (osplOutputFile != "")
172 outStr << "OSpL Output file = "
174 << std::endl;
175 if (mpsFile != "")
176 outStr << "MPS File Name = "
177 << mpsFile
178 << std::endl;
179 if (nlFile != "")
180 outStr << "NL File Name = "
181 << nlFile
182 << std::endl;
183 if (datFile != "")
184 outStr << "GAMS dat file = "
185 << mpsFile
186 << std::endl;
187 if (gamsControlFile != "")
188 outStr << "GAMS control file = "
190 << std::endl;
191
192 if (browser != "")
193 outStr << "Result browser = "
194 << browser
195 << std::endl;
196 outStr << "Print level for stdout: "
197 << printLevel
198 << std::endl;
199
200 if (logFile != "")
201 outStr << "Secondary log to "
202 << logFile
203 << std::endl;
204 outStr << "Print level for " << logFile << ": "
205 << printLevel
206 << std::endl;
207
208 if (jobID != "")
209 outStr << "job ID = "
210 << jobID
211 << std::endl;
212
213 if (printModel)
214 outStr << "Print model = true"
215 << std::endl;
216 if (printRowNumberAsString != "")
217 outStr << "Print row "
219 << std::endl;
220 return outStr.str();
221}// list_options
const OSSmartPtr< OSOutput > osoutput
Definition OSOutput.cpp:39
const OSSmartPtr< OSOutput > osoutput
Definition OSOutput.cpp:39
OSOption * osoption
bool quit
if this parameter is true we quit/exit
std::string jobID
the JobID
OSOption * osoption
osoption is a representation of the solver options in OSOption format
std::string insListFile
name of the file containing the instance in LINDO instruction list format
std::string nl
the string that holds an instance in AMPL nl format
std::string serviceLocation
serviceLocation is the URL of the remote solver when a local solver is not used
std::string osplInputFile
name of an input file with xml in OS process language format, used for example to knock on a server,...
OSInstance * osinstance
osinstance is a representation of the instance in OSInstance format
bool writeVersion
if this parameter is true we print the current version of the OS project
int printLevel
this parameter controls the amount of output to print the higher the number, the more output is gener...
std::string datFile
the name of the file that holds an instance in GAMS dat format
~OSCommandLine()
destructor method
std::string printRowNumberAsString
this parameter contains a string representation (!) of the row number if only a single row (constrain...
std::string nlFile
the name of the file that holds an instance in AMPL nl format
std::string dat
the string that holds an instance in GAMS dat format
std::string osilOutputFile
osilOutputFile is the name of the file to which the instance can be written in OSiL format.
std::string logFile
this optional parameter contains the path to a logfile that can be used as an alternate output stream...
std::string osplOutputFile
name of an output file where the solver should write the result of a knock or kill service request
std::string solverName
the name of the solver to be invoked locally, e.g -solver Ipopt
std::string mpsFile
the name of the file that holds an instance in MPS format
void convertSolverNameToLowerCase()
to avoid ambiguity it might be necessary to convert the solver name to lower case ....
std::string list_options()
a function to print the current command line option values
bool listOptions
if this parameter is true we echo the values of the options found on the command line
bool invokeHelp
if this parameter is true we print the contents of the file help.txt and return
std::string osolFile
osolFile is the name of the file that holds the solver options in OSoL format
std::string osplInput
osplInput is the content of the osplInputFile
std::string browser
this parameter is a path to the browser on the local machine.
int filePrintLevel
this parameter controls the amount of output to send to the log file (if used) the higher the number,...
std::string configFile
configFile is the name of the file that holds the configuration options if the OSSolverService reads ...
void reset_options()
a function to reset the command line to default values useful especially in the interactive shell
std::string gamsControlFile
the name of the file that holds the GAMS control parameters
std::string osil
osil is the content of the osilFile
std::string insList
insList is the content of the insListFile – this is not implemented
bool printModel
if this parameter is true we print the current instance as read from an osil, nl or mps file
std::string osrlFile
osrlFile is the name of the file where the solver should write the result (in OSrL format)
std::string osolOutputFile
osolOutputFile is the name of the file to which the solver options can be written in OSoL format.
OSCommandLine()
constructor method
std::string serviceMethod
the service method the OSSolverService should execute, i.e.
void convertSolverNameToUpperCase()
... or to upper case
std::string mps
the string that holds an instance in MPS format
std::string osilFile
osilFile is the name of the file that holds the model instance in OSiL format
std::string osol
osol is the content of the osolFile
Template class for Smart Pointers.
This file defines the OSInstance class along with its supporting classes.
#define DEFAULT_OUTPUT_LEVEL
@ ENUM_OUTPUT_LEVEL_trace
@ ENUM_OUTPUT_AREA_main