My Project
OSoLWriter.cpp
Go to the documentation of this file.
1
16
17#define DEBUG
18
19#include "OSoLWriter.h"
20#include "OSOption.h"
21#include "OSParameters.h"
22#include "OSCommonUtil.h"
23#include "OSConfig.h"
24#include "OSBase64.h"
25#include "OSMathUtil.h"
26#include <sstream>
27#include <iostream>
28#include <stdio.h>
29
30using std::cout;
31using std::endl;
32using std::ostringstream;
33
35}
36
38}
39
40
41/*char* OSoLWriter::writeOSoLWrap( OSOption *theosoption){
42 std::string sTmp = writeOSoL( theosoption);
43 char *ch;
44 ch = new char[sTmp.size() + 1];
45 strcpy(ch, sTmp.c_str());
46 return ch;
47}
48*/
49
50
51std::string OSoLWriter::writeOSoL( OSOption *theosoption)
52{ m_OSOption = theosoption;
53 std::ostringstream outStr;
54 #ifdef WIN_
55 const char dirsep='\\';
56 #else
57 const char dirsep='/';
58 #endif
59 // Set directory containing stylesheet files.
60 std::string xsltDir;
61 xsltDir = dirsep == '/' ? "../stylesheets/" : "..\\stylesheets\\";
62 // always go with '/' -- it is a hypertext reference
63 xsltDir = "../stylesheets/";
64 if(m_OSOption == NULL) return outStr.str();
65 outStr << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
66 outStr << "<?xml-stylesheet type=\"text/xsl\" href=\"";
67 outStr << xsltDir;
68 outStr << "OSoL.xslt\"?>";
69 outStr << "<osol xmlns=\"os.optimizationservices.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
70 outStr << "xsi:schemaLocation=\"os.optimizationservices.org http://www.optimizationservices.org/schemas/";
71 outStr << OS_SCHEMA_VERSION;
72 outStr <<"/OSoL.xsd\" >" ;
73 outStr << endl;
74
78 if(m_OSOption->general != NULL)
79 { outStr << "<general>" << endl;
80 if (m_OSOption->general->serviceURI != "")
81 outStr << "<serviceURI>" << m_OSOption->general->serviceURI << "</serviceURI>" << endl;
82 if (m_OSOption->general->serviceName != "")
83 outStr << "<serviceName>" << m_OSOption->general->serviceName << "</serviceName>" << endl;
84 if (m_OSOption->general->instanceName != "")
85 outStr << "<instanceName>" << m_OSOption->general->instanceName << "</instanceName>" << endl;
86 if (m_OSOption->general->instanceLocation != NULL)
87 { if (m_OSOption->general->instanceLocation->locationType == "")
88 { outStr << "<instanceLocation>";
89 }
90 else
91 { outStr << "<instanceLocation locationType=\"" << m_OSOption->general->instanceLocation->locationType << "\">";
92 };
93 outStr << m_OSOption->general->instanceLocation->value << "</instanceLocation>" << endl;
94 };
95 if (m_OSOption->general->jobID != "")
96 { outStr << "<jobID>" << m_OSOption->general->jobID << "</jobID>" << endl;
97 };
98 if (m_OSOption->general->solverToInvoke != "")
99 { outStr << "<solverToInvoke>" << m_OSOption->general->solverToInvoke << "</solverToInvoke>" << endl;
100 };
101 if (m_OSOption->general->license != "")
102 { outStr << "<license>" << m_OSOption->general->license << "</license>" << endl;
103 };
104 if (m_OSOption->general->userName != "")
105 { outStr << "<userName>" << m_OSOption->general->userName << "</userName>" << endl;
106 };
107 if (m_OSOption->general->password != "")
108 { outStr << "<password>" << m_OSOption->general->password << "</password>" << endl;
109 };
110 if (m_OSOption->general->contact != NULL)
111 { if (m_OSOption->general->contact->transportType == "")
112 { outStr << "<contact>";
113 }
114 else
115 { outStr << "<contact transportType=\"" << m_OSOption->general->contact->transportType << "\">";
116 };
117 outStr << m_OSOption->general->contact->value << "</contact>" << endl;
118 };
119 if (m_OSOption->general->otherOptions != NULL)
120 { if (m_OSOption->general->otherOptions->numberOfOtherOptions > 0)
121 { outStr << "<otherOptions numberOfOtherOptions=\"";
122 outStr << m_OSOption->general->otherOptions->numberOfOtherOptions << "\">" << endl;
123 for (int i=0; i < m_OSOption->general->otherOptions->numberOfOtherOptions; i++)
124 { outStr << "<other name=\"" << m_OSOption->general->otherOptions->other[i]->name << "\"";
125 if (m_OSOption->general->otherOptions->other[i]->value != "")
126 outStr << " value=\"" << m_OSOption->general->otherOptions->other[i]->value << "\"";
127 if (m_OSOption->general->otherOptions->other[i]->description != "")
128 outStr << " description=\"" << m_OSOption->general->otherOptions->other[i]->description << "\"";
129 outStr << "/>" << endl;
130 }
131 outStr << "</otherOptions>" << endl;
132 }
133 }
134 outStr << "</general>" << endl;
135// cout << "Done with <general> element" << endl;
136 };
137
141 if(m_OSOption->system != NULL)
142 { outStr << "<system>" << endl;
143 if (m_OSOption->system->minDiskSpace != NULL)
144 { if (m_OSOption->system->minDiskSpace->unit == "")
145 m_OSOption->system->minDiskSpace->unit = "byte";
146 outStr << "<minDiskSpace unit=\"" << m_OSOption->system->minDiskSpace->unit << "\">";
147 outStr << os_dtoa_format(m_OSOption->system->minDiskSpace->value) << "</minDiskSpace>" << endl;
148 }
149 if (m_OSOption->system->minMemorySize != NULL)
150 { if (m_OSOption->system->minMemorySize->unit == "")
151 m_OSOption->system->minMemorySize->unit = "byte";
152 outStr << "<minMemorySize unit=\"" << m_OSOption->system->minMemorySize->unit << "\">";
153 outStr << os_dtoa_format(m_OSOption->system->minMemorySize->value) << "</minMemorySize>" << endl;
154 }
155 if (m_OSOption->system->minCPUSpeed != NULL)
156 { if (m_OSOption->system->minCPUSpeed->unit == "")
157 m_OSOption->system->minCPUSpeed->unit = "hertz";
158 outStr << "<minCPUSpeed unit=\"" << m_OSOption->system->minCPUSpeed->unit << "\">";
159 outStr << os_dtoa_format(m_OSOption->system->minCPUSpeed->value) << "</minCPUSpeed>" << endl;
160 }
161 if (m_OSOption->system->minCPUNumber != 1.0)
162 { outStr << "<minCPUNumber>" << m_OSOption->system->minCPUNumber << "</minCPUNumber>";
163 };
164 if (m_OSOption->system->otherOptions != NULL)
165 { if (m_OSOption->system->otherOptions->numberOfOtherOptions > 0)
166 { outStr << "<otherOptions numberOfOtherOptions=\"";
167 outStr << m_OSOption->system->otherOptions->numberOfOtherOptions << "\">" << endl;
168 for (int i=0; i < m_OSOption->system->otherOptions->numberOfOtherOptions; i++)
169 { outStr << "<other name=\"" << m_OSOption->system->otherOptions->other[i]->name << "\"";
170 if (m_OSOption->system->otherOptions->other[i]->value != "")
171 outStr << " value=\"" << m_OSOption->system->otherOptions->other[i]->value << "\"";
172 if (m_OSOption->system->otherOptions->other[i]->description != "")
173 outStr << " description=\"" << m_OSOption->system->otherOptions->other[i]->description << "\"";
174 outStr << "/>" << endl;
175 }
176 outStr << "</otherOptions>" << endl;
177 }
178 }
179 outStr << "</system>" << endl;
180 cout << "Done with <system> element" << endl;
181 };
182
186 if(m_OSOption->service != NULL)
187 { outStr << "<service>" << endl;
188 if (m_OSOption->service->type != "")
189 { outStr << "<type>" << m_OSOption->service->type << "</type>" << endl;
190 };
191 if (m_OSOption->service->otherOptions != NULL)
192 { if (m_OSOption->service->otherOptions->numberOfOtherOptions > 0)
193 { outStr << "<otherOptions numberOfOtherOptions=\"";
194 outStr << m_OSOption->service->otherOptions->numberOfOtherOptions << "\">" << endl;
195 for (int i=0; i < m_OSOption->service->otherOptions->numberOfOtherOptions; i++)
196 { outStr << "<other name=\"" << m_OSOption->service->otherOptions->other[i]->name << "\"";
197 if (m_OSOption->service->otherOptions->other[i]->value != "")
198 outStr << " value=\"" << m_OSOption->service->otherOptions->other[i]->value << "\"";
199 if (m_OSOption->service->otherOptions->other[i]->description != "")
200 outStr << " description=\"" << m_OSOption->service->otherOptions->other[i]->description << "\"";
201 outStr << "/>" << endl;
202 }
203 outStr << "</otherOptions>" << endl;
204 }
205 }
206 outStr << "</service>" << endl;
207 cout << "Done with <service> element" << endl;
208 };
209
213 if(m_OSOption->job != NULL)
214 { outStr << "<job>" << endl;
215 if (m_OSOption->job->maxTime != NULL)
216 { if (m_OSOption->job->maxTime->unit == "")
217 m_OSOption->job->maxTime->unit = "second";
218 outStr << "<maxTime unit=\"" << m_OSOption->job->maxTime->unit << "\">";
219 if (m_OSOption->job->maxTime->value == OSDBL_MAX)
220 outStr << "INF" << "</maxTime>" << endl;
221 else
222 outStr << os_dtoa_format(m_OSOption->job->maxTime->value) << "</maxTime>" << endl;
223 }
224 if (m_OSOption->job->requestedStartTime != "")
225 outStr << "<requestedStartTime>" << m_OSOption->job->requestedStartTime << "</requestedStartTime>" << endl;
226 if (m_OSOption->job->dependencies != NULL)
227 { if (m_OSOption->job->dependencies->numberOfJobIDs > 0)
228 { outStr << "<dependencies numberOfJobIDs=\"";
229 outStr << m_OSOption->job->dependencies->numberOfJobIDs << "\">" << endl;
230 for (int i=0; i < m_OSOption->job->dependencies->numberOfJobIDs; i++)
231 { outStr << "<jobID>" << m_OSOption->job->dependencies->jobID[i] << "</jobID>" << endl;
232 }
233 outStr << "</dependencies>" << endl;
234 }
235 }
236 if (m_OSOption->job->requiredDirectories != NULL)
237 { if (m_OSOption->job->requiredDirectories->numberOfPaths > 0)
238 { outStr << "<requiredDirectories numberOfPaths=\"";
239 outStr << m_OSOption->job->requiredDirectories->numberOfPaths << "\">" << endl;
240 for (int i=0; i < m_OSOption->job->requiredDirectories->numberOfPaths; i++)
241 outStr << "<path>" << m_OSOption->job->requiredDirectories->path[i] << "</path>" << endl;
242 outStr << "</requiredDirectories>" << endl;
243 }
244 }
245 if (m_OSOption->job->requiredFiles != NULL)
246 { if (m_OSOption->job->requiredFiles->numberOfPaths > 0)
247 { outStr << "<requiredFiles numberOfPaths=\"";
248 outStr << m_OSOption->job->requiredFiles->numberOfPaths << "\">" << endl;
249 for (int i=0; i < m_OSOption->job->requiredFiles->numberOfPaths; i++)
250 outStr << "<path>" << m_OSOption->job->requiredFiles->path[i] << "</path>" << endl;
251 outStr << "</requiredFiles>" << endl;
252 }
253 }
254 if (m_OSOption->job->directoriesToMake != NULL)
255 { if (m_OSOption->job->directoriesToMake->numberOfPaths > 0)
256 { outStr << "<directoriesToMake numberOfPaths=\"";
257 outStr << m_OSOption->job->directoriesToMake->numberOfPaths << "\">" << endl;
258 for (int i=0; i < m_OSOption->job->directoriesToMake->numberOfPaths; i++)
259 outStr << "<path>" << m_OSOption->job->directoriesToMake->path[i] << "</path>" << endl;
260 outStr << "</directoriesToMake>" << endl;
261 }
262 }
263 if (m_OSOption->job->filesToMake != NULL)
264 { if (m_OSOption->job->filesToMake->numberOfPaths > 0)
265 { outStr << "<filesToMake numberOfPaths=\"";
266 outStr << m_OSOption->job->filesToMake->numberOfPaths << "\">" << endl;
267 for (int i=0; i < m_OSOption->job->filesToMake->numberOfPaths; i++)
268 outStr << "<path>" << m_OSOption->job->filesToMake->path[i] << "</path>" << endl;
269 outStr << "</filesToMake>" << endl;
270 }
271 }
272 if (m_OSOption->job->inputDirectoriesToMove != NULL)
273 { if (m_OSOption->job->inputDirectoriesToMove->numberOfPathPairs > 0)
274 { outStr << "<inputDirectoriesToMove numberOfPathPairs=\"";
275 outStr << m_OSOption->job->inputDirectoriesToMove->numberOfPathPairs << "\">" << endl;
276 for (int i=0; i < m_OSOption->job->inputDirectoriesToMove->numberOfPathPairs; i++)
277 { outStr << "<pathPair";
278 outStr << " from=\"" << m_OSOption->job->inputDirectoriesToMove->pathPair[i]->from << "\"";
279 outStr << " to=\"" << m_OSOption->job->inputDirectoriesToMove->pathPair[i]->to << "\"";
280 if (m_OSOption->job->inputDirectoriesToMove->pathPair[i]->makeCopy)
281 outStr << " makeCopy=\"true\"";
282 outStr << "/>" << endl;
283 }
284 outStr << "</inputDirectoriesToMove>" << endl;
285 }
286 }
287 if (m_OSOption->job->inputFilesToMove != NULL)
288 { if (m_OSOption->job->inputFilesToMove->numberOfPathPairs > 0)
289 { outStr << "<inputFilesToMove numberOfPathPairs=\"";
290 outStr << m_OSOption->job->inputFilesToMove->numberOfPathPairs << "\">" << endl;
291 for (int i=0; i < m_OSOption->job->inputFilesToMove->numberOfPathPairs; i++)
292 { outStr << "<pathPair";
293 outStr << " from=\"" << m_OSOption->job->inputFilesToMove->pathPair[i]->from << "\"";
294 outStr << " to=\"" << m_OSOption->job->inputFilesToMove->pathPair[i]->to << "\"";
295 if (m_OSOption->job->inputFilesToMove->pathPair[i]->makeCopy)
296 outStr << " makeCopy=\"true\"";
297 outStr << "/>" << endl;
298 }
299 outStr << "</inputFilesToMove>" << endl;
300 }
301 }
302 if (m_OSOption->job->outputFilesToMove != NULL)
303 { if (m_OSOption->job->outputFilesToMove->numberOfPathPairs > 0)
304 { outStr << "<outputFilesToMove numberOfPathPairs=\"";
305 outStr << m_OSOption->job->outputFilesToMove->numberOfPathPairs << "\">" << endl;
306 for (int i=0; i < m_OSOption->job->outputFilesToMove->numberOfPathPairs; i++)
307 { outStr << "<pathPair";
308 outStr << " from=\"" << m_OSOption->job->outputFilesToMove->pathPair[i]->from << "\"";
309 outStr << " to=\"" << m_OSOption->job->outputFilesToMove->pathPair[i]->to << "\"";
310 if (m_OSOption->job->outputFilesToMove->pathPair[i]->makeCopy)
311 outStr << " makeCopy=\"true\"";
312 outStr << "/>" << endl;
313 }
314 outStr << "</outputFilesToMove>" << endl;
315 }
316 }
317 if (m_OSOption->job->outputDirectoriesToMove != NULL)
318 { if (m_OSOption->job->outputDirectoriesToMove->numberOfPathPairs > 0)
319 { outStr << "<outputDirectoriesToMove numberOfPathPairs=\"";
320 outStr << m_OSOption->job->outputDirectoriesToMove->numberOfPathPairs << "\">" << endl;
321 for (int i=0; i < m_OSOption->job->outputDirectoriesToMove->numberOfPathPairs; i++)
322 { outStr << "<pathPair";
323 outStr << " from=\"" << m_OSOption->job->outputDirectoriesToMove->pathPair[i]->from << "\"";
324 outStr << " to=\"" << m_OSOption->job->outputDirectoriesToMove->pathPair[i]->to << "\"";
325 if (m_OSOption->job->outputDirectoriesToMove->pathPair[i]->makeCopy)
326 outStr << " makeCopy=\"true\"";
327 outStr << "/>" << endl;
328 }
329 outStr << "</outputDirectoriesToMove>" << endl;
330 }
331 }
332 if (m_OSOption->job->filesToDelete != NULL)
333 { if (m_OSOption->job->filesToDelete->numberOfPaths > 0)
334 { outStr << "<filesToDelete numberOfPaths=\"";
335 outStr << m_OSOption->job->filesToDelete->numberOfPaths << "\">" << endl;
336 for (int i=0; i < m_OSOption->job->filesToDelete->numberOfPaths; i++)
337 outStr << "<path>" << m_OSOption->job->filesToDelete->path[i] << "</path>" << endl;
338 outStr << "</filesToDelete>" << endl;
339 }
340 }
341 if (m_OSOption->job->directoriesToDelete != NULL)
342 { if (m_OSOption->job->directoriesToDelete->numberOfPaths > 0)
343 { outStr << "<directoriesToDelete numberOfPaths=\"";
344 outStr << m_OSOption->job->directoriesToDelete->numberOfPaths << "\">" << endl;
345 for (int i=0; i < m_OSOption->job->directoriesToDelete->numberOfPaths; i++)
346 outStr << "<path>" << m_OSOption->job->directoriesToDelete->path[i] << "</path>" << endl;
347 outStr << "</directoriesToDelete>" << endl;
348 }
349 }
350 if (m_OSOption->job->processesToKill != NULL)
351 { if (m_OSOption->job->processesToKill->numberOfProcesses > 0)
352 { outStr << "<processesToKill numberOfProcesses=\"";
353 outStr << m_OSOption->job->processesToKill->numberOfProcesses << "\">" << endl;
354 for (int i=0; i < m_OSOption->job->processesToKill->numberOfProcesses; i++)
355 outStr << "<process>" << m_OSOption->job->processesToKill->process[i] << "</process>" << endl;
356 outStr << "</processesToKill>" << endl;
357 }
358 }
359 if (m_OSOption->job->otherOptions != NULL)
360 { if (m_OSOption->job->otherOptions->numberOfOtherOptions > 0)
361 { outStr << "<otherOptions numberOfOtherOptions=\"";
362 outStr << m_OSOption->job->otherOptions->numberOfOtherOptions << "\">" << endl;
363 for (int i=0; i < m_OSOption->job->otherOptions->numberOfOtherOptions; i++)
364 { outStr << "<other name=\"" << m_OSOption->job->otherOptions->other[i]->name << "\"";
365 if (m_OSOption->job->otherOptions->other[i]->value != "")
366 outStr << " value=\"" << m_OSOption->job->otherOptions->other[i]->value << "\"";
367 if (m_OSOption->job->otherOptions->other[i]->description != "")
368 outStr << " description=\"" << m_OSOption->job->otherOptions->other[i]->description << "\"";
369 outStr << "/>" << endl;
370 }
371 outStr << "</otherOptions>" << endl;
372 }
373 }
374 outStr << "</job>" << endl;
375 cout << "Done with <job> element" << endl;
376 };
377
381 if (m_OSOption->optimization != NULL)
382 { outStr << "<optimization";
383 outStr << " numberOfVariables=\"" << m_OSOption->optimization->numberOfVariables << "\" ";
384 outStr << " numberOfObjectives=\"" << m_OSOption->optimization->numberOfObjectives << "\" ";
385 outStr << " numberOfConstraints=\"" << m_OSOption->optimization->numberOfConstraints << "\" ";
386 outStr << ">" << endl;
387 if (m_OSOption->optimization->variables != NULL)
388 { outStr << "<variables";
389 if (m_OSOption->optimization->variables->numberOfOtherVariableOptions > 0)
390 outStr << " numberOfOtherVariableOptions=\"" << m_OSOption->optimization->variables->numberOfOtherVariableOptions << "\"";
391 outStr << ">" << endl;
392#ifdef DEBUG
393 cout << "initialVariableValues: " << (m_OSOption->optimization->variables->initialVariableValues != NULL) << endl;
394#endif
395 if (m_OSOption->optimization->variables->initialVariableValues != NULL)
396 { outStr << "<initialVariableValues numberOfVar=\"";
397 outStr << m_OSOption->optimization->variables->initialVariableValues->numberOfVar << "\">" << endl;
398 for (int i=0; i < m_OSOption->optimization->variables->initialVariableValues->numberOfVar; i++)
399 { outStr << "<var";
400 outStr << " idx=\"" << m_OSOption->optimization->variables->initialVariableValues->var[i]->idx << "\"";
401 if (m_OSOption->optimization->variables->initialVariableValues->var[i]->value != OSNAN)
402 { outStr << " value=\"";
403 if (m_OSOption->optimization->variables->initialVariableValues->var[i]->value == OSDBL_MAX)
404 outStr << "INF";
405 else if (m_OSOption->optimization->variables->initialVariableValues->var[i]->value == -OSDBL_MAX)
406 outStr << "-INF";
407 else
408 outStr << os_dtoa_format(m_OSOption->optimization->variables->initialVariableValues->var[i]->value);
409 }
410 outStr << "\"/>" << endl;
411 }
412 outStr << "</initialVariableValues>" << endl;
413 }
414#ifdef DEBUG
415 cout << "initialVariableValuesString: " << (m_OSOption->optimization->variables->initialVariableValuesString != NULL) << endl;
416#endif
417 if (m_OSOption->optimization->variables->initialVariableValuesString != NULL)
418 { outStr << "<initialVariableValuesString numberOfVar=\"";
419 outStr << m_OSOption->optimization->variables->initialVariableValuesString->numberOfVar << "\">" << endl;
420 for (int i=0; i < m_OSOption->optimization->variables->initialVariableValuesString->numberOfVar; i++)
421 { outStr << "<var";
422 outStr << " idx=\"" << m_OSOption->optimization->variables->initialVariableValuesString->var[i]->idx << "\"";
423 outStr << " value=\"" << m_OSOption->optimization->variables->initialVariableValuesString->var[i]->value << "\"";
424 outStr << "/>" << endl;
425 }
426 outStr << "</initialVariableValuesString>" << endl;
427 }
428#ifdef DEBUG
429 cout << "initialBasisStatus: " << (m_OSOption->optimization->variables->initialBasisStatus != NULL) << endl;
430#endif
431 if (m_OSOption->optimization->variables->initialBasisStatus != NULL)
432 { outStr << "<initialBasisStatus numberOfVar=\"";
433 outStr << m_OSOption->optimization->variables->initialBasisStatus->numberOfVar << "\">" << endl;
434 for (int i=0; i < m_OSOption->optimization->variables->initialBasisStatus->numberOfVar; i++)
435 { outStr << "<var";
436 outStr << " idx=\"" << m_OSOption->optimization->variables->initialBasisStatus->var[i]->idx << "\"";
437 outStr << " value=\"" << m_OSOption->optimization->variables->initialBasisStatus->var[i]->value << "\"";
438 outStr << "/>" << endl;
439 }
440 outStr << "</initialBasisStatus>" << endl;
441 }
442#ifdef DEBUG
443 cout << "integerVariableBranchingWeights: " << (m_OSOption->optimization->variables->integerVariableBranchingWeights != NULL) << endl;
444#endif
445 if (m_OSOption->optimization->variables->integerVariableBranchingWeights != NULL)
446 { outStr << "<integerVariableBranchingWeights numberOfVar=\"";
447 outStr << m_OSOption->optimization->variables->integerVariableBranchingWeights->numberOfVar << "\">" << endl;
448 for (int i=0; i < m_OSOption->optimization->variables->integerVariableBranchingWeights->numberOfVar; i++)
449 { outStr << "<var";
450 outStr << " idx=\"" << m_OSOption->optimization->variables->integerVariableBranchingWeights->var[i]->idx << "\"";
451 outStr << " value=\"" << os_dtoa_format(m_OSOption->optimization->variables->integerVariableBranchingWeights->var[i]->value) << "\"";
452 outStr << "/>" << endl;
453 }
454 outStr << "</integerVariableBranchingWeights>" << endl;
455 }
456#ifdef DEBUG
457 cout << "sosVariableBranchingWeights: " << (m_OSOption->optimization->variables->sosVariableBranchingWeights != NULL) << endl;
458#endif
459 if (m_OSOption->optimization->variables->sosVariableBranchingWeights != NULL)
460 { outStr << "<sosVariableBranchingWeights numberOfSOS=\"";
461#ifdef DEBUG
462 cout << "start: numberOfSOS" << endl;
463#endif
464 outStr << m_OSOption->optimization->variables->sosVariableBranchingWeights->numberOfSOS << "\">" << endl;
465 for (int i=0; i < m_OSOption->optimization->variables->sosVariableBranchingWeights->numberOfSOS; i++)
466 { outStr << "<sos";
467#ifdef DEBUG
468 cout << "sosIdx - nvar: " << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->numberOfVar << endl;
469#endif
470 outStr << " sosIdx=\"" << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->sosIdx << "\"";
471 outStr << " numberOfVar=\"" << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->numberOfVar << "\"";
472 outStr << " groupWeight=\"" << os_dtoa_format(m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->groupWeight) << "\">" << endl;
473 for (int j=0; j < m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->numberOfVar; j++)
474 { outStr << "<var";
475#ifdef DEBUG
476 cout << "idx" << endl;
477#endif
478 outStr << " idx=\"" << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->var[j]->idx << "\"";
479 outStr << " value=\"" << os_dtoa_format(m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->var[j]->value) << "\"";
480 outStr << "/>" << endl;
481 }
482 outStr << "</sos>" << endl;
483 }
484 outStr << "</sosVariableBranchingWeights>" << endl;
485 }
486#ifdef DEBUG
487 printf("\n%s%d\n","Number of other variable options: ",m_OSOption->optimization->variables->numberOfOtherVariableOptions);
488#endif
489 if (m_OSOption->optimization->variables->numberOfOtherVariableOptions > 0)
490 for (int i=0; i < m_OSOption->optimization->variables->numberOfOtherVariableOptions; i++)
491 { outStr << "<other name=\"" << m_OSOption->optimization->variables->other[i]->name << "\"";
492#ifdef DEBUG
493 cout << "option " << i << ":" << endl;
494 cout << " numberOfVar \'" << m_OSOption->optimization->variables->other[i]->numberOfVar << "\'" << endl;
495 cout << " value \'" << m_OSOption->optimization->variables->other[i]->value << "\'" << endl;
496 cout << " solver \'" << m_OSOption->optimization->variables->other[i]->solver << "\'" << endl;
497 cout << " category \'" << m_OSOption->optimization->variables->other[i]->category << "\'" << endl;
498 cout << " type \'" << m_OSOption->optimization->variables->other[i]->type << "\'" << endl;
499 cout << " description \'" << m_OSOption->optimization->variables->other[i]->description << "\'" << endl;
500#endif
501// if (m_OSOption->optimization->variables->other[i]->numberOfVar > 0)
502 outStr << " numberOfVar=\"" << m_OSOption->optimization->variables->other[i]->numberOfVar << "\"";
503 if (m_OSOption->optimization->variables->other[i]->value != "")
504 outStr << " value=\"" << m_OSOption->optimization->variables->other[i]->value << "\"";
505 if (m_OSOption->optimization->variables->other[i]->solver != "")
506 outStr << " solver=\"" << m_OSOption->optimization->variables->other[i]->solver << "\"";
507 if (m_OSOption->optimization->variables->other[i]->category != "")
508 outStr << " category=\"" << m_OSOption->optimization->variables->other[i]->category << "\"";
509 if (m_OSOption->optimization->variables->other[i]->type != "")
510 outStr << " type=\"" << m_OSOption->optimization->variables->other[i]->type << "\"";
511 if (m_OSOption->optimization->variables->other[i]->description != "")
512 outStr << " description=\"" << m_OSOption->optimization->variables->other[i]->description << "\"";
513 outStr << ">" << endl;
514 if (m_OSOption->optimization->variables->other[i]->numberOfVar > 0)
515 for (int j=0; j < m_OSOption->optimization->variables->other[i]->numberOfVar; j++)
516 { outStr << "<var idx=\"" << m_OSOption->optimization->variables->other[i]->var[j]->idx << "\"";
517 if (m_OSOption->optimization->variables->other[i]->var[j]->value != "")
518 outStr << " value=\"" << m_OSOption->optimization->variables->other[i]->var[j]->value << "\"";
519 if (m_OSOption->optimization->variables->other[i]->var[j]->lbValue != "")
520 outStr << " lbValue=\"" << m_OSOption->optimization->variables->other[i]->var[j]->lbValue << "\"";
521 if (m_OSOption->optimization->variables->other[i]->var[j]->ubValue != "")
522 outStr << " ubValue=\"" << m_OSOption->optimization->variables->other[i]->var[j]->ubValue << "\"";
523 outStr << "/>" << endl;
524 }
525 outStr << "</other>" << endl;
526 }
527 outStr << "</variables>" << endl;
528 }
529 if (m_OSOption->optimization->objectives != NULL)
530 { outStr << "<objectives";
531 if (m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions > 0)
532 outStr << " numberOfOtherObjectiveOptions=\"" << m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions << "\"";
533 outStr << ">" << endl;
534 if (m_OSOption->optimization->objectives->initialObjectiveValues != NULL)
535 { outStr << "<initialObjectiveValues numberOfObj=\"";
536 outStr << m_OSOption->optimization->objectives->initialObjectiveValues->numberOfObj << "\">" << endl;
537 for (int i=0; i < m_OSOption->optimization->objectives->initialObjectiveValues->numberOfObj; i++)
538 { outStr << "<obj";
539 outStr << " idx=\"" << m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->idx << "\"";
540 if (m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->value != OSNAN)
541 { outStr << " value=\"";
542 if (m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->value == OSDBL_MAX)
543 outStr << "INF";
544 else if (m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->value == -OSDBL_MAX)
545 outStr << "-INF";
546 else
547 outStr << os_dtoa_format(m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->value);
548 }
549 outStr << "\"/>" << endl;
550 }
551 outStr << "</initialObjectiveValues>" << endl;
552 }
553 if (m_OSOption->optimization->objectives->initialObjectiveBounds != NULL)
554 { outStr << "<initialObjectiveBounds numberOfObj=\"";
555 outStr << m_OSOption->optimization->objectives->initialObjectiveBounds->numberOfObj << "\">" << endl;
556 for (int i=0; i < m_OSOption->optimization->objectives->initialObjectiveBounds->numberOfObj; i++)
557 { outStr << "<obj";
558 outStr << " idx=\"" << m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->idx << "\"";
559 outStr << " lbValue=\"";
560 if (m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->lbValue == OSDBL_MAX)
561 outStr << "INF";
562 else if (m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->lbValue == -OSDBL_MAX)
563 outStr << "-INF";
564 else
565 outStr << os_dtoa_format(m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->lbValue);
566 outStr << "\" ubValue=\"";
567 if (m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->ubValue == OSDBL_MAX)
568 outStr << "INF";
569 else if (m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->ubValue == -OSDBL_MAX)
570 outStr << "-INF";
571 else
572 outStr << os_dtoa_format(m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->ubValue);
573 outStr << "\"/>" << endl;
574 }
575 outStr << "</initialObjectiveBounds>" << endl;
576 }
577#ifdef DEBUG
578 printf("\n%s%d\n","Number of other objective options: ",m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions);
579#endif
580 if (m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions > 0)
581 for (int i=0; i < m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions; i++)
582 { outStr << "<other name=\"" << m_OSOption->optimization->objectives->other[i]->name << "\"";
583#ifdef DEBUG
584 cout << "option " << i << ":" << endl;
585 cout << " numberOfObj \'" << m_OSOption->optimization->objectives->other[i]->numberOfObj << "\'" << endl;
586 cout << " value \'" << m_OSOption->optimization->objectives->other[i]->value << "\'" << endl;
587 cout << " solver \'" << m_OSOption->optimization->objectives->other[i]->solver << "\'" << endl;
588 cout << " category \'" << m_OSOption->optimization->objectives->other[i]->category << "\'" << endl;
589 cout << " type \'" << m_OSOption->optimization->objectives->other[i]->type << "\'" << endl;
590 cout << " description \'" << m_OSOption->optimization->objectives->other[i]->description << "\'" << endl;
591#endif
592
593// if (m_OSOption->optimization->objectives->other[i]->numberOfObj > 0)
594 outStr << " numberOfObj=\"" << m_OSOption->optimization->objectives->other[i]->numberOfObj << "\"";
595 if (m_OSOption->optimization->objectives->other[i]->value != "")
596 outStr << " value=\"" << m_OSOption->optimization->objectives->other[i]->value << "\"";
597 if (m_OSOption->optimization->objectives->other[i]->solver != "")
598 outStr << " solver=\"" << m_OSOption->optimization->objectives->other[i]->solver << "\"";
599 if (m_OSOption->optimization->objectives->other[i]->category != "")
600 outStr << " category=\"" << m_OSOption->optimization->objectives->other[i]->category << "\"";
601 if (m_OSOption->optimization->objectives->other[i]->type != "")
602 outStr << " type=\"" << m_OSOption->optimization->objectives->other[i]->type << "\"";
603 if (m_OSOption->optimization->objectives->other[i]->description != "")
604 outStr << " description=\"" << m_OSOption->optimization->objectives->other[i]->description << "\"";
605 outStr << ">" << endl;
606 if (m_OSOption->optimization->objectives->other[i]->numberOfObj > 0)
607 for (int j=0; j < m_OSOption->optimization->objectives->other[i]->numberOfObj; j++)
608 { outStr << "<var idx=\"" << m_OSOption->optimization->objectives->other[i]->obj[j]->idx << "\"";
609 if (m_OSOption->optimization->objectives->other[i]->obj[j]->value != "")
610 outStr << " value=\"" << m_OSOption->optimization->objectives->other[i]->obj[j]->value << "\"";
611 outStr << "/>" << endl;
612 }
613 outStr << "</other>" << endl;
614 }
615 outStr << "</objectives>" << endl;
616 }
617 if (m_OSOption->optimization->constraints != NULL)
618 { outStr << "<constraints";
619 if (m_OSOption->optimization->constraints->numberOfOtherConstraintOptions > 0)
620 outStr << " numberOfOtherConstraintOptions=\"" << m_OSOption->optimization->constraints->numberOfOtherConstraintOptions << "\"";
621 outStr << ">" << endl;
622 if (m_OSOption->optimization->constraints->initialConstraintValues != NULL)
623 { outStr << "<initialConstraintValues numberOfCon=\"";
624 outStr << m_OSOption->optimization->constraints->initialConstraintValues->numberOfCon << "\">" << endl;
625 for (int i=0; i < m_OSOption->optimization->constraints->initialConstraintValues->numberOfCon; i++)
626 { outStr << "<con";
627 outStr << " idx=\"" << m_OSOption->optimization->constraints->initialConstraintValues->con[i]->idx << "\"";
628 if (m_OSOption->optimization->constraints->initialConstraintValues->con[i]->value != OSNAN)
629 { outStr << " value=\"";
630 if (m_OSOption->optimization->constraints->initialConstraintValues->con[i]->value == OSDBL_MAX)
631 outStr << "INF";
632 else if (m_OSOption->optimization->constraints->initialConstraintValues->con[i]->value == -OSDBL_MAX)
633 outStr << "-INF";
634 else
635 outStr << os_dtoa_format(m_OSOption->optimization->constraints->initialConstraintValues->con[i]->value);
636 }
637 outStr << "\"/>" << endl;
638 }
639 outStr << "</initialConstraintValues>" << endl;
640 }
641 if (m_OSOption->optimization->constraints->initialDualValues != NULL)
642 { outStr << "<initialDualValues numberOfCon=\"";
643 outStr << m_OSOption->optimization->constraints->initialDualValues->numberOfCon << "\">" << endl;
644 for (int i=0; i < m_OSOption->optimization->constraints->initialDualValues->numberOfCon; i++)
645 { outStr << "<con";
646 outStr << " idx=\"" << m_OSOption->optimization->constraints->initialDualValues->con[i]->idx << "\"";
647 outStr << " lbDualValue=\"";
648 if (m_OSOption->optimization->constraints->initialDualValues->con[i]->lbDualValue == OSDBL_MAX)
649 outStr << "INF";
650 else if (m_OSOption->optimization->constraints->initialDualValues->con[i]->lbDualValue == -OSDBL_MAX)
651 outStr << "-INF";
652 else
653 outStr << os_dtoa_format(m_OSOption->optimization->constraints->initialDualValues->con[i]->lbDualValue);
654 outStr << "\" ubDualValue=\"";
655 if (m_OSOption->optimization->constraints->initialDualValues->con[i]->ubDualValue == OSDBL_MAX)
656 outStr << "INF";
657 else if (m_OSOption->optimization->constraints->initialDualValues->con[i]->ubDualValue == -OSDBL_MAX)
658 outStr << "-INF";
659 else
660 outStr << os_dtoa_format(m_OSOption->optimization->constraints->initialDualValues->con[i]->ubDualValue);
661 outStr << "\"/>" << endl;
662 }
663 outStr << "</initialDualValues>" << endl;
664 }
665#ifdef DEBUG
666 printf("\n%s%d\n","Number of other constraint options: ",m_OSOption->optimization->constraints->numberOfOtherConstraintOptions);
667#endif
668 if (m_OSOption->optimization->constraints->numberOfOtherConstraintOptions > 0)
669 for (int i=0; i < m_OSOption->optimization->constraints->numberOfOtherConstraintOptions; i++)
670 { outStr << "<other name=\"" << m_OSOption->optimization->constraints->other[i]->name << "\"";
671#ifdef DEBUG
672 cout << "option " << i << ":" << endl;
673 cout << " numberOfCon \'" << m_OSOption->optimization->constraints->other[i]->numberOfCon << "\'" << endl;
674 cout << " value \'" << m_OSOption->optimization->constraints->other[i]->value << "\'" << endl;
675 cout << " solver \'" << m_OSOption->optimization->constraints->other[i]->solver << "\'" << endl;
676 cout << " category \'" << m_OSOption->optimization->constraints->other[i]->category << "\'" << endl;
677 cout << " type \'" << m_OSOption->optimization->constraints->other[i]->type << "\'" << endl;
678 cout << " description \'" << m_OSOption->optimization->constraints->other[i]->description << "\'" << endl;
679#endif
680
681// if (m_OSOption->optimization->constraints->other[i]->numberOfCon > 0)
682 outStr << " numberOfCon=\"" << m_OSOption->optimization->constraints->other[i]->numberOfCon << "\"";
683 if (m_OSOption->optimization->constraints->other[i]->value != "")
684 outStr << " value=\"" << m_OSOption->optimization->constraints->other[i]->value << "\"";
685 if (m_OSOption->optimization->constraints->other[i]->solver != "")
686 outStr << " solver=\"" << m_OSOption->optimization->constraints->other[i]->solver << "\"";
687 if (m_OSOption->optimization->constraints->other[i]->category != "")
688 outStr << " category=\"" << m_OSOption->optimization->constraints->other[i]->category << "\"";
689 if (m_OSOption->optimization->constraints->other[i]->type != "")
690 outStr << " type=\"" << m_OSOption->optimization->constraints->other[i]->type << "\"";
691 if (m_OSOption->optimization->constraints->other[i]->description != "")
692 outStr << " description=\"" << m_OSOption->optimization->constraints->other[i]->description << "\"";
693 outStr << ">" << endl;
694 if (m_OSOption->optimization->constraints->other[i]->numberOfCon > 0)
695 for (int j=0; j < m_OSOption->optimization->constraints->other[i]->numberOfCon; j++)
696 { outStr << "<con idx=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->idx << "\"";
697 if (m_OSOption->optimization->constraints->other[i]->con[j]->value != "")
698 outStr << " value=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->value << "\"";
699 if (m_OSOption->optimization->constraints->other[i]->con[j]->lbValue != "")
700 outStr << " lbValue=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->lbValue << "\"";
701 if (m_OSOption->optimization->constraints->other[i]->con[j]->ubValue != "")
702 outStr << " ubValue=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->ubValue << "\"";
703 outStr << "/>" << endl;
704 }
705 outStr << "</other>" << endl;
706 }
707 outStr << "</constraints>" << endl;
708 }
709 if (m_OSOption->optimization->solverOptions != NULL)
710 { if (m_OSOption->optimization->solverOptions->numberOfSolverOptions > 0)
711 { outStr << "<solverOptions numberOfSolverOptions=\"";
712 outStr << m_OSOption->optimization->solverOptions->numberOfSolverOptions << "\">" << endl;
713 for (int i=0; i < m_OSOption->optimization->solverOptions->numberOfSolverOptions; i++)
714 { outStr << "<solverOption name=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->name << "\"";
715 if (m_OSOption->optimization->solverOptions->solverOption[i]->value != "")
716 outStr << " value=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->value << "\"";
717 if (m_OSOption->optimization->solverOptions->solverOption[i]->solver != "")
718 outStr << " solver=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->solver << "\"";
719 if (m_OSOption->optimization->solverOptions->solverOption[i]->category != "")
720 outStr << " category=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->category << "\"";
721 if (m_OSOption->optimization->solverOptions->solverOption[i]->type != "")
722 outStr << " type=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->type << "\"";
723 if (m_OSOption->optimization->solverOptions->solverOption[i]->description != "")
724 outStr << " description=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->description << "\"";
725 outStr << "/>" << endl;
726 }
727 outStr << "</solverOptions>" << endl;
728 }
729 }
730 outStr << "</optimization>" << endl;
731 };
732 outStr << "</osol>" << endl;
733 return outStr.str();
734}// end writeOSoL
735
736
737
std::string os_dtoa_format(double x)
The Option Class.
Definition OSOption.h:3565
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
OSoLWriter()
Default constructor.
~OSoLWriter()
Class destructor.
const OSOption * m_OSOption
m_OSOption is an object in the class OSOption
Definition OSoLWriter.h:35
#define OS_SCHEMA_VERSION
#define OSNAN
#define OSDBL_MAX