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