- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/OS-2.3.5/OS/src/OSCommonInterfaces/OSiLWriter.cpp

Go to the documentation of this file.

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