00001
00016
00017
00018 #include "OSoLWriter.h"
00019 #include "OSOption.h"
00020 #include "OSgLWriter.h"
00021 #include "OSGeneral.h"
00022 #include "OSParameters.h"
00023 #include "OSConfig.h"
00024 #include "OSBase64.h"
00025 #include "OSMathUtil.h"
00026 #include <sstream>
00027 #include <iostream>
00028 #include <stdio.h>
00029
00030 using std::cout;
00031 using std::endl;
00032 using std::ostringstream;
00033
00034 OSoLWriter::OSoLWriter( ) {
00035 m_bWriteBase64 = false;
00036 m_bWhiteSpace = false;
00037 }
00038
00039 OSoLWriter::~OSoLWriter(){
00040 }
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 std::string OSoLWriter::writeOSoL( OSOption *theosoption)
00054 { m_OSOption = theosoption;
00055 std::ostringstream outStr;
00056 #ifdef WIN_
00057 const char dirsep='\\';
00058 #else
00059 const char dirsep='/';
00060 #endif
00061
00062 std::string xsltDir;
00063 xsltDir = dirsep == '/' ? "../stylesheets/" : "..\\stylesheets\\";
00064
00065 xsltDir = "http://www.coin-or.org/OS/stylesheets/";
00066
00067 bool generalTagPrinted;
00068 #ifdef DEBUG
00069 cout << "in OSoLWriter" << endl;
00070 #endif
00071
00072 if(m_OSOption == NULL) return outStr.str();
00073 outStr << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
00074 outStr << "<?xml-stylesheet type=\"text/xsl\" href=\"";
00075 outStr << xsltDir;
00076 outStr << "OSoL.xslt\"?>";
00077 outStr << endl;
00078 outStr << "<osol xmlns=\"os.optimizationservices.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
00079 outStr << "xsi:schemaLocation=\"os.optimizationservices.org http://www.optimizationservices.org/schemas/";
00080 outStr << OS_SCHEMA_VERSION;
00081 outStr << "/OSoL.xsd\" >" ;
00082 outStr << endl;
00083
00084 #ifdef DEBUG
00085 cout << "output <optionHeader>" << endl;
00086 #endif
00087 if(m_OSOption->optionHeader != NULL)
00088 {
00089 outStr << "<optionHeader>" << endl;
00090 outStr << writeGeneralFileHeader(m_OSOption->optionHeader, true);
00091 outStr << "</optionHeader>" << endl;
00092 }
00093
00094 #ifdef DEBUG
00095 cout << "output <general>" << endl;
00096 #endif
00097 if(m_OSOption->general != NULL)
00098 {
00099 generalTagPrinted = false;
00100 if (m_OSOption->general->serviceURI != "")
00101 {
00102 if (generalTagPrinted == false)
00103 {
00104 outStr << "<general>" << endl;
00105 generalTagPrinted = true;
00106 }
00107 outStr << "<serviceURI>" << m_OSOption->general->serviceURI << "</serviceURI>" << endl;
00108 }
00109 if (m_OSOption->general->serviceName != "")
00110 {
00111 if (generalTagPrinted == false)
00112 {
00113 outStr << "<general>" << endl;
00114 generalTagPrinted = true;
00115 }
00116 outStr << "<serviceName>" << m_OSOption->general->serviceName << "</serviceName>" << endl;
00117 }
00118 if (m_OSOption->general->instanceName != "")
00119 {
00120 if (generalTagPrinted == false)
00121 {
00122 outStr << "<general>" << endl;
00123 generalTagPrinted = true;
00124 }
00125 outStr << "<instanceName>" << m_OSOption->general->instanceName << "</instanceName>" << endl;
00126 }
00127 if (m_OSOption->general->instanceLocation != NULL)
00128 {
00129 if (generalTagPrinted == false)
00130 {
00131 outStr << "<general>" << endl;
00132 generalTagPrinted = true;
00133 }
00134 if (m_OSOption->general->instanceLocation->locationType == "")
00135 { outStr << "<instanceLocation>";
00136 }
00137 else
00138 { outStr << "<instanceLocation locationType=\"" << m_OSOption->general->instanceLocation->locationType << "\">";
00139 };
00140 outStr << m_OSOption->general->instanceLocation->value << "</instanceLocation>" << endl;
00141 }
00142 if (m_OSOption->general->jobID != "")
00143 {
00144 if (generalTagPrinted == false)
00145 {
00146 outStr << "<general>" << endl;
00147 generalTagPrinted = true;
00148 }
00149 outStr << "<jobID>" << m_OSOption->general->jobID << "</jobID>" << endl;
00150 }
00151 if (m_OSOption->general->solverToInvoke != "")
00152 {
00153 if (generalTagPrinted == false)
00154 {
00155 outStr << "<general>" << endl;
00156 generalTagPrinted = true;
00157 }
00158 outStr << "<solverToInvoke>" << m_OSOption->general->solverToInvoke << "</solverToInvoke>" << endl;
00159 }
00160 if (m_OSOption->general->license != "")
00161 {
00162 if (generalTagPrinted == false)
00163 {
00164 outStr << "<general>" << endl;
00165 generalTagPrinted = true;
00166 }
00167 outStr << "<license>" << m_OSOption->general->license << "</license>" << endl;
00168 }
00169 if (m_OSOption->general->userName != "")
00170 {
00171 if (generalTagPrinted == false)
00172 {
00173 outStr << "<general>" << endl;
00174 generalTagPrinted = true;
00175 }
00176 outStr << "<userName>" << m_OSOption->general->userName << "</userName>" << endl;
00177 }
00178 if (m_OSOption->general->password != "")
00179 {
00180 if (generalTagPrinted == false)
00181 {
00182 outStr << "<general>" << endl;
00183 generalTagPrinted = true;
00184 }
00185 outStr << "<password>" << m_OSOption->general->password << "</password>" << endl;
00186 }
00187 if (m_OSOption->general->contact != NULL)
00188 {
00189 if (generalTagPrinted == false)
00190 {
00191 outStr << "<general>" << endl;
00192 generalTagPrinted = true;
00193 }
00194 if (m_OSOption->general->contact->transportType == "")
00195 { outStr << "<contact>";
00196 }
00197 else
00198 { outStr << "<contact transportType=\"" << m_OSOption->general->contact->transportType << "\">";
00199 };
00200 outStr << m_OSOption->general->contact->value << "</contact>" << endl;
00201 }
00202 if (m_OSOption->general->otherOptions != NULL)
00203 {
00204 if (generalTagPrinted == false)
00205 {
00206 outStr << "<general>" << endl;
00207 generalTagPrinted = true;
00208 }
00209 outStr << "<otherOptions numberOfOtherOptions=\"";
00210 outStr << m_OSOption->general->otherOptions->numberOfOtherOptions << "\">" << endl;
00211 for (int i=0; i < m_OSOption->general->otherOptions->numberOfOtherOptions; i++)
00212 { outStr << "<other name=\"" << m_OSOption->general->otherOptions->other[i]->name << "\"";
00213 if (m_OSOption->general->otherOptions->other[i]->value != "")
00214 outStr << " value=\"" << m_OSOption->general->otherOptions->other[i]->value << "\"";
00215 if (m_OSOption->general->otherOptions->other[i]->description != "")
00216 outStr << " description=\"" << m_OSOption->general->otherOptions->other[i]->description << "\"";
00217 outStr << "/>" << endl;
00218 }
00219 outStr << "</otherOptions>" << endl;
00220 }
00221 if (generalTagPrinted == false)
00222 outStr << "<general>" << endl;
00223
00224 outStr << "</general>" << endl;
00225 #ifdef DEBUG
00226 cout << "Done with <general> element" << endl;
00227 #endif
00228 };
00229
00233 if(m_OSOption->system != NULL)
00234 {
00235 outStr << "<system>" << endl;
00236 if (m_OSOption->system->minDiskSpace != NULL)
00237 {
00238 outStr << "<minDiskSpace";
00239 if (m_OSOption->system->minDiskSpace->unit != "byte")
00240 outStr << " unit=\"" << m_OSOption->system->minDiskSpace->unit << "\"";
00241 if (m_OSOption->system->minDiskSpace->description != "")
00242 outStr << " description=\"" << m_OSOption->system->minDiskSpace->description << "\"";
00243 outStr << ">";
00244 outStr << os_dtoa_format(m_OSOption->system->minDiskSpace->value) << "</minDiskSpace>" << endl;
00245 }
00246 if (m_OSOption->system->minMemorySize != NULL)
00247 {
00248 outStr << "<minMemorySize";
00249 if (m_OSOption->system->minMemorySize->unit != "byte")
00250 outStr << " unit=\"" << m_OSOption->system->minMemorySize->unit << "\"";
00251 if (m_OSOption->system->minMemorySize->description != "")
00252 outStr << " description=\"" << m_OSOption->system->minMemorySize->description << "\"";
00253 outStr << ">";
00254 outStr << os_dtoa_format(m_OSOption->system->minMemorySize->value) << "</minMemorySize>" << endl;
00255 }
00256 if (m_OSOption->system->minCPUSpeed != NULL)
00257 {
00258 outStr << "<minCPUSpeed";
00259 if (m_OSOption->system->minCPUSpeed->unit != "hertz")
00260 outStr << " unit=\"" << m_OSOption->system->minCPUSpeed->unit << "\"";
00261 if (m_OSOption->system->minCPUSpeed->description != "")
00262 outStr << " description=\"" << m_OSOption->system->minCPUSpeed->description << "\"";
00263 outStr << ">";
00264 outStr << os_dtoa_format(m_OSOption->system->minCPUSpeed->value) << "</minCPUSpeed>" << endl;
00265 }
00266 if (m_OSOption->system->minCPUNumber != NULL)
00267 {
00268 outStr << "<minCPUNumber";
00269 if (m_OSOption->system->minCPUNumber->description != "")
00270 outStr << " description=\"" << m_OSOption->system->minCPUNumber->description << "\"";
00271 outStr << ">";
00272 outStr << m_OSOption->system->minCPUNumber->value << "</minCPUNumber>" << endl;
00273 };
00274 if (m_OSOption->system->otherOptions != NULL)
00275 {
00276 outStr << "<otherOptions numberOfOtherOptions=\"";
00277 outStr << m_OSOption->system->otherOptions->numberOfOtherOptions << "\">" << endl;
00278 for (int i=0; i < m_OSOption->system->otherOptions->numberOfOtherOptions; i++)
00279 { outStr << "<other name=\"" << m_OSOption->system->otherOptions->other[i]->name << "\"";
00280 if (m_OSOption->system->otherOptions->other[i]->value != "")
00281 outStr << " value=\"" << m_OSOption->system->otherOptions->other[i]->value << "\"";
00282 if (m_OSOption->system->otherOptions->other[i]->description != "")
00283 outStr << " description=\"" << m_OSOption->system->otherOptions->other[i]->description << "\"";
00284 outStr << "/>" << endl;
00285 }
00286 outStr << "</otherOptions>" << endl;
00287 }
00288 outStr << "</system>" << endl;
00289 #ifdef DEBUG
00290 cout << "Done with <system> element" << endl;
00291 #endif
00292 }
00293
00297 if(m_OSOption->service != NULL)
00298 { outStr << "<service>" << endl;
00299 if (m_OSOption->service->type != "")
00300 { outStr << "<type>" << m_OSOption->service->type << "</type>" << endl;
00301 }
00302 if (m_OSOption->service->otherOptions != NULL)
00303 {
00304 outStr << "<otherOptions numberOfOtherOptions=\"";
00305 outStr << m_OSOption->service->otherOptions->numberOfOtherOptions << "\">" << endl;
00306 for (int i=0; i < m_OSOption->service->otherOptions->numberOfOtherOptions; i++)
00307 { outStr << "<other name=\"" << m_OSOption->service->otherOptions->other[i]->name << "\"";
00308 if (m_OSOption->service->otherOptions->other[i]->value != "")
00309 outStr << " value=\"" << m_OSOption->service->otherOptions->other[i]->value << "\"";
00310 if (m_OSOption->service->otherOptions->other[i]->description != "")
00311 outStr << " description=\"" << m_OSOption->service->otherOptions->other[i]->description << "\"";
00312 outStr << "/>" << endl;
00313 }
00314 outStr << "</otherOptions>" << endl;
00315 }
00316 outStr << "</service>" << endl;
00317 #ifdef DEBUG
00318 cout << "Done with <service> element" << endl;
00319 #endif
00320 };
00321
00325 if(m_OSOption->job != NULL)
00326 { outStr << "<job>" << endl;
00327 if (m_OSOption->job->maxTime != NULL)
00328 { if (m_OSOption->job->maxTime->unit == "")
00329 m_OSOption->job->maxTime->unit = "second";
00330 outStr << "<maxTime unit=\"" << m_OSOption->job->maxTime->unit << "\">";
00331
00332
00333
00334 outStr << os_dtoa_format(m_OSOption->job->maxTime->value) << "</maxTime>" << endl;
00335 }
00336 if (m_OSOption->job->requestedStartTime != "")
00337 outStr << "<requestedStartTime>" << m_OSOption->job->requestedStartTime << "</requestedStartTime>" << endl;
00338 if (m_OSOption->job->dependencies != NULL)
00339 {
00340 outStr << "<dependencies numberOfJobIDs=\"";
00341 outStr << m_OSOption->job->dependencies->numberOfJobIDs << "\">" << endl;
00342 for (int i=0; i < m_OSOption->job->dependencies->numberOfJobIDs; i++)
00343 outStr << "<jobID>" << m_OSOption->job->dependencies->jobID[i] << "</jobID>" << endl;
00344 outStr << "</dependencies>" << endl;
00345 }
00346 if (m_OSOption->job->requiredDirectories != NULL)
00347 {
00348 outStr << "<requiredDirectories numberOfPaths=\"";
00349 outStr << m_OSOption->job->requiredDirectories->numberOfPaths << "\">" << endl;
00350 for (int i=0; i < m_OSOption->job->requiredDirectories->numberOfPaths; i++)
00351 outStr << "<path>" << m_OSOption->job->requiredDirectories->path[i] << "</path>" << endl;
00352 outStr << "</requiredDirectories>" << endl;
00353 }
00354 if (m_OSOption->job->requiredFiles != NULL)
00355 {
00356 outStr << "<requiredFiles numberOfPaths=\"";
00357 outStr << m_OSOption->job->requiredFiles->numberOfPaths << "\">" << endl;
00358 for (int i=0; i < m_OSOption->job->requiredFiles->numberOfPaths; i++)
00359 outStr << "<path>" << m_OSOption->job->requiredFiles->path[i] << "</path>" << endl;
00360 outStr << "</requiredFiles>" << endl;
00361 }
00362 if (m_OSOption->job->directoriesToMake != NULL)
00363 {
00364 outStr << "<directoriesToMake numberOfPaths=\"";
00365 outStr << m_OSOption->job->directoriesToMake->numberOfPaths << "\">" << endl;
00366 for (int i=0; i < m_OSOption->job->directoriesToMake->numberOfPaths; i++)
00367 outStr << "<path>" << m_OSOption->job->directoriesToMake->path[i] << "</path>" << endl;
00368 outStr << "</directoriesToMake>" << endl;
00369 }
00370 if (m_OSOption->job->filesToMake != NULL)
00371 {
00372 outStr << "<filesToMake numberOfPaths=\"";
00373 outStr << m_OSOption->job->filesToMake->numberOfPaths << "\">" << endl;
00374 for (int i=0; i < m_OSOption->job->filesToMake->numberOfPaths; i++)
00375 outStr << "<path>" << m_OSOption->job->filesToMake->path[i] << "</path>" << endl;
00376 outStr << "</filesToMake>" << endl;
00377 }
00378 if (m_OSOption->job->inputDirectoriesToMove != NULL)
00379 {
00380 outStr << "<inputDirectoriesToMove numberOfPathPairs=\"";
00381 outStr << m_OSOption->job->inputDirectoriesToMove->numberOfPathPairs << "\">" << endl;
00382 for (int i=0; i < m_OSOption->job->inputDirectoriesToMove->numberOfPathPairs; i++)
00383 { outStr << "<pathPair";
00384 outStr << " from=\"" << m_OSOption->job->inputDirectoriesToMove->pathPair[i]->from << "\"";
00385 outStr << " to=\"" << m_OSOption->job->inputDirectoriesToMove->pathPair[i]->to << "\"";
00386 if (m_OSOption->job->inputDirectoriesToMove->pathPair[i]->makeCopy)
00387 outStr << " makeCopy=\"true\"";
00388 outStr << "/>" << endl;
00389 }
00390 outStr << "</inputDirectoriesToMove>" << endl;
00391 }
00392 if (m_OSOption->job->inputFilesToMove != NULL)
00393 {
00394 outStr << "<inputFilesToMove numberOfPathPairs=\"";
00395 outStr << m_OSOption->job->inputFilesToMove->numberOfPathPairs << "\">" << endl;
00396 for (int i=0; i < m_OSOption->job->inputFilesToMove->numberOfPathPairs; i++)
00397 { outStr << "<pathPair";
00398 outStr << " from=\"" << m_OSOption->job->inputFilesToMove->pathPair[i]->from << "\"";
00399 outStr << " to=\"" << m_OSOption->job->inputFilesToMove->pathPair[i]->to << "\"";
00400 if (m_OSOption->job->inputFilesToMove->pathPair[i]->makeCopy)
00401 outStr << " makeCopy=\"true\"";
00402 outStr << "/>" << endl;
00403 }
00404 outStr << "</inputFilesToMove>" << endl;
00405 }
00406 if (m_OSOption->job->outputFilesToMove != NULL)
00407 {
00408 outStr << "<outputFilesToMove numberOfPathPairs=\"";
00409 outStr << m_OSOption->job->outputFilesToMove->numberOfPathPairs << "\">" << endl;
00410 for (int i=0; i < m_OSOption->job->outputFilesToMove->numberOfPathPairs; i++)
00411 { outStr << "<pathPair";
00412 outStr << " from=\"" << m_OSOption->job->outputFilesToMove->pathPair[i]->from << "\"";
00413 outStr << " to=\"" << m_OSOption->job->outputFilesToMove->pathPair[i]->to << "\"";
00414 if (m_OSOption->job->outputFilesToMove->pathPair[i]->makeCopy)
00415 outStr << " makeCopy=\"true\"";
00416 outStr << "/>" << endl;
00417 }
00418 outStr << "</outputFilesToMove>" << endl;
00419 }
00420 if (m_OSOption->job->outputDirectoriesToMove != NULL)
00421 {
00422 outStr << "<outputDirectoriesToMove numberOfPathPairs=\"";
00423 outStr << m_OSOption->job->outputDirectoriesToMove->numberOfPathPairs << "\">" << endl;
00424 for (int i=0; i < m_OSOption->job->outputDirectoriesToMove->numberOfPathPairs; i++)
00425 { outStr << "<pathPair";
00426 outStr << " from=\"" << m_OSOption->job->outputDirectoriesToMove->pathPair[i]->from << "\"";
00427 outStr << " to=\"" << m_OSOption->job->outputDirectoriesToMove->pathPair[i]->to << "\"";
00428 if (m_OSOption->job->outputDirectoriesToMove->pathPair[i]->makeCopy)
00429 outStr << " makeCopy=\"true\"";
00430 outStr << "/>" << endl;
00431 }
00432 outStr << "</outputDirectoriesToMove>" << endl;
00433 }
00434 if (m_OSOption->job->filesToDelete != NULL)
00435 {
00436 outStr << "<filesToDelete numberOfPaths=\"";
00437 outStr << m_OSOption->job->filesToDelete->numberOfPaths << "\">" << endl;
00438 for (int i=0; i < m_OSOption->job->filesToDelete->numberOfPaths; i++)
00439 outStr << "<path>" << m_OSOption->job->filesToDelete->path[i] << "</path>" << endl;
00440 outStr << "</filesToDelete>" << endl;
00441 }
00442 if (m_OSOption->job->directoriesToDelete != NULL)
00443 {
00444 outStr << "<directoriesToDelete numberOfPaths=\"";
00445 outStr << m_OSOption->job->directoriesToDelete->numberOfPaths << "\">" << endl;
00446 for (int i=0; i < m_OSOption->job->directoriesToDelete->numberOfPaths; i++)
00447 outStr << "<path>" << m_OSOption->job->directoriesToDelete->path[i] << "</path>" << endl;
00448 outStr << "</directoriesToDelete>" << endl;
00449 }
00450 if (m_OSOption->job->processesToKill != NULL)
00451 {
00452 outStr << "<processesToKill numberOfProcesses=\"";
00453 outStr << m_OSOption->job->processesToKill->numberOfProcesses << "\">" << endl;
00454 for (int i=0; i < m_OSOption->job->processesToKill->numberOfProcesses; i++)
00455 outStr << "<process>" << m_OSOption->job->processesToKill->process[i] << "</process>" << endl;
00456 outStr << "</processesToKill>" << endl;
00457 }
00458 if (m_OSOption->job->otherOptions != NULL)
00459 {
00460 outStr << "<otherOptions numberOfOtherOptions=\"";
00461 outStr << m_OSOption->job->otherOptions->numberOfOtherOptions << "\">" << endl;
00462 for (int i=0; i < m_OSOption->job->otherOptions->numberOfOtherOptions; i++)
00463 { outStr << "<other name=\"" << m_OSOption->job->otherOptions->other[i]->name << "\"";
00464 if (m_OSOption->job->otherOptions->other[i]->value != "")
00465 outStr << " value=\"" << m_OSOption->job->otherOptions->other[i]->value << "\"";
00466 if (m_OSOption->job->otherOptions->other[i]->description != "")
00467 outStr << " description=\"" << m_OSOption->job->otherOptions->other[i]->description << "\"";
00468 outStr << "/>" << endl;
00469 }
00470 outStr << "</otherOptions>" << endl;
00471 }
00472 outStr << "</job>" << endl;
00473 #ifdef DEBUG
00474 cout << "Done with <job> element" << endl;
00475 #endif
00476 };
00477
00481 if (m_OSOption->optimization != NULL)
00482 { outStr << "<optimization";
00483 if (m_OSOption->optimization->numberOfVariables >= 0)
00484 outStr << " numberOfVariables=\"" << m_OSOption->optimization->numberOfVariables << "\" ";
00485 if (m_OSOption->optimization->numberOfObjectives >= 0)
00486 outStr << " numberOfObjectives=\"" << m_OSOption->optimization->numberOfObjectives << "\" ";
00487 if (m_OSOption->optimization->numberOfConstraints >= 0)
00488 outStr << " numberOfConstraints=\"" << m_OSOption->optimization->numberOfConstraints << "\" ";
00489 outStr << ">" << endl;
00490 if (m_OSOption->optimization->variables != NULL)
00491 { outStr << "<variables";
00492 if (m_OSOption->optimization->variables->numberOfOtherVariableOptions > 0)
00493 outStr << " numberOfOtherVariableOptions=\"" << m_OSOption->optimization->variables->numberOfOtherVariableOptions << "\"";
00494 outStr << ">" << endl;
00495 #ifdef DEBUG
00496 cout << "initialVariableValues: " << (m_OSOption->optimization->variables->initialVariableValues != NULL) << endl;
00497 #endif
00498 if (m_OSOption->optimization->variables->initialVariableValues != NULL)
00499 { outStr << "<initialVariableValues numberOfVar=\"";
00500 outStr << m_OSOption->optimization->variables->initialVariableValues->numberOfVar << "\">" << endl;
00501 for (int i=0; i < m_OSOption->optimization->variables->initialVariableValues->numberOfVar; i++)
00502 { outStr << "<var";
00503 outStr << " idx=\"" << m_OSOption->optimization->variables->initialVariableValues->var[i]->idx << "\"";
00504 if (m_OSOption->optimization->variables->initialVariableValues->var[i]->value != OSNAN)
00505 { outStr << " value=\"";
00506 if (m_OSOption->optimization->variables->initialVariableValues->var[i]->value == OSDBL_MAX)
00507 outStr << "INF";
00508
00509
00510
00511 outStr << os_dtoa_format(m_OSOption->optimization->variables->initialVariableValues->var[i]->value);
00512 }
00513 outStr << "\"/>" << endl;
00514 }
00515 outStr << "</initialVariableValues>" << endl;
00516 }
00517 #ifdef DEBUG
00518 cout << "initialVariableValuesString: " << (m_OSOption->optimization->variables->initialVariableValuesString != NULL) << endl;
00519 #endif
00520 if (m_OSOption->optimization->variables->initialVariableValuesString != NULL)
00521 { outStr << "<initialVariableValuesString numberOfVar=\"";
00522 outStr << m_OSOption->optimization->variables->initialVariableValuesString->numberOfVar << "\">" << endl;
00523 for (int i=0; i < m_OSOption->optimization->variables->initialVariableValuesString->numberOfVar; i++)
00524 { outStr << "<var";
00525 outStr << " idx=\"" << m_OSOption->optimization->variables->initialVariableValuesString->var[i]->idx << "\"";
00526 outStr << " value=\"" << m_OSOption->optimization->variables->initialVariableValuesString->var[i]->value << "\"";
00527 outStr << "/>" << endl;
00528 }
00529 outStr << "</initialVariableValuesString>" << endl;
00530 }
00531
00532 if (m_OSOption->optimization->variables->initialBasisStatus != NULL)
00533 {
00534 #ifdef DEBUG
00535 cout << "output <variables> <basisStatus>" << endl;
00536 #endif
00537 outStr << "<initialBasisStatus>" << endl;
00538 outStr << writeBasisStatus(m_OSOption->optimization->variables->initialBasisStatus, m_bWhiteSpace, m_bWriteBase64);
00539 outStr << "</initialBasisStatus>" << endl;
00540 }
00541
00542 #ifdef DEBUG
00543 cout << "integerVariableBranchingWeights: " << (m_OSOption->optimization->variables->integerVariableBranchingWeights != NULL) << endl;
00544 #endif
00545 if (m_OSOption->optimization->variables->integerVariableBranchingWeights != NULL)
00546 { outStr << "<integerVariableBranchingWeights numberOfVar=\"";
00547 outStr << m_OSOption->optimization->variables->integerVariableBranchingWeights->numberOfVar << "\">" << endl;
00548 for (int i=0; i < m_OSOption->optimization->variables->integerVariableBranchingWeights->numberOfVar; i++)
00549 { outStr << "<var";
00550 outStr << " idx=\"" << m_OSOption->optimization->variables->integerVariableBranchingWeights->var[i]->idx << "\"";
00551 outStr << " value=\"" << os_dtoa_format(m_OSOption->optimization->variables->integerVariableBranchingWeights->var[i]->value) << "\"";
00552 outStr << "/>" << endl;
00553 }
00554 outStr << "</integerVariableBranchingWeights>" << endl;
00555 }
00556 #ifdef DEBUG
00557 cout << "sosVariableBranchingWeights: " << (m_OSOption->optimization->variables->sosVariableBranchingWeights != NULL) << endl;
00558 #endif
00559 if (m_OSOption->optimization->variables->sosVariableBranchingWeights != NULL)
00560 { outStr << "<sosVariableBranchingWeights numberOfSOS=\"";
00561 #ifdef DEBUG
00562 cout << "start: numberOfSOS" << endl;
00563 #endif
00564 outStr << m_OSOption->optimization->variables->sosVariableBranchingWeights->numberOfSOS << "\">" << endl;
00565 for (int i=0; i < m_OSOption->optimization->variables->sosVariableBranchingWeights->numberOfSOS; i++)
00566 { outStr << "<sos";
00567 #ifdef DEBUG
00568 cout << "sosIdx - nvar: " << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->numberOfVar << endl;
00569 #endif
00570 outStr << " sosIdx=\"" << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->sosIdx << "\"";
00571 outStr << " numberOfVar=\"" << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->numberOfVar << "\"";
00572 outStr << " groupWeight=\"" << os_dtoa_format(m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->groupWeight) << "\">" << endl;
00573 for (int j=0; j < m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->numberOfVar; j++)
00574 { outStr << "<var";
00575 #ifdef DEBUG
00576 cout << "idx" << endl;
00577 #endif
00578 outStr << " idx=\"" << m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->var[j]->idx << "\"";
00579 outStr << " value=\"" << os_dtoa_format(m_OSOption->optimization->variables->sosVariableBranchingWeights->sos[i]->var[j]->value) << "\"";
00580 outStr << "/>" << endl;
00581 }
00582 outStr << "</sos>" << endl;
00583 }
00584 outStr << "</sosVariableBranchingWeights>" << endl;
00585 }
00586 #ifdef DEBUG
00587 printf("\n%s%d\n","Number of other variable options: ",m_OSOption->optimization->variables->numberOfOtherVariableOptions);
00588 #endif
00589
00590 for (int i=0; i < m_OSOption->optimization->variables->numberOfOtherVariableOptions; i++)
00591 { outStr << "<other name=\"" << m_OSOption->optimization->variables->other[i]->name << "\"";
00592
00593 outStr << " numberOfVar=\"" << m_OSOption->optimization->variables->other[i]->numberOfVar << "\"";
00594
00595 outStr << " numberOfEnumerations=\"" << m_OSOption->optimization->variables->other[i]->numberOfEnumerations << "\"";
00596 if (m_OSOption->optimization->variables->other[i]->value != "")
00597 outStr << " value=\"" << m_OSOption->optimization->variables->other[i]->value << "\"";
00598 if (m_OSOption->optimization->variables->other[i]->solver != "")
00599 outStr << " solver=\"" << m_OSOption->optimization->variables->other[i]->solver << "\"";
00600 if (m_OSOption->optimization->variables->other[i]->category != "")
00601 outStr << " category=\"" << m_OSOption->optimization->variables->other[i]->category << "\"";
00602 if (m_OSOption->optimization->variables->other[i]->type != "")
00603 outStr << " type=\"" << m_OSOption->optimization->variables->other[i]->type << "\"";
00604 if (m_OSOption->optimization->variables->other[i]->description != "")
00605 outStr << " description=\"" << m_OSOption->optimization->variables->other[i]->description << "\"";
00606 outStr << ">" << endl;
00607
00608 for (int j=0; j < m_OSOption->optimization->variables->other[i]->numberOfVar; j++)
00609 { outStr << "<var idx=\"" << m_OSOption->optimization->variables->other[i]->var[j]->idx << "\"";
00610 if (m_OSOption->optimization->variables->other[i]->var[j]->value != "")
00611 outStr << " value=\"" << m_OSOption->optimization->variables->other[i]->var[j]->value << "\"";
00612 if (m_OSOption->optimization->variables->other[i]->var[j]->lbValue != "")
00613 outStr << " lbValue=\"" << m_OSOption->optimization->variables->other[i]->var[j]->lbValue << "\"";
00614 if (m_OSOption->optimization->variables->other[i]->var[j]->ubValue != "")
00615 outStr << " ubValue=\"" << m_OSOption->optimization->variables->other[i]->var[j]->ubValue << "\"";
00616 outStr << "/>" << endl;
00617 }
00618
00619 {
00620
00621 for (int j=0; j < m_OSOption->optimization->variables->other[i]->numberOfEnumerations; j++)
00622 outStr << writeOtherOptionEnumeration(m_OSOption->optimization->variables->other[i]->enumeration[j], m_bWhiteSpace, m_bWriteBase64);
00623 }
00624 outStr << "</other>" << endl;
00625 }
00626 outStr << "</variables>" << endl;
00627 }
00628 if (m_OSOption->optimization->objectives != NULL)
00629 { outStr << "<objectives";
00630
00631 outStr << " numberOfOtherObjectiveOptions=\"" << m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions << "\"";
00632 outStr << ">" << endl;
00633 if (m_OSOption->optimization->objectives->initialObjectiveValues != NULL)
00634 { outStr << "<initialObjectiveValues numberOfObj=\"";
00635 outStr << m_OSOption->optimization->objectives->initialObjectiveValues->numberOfObj << "\">" << endl;
00636 for (int i=0; i < m_OSOption->optimization->objectives->initialObjectiveValues->numberOfObj; i++)
00637 { outStr << "<obj";
00638 outStr << " idx=\"" << m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->idx << "\"";
00639 if (m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->value != OSNAN)
00640 { outStr << " value=\"";
00641
00642
00643
00644
00645
00646 outStr << os_dtoa_format(m_OSOption->optimization->objectives->initialObjectiveValues->obj[i]->value);
00647 outStr << "\"" << endl;
00648 }
00649 outStr << "/>" << endl;
00650 }
00651 outStr << "</initialObjectiveValues>" << endl;
00652 }
00653 if (m_OSOption->optimization->objectives->initialObjectiveBounds != NULL)
00654 { outStr << "<initialObjectiveBounds numberOfObj=\"";
00655 outStr << m_OSOption->optimization->objectives->initialObjectiveBounds->numberOfObj << "\">" << endl;
00656 for (int i=0; i < m_OSOption->optimization->objectives->initialObjectiveBounds->numberOfObj; i++)
00657 { outStr << "<obj";
00658 outStr << " idx=\"" << m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->idx << "\"";
00659 outStr << " lbValue=\"";
00660
00661
00662
00663
00664
00665 outStr << os_dtoa_format(m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->lbValue);
00666 outStr << "\" ubValue=\"";
00667
00668
00669
00670
00671
00672 outStr << os_dtoa_format(m_OSOption->optimization->objectives->initialObjectiveBounds->obj[i]->ubValue);
00673 outStr << "\"/>" << endl;
00674 }
00675 outStr << "</initialObjectiveBounds>" << endl;
00676 }
00677
00678 if (m_OSOption->optimization->objectives->initialBasisStatus != NULL)
00679 {
00680 #ifdef DEBUG
00681 cout << "output <objectives> <basisStatus>" << endl;
00682 #endif
00683 outStr << "<initialBasisStatus>" << endl;
00684 outStr << writeBasisStatus(m_OSOption->optimization->objectives->initialBasisStatus, m_bWhiteSpace, m_bWriteBase64);
00685 outStr << "</initialBasisStatus>" << endl;
00686 }
00687
00688 #ifdef DEBUG
00689 printf("\n%s%d\n","Number of other objective options: ",m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions);
00690 #endif
00691
00692 for (int i=0; i < m_OSOption->optimization->objectives->numberOfOtherObjectiveOptions; i++)
00693 {
00694 outStr << "<other name=\"" << m_OSOption->optimization->objectives->other[i]->name << "\"";
00695
00696 outStr << " numberOfObj=\"" << m_OSOption->optimization->objectives->other[i]->numberOfObj << "\"";
00697
00698 outStr << " numberOfEnumerations=\"" << m_OSOption->optimization->objectives->other[i]->numberOfEnumerations << "\"";
00699 if (m_OSOption->optimization->objectives->other[i]->value != "")
00700 outStr << " value=\"" << m_OSOption->optimization->objectives->other[i]->value << "\"";
00701 if (m_OSOption->optimization->objectives->other[i]->solver != "")
00702 outStr << " solver=\"" << m_OSOption->optimization->objectives->other[i]->solver << "\"";
00703 if (m_OSOption->optimization->objectives->other[i]->category != "")
00704 outStr << " category=\"" << m_OSOption->optimization->objectives->other[i]->category << "\"";
00705 if (m_OSOption->optimization->objectives->other[i]->type != "")
00706 outStr << " type=\"" << m_OSOption->optimization->objectives->other[i]->type << "\"";
00707 if (m_OSOption->optimization->objectives->other[i]->description != "")
00708 outStr << " description=\"" << m_OSOption->optimization->objectives->other[i]->description << "\"";
00709 outStr << ">" << endl;
00710
00711 for (int j=0; j < m_OSOption->optimization->objectives->other[i]->numberOfObj; j++)
00712 { outStr << "<var idx=\"" << m_OSOption->optimization->objectives->other[i]->obj[j]->idx << "\"";
00713 if (m_OSOption->optimization->objectives->other[i]->obj[j]->value != "")
00714 outStr << " value=\"" << m_OSOption->optimization->objectives->other[i]->obj[j]->value << "\"";
00715 outStr << "/>" << endl;
00716 }
00717
00718 for (int j=0; j < m_OSOption->optimization->objectives->other[i]->numberOfEnumerations; j++)
00719 outStr << writeOtherOptionEnumeration(m_OSOption->optimization->objectives->other[i]->enumeration[j], m_bWhiteSpace, m_bWriteBase64);
00720
00721 outStr << "</other>" << endl;
00722 }
00723 outStr << "</objectives>" << endl;
00724 }
00725 #ifdef DEBUG
00726 cout << "Done with <objectives> element" << endl;
00727 #endif
00728 if (m_OSOption->optimization->constraints != NULL)
00729 { outStr << "<constraints";
00730
00731 outStr << " numberOfOtherConstraintOptions=\"" << m_OSOption->optimization->constraints->numberOfOtherConstraintOptions << "\"";
00732 outStr << ">" << endl;
00733 if (m_OSOption->optimization->constraints->initialConstraintValues != NULL)
00734 { outStr << "<initialConstraintValues numberOfCon=\"";
00735 outStr << m_OSOption->optimization->constraints->initialConstraintValues->numberOfCon << "\">" << endl;
00736 for (int i=0; i < m_OSOption->optimization->constraints->initialConstraintValues->numberOfCon; i++)
00737 { outStr << "<con";
00738 outStr << " idx=\"" << m_OSOption->optimization->constraints->initialConstraintValues->con[i]->idx << "\"";
00739 if (m_OSOption->optimization->constraints->initialConstraintValues->con[i]->value != OSNAN)
00740 { outStr << " value=\"";
00741
00742
00743
00744
00745
00746 outStr << os_dtoa_format(m_OSOption->optimization->constraints->initialConstraintValues->con[i]->value);
00747 }
00748 outStr << "\"/>" << endl;
00749 }
00750 outStr << "</initialConstraintValues>" << endl;
00751 }
00752
00753 if (m_OSOption->optimization->constraints->initialDualValues != NULL)
00754 { outStr << "<initialDualValues numberOfCon=\"";
00755 outStr << m_OSOption->optimization->constraints->initialDualValues->numberOfCon << "\">" << endl;
00756 for (int i=0; i < m_OSOption->optimization->constraints->initialDualValues->numberOfCon; i++)
00757 { outStr << "<con";
00758 outStr << " idx=\"" << m_OSOption->optimization->constraints->initialDualValues->con[i]->idx << "\"";
00759 outStr << " lbDualValue=\"";
00760
00761
00762
00763
00764
00765 outStr << os_dtoa_format(m_OSOption->optimization->constraints->initialDualValues->con[i]->lbDualValue);
00766 outStr << "\" ubDualValue=\"";
00767
00768
00769
00770
00771
00772 outStr << os_dtoa_format(m_OSOption->optimization->constraints->initialDualValues->con[i]->ubDualValue);
00773 outStr << "\"/>" << endl;
00774 }
00775 outStr << "</initialDualValues>" << endl;
00776 }
00777
00778 if (m_OSOption->optimization->constraints->initialBasisStatus != NULL)
00779 {
00780 #ifdef DEBUG
00781 cout << "output <constraints> <basisStatus>" << endl;
00782 #endif
00783 outStr << "<initialBasisStatus>" << endl;
00784 outStr << writeBasisStatus(m_OSOption->optimization->constraints->initialBasisStatus, m_bWhiteSpace, m_bWriteBase64);
00785 outStr << "</initialBasisStatus>" << endl;
00786 }
00787
00788 #ifdef DEBUG
00789 printf("\n%s%d\n","Number of other constraint options: ",m_OSOption->optimization->constraints->numberOfOtherConstraintOptions);
00790 #endif
00791
00792 for (int i=0; i < m_OSOption->optimization->constraints->numberOfOtherConstraintOptions; i++)
00793 { outStr << "<other name=\"" << m_OSOption->optimization->constraints->other[i]->name << "\"";
00794
00795
00796 outStr << " numberOfCon=\"" << m_OSOption->optimization->constraints->other[i]->numberOfCon << "\"";
00797
00798 outStr << " numberOfEnumerations=\"" << m_OSOption->optimization->constraints->other[i]->numberOfEnumerations << "\"";
00799 if (m_OSOption->optimization->constraints->other[i]->value != "")
00800 outStr << " value=\"" << m_OSOption->optimization->constraints->other[i]->value << "\"";
00801 if (m_OSOption->optimization->constraints->other[i]->solver != "")
00802 outStr << " solver=\"" << m_OSOption->optimization->constraints->other[i]->solver << "\"";
00803 if (m_OSOption->optimization->constraints->other[i]->category != "")
00804 outStr << " category=\"" << m_OSOption->optimization->constraints->other[i]->category << "\"";
00805 if (m_OSOption->optimization->constraints->other[i]->type != "")
00806 outStr << " type=\"" << m_OSOption->optimization->constraints->other[i]->type << "\"";
00807 if (m_OSOption->optimization->constraints->other[i]->description != "")
00808 outStr << " description=\"" << m_OSOption->optimization->constraints->other[i]->description << "\"";
00809 outStr << ">" << endl;
00810
00811 for (int j=0; j < m_OSOption->optimization->constraints->other[i]->numberOfCon; j++)
00812 { outStr << "<con idx=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->idx << "\"";
00813 if (m_OSOption->optimization->constraints->other[i]->con[j]->value != "")
00814 outStr << " value=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->value << "\"";
00815 if (m_OSOption->optimization->constraints->other[i]->con[j]->lbValue != "")
00816 outStr << " lbValue=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->lbValue << "\"";
00817 if (m_OSOption->optimization->constraints->other[i]->con[j]->ubValue != "")
00818 outStr << " ubValue=\"" << m_OSOption->optimization->constraints->other[i]->con[j]->ubValue << "\"";
00819 outStr << "/>" << endl;
00820 }
00821
00822 for (int j=0; j < m_OSOption->optimization->constraints->other[i]->numberOfEnumerations; j++)
00823 outStr << writeOtherOptionEnumeration(m_OSOption->optimization->constraints->other[i]->enumeration[j], m_bWhiteSpace, m_bWriteBase64);
00824
00825 outStr << "</other>" << endl;
00826 }
00827 outStr << "</constraints>" << endl;
00828 }
00829 #ifdef DEBUG
00830 cout << "Done with <constraint> element" << endl;
00831 #endif
00832 if (m_OSOption->optimization->solverOptions != NULL)
00833 {
00834
00835 { outStr << "<solverOptions numberOfSolverOptions=\"";
00836 outStr << m_OSOption->optimization->solverOptions->numberOfSolverOptions << "\">" << endl;
00837 for (int i=0; i < m_OSOption->optimization->solverOptions->numberOfSolverOptions; i++)
00838 {
00839 outStr << "<solverOption name=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->name << "\"";
00840 if (m_OSOption->optimization->solverOptions->solverOption[i]->value != "")
00841 outStr << " value=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->value << "\"";
00842 if (m_OSOption->optimization->solverOptions->solverOption[i]->solver != "")
00843 outStr << " solver=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->solver << "\"";
00844 if (m_OSOption->optimization->solverOptions->solverOption[i]->category != "")
00845 outStr << " category=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->category << "\"";
00846 if (m_OSOption->optimization->solverOptions->solverOption[i]->type != "")
00847 outStr << " type=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->type << "\"";
00848 if (m_OSOption->optimization->solverOptions->solverOption[i]->description != "")
00849 outStr << " description=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->description << "\"";
00850 if (m_OSOption->optimization->solverOptions->solverOption[i]->numberOfItems == 0)
00851 outStr << "/>" << endl;
00852 else
00853 {
00854 outStr << " numberOfItems=\"" << m_OSOption->optimization->solverOptions->solverOption[i]->numberOfItems << "\">";
00855 for (int k=0; k<m_OSOption->optimization->solverOptions->solverOption[i]->numberOfItems; k++)
00856 outStr << "<item>" << m_OSOption->optimization->solverOptions->solverOption[i]->item[k] << "</item>" << endl;
00857 outStr << "</solverOption>" << endl;
00858 }
00859 }
00860 outStr << "</solverOptions>" << endl;
00861 }
00862 }
00863 outStr << "</optimization>" << endl;
00864 };
00865 outStr << "</osol>" << endl;
00866 #ifdef DEBUG
00867 cout << "Done with <optimization> element" << endl;
00868 #endif
00869 return outStr.str();
00870 }
00871
00872
00873