00001
00019
00020
00021
00022
00023 #include "OSrLWriter.h"
00024 #include "OSResult.h"
00025 #include "OSgLWriter.h"
00026
00027 #include "OSGeneral.h"
00028 #include "OSParameters.h"
00029 #include "OSMathUtil.h"
00030
00031
00032 #include <sstream>
00033 #include <iostream>
00034
00035
00036 using std::cout;
00037 using std::endl;
00038 using std::ostringstream;
00039
00040 OSrLWriter::OSrLWriter( ) {
00041 m_bWriteBase64 = false;
00042 m_bWhiteSpace = false;
00043 }
00044
00045 OSrLWriter::~OSrLWriter(){
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 std::string OSrLWriter::writeOSrL( OSResult *theosresult){
00063 m_OSResult = theosresult;
00064 std::ostringstream outStr;
00065
00066
00067
00068
00069
00070
00071 std::string xsltDir;
00072
00073
00074
00075 xsltDir = "http://www.coin-or.org/OS/stylesheets/";
00076 int i, j;
00077 bool generalTagPrinted;
00078 bool systemTagPrinted;
00079 bool serviceTagPrinted;
00080 bool jobTagPrinted;
00081 #ifdef DEBUG
00082 cout << "in OSrLWriter" << endl;
00083 #endif
00084 if(m_OSResult == NULL) return outStr.str();
00085 outStr << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
00086 outStr << "<?xml-stylesheet type=\"text/xsl\" href=\"";
00087 outStr << xsltDir;
00088 outStr << "OSrL.xslt\"?>";
00089 outStr << endl;
00090 outStr << "<osrl xmlns=\"os.optimizationservices.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
00091 outStr << "xsi:schemaLocation=\"os.optimizationservices.org http://www.optimizationservices.org/schemas/";
00092 outStr << OS_SCHEMA_VERSION;
00093 outStr << "/OSrL.xsd\" >" ;
00094 outStr << endl;
00095
00096 #ifdef DEBUG
00097 cout << "output <general>" << endl;
00098 #endif
00099 if(m_OSResult->general != NULL){
00100 generalTagPrinted = false;
00101 if(m_OSResult->general->generalStatus != NULL){
00102 if (generalTagPrinted == false)
00103 {
00104 outStr << "<general>" << endl;
00105 generalTagPrinted = true;
00106 }
00107 outStr << "<generalStatus";
00108 if(m_OSResult->general->generalStatus->type.length() > 0){
00109 outStr << " type=\"";
00110 outStr << m_OSResult->general->generalStatus->type ;
00111 outStr << "\"";
00112 }
00113 if(m_OSResult->general->generalStatus->description.length() > 0){
00114 outStr << " description=\"";
00115 outStr << m_OSResult->general->generalStatus->description ;
00116 outStr << "\"";
00117 }
00118 if (m_OSResult->general->generalStatus->numberOfSubstatuses > 0)
00119 {
00120 outStr << " numberOfSubstatuses=\"";
00121 outStr << m_OSResult->general->generalStatus->numberOfSubstatuses;
00122 outStr << "\"";
00123 }
00124 outStr << ">" << endl;
00125 for (int i=0; i < m_OSResult->general->generalStatus->numberOfSubstatuses; i++)
00126 { outStr << "<substatus";
00127 if (m_OSResult->general->generalStatus->substatus[i]->name.length() > 0)
00128 { outStr << " name=\"";
00129 outStr << m_OSResult->general->generalStatus->substatus[i]->name ;
00130 outStr << "\"";
00131 }
00132 if (m_OSResult->general->generalStatus->substatus[i]->description.length() > 0)
00133 { outStr << " description=\"";
00134 outStr << m_OSResult->general->generalStatus->substatus[i]->description ;
00135 outStr << "\"";
00136 }
00137 outStr << "/>" << endl;
00138 }
00139 outStr << "</generalStatus>" << endl;
00140 }
00141
00142 if(m_OSResult->general->message.length() > 0){
00143 if (generalTagPrinted == false)
00144 {
00145 outStr << "<general>" << endl;
00146 generalTagPrinted = true;
00147 }
00148 outStr << "<message>" + m_OSResult->general->message + "</message>" << endl;
00149 }
00150 if(m_OSResult->general->serviceURI.length() > 0){
00151 if (generalTagPrinted == false)
00152 {
00153 outStr << "<general>" << endl;
00154 generalTagPrinted = true;
00155 }
00156 outStr << "<serviceURI>" + m_OSResult->general->serviceURI + "</serviceURI>" << endl;
00157 }
00158 if(m_OSResult->general->serviceName.length() > 0){
00159 if (generalTagPrinted == false)
00160 {
00161 outStr << "<general>" << endl;
00162 generalTagPrinted = true;
00163 }
00164 outStr << "<serviceName>" + m_OSResult->general->serviceName + "</serviceName>" << endl;
00165 }
00166 if(m_OSResult->general->instanceName.length() > 0){
00167 if (generalTagPrinted == false)
00168 {
00169 outStr << "<general>" << endl;
00170 generalTagPrinted = true;
00171 }
00172 outStr << "<instanceName>" + m_OSResult->general->instanceName + "</instanceName>" << endl;
00173 }
00174 if(m_OSResult->general->jobID.length() > 0){
00175 if (generalTagPrinted == false)
00176 {
00177 outStr << "<general>" << endl;
00178 generalTagPrinted = true;
00179 }
00180 outStr << "<jobID>" + m_OSResult->general->jobID + "</jobID>" << endl;
00181 }
00182 if(m_OSResult->general->solverInvoked.length() > 0){
00183 if (generalTagPrinted == false)
00184 {
00185 outStr << "<general>" << endl;
00186 generalTagPrinted = true;
00187 }
00188 outStr << "<solverInvoked>" + m_OSResult->general->solverInvoked + "</solverInvoked>" << endl;
00189 }
00190 if(m_OSResult->general->timeStamp.length() > 0){
00191 if (generalTagPrinted == false)
00192 {
00193 outStr << "<general>" << endl;
00194 generalTagPrinted = true;
00195 }
00196 outStr << "<timeStamp>" + m_OSResult->general->timeStamp + "</timeStamp>" << endl;
00197 }
00198
00199 if(m_OSResult->general->otherResults != NULL)
00200 { if(m_OSResult->general->otherResults->numberOfOtherResults > 0)
00201 {
00202 if (generalTagPrinted == false)
00203 {
00204 outStr << "<general>" << endl;
00205 generalTagPrinted = true;
00206 }
00207 outStr << "<otherResults numberOfOtherResults=\"";
00208 outStr << m_OSResult->general->otherResults->numberOfOtherResults;
00209 outStr << "\">" << endl;
00210 for (int i=0; i < m_OSResult->general->otherResults->numberOfOtherResults; i++)
00211 { outStr << "<other";
00212 if (m_OSResult->general->otherResults->other[i]->name.length() > 0)
00213 { outStr << " name=\"";
00214 outStr << m_OSResult->general->otherResults->other[i]->name;
00215 outStr << "\"";
00216 }
00217 if (m_OSResult->general->otherResults->other[i]->value.length() > 0)
00218 { outStr << " value=\"";
00219 outStr << m_OSResult->general->otherResults->other[i]->value;
00220 outStr << "\"";
00221 }
00222 if (m_OSResult->general->otherResults->other[i]->description.length() > 0)
00223 { outStr << " description=\"";
00224 outStr << m_OSResult->general->otherResults->other[i]->description;
00225 outStr << "\"";
00226 }
00227 outStr << " />" << endl;
00228 }
00229 outStr << "</otherResults>" << endl;;
00230 }
00231 }
00232 if (generalTagPrinted == true)
00233 outStr << "</general>" << endl;
00234 }
00235
00236
00237 #ifdef DEBUG
00238 cout << "output <system>" << endl;
00239 #endif
00240 if(m_OSResult->system != NULL){
00241 systemTagPrinted = false;
00242 if(m_OSResult->system->systemInformation.length() > 0){
00243 if (systemTagPrinted == false)
00244 {
00245 outStr << "<system>" << endl;
00246 systemTagPrinted = true;
00247 }
00248 outStr << "<systemInformation>" + m_OSResult->system->systemInformation + "</systemInformation>" << endl;
00249 }
00250
00251 if(m_OSResult->system->availableDiskSpace != NULL){
00252 if (systemTagPrinted == false)
00253 {
00254 outStr << "<system>" << endl;
00255 systemTagPrinted = true;
00256 }
00257 outStr << "<availableDiskSpace";
00258 if(m_OSResult->system->availableDiskSpace->unit.length() > 0){
00259 outStr << " unit=\"";
00260 outStr << m_OSResult->system->availableDiskSpace->unit ;
00261 outStr << "\"";
00262 }
00263 if(m_OSResult->system->availableDiskSpace->description.length() > 0){
00264 outStr << " description=\"";
00265 outStr << m_OSResult->system->availableDiskSpace->description ;
00266 outStr << "\"";
00267 }
00268 outStr << ">";
00269 outStr << m_OSResult->system->availableDiskSpace->value ;
00270 outStr << "</availableDiskSpace>" << endl;
00271 }
00272
00273 if(m_OSResult->system->availableMemory != NULL){
00274 if (systemTagPrinted == false)
00275 {
00276 outStr << "<system>" << endl;
00277 systemTagPrinted = true;
00278 }
00279 outStr << "<availableMemory";
00280 if(m_OSResult->system->availableMemory->unit.length() > 0){
00281 outStr << " unit=\"";
00282 outStr << m_OSResult->system->availableMemory->unit ;
00283 outStr << "\"";
00284 }
00285 if(m_OSResult->system->availableMemory->description.length() > 0){
00286 outStr << " description=\"";
00287 outStr << m_OSResult->system->availableMemory->description ;
00288 outStr << "\"";
00289 }
00290 outStr << ">";
00291 outStr << m_OSResult->system->availableMemory->value ;
00292 outStr << "</availableMemory>" << endl;
00293 }
00294
00295 if(m_OSResult->system->availableCPUSpeed != NULL){
00296 if (systemTagPrinted == false)
00297 {
00298 outStr << "<system>" << endl;
00299 systemTagPrinted = true;
00300 }
00301 outStr << "<availableCPUSpeed";
00302 if(m_OSResult->system->availableCPUSpeed->unit.length() > 0){
00303 outStr << " unit=\"";
00304 outStr << m_OSResult->system->availableCPUSpeed->unit ;
00305 outStr << "\"";
00306 }
00307 if(m_OSResult->system->availableCPUSpeed->description.length() > 0){
00308 outStr << " description=\"";
00309 outStr << m_OSResult->system->availableCPUSpeed->description ;
00310 outStr << "\"";
00311 }
00312 outStr << ">";
00313 outStr << m_OSResult->system->availableCPUSpeed->value ;
00314 outStr << "</availableCPUSpeed>" << endl;
00315 }
00316
00317 if(m_OSResult->system->availableCPUNumber != NULL){
00318 if (systemTagPrinted == false)
00319 {
00320 outStr << "<system>" << endl;
00321 systemTagPrinted = true;
00322 }
00323 outStr << "<availableCPUNumber";
00324 if(m_OSResult->system->availableCPUNumber->description.length() > 0){
00325 outStr << " description=\"";
00326 outStr << m_OSResult->system->availableCPUNumber->description ;
00327 outStr << "\"";
00328 }
00329 outStr << ">";
00330 outStr << m_OSResult->system->availableCPUNumber->value;
00331 outStr << "</availableCPUNumber>" << endl;
00332 }
00333
00334 if(m_OSResult->system->otherResults != NULL)
00335 { if(m_OSResult->system->otherResults->numberOfOtherResults > 0)
00336 {
00337 if (systemTagPrinted == false)
00338 {
00339 outStr << "<system>" << endl;
00340 systemTagPrinted = true;
00341 }
00342 outStr << "<otherResults numberOfOtherResults=\"";
00343 outStr << m_OSResult->system->otherResults->numberOfOtherResults;
00344 outStr << "\">" << endl;
00345 for (int i=0; i < m_OSResult->system->otherResults->numberOfOtherResults; i++)
00346 { outStr << "<other";
00347 if (m_OSResult->system->otherResults->other[i]->name.length() > 0)
00348 { outStr << " name=\"";
00349 outStr << m_OSResult->system->otherResults->other[i]->name;
00350 outStr << "\"";
00351 }
00352 if (m_OSResult->system->otherResults->other[i]->value.length() > 0)
00353 { outStr << " value=\"";
00354 outStr << m_OSResult->system->otherResults->other[i]->value;
00355 outStr << "\"";
00356 }
00357 if (m_OSResult->system->otherResults->other[i]->description.length() > 0)
00358 { outStr << " description=\"";
00359 outStr << m_OSResult->system->otherResults->other[i]->description;
00360 outStr << "\"";
00361 }
00362 outStr << " />" << endl;
00363 }
00364 outStr << "</otherResults>" << endl;
00365 }
00366 }
00367 if (systemTagPrinted == true)
00368 outStr << "</system>" << endl;
00369 }
00370
00371
00372 #ifdef DEBUG
00373 cout << "output <service>" << endl;
00374 #endif
00375 if(m_OSResult->service != NULL){
00376 serviceTagPrinted = false;
00377 if(m_OSResult->service->currentState.length() > 0 && m_OSResult->service->currentState != "unknown"){
00378 if (serviceTagPrinted == false)
00379 {
00380 outStr << "<service>" << endl;
00381 serviceTagPrinted = true;
00382 }
00383 outStr << "<currentState>" << m_OSResult->service->currentState << "</currentState>" << endl;
00384 }
00385 if(m_OSResult->service->currentJobCount >= 0){
00386 if (serviceTagPrinted == false)
00387 {
00388 outStr << "<service>" << endl;
00389 serviceTagPrinted = true;
00390 }
00391 outStr << "<currentJobCount>" << m_OSResult->service->currentJobCount << "</currentJobCount>" << endl;
00392 }
00393 if(m_OSResult->service->totalJobsSoFar >= 0){
00394 if (serviceTagPrinted == false)
00395 {
00396 outStr << "<service>" << endl;
00397 serviceTagPrinted = true;
00398 }
00399 outStr << "<totalJobsSoFar>" << m_OSResult->service->totalJobsSoFar << "</totalJobsSoFar>" << endl;
00400 }
00401 if(m_OSResult->service->timeServiceStarted.length() > 0 && m_OSResult->service->timeServiceStarted != "1970-01-01T00:00:00-00:00"){
00402 if (serviceTagPrinted == false)
00403 {
00404 outStr << "<service>" << endl;
00405 serviceTagPrinted = true;
00406 }
00407 outStr << "<timeServiceStarted>" << m_OSResult->service->timeServiceStarted << "</timeServiceStarted>" << endl;
00408 }
00409 if(m_OSResult->service->serviceUtilization >= 0){
00410 if (serviceTagPrinted == false)
00411 {
00412 outStr << "<service>" << endl;
00413 serviceTagPrinted = true;
00414 }
00415 outStr << "<serviceUtilization>" << m_OSResult->service->serviceUtilization << "</serviceUtilization>" << endl;
00416 }
00417
00418 if(m_OSResult->service->otherResults != NULL)
00419 { if(m_OSResult->service->otherResults->numberOfOtherResults > 0)
00420 {
00421 if (serviceTagPrinted == false)
00422 {
00423 outStr << "<service>" << endl;
00424 serviceTagPrinted = true;
00425 }
00426 outStr << "<otherResults numberOfOtherResults=\"";
00427 outStr << m_OSResult->service->otherResults->numberOfOtherResults;
00428 outStr << "\">" << endl;
00429 for (int i=0; i < m_OSResult->service->otherResults->numberOfOtherResults; i++)
00430 { outStr << "<other";
00431 if (m_OSResult->service->otherResults->other[i]->name.length() > 0)
00432 { outStr << " name=\"";
00433 outStr << m_OSResult->service->otherResults->other[i]->name;
00434 outStr << "\"";
00435 }
00436 if (m_OSResult->service->otherResults->other[i]->value.length() > 0)
00437 { outStr << " value=\"";
00438 outStr << m_OSResult->service->otherResults->other[i]->value;
00439 outStr << "\"";
00440 }
00441 if (m_OSResult->service->otherResults->other[i]->description.length() > 0)
00442 { outStr << " description=\"";
00443 outStr << m_OSResult->service->otherResults->other[i]->description;
00444 outStr << "\"";
00445 }
00446 outStr << " />" << endl;
00447 }
00448 outStr << "</otherResults>" << endl;
00449 }
00450 }
00451 if (serviceTagPrinted == true)
00452 outStr << "</service>" << endl;
00453 }
00454
00455
00456 #ifdef DEBUG
00457 cout << "output <job>" << endl;
00458 #endif
00459 if(m_OSResult->job != NULL){
00460 jobTagPrinted = false;
00461
00462 if(m_OSResult->job->status.length() > 0 && m_OSResult->job->status != "finished"){
00463 if (jobTagPrinted == false)
00464 {
00465 outStr << "<job>" << endl;
00466 jobTagPrinted = true;
00467 }
00468 outStr << "<status>" + m_OSResult->job->status + "</status>" << endl;
00469 }
00470 if(m_OSResult->job->submitTime.length() > 0 && m_OSResult->job->submitTime != "1970-01-01T00:00:00-00:00"){
00471 if (jobTagPrinted == false)
00472 {
00473 outStr << "<job>" << endl;
00474 jobTagPrinted = true;
00475 }
00476 outStr << "<submitTime>" + m_OSResult->job->submitTime + "</submitTime>" << endl;
00477 }
00478 if(m_OSResult->job->scheduledStartTime.length() > 0 && m_OSResult->job->scheduledStartTime != "1970-01-01T00:00:00-00:00"){
00479 if (jobTagPrinted == false)
00480 {
00481 outStr << "<job>" << endl;
00482 jobTagPrinted = true;
00483 }
00484 outStr << "<scheduledStartTime>" + m_OSResult->job->scheduledStartTime + "</scheduledStartTime>" << endl;
00485 }
00486 if(m_OSResult->job->actualStartTime.length() > 0 && m_OSResult->job->actualStartTime != "1970-01-01T00:00:00-00:00"){
00487 if (jobTagPrinted == false)
00488 {
00489 outStr << "<job>" << endl;
00490 jobTagPrinted = true;
00491 }
00492 outStr << "<actualStartTime>" + m_OSResult->job->actualStartTime + "</actualStartTime>" << endl;
00493 }
00494 if(m_OSResult->job->endTime.length() > 0 && m_OSResult->job->endTime != "1970-01-01T00:00:00-00:00"){
00495 if (jobTagPrinted == false)
00496 {
00497 outStr << "<job>" << endl;
00498 jobTagPrinted = true;
00499 }
00500 outStr << "<endTime>" + m_OSResult->job->endTime + "</endTime>" << endl;
00501 }
00502
00503 if (m_OSResult->job->timingInformation != NULL)
00504 if (m_OSResult->job->timingInformation->numberOfTimes > 0)
00505 {
00506 if (jobTagPrinted == false)
00507 {
00508 outStr << "<job>" << endl;
00509 jobTagPrinted = true;
00510 }
00511 outStr << "<timingInformation numberOfTimes=\"";
00512 outStr << m_OSResult->job->timingInformation->numberOfTimes << "\">" << endl;
00513 for (i=0; i<m_OSResult->job->timingInformation->numberOfTimes; i++)
00514 { outStr << "<time ";
00515 if (m_OSResult->job->timingInformation->time[i]->type != "")
00516 outStr << "type=\"" << m_OSResult->job->timingInformation->time[i]->type << "\" ";
00517 if (m_OSResult->job->timingInformation->time[i]->unit != "")
00518 outStr << "unit=\"" << m_OSResult->job->timingInformation->time[i]->unit << "\" ";
00519 if (m_OSResult->job->timingInformation->time[i]->category != "")
00520 outStr << "category=\"" << m_OSResult->job->timingInformation->time[i]->category << "\" ";
00521 if (m_OSResult->job->timingInformation->time[i]->description != "")
00522 outStr << "description=\"" << m_OSResult->job->timingInformation->time[i]->description << "\" ";
00523 outStr << ">" << endl;
00524 outStr << os_dtoa_format(m_OSResult->job->timingInformation->time[i]->value);
00525 outStr << "</time>" << endl;
00526 }
00527 outStr << "</timingInformation>" << endl;
00528 }
00529
00530 if(m_OSResult->job->usedDiskSpace != NULL){
00531 if (jobTagPrinted == false)
00532 {
00533 outStr << "<job>" << endl;
00534 jobTagPrinted = true;
00535 }
00536 outStr << "<usedDiskSpace";
00537 if(m_OSResult->job->usedDiskSpace->unit.length() > 0){
00538 outStr << " unit=\"";
00539 outStr << m_OSResult->job->usedDiskSpace->unit ;
00540 outStr << "\"";
00541 }
00542 if(m_OSResult->job->usedDiskSpace->description.length() > 0){
00543 outStr << " description=\"";
00544 outStr << m_OSResult->job->usedDiskSpace->description ;
00545 outStr << "\"";
00546 }
00547 outStr << ">";
00548 outStr << m_OSResult->job->usedDiskSpace->value ;
00549 outStr << "</usedDiskSpace>" << endl;
00550 }
00551
00552 if(m_OSResult->job->usedMemory != NULL){
00553 if (jobTagPrinted == false)
00554 {
00555 outStr << "<job>" << endl;
00556 jobTagPrinted = true;
00557 }
00558 outStr << "<usedMemory";
00559 if(m_OSResult->job->usedMemory->unit.length() > 0){
00560 outStr << " unit=\"";
00561 outStr << m_OSResult->job->usedMemory->unit ;
00562 outStr << "\"";
00563 }
00564 if(m_OSResult->job->usedMemory->description.length() > 0){
00565 outStr << " description=\"";
00566 outStr << m_OSResult->job->usedMemory->description ;
00567 outStr << "\"";
00568 }
00569 outStr << ">";
00570 outStr << m_OSResult->job->usedMemory->value ;
00571 outStr << "</usedMemory>" << endl;
00572 }
00573
00574 if(m_OSResult->job->usedCPUSpeed != NULL){
00575 if (jobTagPrinted == false)
00576 {
00577 outStr << "<job>" << endl;
00578 jobTagPrinted = true;
00579 }
00580 outStr << "<usedCPUSpeed";
00581 if(m_OSResult->job->usedCPUSpeed->unit.length() > 0){
00582 outStr << " unit=\"";
00583 outStr << m_OSResult->job->usedCPUSpeed->unit ;
00584 outStr << "\"";
00585 }
00586 if(m_OSResult->job->usedCPUSpeed->description.length() > 0){
00587 outStr << " description=\"";
00588 outStr << m_OSResult->job->usedCPUSpeed->description;
00589 outStr << "\"";
00590 }
00591 outStr << ">";
00592 outStr << m_OSResult->job->usedCPUSpeed->value ;
00593 outStr << "</usedCPUSpeed>" << endl;
00594 }
00595
00596 if(m_OSResult->job->usedCPUNumber != NULL){
00597 if (jobTagPrinted == false)
00598 {
00599 outStr << "<job>" << endl;
00600 jobTagPrinted = true;
00601 }
00602 outStr << "<usedCPUNumber";
00603 if(m_OSResult->job->usedCPUNumber->description.length() > 0){
00604 outStr << " description=\"";
00605 outStr << m_OSResult->job->usedCPUNumber->description;
00606 outStr << "\"";
00607 }
00608 outStr << ">";
00609 outStr << m_OSResult->job->usedCPUNumber->value;
00610 outStr << "</usedCPUNumber>" << endl;
00611 }
00612
00613 if(m_OSResult->job->otherResults != NULL)
00614 { if(m_OSResult->job->otherResults->numberOfOtherResults > 0)
00615 {
00616 if (jobTagPrinted == false)
00617 {
00618 outStr << "<job>" << endl;
00619 jobTagPrinted = true;
00620 }
00621 outStr << "<otherResults numberOfOtherResults=\"";
00622 outStr << m_OSResult->job->otherResults->numberOfOtherResults;
00623 outStr << "\">" << endl;
00624 for (int i=0; i < m_OSResult->job->otherResults->numberOfOtherResults; i++)
00625 { outStr << "<other";
00626 if (m_OSResult->job->otherResults->other[i]->name.length() > 0)
00627 { outStr << " name=\"";
00628 outStr << m_OSResult->job->otherResults->other[i]->name;
00629 outStr << "\"";
00630 }
00631 if (m_OSResult->job->otherResults->other[i]->value.length() > 0)
00632 { outStr << " value=\"";
00633 outStr << m_OSResult->job->otherResults->other[i]->value;
00634 outStr << "\"";
00635 }
00636 if (m_OSResult->job->otherResults->other[i]->description.length() > 0)
00637 { outStr << " description=\"";
00638 outStr << m_OSResult->job->otherResults->other[i]->description;
00639 outStr << "\"";
00640 }
00641 outStr << " />" << endl;
00642 }
00643 outStr << "</otherResults>" << endl;
00644 }
00645 }
00646 if (jobTagPrinted == true)
00647 outStr << "</job>" << endl;
00648 }
00649
00650
00651 #ifdef DEBUG
00652 cout << "output <optimization>" << endl;
00653 #endif
00654 if(m_OSResult->optimization != NULL && m_OSResult->optimization->numberOfSolutions > 0){
00655 outStr << "<optimization " ;
00656 outStr << "numberOfSolutions=\"";
00657 outStr << m_OSResult->optimization->numberOfSolutions ;
00658 outStr << "\"";
00659 outStr << " numberOfVariables=\"";
00660 outStr << m_OSResult->optimization->numberOfVariables ;
00661 outStr << "\"";
00662 outStr << " numberOfConstraints=\"";
00663 outStr << m_OSResult->optimization->numberOfConstraints ;
00664 outStr << "\"";
00665 outStr << " numberOfObjectives=\"";
00666 outStr << m_OSResult->optimization->numberOfObjectives ;
00667 outStr << "\"" ;
00668 outStr << ">" << endl;
00669
00670 for(i = 0; i < m_OSResult->optimization->numberOfSolutions; i++){
00671 if(m_OSResult->optimization->solution[i] != NULL){
00672 outStr << "<solution" ;
00673 outStr << " targetObjectiveIdx=\"";
00674 outStr << m_OSResult->optimization->solution[i]->targetObjectiveIdx ;
00675 outStr << "\"" ;
00676 if (m_OSResult->optimization->solution[i]->weightedObjectives)
00677 outStr << " weightedObjectives=\"true\"";
00678 outStr << ">" << endl;
00679 if(m_OSResult->optimization->solution[i]->status != NULL){
00680 outStr << "<status";
00681 if (m_OSResult->optimization->solution[i]->status->numberOfSubstatuses > 0)
00682 {
00683 outStr << " numberOfSubstatuses=\"";
00684 outStr << m_OSResult->optimization->solution[i]->status->numberOfSubstatuses ;
00685 outStr << "\"";
00686 }
00687 if(m_OSResult->optimization->solution[i]->status->type.length() > 0){
00688 outStr << " type=\"";
00689 outStr << m_OSResult->optimization->solution[i]->status->type;
00690 outStr << "\"";
00691 }
00692 if(m_OSResult->optimization->solution[i]->status->description.length() > 0){
00693 outStr << " description=\"";
00694 outStr << m_OSResult->optimization->solution[i]->status->description;
00695 outStr << "\"" ;
00696 }
00697 outStr << ">" << endl;
00698 for (int j=0; j < m_OSResult->optimization->solution[i]->status->numberOfSubstatuses; j++)
00699 { outStr << "<substatus";
00700 if(m_OSResult->optimization->solution[i]->status->substatus[j]->type.length() > 0){
00701 outStr << " type=\"";
00702 outStr << m_OSResult->optimization->solution[i]->status->substatus[j]->type;
00703 outStr << "\"";
00704 }
00705 if(m_OSResult->optimization->solution[i]->status->substatus[j]->description.length() > 0){
00706 outStr << " description=\"";
00707 outStr << m_OSResult->optimization->solution[i]->status->substatus[j]->description;
00708 outStr << "\"" ;
00709 }
00710 outStr << "/>" << endl;
00711 }
00712 outStr << "</status>" << endl;
00713 }
00714
00715 if(m_OSResult->optimization->solution[i]->message != ""){
00716 outStr << "<message>";
00717 outStr << m_OSResult->optimization->solution[i]->message;
00718 outStr << "</message>" << endl;
00719 }
00720 if(m_OSResult->optimization->solution[i]->variables != NULL){
00721 outStr << "<variables ";
00722 if (m_OSResult->optimization->solution[i]->variables->numberOfOtherVariableResults > 0)
00723 outStr << "numberOfOtherVariableResults=\"" << m_OSResult->optimization->solution[i]->variables->numberOfOtherVariableResults << "\"";
00724 outStr << ">" << endl;
00725 if(m_OSResult->optimization->solution[i]->variables->values != NULL){
00726 #ifdef DEBUG
00727 cout << "output <variables> <values>" << endl;
00728 #endif
00729 outStr << "<values numberOfVar=\"" << m_OSResult->optimization->solution[i]->variables->values->numberOfVar << "\">" << endl;
00730 for(j = 0; j < m_OSResult->optimization->solution[i]->variables->values->numberOfVar; j++){
00731 if(m_OSResult->optimization->solution[i]->variables->values->var[j] != NULL){
00732 outStr << "<var";
00733 outStr << " idx=\"";
00734 outStr << m_OSResult->optimization->solution[i]->variables->values->var[j]->idx;
00735 outStr << "\">";
00736 outStr << os_dtoa_format( m_OSResult->optimization->solution[i]->variables->values->var[j]->value );
00737 outStr << "</var>" << endl;
00738 }
00739 }
00740 outStr << "</values>" << endl;
00741 }
00742
00743 if(m_OSResult->optimization->solution[i]->variables->valuesString != NULL){
00744 #ifdef DEBUG
00745 cout << "output <variables> <valuesString>" << endl;
00746 #endif
00747 outStr << "<valuesString numberOfVar=\"" << m_OSResult->optimization->solution[i]->variables->valuesString->numberOfVar << "\">" << endl;
00748 for(j = 0; j < m_OSResult->optimization->solution[i]->variables->valuesString->numberOfVar; j++){
00749 if(m_OSResult->optimization->solution[i]->variables->valuesString->var[j] != NULL){
00750 outStr << "<var";
00751 outStr << " idx=\"";
00752 outStr << m_OSResult->optimization->solution[i]->variables->valuesString->var[j]->idx;
00753 outStr << "\">";
00754 outStr << m_OSResult->optimization->solution[i]->variables->valuesString->var[j]->value;
00755 outStr << "</var>" << endl;
00756 }
00757 }
00758 outStr << "</valuesString>" << endl;
00759 }
00760
00761 if(m_OSResult->optimization->solution[i]->variables->basisStatus != NULL){
00762 #ifdef DEBUG
00763 cout << "output <variables> <basisStatus>" << endl;
00764 #endif
00765 outStr << writeBasisStatus(m_OSResult->optimization->solution[i]->variables->basisStatus, m_bWhiteSpace, m_bWriteBase64);
00766 }
00767
00768 #ifdef DEBUG
00769 cout << "output <variables> <other>" << endl;
00770 #endif
00771 if(m_OSResult->optimization->solution[i]->variables->other != NULL){
00772 if(m_OSResult->optimization->solution[i]->variables->numberOfOtherVariableResults > 0){
00773 for(int k = 0; k < m_OSResult->optimization->solution[i]->variables->numberOfOtherVariableResults; k++)
00774 {
00775 outStr << "<other";
00776 if (m_OSResult->optimization->solution[i]->variables->other[k]->numberOfVar > 0)
00777 {
00778 outStr << " numberOfVar=\"";
00779 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->numberOfVar;
00780 outStr << "\"" ;
00781 }
00782 else if(m_OSResult->optimization->solution[i]->variables->other[k]->numberOfEnumerations > 0)
00783 {
00784 outStr << " numberOfEnumerations=\"";
00785 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->numberOfEnumerations;
00786 outStr << "\"" ;
00787 }
00788 outStr << " name=\"";
00789 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->name;
00790 outStr << "\"" ;
00791 if (m_OSResult->optimization->solution[i]->variables->other[k]->value != "")
00792 {
00793 outStr << " value=\"";
00794 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->value;
00795 outStr << "\"" ;
00796 }
00797 if (m_OSResult->optimization->solution[i]->variables->other[k]->description != "")
00798 {
00799 outStr << " description=\"";
00800 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->description;
00801 outStr << "\"" ;
00802 }
00803 outStr << ">" << endl;
00804 if(m_OSResult->optimization->solution[i]->variables->other[k]->numberOfVar > 0)
00805 {
00806 for(j = 0; j < m_OSResult->optimization->solution[i]->variables->other[k]->numberOfVar; j++)
00807 {
00808 outStr << "<var";
00809 outStr << " idx=\"";
00810 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->var[j]->idx ;
00811 outStr << "\">";
00812 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->var[j]->value;
00813 outStr << "</var>" << endl;
00814 }
00815 }
00816 else if (m_OSResult->optimization->solution[i]->variables->other[k]->numberOfEnumerations > 0)
00817 {
00818 for(j = 0; j < m_OSResult->optimization->solution[i]->variables->other[k]->numberOfEnumerations; j++)
00819 {
00820 outStr << writeOtherOptionEnumeration(m_OSResult->optimization->solution[i]->variables->other[k]->enumeration[j],
00821 m_bWhiteSpace, m_bWriteBase64);
00822 }
00823 }
00824 outStr << "</other>" << endl;
00825 }
00826 }
00827 }
00828 outStr << "</variables>" << endl;
00829 }
00830 if(m_OSResult->optimization->solution[i]->objectives != NULL){
00831 outStr << "<objectives ";
00832 if (m_OSResult->optimization->solution[i]->objectives->numberOfOtherObjectiveResults > 0)
00833 outStr << "numberOfOtherObjectiveResults=\"" << m_OSResult->optimization->solution[i]->objectives->numberOfOtherObjectiveResults << "\"";
00834 outStr << ">" << endl;
00835 #ifdef DEBUG
00836 cout << "output <objectives> <values>" << endl;
00837 #endif
00838 if(m_OSResult->optimization->solution[i]->objectives->values != NULL){
00839 outStr << "<values numberOfObj=\"" << m_OSResult->optimization->solution[i]->objectives->values->numberOfObj << "\">" << endl;
00840 for(j = 0; j < m_OSResult->optimization->solution[i]->objectives->values->numberOfObj; j++){
00841 if(m_OSResult->optimization->solution[i]->objectives->values->obj[j] != NULL){
00842 outStr << "<obj";
00843 outStr << " idx=\"";
00844 outStr << m_OSResult->optimization->solution[i]->objectives->values->obj[j]->idx;
00845 outStr << "\">";
00846 outStr << os_dtoa_format( m_OSResult->optimization->solution[i]->objectives->values->obj[j]->value);
00847 outStr << "</obj>" << endl;
00848 }
00849 }
00850
00851 outStr << "</values>" << endl;
00852 }
00853
00854 if(m_OSResult->optimization->solution[i]->objectives->basisStatus != NULL){
00855 #ifdef DEBUG
00856 cout << "output <objectives> <basisStatus>" << endl;
00857 #endif
00858 outStr << writeBasisStatus(m_OSResult->optimization->solution[i]->objectives->basisStatus, m_bWhiteSpace, m_bWriteBase64);
00859 }
00860
00861 #ifdef DEBUG
00862 cout << "output <objectives> <other>" << endl;
00863 #endif
00864 if(m_OSResult->optimization->solution[i]->objectives->other != NULL){
00865 if(m_OSResult->optimization->solution[i]->objectives->numberOfOtherObjectiveResults > 0){
00866 for(int k = 0; k < m_OSResult->optimization->solution[i]->objectives->numberOfOtherObjectiveResults; k++)
00867 {
00868 outStr << "<other" ;
00869 if (m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfObj > 0)
00870 {
00871 outStr << " numberOfObj=\"";
00872 outStr << m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfObj;
00873 outStr << "\"" ;
00874 }
00875 else if(m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfEnumerations > 0)
00876 {
00877 outStr << " numberOfEnumerations=\"";
00878 outStr << m_OSResult->optimization->solution[i]->variables->other[k]->numberOfEnumerations;
00879 outStr << "\"" ;
00880 }
00881 if (m_OSResult->optimization->solution[i]->objectives->other[k]->name != "")
00882 {
00883 outStr << " name=\"";\
00884 outStr << m_OSResult->optimization->solution[i]->objectives->other[k]->name;
00885 outStr << "\"" ;
00886 };
00887 if (m_OSResult->optimization->solution[i]->objectives->other[k]->value != "")
00888 {
00889 outStr << " value=\"";\
00890 outStr << m_OSResult->optimization->solution[i]->objectives->other[k]->value;
00891 outStr << "\"" ;
00892 };
00893 if (m_OSResult->optimization->solution[i]->objectives->other[k]->description != "")
00894 {
00895 outStr << " description=\"";
00896 outStr << m_OSResult->optimization->solution[i]->objectives->other[k]->description;
00897 outStr << "\"" ;
00898 };
00899 outStr << ">" << endl;
00900 if(m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfObj > 0)
00901 {
00902 for(j = 0; j < m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfObj; j++)
00903 {
00904 outStr << "<obj";
00905 outStr << " idx=\"";
00906 outStr << m_OSResult->optimization->solution[i]->objectives->other[k]->obj[j]->idx;
00907 outStr << "\">";
00908 outStr << m_OSResult->optimization->solution[i]->objectives->other[k]->obj[j]->value;
00909 outStr << "</obj>" << endl;
00910 }
00911 }
00912 else if (m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfEnumerations > 0)
00913 {
00914 for(j = 0; j < m_OSResult->optimization->solution[i]->objectives->other[k]->numberOfEnumerations; j++)
00915 {
00916 outStr << writeOtherOptionEnumeration(m_OSResult->optimization->solution[i]->objectives->other[k]->enumeration[j],
00917 m_bWhiteSpace, m_bWriteBase64);
00918 }
00919 }
00920 outStr << "</other>" << endl;
00921 }
00922 }
00923 }
00924 outStr << "</objectives>" << endl;
00925 }
00926 if(m_OSResult->optimization->solution[i]->constraints != NULL){
00927 outStr << "<constraints ";
00928 if (m_OSResult->optimization->solution[i]->constraints->numberOfOtherConstraintResults > 0)
00929 outStr << "numberOfOtherConstraintResults=\"" << m_OSResult->optimization->solution[i]->constraints->numberOfOtherConstraintResults << "\"";
00930 outStr << ">" << endl;
00931 #ifdef DEBUG
00932 cout << "output <constraints> <dualValues>" << endl;
00933 #endif
00934 if(m_OSResult->optimization->solution[i]->constraints->dualValues != NULL){
00935 outStr << "<dualValues numberOfCon=\"" << m_OSResult->optimization->solution[i]->constraints->dualValues->numberOfCon << "\">" << endl;
00936 for(j = 0; j < m_OSResult->optimization->solution[i]->constraints->dualValues->numberOfCon; j++){
00937 if(m_OSResult->optimization->solution[i]->constraints->dualValues->con[j] != NULL){
00938 outStr << "<con";
00939 outStr << " idx=\"";
00940 outStr << m_OSResult->optimization->solution[i]->constraints->dualValues->con[j]->idx;
00941 outStr << "\">";
00942 outStr << os_dtoa_format( m_OSResult->optimization->solution[i]->constraints->dualValues->con[j]->value);
00943 outStr << "</con>" << endl;
00944 }
00945 }
00946 outStr << "</dualValues>" << endl;
00947 }
00948
00949 if(m_OSResult->optimization->solution[i]->constraints->basisStatus != NULL){
00950 #ifdef DEBUG
00951 cout << "output <constraints> <basisStatus>" << endl;
00952 #endif
00953 outStr << writeBasisStatus(m_OSResult->optimization->solution[i]->constraints->basisStatus, m_bWhiteSpace, m_bWriteBase64);
00954 }
00955
00956 #ifdef DEBUG
00957 cout << "output <constraints> <other>" << endl;
00958 #endif
00959 if(m_OSResult->optimization->solution[i]->constraints->other != NULL){
00960 if(m_OSResult->optimization->solution[i]->constraints->numberOfOtherConstraintResults > 0){
00961 for(int k = 0; k < m_OSResult->optimization->solution[i]->constraints->numberOfOtherConstraintResults; k++){
00962 outStr << "<other" ;
00963 if (m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfCon > 0)
00964 {
00965 outStr << " numberOfCon=\"";
00966 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfCon;
00967 outStr << "\"";
00968 }
00969 else if(m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfEnumerations > 0)
00970 {
00971 outStr << " numberOfEnumerations=\"";
00972 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfEnumerations;
00973 outStr << "\"" ;
00974 }
00975 outStr << " name=\"";\
00976 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->name;
00977 outStr << "\"" ;
00978 if (m_OSResult->optimization->solution[i]->constraints->other[k]->value != "")
00979 {
00980 outStr << " value=\"";\
00981 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->value;
00982 outStr << "\"" ;
00983 };
00984 if (m_OSResult->optimization->solution[i]->constraints->other[k]->description != "")
00985 {
00986 outStr << " description=\"";
00987 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->description;
00988 outStr << "\"" ;
00989 };
00990 outStr << ">" << endl;
00991 if(m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfCon > 0)
00992 {
00993 for(j = 0; j < m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfCon; j++){
00994 outStr << "<con";
00995 outStr << " idx=\"";
00996 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->con[j]->idx;
00997 outStr << "\">";
00998 outStr << m_OSResult->optimization->solution[i]->constraints->other[k]->con[j]->value;
00999 outStr << "</con>" << endl;
01000 }
01001 }
01002 else if (m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfEnumerations > 0)
01003 {
01004 for(j = 0; j < m_OSResult->optimization->solution[i]->constraints->other[k]->numberOfEnumerations; j++)
01005 {
01006 outStr << writeOtherOptionEnumeration(m_OSResult->optimization->solution[i]->constraints->other[k]->enumeration[j],
01007 m_bWhiteSpace, m_bWriteBase64);
01008 }
01009 }
01010 outStr << "</other>" << endl;
01011 }
01012 }
01013 }
01014 outStr << "</constraints>" << endl;
01015 }
01016
01017
01018 #ifdef DEBUG
01019 cout << "output <otherSolutionResults>" << endl;
01020 #endif
01021 if (m_OSResult->optimization->solution[i]->otherSolutionResults != NULL)
01022 if (m_OSResult->optimization->solution[i]->otherSolutionResults->numberOfOtherSolutionResults > 0){
01023 outStr << "<otherSolutionResults numberOfOtherSolutionResults=\"";
01024 outStr << m_OSResult->optimization->solution[i]->otherSolutionResults->numberOfOtherSolutionResults;
01025 outStr << "\">" << std::endl;
01026 for(int k = 0; k < m_OSResult->optimization->solution[i]->otherSolutionResults->numberOfOtherSolutionResults; k++){
01027 outStr << "<otherSolutionResult";
01028 outStr << " name=\"";
01029 outStr << m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->name;
01030 outStr << "\"";
01031 outStr << " numberOfItems=\"";
01032 outStr << m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->numberOfItems;
01033 outStr << "\"";
01034 if (m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->category != "")
01035 outStr << " category=\"" << m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->category << "\"";
01036 if (m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->description != "")
01037 outStr << " description=\"" << m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->description << "\"";
01038 outStr << ">" << std::endl;
01039 for(int j = 0; j < m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->numberOfItems; j++){
01040 outStr << "<item>" << m_OSResult->optimization->solution[i]->otherSolutionResults->otherSolutionResult[k]->item[j] << "</item>" << std::endl;
01041 }
01042 outStr << "</otherSolutionResult>" << std::endl;
01043 }
01044 outStr << "</otherSolutionResults>" << std::endl;
01045 }
01046 outStr << "</solution>" << endl;
01047 }
01048 }
01049
01050
01051 #ifdef DEBUG
01052 cout << "output <otherSolverOutput>" << endl;
01053 #endif
01054 if (m_OSResult->optimization->otherSolverOutput != NULL)
01055 if (m_OSResult->optimization->otherSolverOutput->numberOfSolverOutputs > 0){
01056 outStr << "<otherSolverOutput numberOfSolverOutputs=\"";
01057 outStr << m_OSResult->optimization->otherSolverOutput->numberOfSolverOutputs;
01058 outStr << "\">" << std::endl;
01059 for(int k = 0; k < m_OSResult->optimization->otherSolverOutput->numberOfSolverOutputs; k++){
01060 outStr << "<solverOutput";
01061 outStr << " name=\"";
01062 outStr << m_OSResult->optimization->otherSolverOutput->solverOutput[k]->name;
01063 outStr << "\"";
01064 outStr << " numberOfItems=\"";
01065 outStr << m_OSResult->optimization->otherSolverOutput->solverOutput[k]->numberOfItems;
01066 outStr << "\"";
01067 if (m_OSResult->optimization->otherSolverOutput->solverOutput[k]->category != "")
01068 outStr << " category=\"" << m_OSResult->optimization->otherSolverOutput->solverOutput[k]->category << "\"";
01069 if (m_OSResult->optimization->otherSolverOutput->solverOutput[k]->description != "")
01070 outStr << " description=\"" << m_OSResult->optimization->otherSolverOutput->solverOutput[k]->description << "\"";
01071 outStr << ">" << std::endl;
01072 for(int j = 0; j < m_OSResult->optimization->otherSolverOutput->solverOutput[k]->numberOfItems; j++){
01073 outStr << "<item>" << m_OSResult->optimization->otherSolverOutput->solverOutput[k]->item[j] << "</item>" << std::endl;
01074 }
01075 outStr << "</solverOutput>" << std::endl;
01076 }
01077 outStr << "</otherSolverOutput>" << std::endl;
01078 }
01079
01080 outStr << "</optimization>" << endl;
01081 }
01082 outStr << "</osrl>" << endl ;
01083 #ifdef DEBUG
01084 cout << "done" << endl;
01085 #endif
01086 return outStr.str();
01087 }
01088
01089