00001
00016 #include "OSiLWriter.h"
00017 #include "OSStringUtil.h"
00018 #include "OSInstance.h"
00019 #include "OSParameters.h"
00020 #include "OSBase64.h"
00021 #include "OSMathUtil.h"
00022 #include "CoinFinite.hpp"
00023
00024 #include <sstream>
00025
00026 using std::endl;
00027 using std::ostringstream;
00028
00029
00030 OSiLWriter::OSiLWriter( )
00031 {
00032 m_bWriteBase64 = false;
00033 m_bWhiteSpace = false;
00034 }
00035
00036 OSiLWriter::~OSiLWriter()
00037 {
00038 }
00039
00040 std::string OSiLWriter::writeOSiL( const OSInstance *theosinstance)
00041 {
00042
00043 m_OSInstance = theosinstance;
00044 ostringstream outStr;
00045 int i, j, k, kk;
00046 int mult;
00047 int incr;
00048 std::string tmpname, tmpsense;
00049 double tmplb, tmpub, tmpconst, tmpweight;
00050 char tmptype;
00051 int tmpnum;
00052
00053
00054 if(m_OSInstance == NULL) return outStr.str();
00055 outStr << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
00056 if( m_bWhiteSpace == true) outStr << endl;
00057 outStr << "<osil xmlns=\"os.optimizationservices.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
00058 outStr << "xsi:schemaLocation=\"os.optimizationservices.org http://www.optimizationservices.org/schemas/";
00059 outStr << OS_SCHEMA_VERSION;
00060 outStr << "/OSiL.xsd\" >" ;
00061 if( m_bWhiteSpace == true) outStr << endl;
00062 outStr << "<instanceHeader>";
00063 if( m_bWhiteSpace == true) outStr << endl;
00064 if(m_OSInstance->instanceHeader != NULL)
00065 {
00066 if(m_OSInstance->instanceHeader->name.length() > 0)
00067 {
00068 outStr << "<name>" + m_OSInstance->instanceHeader->name + "</name>" ;
00069 if( m_bWhiteSpace == true) outStr << endl;
00070 }
00071
00072 if(m_OSInstance->instanceHeader->source.length() > 0)
00073 {
00074 outStr << "<source>" + m_OSInstance->instanceHeader->source + "</source>" ;
00075 if( m_bWhiteSpace == true) outStr << endl;
00076 }
00077 if(m_OSInstance->instanceHeader->description.length() > 0)
00078 {
00079 outStr << "<description>" + m_OSInstance->instanceHeader->description + "</description>";
00080 if( m_bWhiteSpace == true) outStr << endl;
00081 }
00082 if(m_OSInstance->instanceHeader->fileCreator.length() > 0)
00083 {
00084 outStr << "<fileCreator>" + m_OSInstance->instanceHeader->fileCreator + "</fileCreator>";
00085 if( m_bWhiteSpace == true) outStr << endl;
00086 }
00087 if(m_OSInstance->instanceHeader->licence.length() > 0)
00088 {
00089 outStr << "<licence>" + m_OSInstance->instanceHeader->licence + "</licence>";
00090 if( m_bWhiteSpace == true) outStr << endl;
00091 }
00092 }
00093 outStr << "</instanceHeader>" ;
00094 if( m_bWhiteSpace == true) outStr << endl;
00095 outStr << "<instanceData>" ;
00096 if(m_OSInstance->instanceData != NULL)
00097 {
00098 if( m_bWhiteSpace == true) outStr << endl;
00099 if(m_OSInstance->instanceData->variables != NULL && m_OSInstance->instanceData->variables->numberOfVariables > 0)
00100 {
00101 outStr << "<variables " ;
00102 outStr << "numberOfVariables=\"";
00103 outStr << m_OSInstance->instanceData->variables->numberOfVariables ;
00104 outStr << "\"" ;
00105 outStr << ">" ;
00106 if (m_bWhiteSpace == true) outStr << endl;
00107
00108 for (i = 0; i < m_OSInstance->instanceData->variables->numberOfVariables;)
00109 {
00110 mult = 1;
00111 if (m_OSInstance->instanceData->variables->var[i] != NULL)
00112 {
00113 if (i < m_OSInstance->instanceData->variables->numberOfVariables - 1)
00114 {
00115 tmpname = m_OSInstance->instanceData->variables->var[i]->name;
00116 tmptype = m_OSInstance->instanceData->variables->var[i]->type;
00117 tmplb = m_OSInstance->instanceData->variables->var[i]->lb;
00118 tmpub = m_OSInstance->instanceData->variables->var[i]->ub;
00119 for (k=i+1; k < m_OSInstance->instanceData->variables->numberOfVariables; k++)
00120 {
00121 if (tmpname != m_OSInstance->instanceData->variables->var[k]->name) break;
00122 if (tmptype != m_OSInstance->instanceData->variables->var[k]->type) break;
00123 if (tmplb != m_OSInstance->instanceData->variables->var[k]->lb) break;
00124 if (tmpub != m_OSInstance->instanceData->variables->var[k]->ub) break;
00125 mult++;
00126 }
00127 }
00128 outStr << "<var" ;
00129 if (m_OSInstance->instanceData->variables->var[i]->name.length() > 0)
00130 {
00131 outStr << " name=" ;
00132 outStr << writeStringData(m_OSInstance->instanceData->variables->var[i]->name);
00133 }
00134 if( m_OSInstance->instanceData->variables->var[i]->type != 'C')
00135 {
00136 outStr << " type=\"" ;
00137 outStr << m_OSInstance->instanceData->variables->var[i]->type ;
00138 outStr << "\"";
00139 }
00140 if( m_OSInstance->instanceData->variables->var[i]->lb != 0.0)
00141 {
00142 outStr << " lb=\"" ;
00143 outStr << os_dtoa_format( m_OSInstance->instanceData->variables->var[i]->lb) ;
00144 outStr << "\"";
00145 }
00146 if( m_OSInstance->instanceData->variables->var[i]->ub != OSDBL_MAX
00147 && m_OSInstance->instanceData->variables->var[i]->ub != OSNaN() )
00148 {
00149 outStr << " ub=\"" ;
00150 outStr << os_dtoa_format( m_OSInstance->instanceData->variables->var[i]->ub) ;
00151 outStr << "\"";
00152 }
00153 if (mult > 1)
00154 outStr << " mult=\"" << mult << "\"";
00155 outStr << "/>" ;
00156 if( m_bWhiteSpace == true) outStr << endl;
00157 }
00158 i += mult;
00159 }
00160 outStr << "</variables>" ;
00161 if( m_bWhiteSpace == true) outStr << endl;
00162 }
00163 if(m_OSInstance->instanceData->objectives != NULL && m_OSInstance->instanceData->objectives->numberOfObjectives > 0)
00164 {
00165 outStr << "<objectives " ;
00166 outStr << "numberOfObjectives=\"";
00167 outStr << m_OSInstance->instanceData->objectives->numberOfObjectives ;
00168 outStr << "\"" ;
00169 outStr << ">" ;
00170 if( m_bWhiteSpace == true) outStr << endl;
00171 for (j = 0; j < m_OSInstance->instanceData->objectives->numberOfObjectives;)
00172 {
00173 mult = 1;
00174 if(m_OSInstance->instanceData->objectives->obj[j] != NULL)
00175 {
00176 if (j < m_OSInstance->instanceData->objectives->numberOfObjectives - 1)
00177 {
00178 tmpname = m_OSInstance->instanceData->objectives->obj[j]->name;
00179 tmpsense = m_OSInstance->instanceData->objectives->obj[j]->maxOrMin;
00180 tmpconst = m_OSInstance->instanceData->objectives->obj[j]->constant;
00181 tmpweight = m_OSInstance->instanceData->objectives->obj[j]->weight;
00182 tmpnum = m_OSInstance->instanceData->objectives->obj[j]->numberOfObjCoef;
00183 for (k=j+1; k < m_OSInstance->instanceData->objectives->numberOfObjectives; k++)
00184 {
00185 if (tmpname != m_OSInstance->instanceData->objectives->obj[k]->name) break;
00186 if (tmpsense != m_OSInstance->instanceData->objectives->obj[k]->maxOrMin) break;
00187 if (tmpconst != m_OSInstance->instanceData->objectives->obj[k]->constant) break;
00188 if (tmpweight != m_OSInstance->instanceData->objectives->obj[k]->weight) break;
00189 if (tmpnum != m_OSInstance->instanceData->objectives->obj[k]->numberOfObjCoef) break;
00190 for (kk=0; kk < tmpnum; kk++)
00191 {
00192 if (m_OSInstance->instanceData->objectives->obj[k]->coef[kk]->idx !=
00193 m_OSInstance->instanceData->objectives->obj[j]->coef[kk]->idx) break;
00194 if (m_OSInstance->instanceData->objectives->obj[k]->coef[kk]->value !=
00195 m_OSInstance->instanceData->objectives->obj[j]->coef[kk]->value) break;
00196 }
00197 if ( kk < tmpnum) break;
00198 mult++;
00199 }
00200 }
00201 outStr << "<obj" ;
00202 if(m_OSInstance->instanceData->objectives->obj[j]->maxOrMin.length() > 0)
00203 {
00204 outStr << " maxOrMin=\"" ;
00205 outStr << m_OSInstance->instanceData->objectives->obj[j]->maxOrMin ;
00206 outStr << "\"";
00207 }
00208 if(m_OSInstance->instanceData->objectives->obj[j]->constant != 0.0)
00209 {
00210 outStr << " constant=\"" ;
00211 outStr << os_dtoa_format(m_OSInstance->instanceData->objectives->obj[j]->constant) ;
00212 outStr << "\"";
00213 }
00214 if(m_OSInstance->instanceData->objectives->obj[j]->weight != 1.0)
00215 {
00216 outStr << " weight=\"" ;
00217 outStr << os_dtoa_format(m_OSInstance->instanceData->objectives->obj[j]->weight) ;
00218 outStr << "\"";
00219 }
00220 if(m_OSInstance->instanceData->objectives->obj[j]->name.length() > 0)
00221 {
00222 outStr << " name=" ;
00223 outStr << writeStringData(m_OSInstance->instanceData->objectives->obj[j]->name);
00224 }
00225 outStr << " numberOfObjCoef=\"" ;
00226 outStr << m_OSInstance->instanceData->objectives->obj[j]->numberOfObjCoef ;
00227 outStr << "\"";
00228 if (mult > 1)
00229 outStr << " mult=\"" << mult << "\"";
00230 outStr << ">" ;
00231 if( m_bWhiteSpace == true) outStr << endl;
00232 if(m_OSInstance->instanceData->objectives->obj[j]->coef != NULL)
00233 {
00234 for (i = 0; i < m_OSInstance->instanceData->objectives->obj[ j]->numberOfObjCoef; i++)
00235 {
00236 if(m_OSInstance->instanceData->objectives->obj[j]->coef[i]->idx > -1 )
00237 {
00238 outStr << "<coef" ;
00239 outStr << " idx=\"" ;
00240 outStr << m_OSInstance->instanceData->objectives->obj[j]->coef[i]->idx ;
00241 outStr << "\"";
00242 outStr << ">";
00243
00244
00245 outStr << os_dtoa_format( m_OSInstance->instanceData->objectives->obj[j]->coef[i]->value) ;
00246
00247 outStr << "</coef>" ;
00248 if( m_bWhiteSpace == true) outStr << endl;
00249 }
00250 }
00251 }
00252 outStr << "</obj>" ;
00253 if( m_bWhiteSpace == true) outStr << endl;
00254 }
00255 j += mult;
00256 }
00257 outStr << "</objectives>" ;
00258 if( m_bWhiteSpace == true) outStr << endl;
00259 }
00260
00261 if(m_OSInstance->instanceData->constraints != NULL && m_OSInstance->instanceData->constraints->numberOfConstraints > 0)
00262 {
00263 outStr << "<constraints " ;
00264 outStr << "numberOfConstraints=\"";
00265 outStr << m_OSInstance->instanceData->constraints->numberOfConstraints ;
00266 outStr << "\"" ;
00267 outStr << ">" ;
00268 if( m_bWhiteSpace == true) outStr << endl;
00269 for (i = 0; i < m_OSInstance->instanceData->constraints->numberOfConstraints;)
00270 {
00271 mult = 1;
00272 if(m_OSInstance->instanceData->constraints->con[i] != NULL)
00273 {
00274 if (i < m_OSInstance->instanceData->constraints->numberOfConstraints - 1)
00275 {
00276 tmpname = m_OSInstance->instanceData->constraints->con[i]->name;
00277 tmpconst = m_OSInstance->instanceData->constraints->con[i]->constant;
00278 tmplb = m_OSInstance->instanceData->constraints->con[i]->lb;
00279 tmpub = m_OSInstance->instanceData->constraints->con[i]->ub;
00280 for (k=i+1; k < m_OSInstance->instanceData->constraints->numberOfConstraints; k++)
00281 {
00282 if (tmpname != m_OSInstance->instanceData->constraints->con[k]->name) break;
00283 if (tmpconst != m_OSInstance->instanceData->constraints->con[k]->constant) break;
00284 if (tmplb != m_OSInstance->instanceData->constraints->con[k]->lb) break;
00285 if (tmpub != m_OSInstance->instanceData->constraints->con[k]->ub) break;
00286 mult++;
00287 }
00288 }
00289 outStr << "<con" ;
00290 if(m_OSInstance->instanceData->constraints->con[i]->name.length())
00291 {
00292 outStr << " name=" ;
00293 outStr << writeStringData(m_OSInstance->instanceData->constraints->con[i]->name);
00294 }
00295 if(m_OSInstance->instanceData->constraints->con[i]->constant != 0)
00296 {
00297 outStr << " constant=\"" ;
00298 outStr << os_dtoa_format( m_OSInstance->instanceData->constraints->con[i]->constant) ;
00299 outStr << "\"";
00300 }
00301 if(m_OSInstance->instanceData->constraints->con[i]->lb != -OSDBL_MAX )
00302 {
00303 outStr << " lb=\"" ;
00304 outStr << os_dtoa_format( m_OSInstance->instanceData->constraints->con[i]->lb) ;
00305 outStr << "\"";
00306 }
00307 if(m_OSInstance->instanceData->constraints->con[i]->ub != OSDBL_MAX)
00308 {
00309 outStr << " ub=\"" ;
00310 outStr << os_dtoa_format( m_OSInstance->instanceData->constraints->con[i]->ub) ;
00311 outStr << "\"";
00312 }
00313 if (mult > 1)
00314 outStr << " mult=\"" << mult << "\"";
00315 outStr << "/>" ;
00316 if( m_bWhiteSpace == true) outStr << endl;
00317 }
00318 i += mult;
00319 }
00320 outStr << "</constraints>" ;
00321 if( m_bWhiteSpace == true) outStr << endl;
00322 }
00323
00324 if(m_OSInstance->instanceData->linearConstraintCoefficients != NULL && m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues > 0)
00325 {
00326 outStr << "<linearConstraintCoefficients " ;
00327 outStr << "numberOfValues=\"";
00328 outStr << m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues ;
00329 outStr << "\"" ;
00330 outStr << ">" ;
00331 if( m_bWhiteSpace == true) outStr << endl;
00332 if( (m_OSInstance->instanceData->linearConstraintCoefficients->rowIdx != NULL) &&
00333 (m_OSInstance->instanceData->linearConstraintCoefficients->rowIdx->el != NULL) )
00334 {
00335 if(m_OSInstance->instanceData->linearConstraintCoefficients->start->el != NULL)
00336 {
00337 outStr << "<start>" ;
00338 if( m_bWhiteSpace == true) outStr << endl;
00339 if(m_OSInstance->instanceData->variables != NULL && m_OSInstance->instanceData->variables->numberOfVariables > 0)
00340 {
00341 if(m_bWriteBase64 == false)
00342 {
00343 for(i = 0; i <= m_OSInstance->instanceData->variables->numberOfVariables;)
00344 {
00345 getMultIncr(&(m_OSInstance->instanceData->linearConstraintCoefficients->start->el[i]),
00346 &mult, &incr, (m_OSInstance->instanceData->variables->numberOfVariables) + 1-i,1);
00347 if (mult == 1)
00348 outStr << "<el>" ;
00349 else if (incr == 0)
00350 outStr << "<el mult=\"" << mult << "\">";
00351 else
00352 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">";
00353 outStr << m_OSInstance->instanceData->linearConstraintCoefficients->start->el[i];
00354 outStr << "</el>" ;
00355 if( m_bWhiteSpace == true) outStr << endl;
00356 i += mult;
00357 }
00358 }
00359 else
00360 {
00361 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\" >" ;
00362 outStr << Base64::encodeb64( (char*)m_OSInstance->instanceData->linearConstraintCoefficients->start->el,
00363 (m_OSInstance->instanceData->variables->numberOfVariables + 1)*sizeof(int) );
00364 outStr << "</base64BinaryData>" ;
00365 if( m_bWhiteSpace == true) outStr << endl;
00366 }
00367 }
00368 outStr << "</start>" ;
00369 if( m_bWhiteSpace == true) outStr << endl;
00370 }
00371 outStr << "<rowIdx>" ;
00372 if( m_bWhiteSpace == true) outStr << endl;
00373 if(m_bWriteBase64 == false)
00374 {
00375 for(i = 0; i < m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues;)
00376 {
00377 getMultIncr(&(m_OSInstance->instanceData->linearConstraintCoefficients->rowIdx->el[i]),
00378 &mult, &incr, (m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues)-i,1);
00379 if (mult == 1)
00380 outStr << "<el>" ;
00381 else if (incr == 0)
00382 outStr << "<el mult=\"" << mult << "\">";
00383 else
00384 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">";
00385 outStr << m_OSInstance->instanceData->linearConstraintCoefficients->rowIdx->el[i];
00386 outStr << "</el>" ;
00387 if( m_bWhiteSpace == true) outStr << endl;
00388 i += mult;
00389 }
00390 }
00391 else
00392 {
00393
00394 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\" >" ;
00395 outStr << Base64::encodeb64( (char*)m_OSInstance->instanceData->linearConstraintCoefficients->rowIdx->el,
00396 m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues*sizeof(int) );
00397 outStr << "</base64BinaryData>" ;
00398 if( m_bWhiteSpace == true) outStr << endl;
00399 }
00400 outStr << "</rowIdx>" ;
00401 if( m_bWhiteSpace == true) outStr << endl;
00402 }
00403 else
00404 {
00405 if( (m_OSInstance->instanceData->linearConstraintCoefficients->colIdx != NULL) &&
00406 (m_OSInstance->instanceData->linearConstraintCoefficients->colIdx->el != NULL) )
00407 {
00408 if(m_OSInstance->instanceData->linearConstraintCoefficients->start->el != NULL)
00409 {
00410 outStr << "<start>" ;
00411 if( m_bWhiteSpace == true) outStr << endl;
00412 if(m_OSInstance->instanceData->constraints != NULL && m_OSInstance->instanceData->constraints->numberOfConstraints > 0)
00413 {
00414 if(m_bWriteBase64 == false)
00415 {
00416 for(i = 0; i <= m_OSInstance->instanceData->constraints->numberOfConstraints;)
00417 {
00418 getMultIncr(&(m_OSInstance->instanceData->linearConstraintCoefficients->start->el[i]),
00419 &mult, &incr, (m_OSInstance->instanceData->constraints->numberOfConstraints) + 1-i,1);
00420 if (mult == 1)
00421 outStr << "<el>" ;
00422 else if (incr == 0)
00423 outStr << "<el mult=\"" << mult << "\">";
00424 else
00425 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">";
00426 outStr << m_OSInstance->instanceData->linearConstraintCoefficients->start->el[i];
00427 outStr << "</el>" ;
00428 if( m_bWhiteSpace == true) outStr << endl;
00429 i += mult;
00430 }
00431 }
00432 else
00433 {
00434 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\" >" ;
00435 outStr << Base64::encodeb64( (char*)m_OSInstance->instanceData->linearConstraintCoefficients->start->el,
00436 (m_OSInstance->instanceData->variables->numberOfVariables + 1)*sizeof(int) );
00437 outStr << "</base64BinaryData>" ;
00438 if( m_bWhiteSpace == true) outStr << endl;
00439 }
00440 }
00441 outStr << "</start>" ;
00442 if( m_bWhiteSpace == true) outStr << endl;
00443 }
00444 outStr << "<colIdx>";
00445 if( m_bWhiteSpace == true) outStr << endl;
00446 if(m_bWriteBase64 == false)
00447 {
00448 for(i = 0; i < m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues;)
00449 {
00450 getMultIncr(&(m_OSInstance->instanceData->linearConstraintCoefficients->colIdx->el[i]),
00451 &mult, &incr, (m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues)-i,1);
00452 if (mult == 1)
00453 outStr << "<el>" ;
00454 else if (incr == 0)
00455 outStr << "<el mult=\"" << mult << "\">";
00456 else
00457 outStr << "<el mult=\"" << mult << "\" incr=\"" << incr << "\">";
00458 outStr << m_OSInstance->instanceData->linearConstraintCoefficients->colIdx->el[i];
00459 outStr << "</el>" ;
00460 if( m_bWhiteSpace == true) outStr << endl;
00461 i += mult;
00462 }
00463 }
00464 else
00465 {
00466 outStr << "<base64BinaryData sizeOf=\"" << sizeof(int) << "\" >" ;
00467 outStr << Base64::encodeb64( (char*)m_OSInstance->instanceData->linearConstraintCoefficients->colIdx->el,
00468 m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues*sizeof(int) );
00469 outStr << "</base64BinaryData>" ;
00470 if( m_bWhiteSpace == true) outStr << endl;
00471 }
00472 outStr << "</colIdx>" ;
00473 if( m_bWhiteSpace == true) outStr << endl;
00474 }
00475 }
00476 if(m_OSInstance->instanceData->linearConstraintCoefficients->value != NULL)
00477 {
00478 outStr << "<value>" ;
00479 if( m_bWhiteSpace == true) outStr << endl;
00480 if(m_OSInstance->instanceData->linearConstraintCoefficients->value->el != NULL)
00481 {
00482 if(m_bWriteBase64 == false)
00483 {
00484 for(i = 0; i < m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues;)
00485 {
00486 mult = getMult(&(m_OSInstance->instanceData->linearConstraintCoefficients->value->el[i]),
00487 (m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues)-i);
00488 if (mult == 1)
00489 outStr << "<el>" ;
00490 else
00491 outStr << "<el mult=\"" << mult << "\">";
00492 outStr << os_dtoa_format( m_OSInstance->instanceData->linearConstraintCoefficients->value->el[i] );
00493 outStr << "</el>" ;
00494 if( m_bWhiteSpace == true) outStr << endl;
00495 i += mult;
00496 }
00497 }
00498 else
00499 {
00500 outStr << "<base64BinaryData sizeOf=\"" << sizeof(double) << "\" >" ;
00501 outStr << Base64::encodeb64( (char*)m_OSInstance->instanceData->linearConstraintCoefficients->value->el,
00502 m_OSInstance->instanceData->linearConstraintCoefficients->numberOfValues*sizeof( double) );
00503 outStr << "</base64BinaryData>" ;
00504 if( m_bWhiteSpace == true) outStr << endl;
00505 }
00506 }
00507 outStr << "</value>" ;
00508 if( m_bWhiteSpace == true) outStr << endl;
00509 }
00510 outStr << "</linearConstraintCoefficients>" ;
00511 if( m_bWhiteSpace == true) outStr << endl;
00512 }
00513 if(m_OSInstance->instanceData->quadraticCoefficients != NULL && m_OSInstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms > 0)
00514 {
00515 outStr << "<quadraticCoefficients";
00516 outStr << " numberOfQuadraticTerms=\"";
00517 outStr << m_OSInstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms;
00518 outStr << "\" >" ;
00519 if( m_bWhiteSpace == true) outStr << endl;
00520 for(i = 0; i < m_OSInstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms; i++)
00521 {
00522 if(m_OSInstance->instanceData->quadraticCoefficients->qTerm[i])
00523 {
00524 outStr << "<qTerm" ;
00525
00526 outStr << " idx=\"";
00527 outStr << m_OSInstance->instanceData->quadraticCoefficients->qTerm[i]->idx;
00528 outStr << "\"";
00529 outStr << " idxOne=\"";
00530 outStr << m_OSInstance->instanceData->quadraticCoefficients->qTerm[i]->idxOne;
00531 outStr << "\"";
00532 outStr << " idxTwo=\"";
00533 outStr << m_OSInstance->instanceData->quadraticCoefficients->qTerm[i]->idxTwo;
00534 outStr << "\"";
00535 if(m_OSInstance->instanceData->quadraticCoefficients->qTerm[i]->coef != 0)
00536 {
00537 outStr << " coef=\"";
00538 outStr << os_dtoa_format(m_OSInstance->instanceData->quadraticCoefficients->qTerm[i]->coef);
00539 outStr << "\"";
00540 }
00541 outStr << "/>" ;
00542 if( m_bWhiteSpace == true) outStr << endl;
00543 }
00544 }
00545 outStr << "</quadraticCoefficients>";
00546 if( m_bWhiteSpace == true) outStr << endl;
00547 }
00548 if(m_OSInstance->instanceData->nonlinearExpressions != NULL && m_OSInstance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions > 0)
00549 {
00550 outStr << "<nonlinearExpressions";
00551 outStr << " numberOfNonlinearExpressions=\"";
00552 outStr << m_OSInstance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions;
00553 outStr << "\" >" ;
00554 if( m_bWhiteSpace == true) outStr << endl;
00555 for(i = 0; i < m_OSInstance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions; i++)
00556 {
00557 if(m_OSInstance->instanceData->nonlinearExpressions->nl[i] != NULL)
00558 {
00559 outStr << "<nl" ;
00560
00561 outStr << " idx=\"";
00562 outStr << m_OSInstance->instanceData->nonlinearExpressions->nl[i]->idx;
00563 outStr << "\">";
00564 if(m_OSInstance->instanceData->nonlinearExpressions->nl[i]->osExpressionTree->m_treeRoot != NULL)
00565 outStr << m_OSInstance->instanceData->nonlinearExpressions->nl[i]->osExpressionTree->m_treeRoot->getNonlinearExpressionInXML();
00566 outStr << "</nl>";
00567 }
00568 if( m_bWhiteSpace == true) outStr << endl;
00569 }
00570 outStr << "</nonlinearExpressions>";
00571 if( m_bWhiteSpace == true) outStr << endl;
00572 }
00573 if( m_bWhiteSpace == true) outStr << endl;
00574 }
00575 outStr << "</instanceData>" ;
00576 outStr << "</osil>" ;
00577 if( m_bWhiteSpace == true) outStr << endl;
00578 outStr << endl;
00579 return outStr.str();
00580 }