/home/coin/SVN-release/OS-2.0.0/OS/test/unitTest.cpp

Go to the documentation of this file.
00001 /* $Id: unitTest.cpp 2833 2009-07-21 21:17:06Z kmartin $ */
00105 #define DEBUG       
00106 
00107 #include <cppad/cppad.hpp> 
00108 //#include "CoinUtilsConfig.h"
00109 #include "OSCoinSolver.h"
00110 #include "OSConfig.h"
00111 #include "OSmps2osil.h" 
00112 #include "OSResult.h" 
00113 #include "OSOption.h"
00114 #include "OSiLReader.h"        
00115 #include "OSiLWriter.h" 
00116 #include "OSoLReader.h"        
00117 #include "OSoLWriter.h" 
00118 #include "OSrLReader.h"          
00119 #include "OSrLWriter.h"      
00120 #include "OSInstance.h"  
00121 #include "OSFileUtil.h"  
00122 #include "CoinError.hpp"
00123 
00124 #include "OSDefaultSolver.h"  
00125 #include "OSWSUtil.h" 
00126 #include "OSSolverAgent.h"   
00127 #include "OShL.h"     
00128 #include "OSErrorClass.h"
00129 #include "OSBase64.h"
00130 #include "OSMathUtil.h"
00131 
00132 
00133 #include <CoinMpsIO.hpp>
00134 #include <CoinPackedMatrix.hpp>
00135 
00136 
00137 #include "CoinError.hpp"
00138 #include "CoinHelperFunctions.hpp"
00139 
00140 
00141 
00142 #ifdef COIN_HAS_GLPK
00143 #include <OsiGlpkSolverInterface.hpp>
00144 #endif
00145 
00146 #ifdef COIN_HAS_COUENNE    
00147 #include "OSCouenneSolver.h"
00148 #endif
00149 
00150 #ifdef COIN_HAS_ASL
00151 #include "OSnl2osil.h"
00152 #endif
00153 
00154 #ifdef COIN_HAS_LINDO    
00155 #include "OSLindoSolver.h"
00156 #endif  
00157 
00158 #ifdef COIN_HAS_IPOPT    
00159 #include "OSIpoptSolver.h"
00160 #endif 
00161 
00162 #ifdef COIN_HAS_BONMIN    
00163 #include "OSBonminSolver.h"
00164 #endif 
00165 
00166 
00167 
00168 
00169 #ifdef HAVE_CTIME
00170 # include <ctime>
00171 #else
00172 # ifdef HAVE_TIME_H
00173 #  include <time.h>
00174 # else
00175 #  error "don't have header file for time"
00176 # endif
00177 #endif
00178 
00179 
00180 #ifdef HAVE_CMATH
00181 # include <cmath>
00182 #else
00183 # ifdef HAVE_CMATH_H
00184 #  include <cmath.h>
00185 # endif
00186 #endif
00187 
00188 
00189 
00190 #ifdef HAVE_CSTDIO
00191 # include <cstdio>
00192 #else
00193 # ifdef HAVE_STDIO_H
00194 #  include <stdio.h>
00195 # else
00196 #  error "don't have header file for stdio"
00197 # endif
00198 #endif
00199 
00200 //#ifdef HAVE_WINDOWS_H
00201 //#include <windows.h>
00202 //#endif
00203 
00204 using std::cout;   
00205 using std::endl;
00206 using std::ostringstream; 
00207 
00208 
00209 
00210 
00211 int main(int argC, char* argV[])
00212 {
00213 //#ifdef HAVE_WINDOWS_H
00214 //   SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
00215 //#endif 
00216         WindowsErrorPopupBlocker();
00217         double getObjVal(std::string osrl);
00218         //using CppAD::NearEqual;
00219         bool ok;
00220         double check;
00221         
00222         
00223         bool BASIC_TESTS;  // minimal functionality tests
00224         bool SOLVER_TESTS; // at least one problem for each solver
00225         bool THOROUGH;     // multiple problems for some solvers
00226         bool PARSER_TESTS; // test parser logic
00227         bool OTHER_TESTS;  // other input formats, automatic differentiation, etc.
00228         
00229         //set level of testing
00230       
00231         std::string testConfig = "install";
00232         int testLevel = 1;
00233         if( argC > 2){
00234                 std::cout << "Too Many Input Parameters" << std::endl;
00235                 return 1;
00236         }
00237         if(argC == 2){
00238                 testConfig = argV[ 1];
00239                 std::cout << "test configuration = \'" <<  testConfig << "\'"<< std::endl;
00240         }
00241 
00242 
00243         if (testConfig == "install") testLevel = 1;
00244         if (testConfig == "parser" ) testLevel = 2;
00245         if (testConfig == "parsers") testLevel = 2;
00246         if (testConfig == "solver" ) testLevel = 3;
00247         if (testConfig == "solvers") testLevel = 3;
00248         if (testConfig == "release") testLevel = 4;
00249         if (testConfig == "nightlyBuild") testLevel = 4;
00250         if (testConfig == "all") testLevel = 4;
00251         if (testConfig == "NB") testLevel = 4;
00252         if (testConfig == "nb") testLevel = 4;
00253 
00254         switch (testLevel){
00255         case 1:
00256                 BASIC_TESTS  = true;  
00257                 SOLVER_TESTS = true; 
00258                 THOROUGH     = false;     
00259                 PARSER_TESTS = false; 
00260                 OTHER_TESTS  = false;  
00261                 break;
00262         case 2:
00263                 BASIC_TESTS  = false;  
00264                 SOLVER_TESTS = false; 
00265                 THOROUGH     = false;     
00266                 PARSER_TESTS = true; 
00267                 OTHER_TESTS  = false;  
00268                 break;
00269         case 3:
00270                 BASIC_TESTS  = false;  
00271                 SOLVER_TESTS = true; 
00272                 THOROUGH     = true;     
00273                 PARSER_TESTS = false; 
00274                 OTHER_TESTS  = false;  
00275                 break;
00276         case 4:
00277         default:
00278                 BASIC_TESTS  = true;  
00279                 SOLVER_TESTS = true; 
00280                 THOROUGH     = true;     
00281                 PARSER_TESTS = true; 
00282                 OTHER_TESTS  = true;  
00283                 break;
00284         }
00285         
00286         if (BASIC_TESTS) std::cout << "Perform basic tests" << std::endl;
00287         if (SOLVER_TESTS) {
00288                 if (THOROUGH)
00289                         std::cout << "Perform thorough solver tests" << std::endl;
00290                 else
00291                         std::cout << "Perform simple solver tests" << std::endl;
00292         }
00293         if (PARSER_TESTS) std::cout << "Perform parser tests" << std::endl;
00294         if (OTHER_TESTS) std::cout << "Perform other tests" << std::endl;
00295         std::cout << std::endl << std::endl;
00296 
00297         // end level of testing 
00298         
00299         //return 0;
00300         cout << "START UNIT TEST" << endl;
00301         int nOfTest = 0;
00302         // define the classes
00303         FileUtil *fileUtil = NULL;  
00304 #ifdef COIN_HAS_ASL
00305         OSnl2osil *nl2osil = NULL;
00306 #endif 
00307         OSmps2osil *mps2osil = NULL;
00308         DefaultSolver *solver  = NULL;
00309         OSiLReader *osilreader = NULL;
00310         OSoLReader *osolreader = NULL;
00311         OSrLReader *osrlreader = NULL;
00312         OSrLWriter *osrlwriter = NULL;
00313         OSrLWriter *tmp_writer = NULL;
00314         // end classes    
00315         std::string osilFileName;
00316         std::string osolFileName;
00317         std::string osrlFileName;
00318         std::string nlFileName; 
00319         std::string mpsFileName;     
00320         std::string osil;
00321         std::string osol; 
00322         ostringstream unitTestResult;
00323         ostringstream unitTestResultFailure;
00324         // get the input files
00325          const char dirsep =  CoinFindDirSeparator();
00326         // Set directory containing mps data files.
00327         std::string dataDir;
00328     dataDir = dirsep == '/' ? "../data/" : "..\\data\\";
00329         nlFileName =  dataDir  + "amplFiles" + dirsep + "parinc.nl";
00330         mpsFileName =  dataDir + "mpsFiles" + dirsep + "parinc.mps";
00331         fileUtil = new FileUtil();
00332         // 
00333 //      unitTestResult << "HERE ARE THE UNIT TEST RESULTS:" << std::endl << std::endl;
00334 
00335 if(BASIC_TESTS == true){
00336 
00337         //first make sure we can read files
00338         try{
00339                 std::cout << endl << "TEST " << ++nOfTest << ": Try to read a sample file" << endl << endl;
00340                 osilFileName =  dataDir  + "osilFiles" + dirsep +  "parincLinearByRow.osil";
00341                 //osilFileName =  dataDir  + "osilFiles" + dirsep +  "parincLinear.osil";
00342                 std::cout << "The file is: " ;
00343                 std::cout <<  osilFileName << std::endl;
00344                 osil = fileUtil->getFileAsString( osilFileName.c_str() );
00345                 std::cout << "Done reading the test file" << std::endl;
00346                 osilreader = new OSiLReader(); 
00347                 //OSInstance *osinstance = osilreader->readOSiL( osil);
00348                 //osinstance->initForAlgDiff();
00349                 unitTestResult << "Reading files successfully" << std::endl;
00350                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00351                 OSiLWriter osilwriter;
00352                 osilwriter.m_bWhiteSpace = true;
00353                 //std::cout << osilwriter.writeOSiL( osinstance) << std::endl;
00354                 delete osilreader;
00355                 osilreader = NULL;
00356                 //cout << "The unitTest passed the following" << endl << endl;
00357                 //cout << unitTestResult.str() << endl << endl;
00358                 /*
00359                 // below is just a bunch of misc. stuff kipp is testing
00360                 //
00361                 // Create a problem pointer.  We use the base class here.
00362                 OsiSolverInterface *si, *si2;
00363                 // When we instantiate the object, we need a specific derived class.
00364                 si = new OsiCbcSolverInterface;
00365                 // Read in an mps file.  This one's from the MIPLIB library.
00366                 si->readMps( mpsFileName.c_str());
00367                 // get the problem
00368                 // variable upper and lower bounds
00369                  const double *collb = si->getColLower();
00370                  const double *colub = si->getColUpper();               
00371                 // constraint upper and lower bound     
00372                 const  double *rowlb = si->getRowLower();
00373                 const  double *rowub = si->getRowUpper();               
00374                 //the Coin packed matrix
00375                 const CoinPackedMatrix *m_CoinPackedMatrix =  si->getMatrixByCol();             
00376                 //finally the objective function coefficieCnts          
00377                 const double *objcoef = si->getObjCoefficients();
00378                 //delete si;
00379                 si2 = new OsiCbcSolverInterface;
00380                 std::cout << objcoef[ 0] << std::endl;
00381                 // now load the problem
00382                 si2->loadProblem(*m_CoinPackedMatrix, collb, colub,  objcoef, rowlb, rowub);            
00383                 // Solve the (relaxation of the) problem
00384                 //si2->branchAndBound();        
00385                 delete si;
00386                 delete si2;
00387                 */
00388                 
00389                 
00390                 cout << endl << "TEST " << ++nOfTest << ": Lossless I/O" << endl << endl;
00391                 //mpsFileName =  dataDir + "mpsFiles" + dirsep + "testfile2.mps";
00392                 mpsFileName =  dataDir + "mpsFiles" + dirsep + "parinc.mps";
00393                 mps2osil = new OSmps2osil( mpsFileName);
00394                 // create the first in-memory OSInstance
00395                 mps2osil->createOSInstance() ;
00396                 // write the instance to a string
00397                 OSInstance *osinstance1 = mps2osil->osinstance;
00398                 std::string sOSiL = osilwriter.writeOSiL( osinstance1  );
00399 #ifdef DEBUG
00400                 cout << sOSiL << endl;
00401 #endif
00403                 // now create a second object
00404                 osilreader = new OSiLReader();
00405                 OSInstance *osinstance2 = osilreader->readOSiL( sOSiL);
00406                 // now compare the elements in the A matrix for the two intances
00407                 int nvals = osinstance1->instanceData->linearConstraintCoefficients->numberOfValues;
00408                 double theDiff, theMax;
00409                 int theIndex = -1;
00410                 theMax = 0;
00411                 for(int i = 0; i < nvals; i++){
00412                         theDiff = fabs(osinstance1->instanceData->linearConstraintCoefficients->value->el[ i] -
00413                                 osinstance2->instanceData->linearConstraintCoefficients->value->el[ i])/ fabs(osinstance1->instanceData->linearConstraintCoefficients->value->el[ i]);
00414                         if(theDiff > theMax){
00415                                 theMax = theDiff;
00416                                 theIndex = i;
00417                         }
00418                         //std::cout << theDiff << std::endl;
00419                 }
00420                 std::cout << "MAXIMUM DIFF = " << theMax << std::endl;
00421                 if(theMax > 0) 
00422                 {       std::cout << "MAXIMUM DIFF INDEX  = " << theIndex << std::endl;
00423                         unitTestResult << "WARNING:  you do not have lossless IO" << std::endl;
00424                 }
00425                 else 
00426                 {       unitTestResult << "Passed lossless IO test" << std::endl;
00427                         cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00428                 }
00429                 delete mps2osil;
00430                 delete osilreader;
00431                 osilreader = NULL;
00432 
00433 
00434                 //nl2osil = new OSnl2osil( nlFileName);
00435             //return 0; 
00436                 /*
00437                 //using os_dtoa_format
00438                 MathUtil *mathUtil = new MathUtil();
00439             int decimalPoint; // where the decimal point goes
00440             int sign; // 1 if negative, 0 if positive
00441             double d ;
00442             d = -2./3.;
00443             //d = 123.4567;
00444             d = 1.23456589e-2;
00445             d = .00001123;
00446             char *result = os_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
00447             for(int kj = 5; kj < 9; kj++){
00448                 d = pow(10. ,kj) + pow(10., (kj-1));
00449                 //d = 57.7;
00450                 result =os_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
00451                 printf("HERE IS THE RESULT  %s\n\n", result);
00452                 printf("HERE IS THE RESULT of sign  %d\n\n", sign);
00453                 printf("HERE IS THE RESULT decimal point  %i\n\n", decimalPoint);
00454                 printf("HERE IS THE LENGTH OF THE RESULT  %d\n\n",  strlen(result));
00455                 std::cout << "HERE IS THE RESULT OF OS os_dtoa_format: " << os_dtoa_format( d) << std::endl;
00456             }
00457             d = .00001123;
00458             d = -2./3.;
00459             d = 100;
00460             result = os_dtoa(DBL_MAX, 0, 0, &decimalPoint, &sign, NULL);
00461         printf("HERE IS THE RESULT  %s\n\n", result);
00462         printf("HERE IS THE RESULT of sign  %d\n\n", sign);
00463         printf("HERE IS THE RESULT decimal point  %i\n\n", decimalPoint);
00464         printf("HERE IS THE LENGTH OF THE RESULT  %d\n\n",  strlen(result));
00465         std::cout << "HERE IS THE RESULT OF OS os_dtoa_format: " << os_dtoa_format( OSDBL_MAX) << std::endl;    
00466         d = .000234;
00467             result = os_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
00468         printf("HERE IS THE RESULT  %s\n\n", result);
00469         printf("HERE IS THE RESULT of sign  %d\n\n", sign);
00470         printf("HERE IS THE RESULT decimal point  %i\n\n", decimalPoint);
00471         printf("HERE IS THE LENGTH OF THE RESULT  %d\n\n",  strlen(result));
00472         std::cout << "HERE IS THE RESULT OF OS os_dtoa_format: " << os_dtoa_format( d) << std::endl;
00473         //
00474         char sInput[] = "77.77 99.99";
00475         char *pEnd;
00476         double d1, d2;
00477         d1 = os_strtod (sInput,  &pEnd);
00478         d2 = os_strtod (pEnd,NULL);
00479         std::cout << d1 << std::endl;
00480         std::cout << d2 << std::endl;
00481         
00482         std::cout << "HERE IS THE RESULT OF OS os_dtoa_format OSDBL_MAX: " << os_dtoa_format( OSDBL_MAX) << std::endl;
00483         std::cout << "HERE IS THE RESULT OF OS os_dtoa_format OSDBL_MAX: " << OSDBL_MAX << std::endl;
00484         std::cout << "HERE IS THE RESULT OF OS os_dtoa_format DBL_MAX: " << os_dtoa_format( DBL_MAX) << std::endl;
00485         std::cout << "HERE IS THE RESULT OF OS os_dtoa_format DBL_MAX: " <<  DBL_MAX << std::endl;
00486         d1 = os_strtod(os_dtoa_format( OSDBL_MAX).c_str(),     NULL);
00487         if(d1 == DBL_MAX )std::cout <<  "SUCCESS" << endl;
00488         else std::cout <<  "FAILURE" << endl;
00489         */
00490         }
00491         catch(const ErrorClass& eclass){
00492                 unitTestResultFailure << "Sorry Unit Test Failed Reading a file: "  + eclass.errormsg<< endl; 
00493                 //no point continuing we can't even read a file
00494                 unitTestResultFailure << "Since we can't read files we are terminating"  << endl; 
00495                 cout << unitTestResultFailure.str() << endl << endl;
00496                 cout << "Conclusion: FAILURE" << endl;
00497                 return 1;
00498         }       
00499 } // end of if (BASIC_TESTS)
00500 
00501 if (SOLVER_TESTS){
00502         try{
00503                 cout << endl << "TEST " << ++nOfTest << ": Clp solver on parincLinearByRow.osil" << endl << endl;
00504                 ok = true; 
00505                 std::cout << "create a new COIN Clp for OSiL string solution" << std::endl;
00506                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincLinearByRow.osil";
00507                 osolFileName = dataDir  + "osolFiles" + dirsep + "parincLinearByRow_clp.osol";
00508                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00509                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00510 
00511                 std::cout << "create a new Solver object" << std::endl;
00512                 osilreader = new OSiLReader(); 
00513                 osolreader = new OSoLReader(); 
00514                 solver = new CoinSolver();
00515                 solver->sSolverName = "clp";
00516                 solver->osinstance = osilreader->readOSiL( osil);
00517                 std::cout << " Done reading the OSiL" << std::endl;
00518                 // now write it again as a string
00519                 OSiLWriter *osilwriter;
00520                 osilwriter = new OSiLWriter();
00521                 osilwriter->m_bWhiteSpace = true;
00522                 std::cout << " Write the OSiL" << std::endl;
00523                 osil = osilwriter->writeOSiL( solver->osinstance) ;
00524                 //std::cout <<  osil  << std::endl;
00525                 std::cout << " Done writing the OSiL" << std::endl;
00526                 solver->osoption   = osolreader->readOSoL( osol);
00527                 cout << "call the COIN - clp Solver for parincLinearbyRow" << endl;
00528                 //solver->buildSolverInstance();
00529                 solver->solve();
00530                 check = 7668;
00531                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00532                 if (ok)
00533                 {       
00534 #ifdef DEBUG
00535                         cout << solver->osrl << endl;
00536 #endif
00537                         cout << "COIN clp solver solution for parincLinearByRow checks." << endl;               
00538                 }
00539                 else
00540                 {       cout << "COIN clp solver solution for parincLinearByRow in error:" << endl;
00541                         cout << solver->osrl << endl;
00542                 }
00543                 if(ok == false) throw ErrorClass(" Fail unit test with clp on parincLinearByRow.osil");
00544                 // parse the osrl file
00545                 osrlreader =  new OSrLReader();
00546 #ifdef DEBUG
00547                 cout << "First osrl file\n" << solver->osrl << endl;
00548 #endif
00549                 osrlreader->readOSrL( solver->osrl);
00550 #ifdef DEBUG
00551                 cout << "read successfully" << endl;
00552 #endif
00553                 delete osilreader;
00554 #ifdef DEBUG
00555                 cout << "osilreader successfully deleted" << endl;
00556 #endif
00557                 osilreader = NULL;      
00558                 delete osolreader;
00559 #ifdef DEBUG
00560                 cout << "osolreader successfully deleted" << endl;
00561 #endif
00562                 osolreader = NULL;      
00563                 delete solver;
00564 #ifdef DEBUG
00565                 cout << "solver successfully deleted" << endl;
00566 #endif
00567                 solver = NULL;
00568                 delete osilwriter;
00569 #ifdef DEBUG
00570                 cout << "osilwriter successfully deleted" << endl;
00571 #endif
00572                 osilwriter = NULL;
00573                 delete osrlreader;
00574 #ifdef DEBUG
00575                 cout << "osrlreader successfully deleted" << endl;
00576 #endif
00577                 osrlreader = NULL;
00578                 unitTestResult << "Solved problem parincLinearByRow.osil with Clp" << std::endl;
00579                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00580         }
00581         catch(const ErrorClass& eclass){
00582                 unitTestResultFailure << "Sorry Unit Test Failed Testing Clp Solver:"  + eclass.errormsg<< endl;
00583         }
00584 
00585         // now solve another problem -- try an integer program
00586         try{
00587                 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0033.osil" << endl << endl;
00588                 std::cout << "create a new COIN Cbc for OSiL string solution" << std::endl;
00589                 ok = true;
00590                 osilFileName = dataDir  + "osilFiles" + dirsep + "p0033.osil";
00591                 //osolFileName = dataDir  + "osolFiles" + dirsep + "p0033_cbc.osol";
00592                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00593                 //osol = fileUtil->getFileAsString( osolFileName.c_str());
00594                 osol = "";
00595                 osilreader = new OSiLReader(); 
00596                 osolreader = new OSoLReader(); 
00597                 solver = new CoinSolver();
00598                 solver->sSolverName ="cbc";
00599                 solver->osil = osil;
00600                 solver->osol = osol;  
00601                 solver->osinstance = NULL; 
00602                 solver->osoption   = NULL;
00603                 cout << "call the COIN - Cbc Solver for p0033" << endl;
00604                 solver->buildSolverInstance();
00605                 solver->solve();
00606                 check = 3089;
00607                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00608                 if (ok)
00609                 {       
00610 #ifdef DEBUG
00611                         cout << solver->osrl << endl;
00612 #endif
00613                         cout << "Coin cbc solution for p0033 checks" << endl;
00614                 }
00615                 else
00616                 {       cout << "Coin cbc solution for p0033 in error:" << endl;
00617                         cout << solver->osrl << endl;
00618                 }
00619                 if (ok == false) throw ErrorClass(" Fail unit test with Cbc on p0033.osil");
00620                 delete solver;
00621                 solver = NULL;
00622                 delete osilreader;
00623                 osilreader = NULL;
00624                 delete osolreader;
00625                 osolreader = NULL;
00626                 unitTestResult << "Solved problem p0033.osil with Cbc" << std::endl;
00627                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00628         }
00629         catch(const ErrorClass& eclass){
00630                 unitTestResultFailure << "Sorry Unit Test Failed Testing Cbc Solver:"  + eclass.errormsg<< endl;
00631         }
00632 
00633 if( THOROUGH == true){
00634         // now test p0201.osil
00635         try{
00636                 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0033.osil - node limit set" << endl << endl;
00637                 //std::cout << "create a new COIN Cbc for OSiL string solution" << std::endl;
00638                 ok = true;
00639                 osilFileName = dataDir  + "osilFiles" + dirsep + "p0033.osil";
00640                 osolFileName = dataDir  + "osolFiles" + dirsep + "p0033_cbc.osol";
00641                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00642                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00643                 osilreader = new OSiLReader(); 
00644                 osolreader = new OSoLReader(); 
00645                 solver = new CoinSolver();
00646                 solver->sSolverName ="cbc";
00647                 solver->osil = osil;
00648                 solver->osol = osol;  
00649                 solver->osinstance = NULL; 
00650                 solver->osoption   = NULL;
00651                 cout << "call the COIN - Cbc Solver for p0033" << endl;
00652                 solver->buildSolverInstance();
00653                 solver->solve();
00654                 //cout << "Here is the COIN Cbc solver solution for p0033" << endl;
00655                 //cout << solver->osrl << endl;
00656                 if( solver->osrl.find("node limit reached") != std::string::npos)
00657                         ok = true;
00658                 else
00659                         ok = false;
00660                 if (ok == false) throw ErrorClass(" node limit option on p0033.osil not processed properly");
00661                 delete solver;
00662                 solver = NULL;
00663                 delete osilreader;
00664                 osilreader = NULL;
00665                 delete osolreader;
00666                 osolreader = NULL;
00667                 unitTestResult << "Solved problem p0033.osil with Cbc node limit" << std::endl;
00668                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00669         }
00670         catch(const ErrorClass& eclass){
00671                 unitTestResultFailure << "Sorry Unit Test Failed Testing Cbc Solver:"  + eclass.errormsg<< endl;
00672         }
00673 
00674 
00675         try{
00676                 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0201.osil" << endl << endl;
00677                 ok = true;
00678                 osilFileName = dataDir  + "osilFiles" + dirsep + "p0201.osil";
00679                 osolFileName = dataDir  + "osolFiles" + dirsep + "p0201_cbc.osol";
00680                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00681                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00682                 solver = new CoinSolver();
00683                 solver->sSolverName ="cbc";
00684                 solver->osil = osil;
00685                 osilreader = new OSiLReader(); 
00686                 osolreader = new OSoLReader(); 
00687                 solver->osol = osol;  
00688                 solver->osinstance = NULL; 
00689                 solver->osoption   = NULL;
00690                 cout << "call the COIN - Cbc Solver for p0201" << endl;
00691                 solver->solve();
00692                 cout << "Here is the COIN Cbc solver solution for p0201" << endl;
00693                 std::cout << solver->osrl << std::endl;
00694                 check = 7615;
00695                 // we put a node limit in, so we should not find 7615
00696                 // check that the node limit was found
00697                 string::size_type pos;
00698                 pos = solver->osrl.find( "node limit");
00699                 if(pos == std::string::npos)  throw ErrorClass(" Error with p0201 on Cbc");
00700                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
00701                 //ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00702                 //if(ok == false) throw ErrorClass(" Fail unit test with Cbc on p0201.osil");
00703                 delete solver;
00704                 solver = NULL;
00705                 delete osilreader;
00706                 osilreader = NULL;
00707                 delete osolreader;
00708                 osolreader = NULL;
00709                 unitTestResult << "Solved problem p0201.osil with Cbc" << std::endl;
00710                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00711         }
00712         catch(const ErrorClass& eclass){
00713                 unitTestResultFailure << "Sorry Unit Test Failed Testing Cbc Solver:"  + eclass.errormsg<< endl;
00714         }
00715 
00716                 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on parincInteger.osil" << endl << endl;
00717                 ok = true;
00718                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincInteger.osil";
00719                 osolFileName = dataDir  + "osolFiles" + dirsep + "parincInteger_cbc.osol";
00720                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00721                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00722                 osilreader = new OSiLReader(); 
00723                 osolreader = new OSoLReader(); 
00724 
00725                 solver = new CoinSolver();
00726                 solver->sSolverName ="cbc";
00727                 solver->osinstance = osilreader->readOSiL( osil);
00728                 solver->osol = osol; 
00729                 cout << "call the COIN - Cbc Solver for parincInteger" << endl;
00730 //              solver->buildSolverInstance();
00731                 solver->solve();
00732                 check = 7668;
00733                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00734                 if (ok)
00735                 {       
00736 #ifdef DEBUG
00737                         cout << solver->osrl << endl;
00738 #endif
00739                         cout << "COIN cbc solver solution for parincInteger checks." << endl;
00740                 }
00741                 else
00742                 {       cout << "COIN cbc solver solution for parincInteger in error:" << endl;
00743                         cout << solver->osrl << endl;
00744                 }
00745                 if(ok == false) throw ErrorClass(" Fail unit test with Cbc on parincInteger.osil");
00746                 unitTestResult << "Solved problem parincInteger.osil with Cbc" << std::endl;
00747                 delete osilreader;
00748                 osilreader = NULL;      
00749                 delete osolreader;
00750                 osolreader = NULL;      
00751                 delete solver;
00752                 solver = NULL;
00753                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00754 }       // end of if(THOROUGH)
00755 
00756 #ifdef COIN_HAS_SYMPHONY
00757         try{
00758                 cout << endl << "TEST " << ++nOfTest << ": SYMPHONY solver on p0033.osil" << endl << endl;
00759                 ok = true; 
00760                 osilFileName = dataDir  + "osilFiles" + dirsep + "p0033.osil";
00761                 osolFileName = dataDir  + "osolFiles" + dirsep + "p0033_sym.osol";
00762                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00763                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00764                 osolreader = new OSoLReader(); 
00765                 solver = new CoinSolver();
00766                 solver->sSolverName = "symphony";
00767                 solver->osil = osil;
00768                 solver->osinstance = NULL; 
00769                 solver->osoption   = osolreader->readOSoL( osol);
00770                 cout << "build the solver instance for COIN - SYMPHONY" << endl;
00771                 solver->buildSolverInstance();
00772 //              cout << "call the COIN - SYMPHONY Solver for p0033" << endl;
00773                 solver->solve();
00774                 check = 3089;
00775                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
00776                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00777                 if (ok)
00778                 {       
00779 #ifdef DEBUG
00780                         cout << solver->osrl << endl;
00781 #endif
00782                         cout << "COIN SYMPHONY solver solution for p0033 checks." << endl;
00783                 }
00784                 else
00785                 {       cout << "COIN SYMPHONY solver solution for p0033 in error:" << endl;
00786                         cout << solver->osrl << endl;
00787                 }
00788                 if(ok == false) throw ErrorClass(" Fail unit test with SYMPHONY on p0033.osil");
00789                 delete solver;
00790                 solver = NULL;
00791                 delete osolreader;
00792                 osolreader = NULL;      
00793                 unitTestResult << "Solved problem p0033.osil with SYMPHONY" << std::endl;
00794                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00795         }
00796         catch(const ErrorClass& eclass){
00797                 unitTestResultFailure  << "Sorry Unit Test Failed Testing the SYMPHONY Solver:"  + eclass.errormsg << endl;
00798         }       
00799 #endif
00800         
00801 
00802 
00803 #ifdef COIN_HAS_DYLP
00804         try{
00805                 cout << endl << "TEST " << ++nOfTest << ": DyLP solver on parincLinear.osil" << endl << endl;
00806                 ok = true; 
00807                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincLinear.osil";
00808                 osolFileName = dataDir  + "osolFiles" + dirsep + "parincLinear_dylp.osol";
00809                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00810                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00811                 osilreader = new OSiLReader(); 
00812                 solver = new CoinSolver();
00813                 solver->sSolverName = "dylp";
00814                 solver->osol = osol;   
00815                 solver->osinstance = osilreader->readOSiL( osil);
00816                 cout << "call the COIN - DyLP solver for parincLinear" << endl;
00817                 solver->buildSolverInstance();
00818                 solver->solve();
00819                 check = 7668;
00820                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-1 , 1e-1);
00821                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00822                 if (ok)
00823                 {       
00824 #ifdef DEBUG
00825                         cout << solver->osrl << endl;
00826 #endif
00827                         cout << "COIN DyLP solver solution for parincLinear checks." << endl;
00828                 }
00829                 else
00830                 {       cout << "COIN DyLP solver solution for parincLinear in error:" << endl;
00831                         cout << solver->osrl << endl;
00832                 }
00833                 if(ok == false) throw ErrorClass(" Fail unit test with DyLP on parincLinear.osil");
00834                 delete solver;
00835                 solver = NULL;
00836                 delete osilreader;
00837                 osilreader = NULL;      
00838                 unitTestResult << "Solved problem parincLinear.osil with DyLP" << std::endl;
00839                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00840         }
00841         catch(const ErrorClass& eclass){
00842                 cout << "OSrL =  " <<  solver->osrl <<  endl;
00843                 cout << endl << endl << endl;
00844                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing the DyLP Solver:"  + eclass.errormsg << endl;
00845         }       
00846 #endif
00847         
00848 
00849 #ifdef COIN_HAS_VOL
00850         try{
00851                 cout << endl << "TEST " << ++nOfTest << ": Vol solver on volumeTest.osil" << endl << endl;
00852                 ok = true; 
00853                 osilFileName = dataDir  + "osilFiles" + dirsep + "volumeTest.osil";
00854                 osolFileName = dataDir  + "osolFiles" + dirsep + "volumeTest_vol.osol";
00855                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00856                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00857                 osolreader = new OSoLReader(); 
00858                 solver = new CoinSolver();
00859                 solver->sSolverName = "vol";
00860                 solver->osil = osil;
00861                 solver->osinstance = NULL; 
00862                 solver->osoption = osolreader->readOSoL( osol);
00863                 cout << "call the COIN - Vol solver for volumeTest" << endl;
00864                 solver->buildSolverInstance();
00865                 solver->solve();
00866                 check = 7;
00867                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-1 , 1e-1);
00868                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00869                 if (ok)
00870                 {       
00871 #ifdef DEBUG
00872                         cout << solver->osrl << endl;
00873 #endif
00874                         cout << "COIN Vol solver solution for parincLinear checks." << endl;
00875                 }
00876                 else
00877                 {       cout << "COIN Vol solver solution for parincLinear in error:" << endl;
00878                         cout << solver->osrl << endl;
00879                 }
00880                 if(ok == false) throw ErrorClass(" Fail unit test with Vol on volumeTest.osil");
00881                 delete solver;
00882                 solver = NULL;
00883                 delete osolreader;
00884                 osolreader = NULL;      
00885                 unitTestResult << "Solved problem volumeTest.osil with Vol" << std::endl;
00886                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00887         }
00888         catch(const ErrorClass& eclass){
00889                 cout << "OSrL =  " <<  solver->osrl <<  endl;
00890                 cout << endl << endl << endl;
00891                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing the Vol Solver:"  + eclass.errormsg << endl;
00892         }       
00893 #endif
00894         
00895 #ifdef COIN_HAS_GLPK
00896         try{
00897                 cout << endl << "TEST " << ++nOfTest << ": GLPK solver on p0033.osil" << endl << endl;
00898                 ok = true; 
00899                 osilFileName = dataDir  + "osilFiles" + dirsep + "p0033.osil";
00900                 osolFileName = dataDir  + "osolFiles" + dirsep + "p0033_glpk.osol";
00901                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00902                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00903                 osilreader = new OSiLReader(); 
00904                 osolreader = new OSoLReader(); 
00905                 solver = new CoinSolver();
00906                 solver->sSolverName = "glpk";
00907                 solver->osinstance = osilreader->readOSiL( osil);
00908                 solver->osoption   = osolreader->readOSoL( osol);
00909                 cout << "call the GLPK Solver for p0033" << endl;
00910                 solver->buildSolverInstance();
00911                 solver->solve();
00912                 check = 3089;
00913                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
00914                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00915                 if (ok)
00916                 {       
00917 #ifdef DEBUG
00918                         cout << solver->osrl << endl;
00919 #endif
00920                         cout << "GLPK solver solution for p0033 checks." << endl;
00921                 }
00922                 else
00923                 {       cout << "GLPK solver solution for p0033 in error:" << endl;
00924                         cout << solver->osrl << endl;
00925                 }
00926                 if(ok == false) throw ErrorClass(" Fail unit test with GLPK on p0033.osil");
00927                 delete solver;
00928                 solver = NULL;
00929                 delete osilreader;
00930                 osilreader = NULL;      
00931                 delete osolreader;
00932                 osolreader = NULL;      
00933                 unitTestResult << "Solved problem p0033.osil with GLPK" << std::endl;
00934                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00935         }
00936         catch(const ErrorClass& eclass){
00937                 cout << "OSrL =  " <<  solver->osrl <<  endl;
00938                 cout << endl << endl << endl;
00939                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing the Glpk Solver:"  + eclass.errormsg << endl;
00940         }       
00941 #endif
00942         
00943 
00944 
00945 #ifdef COIN_HAS_CPX
00946         try{
00947                 cout << endl << "TEST " << ++nOfTest << ": Cplex solver on p0033.osil" << endl << endl;
00948                 ok = true; 
00949                 osilFileName = dataDir  + "osilFiles" + dirsep + "p0033.osil";
00950                 osolFileName = dataDir  + "osolFiles" + dirsep + "p0033_cpx.osol";
00951                 osil = fileUtil->getFileAsString( osilFileName.c_str());
00952                 osol = fileUtil->getFileAsString( osolFileName.c_str());
00953                 solver = new CoinSolver();
00954                 solver->sSolverName = "cplex";
00955                 solver->osil = osil;
00956                 solver->osol = osol;  
00957                 solver->osinstance = NULL; 
00958                 cout << "call the CPLEX Solver for p0033" << endl;
00959                 solver->buildSolverInstance();
00960                 solver->solve();
00961                 check = 3089;
00962                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
00963                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
00964                 if (ok)
00965                 {       
00966 #ifdef DEBUG
00967                         cout << solver->osrl << endl;
00968 #endif
00969                         cout << "CPLEX solver solution for p0033 checks." << endl;
00970                 }
00971                 else
00972                 {       cout << "CPLEX solver solution for p0033 in error:" << endl;
00973                         cout << solver->osrl << endl;
00974                 }
00975                 if(ok == false) throw ErrorClass(" Fail unit test with CPLEX on p0033.osil");
00976                 delete solver;
00977                 solver = NULL;
00978                 unitTestResult << "Solved problem p0033.osil with CPLEX" << std::endl;
00979                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
00980         }
00981         catch(const ErrorClass& eclass){
00982                 cout << "OSrL =  " <<  solver->osrl <<  endl;
00983                 cout << endl << endl << endl;
00984                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing the Cplex Solver:"  + eclass.errormsg << endl;
00985         }       
00986 #endif
00987         
00988 
00989 
00990 #ifdef COIN_HAS_IPOPT
00991         IpoptSolver *ipoptSolver  =  NULL;      
00992         try{
00993                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver with avion2.osil" << endl << endl;
00994             ipoptSolver  = new IpoptSolver();
00995                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
00996                 ok = true;
00997 //              OSiLReader *osilreader = NULL;
00998 //              OSoLReader *osolreader = NULL;
00999                 // avion does not work with Mumps on AIX xlC compiler
01000 #ifndef XLC_
01001                 osilFileName =  dataDir  + "osilFiles" + dirsep +  "avion2.osil";
01002                 osolFileName = dataDir  + "osolFiles" + dirsep + "avion2_ipopt.osol";
01003                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01004                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01005                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01006                 ipoptSolver->osol = osol;
01007                 osilreader = new OSiLReader(); 
01008                 osolreader = new OSoLReader(); 
01009                 ipoptSolver->osinstance = osilreader->readOSiL( osil);
01010                 ipoptSolver->osol = osol;
01011                 cout << "call the IPOPT Solver" << endl;        
01012                 ipoptSolver->buildSolverInstance();
01013                 ipoptSolver->solve();
01014                 check = 9.46801e+07;
01015                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-10 , 1e-10);
01016                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01017                 if (ok)
01018                 {       
01019 #ifdef DEBUG
01020                         cout << ipoptSolver->osrl << endl;
01021 #endif
01022                         cout << "IPOPT solver solution for avion2 checks." << endl;
01023                 }
01024                 else
01025                 {       cout << "IPOPT solver solution for avion2 in error:" << endl;
01026                         cout << ipoptSolver->osrl << endl;
01027                 }
01028                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on avion2.osil");
01029                 delete osilreader;
01030                 osilreader = NULL;
01031                 delete osolreader;
01032                 osolreader = NULL;
01033                 delete ipoptSolver;
01034                 ipoptSolver = NULL;
01035                 unitTestResult << "Solved problem avion2.osil with Ipopt" << std::endl;
01036                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01037 #endif
01038 
01039 if(THOROUGH == true){
01040                 // solve another problem
01041                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver with HS071_NLPMod.osil" << endl << endl;
01042                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
01043                 ipoptSolver  = new IpoptSolver();
01044                 // a problem with all nonlinear terms no linear terms
01045                 osilFileName = dataDir  + "osilFiles" + dirsep + "HS071_NLPMod.osil";
01046                 osolFileName = dataDir  + "osolFiles" + dirsep + "HS071_NLPMod_ipopt.osol";
01047                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01048                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01049                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01050 //              osol = "<osol></osol>";
01051                 osilreader = new OSiLReader(); 
01052                 osolreader = new OSoLReader(); 
01053                 ipoptSolver->osinstance = osilreader->readOSiL( osil);
01054                 ipoptSolver->osoption   = osolreader->readOSoL( osol);
01055                 ipoptSolver->osol = osol;
01056                 ipoptSolver->buildSolverInstance();
01057                 ipoptSolver->solve();
01058                 cout << "Here is the IPOPT solver solution for HS071_NLP" << endl;
01059                 check = 17.014;
01060                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-10 , 1e-10);
01061                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01062                 if (ok)
01063                 {       
01064 #ifdef DEBUG
01065                         cout << ipoptSolver->osrl << endl;
01066 #endif
01067                         cout << "IPOPT solver solution for HS071_NLP checks." << endl;
01068                 }
01069                 else
01070                 {       cout << "IPOPT solver solution for HS071_NLP in error:" << endl;
01071                         cout << ipoptSolver->osrl << endl;
01072                 }
01073                 delete osilreader;
01074                 osilreader = NULL;
01075                 delete osolreader;
01076                 osolreader = NULL;
01077                 delete ipoptSolver;
01078                 ipoptSolver = NULL;
01079                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on HS071_NLP.osil");
01080                 unitTestResult << "Solved problem HS071.osil with Ipopt" << std::endl;
01081                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01082 
01083                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on rosenbrockmod.osil" << endl << endl;
01084                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
01085                 ipoptSolver  = new IpoptSolver();
01086                 // solve another problem
01087                 // a problem with both quadratic terms and general nonlinear terms
01088                 osilFileName = dataDir  + "osilFiles" + dirsep + "rosenbrockmod.osil";
01089                 osolFileName = dataDir  + "osolFiles" + dirsep + "rosenbrockmod_ipopt.osol";
01090                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01091                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01092                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01093                 osilreader = new OSiLReader(); 
01094                 osolreader = new OSoLReader(); 
01095                 ipoptSolver->osil     = osil;
01096                 ipoptSolver->osoption = osolreader->readOSoL( osol);
01097                 cout << "call the IPOPT Solver" << endl;
01098                 ipoptSolver->buildSolverInstance();
01099                 ipoptSolver->solve();
01100                 check = 6.7279;
01101                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-10 , 1e-10);
01102                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01103                 if (ok)
01104                 {       
01105 #ifdef DEBUG
01106                         cout << ipoptSolver->osrl << endl;
01107 #endif
01108                         cout << "Ipopt solver solution for rosenbrockmod checks." << endl;
01109                 }
01110                 else
01111                 {       cout << "Ipopt solver solution for rosenbrockmod in error:" << endl;
01112                         cout << ipoptSolver->osrl << endl;
01113                 }
01114                 if(ok == false) 
01115                         throw ErrorClass(" Fail unit test with Ipopt on rosenbrockmod.osil");
01116                 delete osilreader;
01117                 osilreader = NULL;
01118                 delete osolreader;
01119                 osolreader = NULL;
01120                 unitTestResult << "Solved problem rosenbrockmod.osil with Ipopt" << std::endl;
01121                 delete ipoptSolver;
01122                 ipoptSolver = NULL;
01123                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01124                 //return 0;
01125 
01126                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincQuadratic.osil" << endl << endl;
01127                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
01128                 ipoptSolver  = new IpoptSolver();
01129                 // solve another problem
01130                 // a problem that is a pure quadratic
01131                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincQuadratic.osil";
01132                 osolFileName = dataDir  + "osolFiles" + dirsep + "parincQuadratic_ipopt.osol";
01133                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01134                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01135                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01136                 osilreader = new OSiLReader(); 
01137                 osolreader = new OSoLReader(); 
01138                 ipoptSolver->osinstance = osilreader->readOSiL( osil);
01139                 ipoptSolver->osil = osil;
01140                 ipoptSolver->osol = osol;
01141                 cout << "call the IPOPT Solver" << endl;
01142                 ipoptSolver->buildSolverInstance();
01143                 ipoptSolver->solve();
01144                 check = 49920.5;
01145                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-10 , 1e-10);
01146                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01147                 if (ok)
01148                 {       
01149 #ifdef DEBUG
01150                         cout << ipoptSolver->osrl << endl;
01151 #endif
01152                         cout << "IPOPT solver solution for parincQuadratic checks." << endl;
01153                 }
01154                 else
01155                 {       cout << "IPOPT solver solution for parincQuadratic in error:" << endl;
01156                         cout << ipoptSolver->osrl << endl;
01157                 }
01158                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincQuadradic.osil");
01159                 delete osilreader;
01160                 osilreader = NULL;      
01161                 delete osolreader;
01162                 osolreader = NULL;      
01163                 unitTestResult << "Solved problem parincQuadratic.osil with Ipopt" << std::endl;
01164                 delete ipoptSolver;
01165                 ipoptSolver = NULL;
01166                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01167 
01168                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincLinear.osil" << endl << endl;
01169                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
01170                 ipoptSolver  = new IpoptSolver();
01171                 // solve another problem
01172                 // try a pure linear program
01173                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincLinear.osil";
01174                 osolFileName = dataDir  + "osolFiles" + dirsep + "parincLinear_ipopt.osol";
01175                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01176                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01177                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01178                 osilreader = new OSiLReader(); 
01179                 osolreader = new OSoLReader(); 
01180                 ipoptSolver->osinstance = osilreader->readOSiL( osil);
01181                 ipoptSolver->osoption   = NULL;
01182                 ipoptSolver->osol = ""; 
01183                 cout << "call the IPOPT Solver" << endl;
01184                 ipoptSolver->buildSolverInstance();
01185                 ipoptSolver->solve();
01186                 check = 7668;
01187                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-1 , 1e-1);
01188                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01189                 if (ok)
01190                 {       
01191 #ifdef DEBUG
01192                         cout << ipoptSolver->osrl << endl;
01193 #endif
01194                         cout << "IPOPT solver solution for parincLinear checks." << endl;
01195                 }
01196                 else
01197                 {       cout << "IPOPT solver solution for parincLinear in error:" << endl;
01198                         cout << ipoptSolver->osrl << endl;
01199                 }
01200                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincLinear.osil");
01201                 unitTestResult << "Solved problem parincLinear.osil with Ipopt" << std::endl;
01202                 delete osilreader;
01203                 osilreader = NULL;      
01204                 delete osolreader;
01205                 osolreader = NULL;      
01206                 delete ipoptSolver;
01207                 ipoptSolver = NULL;
01208                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01209 
01210                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on callBackTest.osil" << endl << endl;
01211                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
01212                 ipoptSolver  = new IpoptSolver();
01213                 // solve another problem
01214                 // callBackTest.osil
01215                 osilFileName = dataDir  + "osilFiles" + dirsep + "callBackTest.osil";
01216                 osolFileName = dataDir  + "osolFiles" + dirsep + "callBackTest_ipopt.osol";
01217                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01218                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01219                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01220                 osilreader = new OSiLReader(); 
01221                 osolreader = new OSoLReader(); 
01222                 ipoptSolver->osinstance = osilreader->readOSiL( osil);
01223                 ipoptSolver->osoption   = osolreader->readOSoL( osol);
01224                 ipoptSolver->osol = osol;
01225                 cout << "call the IPOPT Solver" << endl;
01226                 ipoptSolver->buildSolverInstance();
01227                 ipoptSolver->solve();
01228                 check = 1.00045e+06;
01229                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-10 , 1e-10);
01230                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01231                 if (ok)
01232                 {       
01233 #ifdef DEBUG
01234                         cout << ipoptSolver->osrl << endl;
01235 #endif
01236                         cout << "IPOPT solver solution for callBackTest checks." << endl;
01237                 }
01238                 else
01239                 {       cout << "IPOPT solver solution for callBackTest in error:" << endl;
01240                         cout << ipoptSolver->osrl << endl;
01241                 }
01242                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on callBackTest.osil");
01243                 unitTestResult << "Solved problem callBackTest.osil with Ipopt" << std::endl;   
01244                 delete osilreader;
01245                 osilreader = NULL;      
01246                 delete osolreader;
01247                 osolreader = NULL;      
01248                 delete ipoptSolver;
01249                 ipoptSolver = NULL;
01250                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01251 
01252                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on callBackTestRowMajor.osil" << endl << endl;
01253                 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
01254                 ipoptSolver  = new IpoptSolver();
01255                 // solve another problem
01256                 // callBackTest.osil
01257                 osilFileName =  dataDir  + "osilFiles" + dirsep + "callBackTestRowMajor.osil";
01258                 osolFileName = dataDir  + "osolFiles" + dirsep + "callBackTestRowMajor_ipopt.osol";
01259                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01260                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01261                 cout << "IPOPT Solver created for OSiL string solution" << endl;
01262                 osilreader = new OSiLReader(); 
01263                 osolreader = new OSoLReader(); 
01264                 ipoptSolver->osinstance = NULL;
01265                 ipoptSolver->osoption   = NULL;
01266                 ipoptSolver->osil = osil;
01267                 ipoptSolver->osol = osol;
01268                 cout << "call the IPOPT Solver" << endl;
01269 //              ipoptSolver->buildSolverInstance();
01270                 ipoptSolver->solve();
01271                 check = 1.00045e+06;
01272                 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check,  1e-10 , 1e-10);
01273                 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01274                 if (ok)
01275                 {       
01276 #ifdef DEBUG
01277                         cout << ipoptSolver->osrl << endl;
01278 #endif
01279                         cout << "IPOPT solver solution for callBackTestRowMajor checks." << endl;
01280                 }
01281                 else
01282                 {       cout << "IPOPT solver solution for callBackTestRowMajor in error:" << endl;
01283                         cout << ipoptSolver->osrl << endl;
01284                 }
01285                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on callBackTestRowMajor.osil");
01286                 delete osilreader;
01287                 osilreader = NULL;      
01288                 delete osolreader;
01289                 osolreader = NULL;      
01290                 delete ipoptSolver;
01291                 ipoptSolver = NULL;     
01292                 unitTestResult << "Solved problem callBackRowMajor.osil with Ipopt" << std::endl;
01293                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01294                 //this is integer, skip it
01295                 /*
01296                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on nonconvex.osil" << endl << endl;
01297 //              OSiLReader *osilreader = NULL;
01298                 osilreader = new OSiLReader(); 
01299                 osolreader = new OSoLReader(); 
01300                 ok = true; 
01301                 osilFileName = dataDir  + "osilFiles" + dirsep + "nonconvex.osil";
01302 //              osolFileName = dataDir  + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
01303                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01304 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01305                 osol = "";
01306                 solver = new IpoptSolver();
01307                 solver->sSolverName = "ipopt";
01308                 solver->osil = osil;
01309                 solver->osol = osol; 
01310 //              solver->osinstance = osilreader->readOSiL( osil);
01311 //              solver->osoption   = osolreader->readOSoL( osol);
01312                 cout << "call the COIN - Ipopt Solver for nonconvex.osil" << endl;
01313                 solver->buildSolverInstance();
01314         
01315                 std::cout << " CALL SOLVE " << std::endl;
01316                 solver->solve();
01317         
01318                 cout << "Here is the Ipopt solver solution for nonconvex.osil" << endl;
01319 
01320 //              OSrLWriter *tmp_writer;
01321                 tmp_writer = new OSrLWriter();
01322                 solver->osrl = tmp_writer->writeOSrL(solver->osresult);
01323                 delete tmp_writer;
01324                 tmp_writer = NULL;
01325 
01326                 cout << solver->osrl << endl << endl;
01327 
01328 //              check = -1.70711;
01329 //              //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01330 //              ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01331 //              if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on nonconvex.osil");
01332         
01333                 delete solver;
01334                 solver = NULL;
01335                 unitTestResult << "Solved problem nonconvex.osil with Ipopt" << std::endl;
01336         
01337         
01338                 delete osilreader;
01339                 osilreader = NULL;
01340                 delete osolreader;
01341                 osolreader = NULL;
01342                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01343                 */
01344                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on rosenbrockorig.osil" << endl << endl;
01345 //              OSiLReader *osilreader = NULL;
01346                 osilreader = new OSiLReader(); 
01347                 osolreader = new OSoLReader(); 
01348                 ok = true; 
01349                 osilFileName = dataDir  + "osilFiles" + dirsep + "rosenbrockorig.osil";
01350 //              osolFileName = dataDir  + "osolFiles" + dirsep + "rosenbrockorig_Ipopt.osol";
01351                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01352 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01353                 osol = "";
01354                 solver = new IpoptSolver();
01355                 solver->sSolverName = "ipopt";
01356                 solver->osil = osil;
01357                 solver->osol = osol; 
01358 //              solver->osinstance = osilreader->readOSiL( osil);
01359 //              solver->osoption   = osolreader->readOSoL( osol);
01360                 cout << "call the COIN - Ipopt Solver for rosenbrockorig" << endl;
01361                 solver->buildSolverInstance();
01362         
01363                 std::cout << " CALL SOLVE " << std::endl;
01364                 solver->solve();
01365                 check = 0;
01366                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01367                 if (ok)
01368                 {       
01369 #ifdef DEBUG
01370                         cout << solver->osrl << endl;
01371 #endif
01372                         cout << "Ipopt solver solution for rosenbrockorig checks." << endl;
01373                 }
01374                 else
01375                 {       cout << "Ipopt solver solution for rosenbrockorig in error:" << endl;
01376                         cout << solver->osrl << endl;
01377                 }
01378                 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on rosenbrockorig.osil");
01379 
01380                 delete solver;
01381                 solver = NULL;
01382                 unitTestResult << "Solved problem rosenbrockorig.osil with Ipopt" << std::endl;
01383         
01384         
01385                 delete osilreader;
01386                 osilreader = NULL;
01387                 delete osolreader;
01388                 osolreader = NULL;
01389                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01390 
01391                 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on HS071_feas.osil" << endl << endl;
01392                 try {
01393                         osilreader = new OSiLReader(); 
01394                         osolreader = new OSoLReader(); 
01395                         ok = true; 
01396                         osilFileName = dataDir  + "osilFiles" + dirsep + "HS071_feas.osil";
01397 //                      osolFileName = dataDir  + "osolFiles" + dirsep + "HS071_feas_Ipopt.osol";
01398                         osil = fileUtil->getFileAsString( osilFileName.c_str());
01399 //                      osol = fileUtil->getFileAsString( osolFileName.c_str());
01400                         osol = "";
01401                         solver = new IpoptSolver();
01402                         solver->sSolverName = "ipopt";
01403                         solver->osil = osil;
01404                         solver->osol = osol; 
01405 //                      solver->osinstance = osilreader->readOSiL( osil);
01406 //                      solver->osoption   = osolreader->readOSoL( osol);
01407                         solver->buildSolverInstance();
01408         
01409                         cout << "call the COIN - Ipopt Solver for HS071_feas.osil" << endl;
01410                         solver->solve();
01411                 }
01412                 catch(const ErrorClass& eclass)
01413                 {
01414                         ok = (solver->osresult->getGeneralMessage() == "Ipopt NEEDS AN OBJECTIVE FUNCTION");
01415                         if(ok == false) 
01416                         {       cout << "Ipopt solver returns:" << endl;
01417                                 cout << solver->osrl << endl;
01418                                 throw ErrorClass(" Fail unit test with Ipopt on HS071_feas.osil");
01419                         }
01420                 }
01421         
01422                 cout << "Received error message from Ipopt: \"Ipopt NEEDS AN OBJECTIVE FUNCTION\"" << endl;
01423                 unitTestResult << "Correctly diagnosed problem HS071_feas with Ipopt" << std::endl;
01424         
01425                 delete solver;
01426                 solver = NULL;
01427                 delete osilreader;
01428                 osilreader = NULL;
01429                 delete osolreader;
01430                 osolreader = NULL;
01431 
01432                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01433 
01434 } // end of if( THOROUGH)
01435         }
01436         catch(const ErrorClass& eclass){
01437                 unitTestResultFailure << "Sorry Unit Test Failed Testing the Ipopt Solver:"  + eclass.errormsg<< endl; 
01438         }
01439 #endif // end of #ifdef COIN_HAS_IPOPT
01440 
01441 
01442 #ifdef COIN_HAS_BONMIN
01443         try{
01444                 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on bonminEx1.osil" << endl << endl;
01445 //              OSiLReader *osilreader = NULL;
01446                 osilreader = new OSiLReader(); 
01447                 osolreader = new OSoLReader(); 
01448                 ok = true; 
01449                 osilFileName = dataDir  + "osilFiles" + dirsep + "bonminEx1.osil";
01450                 osolFileName = dataDir  + "osolFiles" + dirsep + "bonminEx1_Bonmin.osol";
01451                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01452                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01453                 solver = new BonminSolver();
01454                 //solver->sSolverName = "bonmin";
01455 //              solver->osinstance = osilreader->readOSiL( osil);
01456                 solver->osil = osil;
01457                 solver->osoption = osolreader->readOSoL( osol);
01458                 cout << "call the COIN - Bonmin Solver for bonminEx1" << endl;
01459 //              solver->buildSolverInstance();
01460                 solver->solve();
01461                 check = -17.07106795327683;
01462                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01463                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01464                 if (ok)
01465                 {       
01466 #ifdef DEBUG
01467                         cout << solver->osrl << endl;
01468 #endif
01469                         cout << "Bonmin solver solution for bonminEx1 checks." << endl;
01470                 }
01471                 else
01472                 {       cout << "Bonmin solver solution for bonminEx1 in error:" << endl;
01473                         cout << solver->osrl << endl;
01474                 }
01475                 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on bonminEx1.osil");
01476                 delete solver;
01477                 solver = NULL;
01478                 unitTestResult << "Solved problem bonminEx1.osil with Bonmin" << std::endl;
01479                 delete osilreader;
01480                 osilreader = NULL;
01481                 delete osolreader;
01482                 osolreader = NULL;
01483                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01484 
01485 if (THOROUGH == true){
01486                 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on wayneQuadratic.osil" << endl << endl;
01487                 ok = true;
01488                 osilFileName = dataDir  + "osilFiles" + dirsep + "wayneQuadratic.osil";
01489                 osolFileName = dataDir  + "osolFiles" + dirsep + "wayneQuadratic_Bonmin1.osol";
01490                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01491                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01492                 osilreader = new OSiLReader(); 
01493                 solver = new BonminSolver();    
01494                 solver->osol = osol;
01495                 solver->osinstance = osilreader->readOSiL( osil);
01496                 cout << "call the Bonmin Solver for wayneQuadratic" << endl;
01497                 solver->buildSolverInstance();
01498                 // Do this one with two different osol files!!!
01499                 solver->solve();
01500                 check = 2.925;
01501                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01502                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01503                 if (ok)
01504                 {       
01505 #ifdef DEBUG
01506                         cout << solver->osrl << endl;
01507 #endif
01508                         cout << "Bonmin solver solution for wayneQuadratic checks." << endl;
01509                 }
01510                 else
01511                 {       cout << "Bonmin solver solution for wayneQuadratic in error:" << endl;
01512                         cout << solver->osrl << endl;
01513                 }
01514                 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on wayneQuadratic.osil");
01515                 delete solver;
01516                 solver = NULL;
01517                 delete osilreader;
01518                 osilreader = NULL;
01519                 unitTestResult << "Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
01520                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01521 
01522                 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on wayneQuadratic.osil" << endl << endl;
01523                 ok = true;
01524                 osilFileName = dataDir  + "osilFiles" + dirsep + "wayneQuadratic.osil";
01525                 osolFileName = dataDir  + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
01526                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01527                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01528                 osilreader = new OSiLReader(); 
01529                 osolreader = new OSoLReader(); 
01530                 solver = new BonminSolver();    
01531                 solver->osol = osol;
01532                 solver->osinstance = osilreader->readOSiL( osil);
01533                 solver->osoption   = osolreader->readOSoL( osol);
01534                 cout << "call the Bonmin Solver for wayneQuadratic" << endl;
01535                 solver->buildSolverInstance();
01536                 // Do this one with two different osol files!!!
01537                 solver->solve();
01538                 check = 2.925;
01539                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01540                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01541                 if (ok)
01542                 {       
01543 #ifdef DEBUG
01544                         cout << solver->osrl << endl;
01545 #endif
01546                         cout << "Bonmin solver solution for wayneQuadratic checks." << endl;
01547                 }
01548                 else
01549                 {       cout << "Bonmin solver solution for wayneQuadratic in error:" << endl;
01550                         cout << solver->osrl << endl;
01551                 }
01552                 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on wayneQuadratic.osil");
01553                 delete solver;
01554                 solver = NULL;
01555                 delete osilreader;
01556                 osilreader = NULL;      
01557                 delete osolreader;
01558                 osolreader = NULL;      
01559                 unitTestResult << "Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
01560                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01561 
01562 
01563 
01564 #if 1   // this does not work with the current version of Bonmin due to uninitialed variables
01565                 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on rosenbrockorig.osil" << endl << endl;
01566                 ok = true;
01567                 osilFileName = dataDir  + "osilFiles" + dirsep + "rosenbrockorig.osil";
01568 //              osolFileName = dataDir  + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
01569                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01570 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01571                 osilreader = new OSiLReader(); 
01572 //              osolreader = new OSoLReader(); 
01573                 solver = new BonminSolver();    
01574                 solver->osol = "";
01575                 solver->osinstance = osilreader->readOSiL( osil);
01576 //              solver->osoption   = osolreader->readOSoL( osol);
01577                 cout << "build solver instance" << endl;
01578                 solver->buildSolverInstance();
01579                 cout << "call the Bonmin Solver for rosenbrockorig" << endl;
01580                 solver->solve();
01581                 check = 0;
01582                 cout << "Verify solution" <<endl;
01583                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01584                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01585                 if (ok)
01586                 {       
01587 #ifdef DEBUG
01588                         cout << solver->osrl << endl;
01589 #endif
01590                         cout << "Bonmin solver solution for rosenbrockorig checks." << endl;
01591                 }
01592                 else
01593                 {       cout << "Bonmin solver solution for rosenbrockorig in error:" << endl;
01594                         cout << solver->osrl << endl;
01595                 }
01596                 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on rosenbrockorig.osil");
01597                 delete solver;
01598                 solver = NULL;
01599                 delete osilreader;
01600                 osilreader = NULL;      
01601                 delete osolreader;
01602                 osolreader = NULL;      
01603                 unitTestResult << "Solved problem rosenbrockorig.osil with Bonmin" << std::endl;
01604                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01605 
01606                 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on rosenbrockorigInt.osil" << endl << endl;
01607                 ok = true;
01608                 osilFileName = dataDir  + "osilFiles" + dirsep + "rosenbrockorigInt.osil";
01609 //              osolFileName = dataDir  + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
01610                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01611 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01612                 osilreader = new OSiLReader(); 
01613 //              osolreader = new OSoLReader(); 
01614                 solver = new BonminSolver();    
01615                 solver->osol = "";
01616                 solver->osinstance = osilreader->readOSiL( osil);
01617 //              solver->osoption   = osolreader->readOSoL( osol);
01618                 cout << "call the Bonmin Solver for rosenbrockinteger" << endl;
01619                 solver->buildSolverInstance();
01620                 solver->solve();
01621                 check = 0;
01622                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01623                 if (ok)
01624                 {       
01625 #ifdef DEBUG
01626                         cout << solver->osrl << endl;
01627 #endif
01628                         cout << "Bonmin solver solution for rosenbrockorigInt checks." << endl;
01629                 }
01630                 else
01631                 {       cout << "Bonmin solver solution for rosenbrockorigInt in error:" << endl;
01632                         cout << solver->osrl << endl;
01633                 }
01634                 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on rosenbrockorigInt.osil");
01635                 delete solver;
01636                 solver = NULL;
01637                 delete osilreader;
01638                 osilreader = NULL;      
01639                 delete osolreader;
01640                 osolreader = NULL;      
01641                 unitTestResult << "Solved problem rosenbrockorigInt.osil with Bonmin" << std::endl;
01642                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01643 #endif // ---- end of #if 0 above
01644 
01645 }   // end of if( THOROUGH )
01646         }
01647         catch(const ErrorClass& eclass){
01648                 unitTestResultFailure  << "Sorry Unit Test Failed Testing the Bonmin Solver:"  + eclass.errormsg << endl;
01649         }       
01650 #endif   // end of #ifdef COIN_HAS_BONMIN
01651 
01652 
01653 
01654 #ifdef COIN_HAS_COUENNE
01655         try{
01656                 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on bonminEx1.osil" << endl << endl;
01657                 CouenneSolver *solver = NULL;
01658 
01659 //              OSiLReader *osilreader = NULL;
01660                 osilreader = new OSiLReader(); 
01661                 osolreader = new OSoLReader(); 
01662                 ok = true; 
01663                 osilFileName = dataDir  + "osilFiles" + dirsep + "bonminEx1.osil";
01664                 osolFileName = dataDir  + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
01665                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01666                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01667                 solver = new CouenneSolver();
01668                 solver->sSolverName = "bonmin";
01669                 solver->osil = osil;
01670                 solver->osol = osol; 
01671 //              solver->osinstance = osilreader->readOSiL( osil);
01672 //              solver->osoption   = osolreader->readOSoL( osol);
01673                 cout << "call the COIN - Couenne Solver for bonminEx1" << endl;
01674                 solver->buildSolverInstance();
01675         
01676                 std::cout << " CALL SOLVE " << std::endl;
01677                 solver->solve();
01678         
01679                 check = -17.07106795327683;
01680                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01681                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01682                 if (ok)
01683                 {       
01684 #ifdef DEBUG
01685                         cout << solver->osrl << endl;
01686 #endif
01687                         cout << "Couenne solver solution for bonminEx1 checks." << endl;
01688                 }
01689                 else
01690                 {       cout << "Couenne solver solution for bonminEx1 in error:" << endl;
01691                         cout << solver->osrl << endl;
01692                 }
01693                 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on bonminEx1.osil");
01694 
01695                 delete solver;
01696                 solver = NULL;
01697                 unitTestResult << "Solved problem bonminEx1.osil with Couenne" << std::endl;
01698         
01699         
01700                 delete osilreader;
01701                 osilreader = NULL;
01702                 delete osolreader;
01703                 osolreader = NULL;
01704                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01705 
01706 if( THOROUGH == true){
01707                 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on bonminEx1_Nonlinear.osil" << endl << endl;
01708 //              OSiLReader *osilreader = NULL;
01709                 osilreader = new OSiLReader(); 
01710                 osolreader = new OSoLReader(); 
01711                 ok = true; 
01712                 osilFileName = dataDir  + "osilFiles" + dirsep + "bonminEx1_Nonlinear.osil";
01713 //              osolFileName = dataDir  + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
01714                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01715 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01716                 osol = "";
01717                 solver = new CouenneSolver();
01718                 solver->osil = osil;
01719                 solver->osol = osol; 
01720 //              solver->osinstance = osilreader->readOSiL( osil);
01721 //              solver->osoption   = osolreader->readOSoL( osol);
01722                 cout << "call the COIN - Couenne Solver for bonminEx1_Nonlinear" << endl;
01723                 solver->buildSolverInstance();
01724         
01725                 std::cout << " CALL SOLVE " << std::endl;
01726                 solver->solve();
01727         
01728                 check = -1.707107;
01729                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01730                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01731                 if (ok)
01732                 {       
01733 #ifdef DEBUG
01734                         cout << solver->osrl << endl;
01735 #endif
01736                         cout << "Couenne solver solution for bonminEx1_Nonlinear checks." << endl;
01737                 }
01738                 else
01739                 {       cout << "Couenne solver solution for bonminEx1_Nonlinear in error:" << endl;
01740                         cout << solver->osrl << endl;
01741                 }
01742                 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on bonminEx1_Nonlinear.osil");
01743 
01744                 delete solver;
01745                 solver = NULL;
01746                 unitTestResult << "Solved problem bonminEx1_Nonlinear with Couenne" << std::endl;
01747         
01748         
01749                 delete osilreader;
01750                 osilreader = NULL;
01751                 delete osolreader;
01752                 osolreader = NULL;
01753                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01754 
01755 
01756                 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on nonconvex.osil" << endl << endl;
01757 //              OSiLReader *osilreader = NULL;
01758                 osilreader = new OSiLReader(); 
01759                 osolreader = new OSoLReader(); 
01760                 ok = true; 
01761                 osilFileName = dataDir  + "osilFiles" + dirsep + "nonconvex.osil";
01762 //              osolFileName = dataDir  + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
01763                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01764 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01765                 osol = "";
01766                 solver = new CouenneSolver();
01767                 solver->osil = osil;
01768                 solver->osol = osol; 
01769 //              solver->osinstance = osilreader->readOSiL( osil);
01770 //              solver->osoption   = osolreader->readOSoL( osol);
01771                 cout << "call the COIN - Couenne Solver for nonconvex.osil" << endl;
01772                 solver->buildSolverInstance();
01773         
01774                 std::cout << " CALL SOLVE " << std::endl;
01775                 solver->solve();
01776         
01777                 check = -6.551133;
01778                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01779                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01780                 if (ok)
01781                 {       
01782 #ifdef DEBUG
01783                         cout << solver->osrl << endl;
01784 #endif
01785                         cout << "Couenne solver solution for nonconvex.osil checks." << endl;
01786                 }
01787                 else
01788                 {       cout << "Couenne solver solution for nonconvex.osil in error:" << endl;
01789                         cout << solver->osrl << endl;
01790                 }
01791                 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on nonconvex.osil");
01792 
01793                 delete solver;
01794                 solver = NULL;
01795                 unitTestResult << "Solved problem nonconvex.osil with Couenne" << std::endl;
01796         
01797         
01798                 delete osilreader;
01799                 osilreader = NULL;
01800                 delete osolreader;
01801                 osolreader = NULL;
01802                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01803 
01804                 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on rosenbrockorig.osil" << endl << endl;
01805 //              OSiLReader *osilreader = NULL;
01806                 osilreader = new OSiLReader(); 
01807                 osolreader = new OSoLReader(); 
01808                 ok = true; 
01809                 osilFileName = dataDir  + "osilFiles" + dirsep + "rosenbrockorig.osil";
01810 //              osolFileName = dataDir  + "osolFiles" + dirsep + "rosenbrockorig_Couenne.osol";
01811                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01812 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01813                 osol = "";
01814                 solver = new CouenneSolver();
01815                 solver->osil = osil;
01816                 solver->osol = osol; 
01817 //              solver->osinstance = osilreader->readOSiL( osil);
01818 //              solver->osoption   = osolreader->readOSoL( osol);
01819                 cout << "call the COIN - Couenne Solver for rosenbrockorig" << endl;
01820                 solver->buildSolverInstance();
01821         
01822                 std::cout << " CALL SOLVE " << std::endl;
01823                 solver->solve();
01824         
01825                 check = 0;
01826                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01827                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01828                 if (ok)
01829                 {       
01830 #ifdef DEBUG
01831                         cout << solver->osrl << endl;
01832 #endif
01833                         cout << "Couenne solver solution for rosenbrockorig checks." << endl;
01834                 }
01835                 else
01836                 {       cout << "Couenne solver solution for rosenbrockorig in error:" << endl;
01837                         cout << solver->osrl << endl;
01838                 }
01839                 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on rosenbrockorig.osil");
01840 
01841                 delete solver;
01842                 solver = NULL;
01843                 unitTestResult << "Solved problem rosenbrockorig.osil with Couenne" << std::endl;
01844         
01845         
01846                 delete osilreader;
01847                 osilreader = NULL;
01848                 delete osolreader;
01849                 osolreader = NULL;
01850                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01851 
01852 
01853 
01854                 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on wayneQuadratic.osil" << endl << endl;
01855 //              OSiLReader *osilreader = NULL;
01856                 osilreader = new OSiLReader(); 
01857                 osolreader = new OSoLReader(); 
01858                 ok = true; 
01859                 osilFileName = dataDir  + "osilFiles" + dirsep + "wayneQuadratic.osil";
01860                 
01861 //              osolFileName = dataDir  + "osolFiles" + dirsep + "rosenbrockinteger_Couenne.osol";
01862                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01863 //              osol = fileUtil->getFileAsString( osolFileName.c_str());
01864                 osol = "";
01865                 solver = new CouenneSolver();
01866                 solver->osinstance = NULL;
01867                 solver->osil = osil;
01868                 solver->osol = osol; 
01869 //              solver->osinstance = osilreader->readOSiL( osil);
01870 //              solver->osoption   = osolreader->readOSoL( osol);
01871                 cout << "call the COIN - Couenne Solver for wayneQuadraticr" << endl;
01872                 //solver->buildSolverInstance();
01873                 std::cout << " CALL SOLVE " << std::endl;
01874                 solver->buildSolverInstance();
01875                 solver->setSolverOptions();
01876                 solver->solve();
01877                 check = 2.925;
01878                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01879                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01880                 if (ok)
01881                 {       
01882 #ifdef DEBUG
01883                         cout << solver->osrl << endl;
01884 #endif
01885                         cout << "Couenne solver solution for wayneQuadratic checks." << endl;
01886                 }
01887                 else
01888                 {       cout << "Couenne solver solution for wayneQuadratic in error:" << endl;
01889                         cout << solver->osrl << endl;
01890                 }
01891                 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on rosenbrockinteger.osil");
01892 
01893                 delete solver;
01894                 solver = NULL;
01895                 unitTestResult << "Solved problem wayneQuadratic.osil with Couenne" << std::endl;
01896         
01897         
01898                 delete osilreader;
01899                 osilreader = NULL;
01900                 delete osolreader;
01901                 osolreader = NULL;
01902                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01903                 
01904 
01905                 
01906                 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on wayneQuadratic.osil" << endl << endl;
01907 //              OSiLReader *osilreader = NULL;
01908                 osilreader = new OSiLReader(); 
01909                 osolreader = new OSoLReader(); 
01910                 ok = true; 
01911                 osilFileName = dataDir  + "osilFiles" + dirsep + "wayneQuadratic.osil";
01912                 osolFileName = dataDir  + "osolFiles" + dirsep + "wayneQuadratic_Couenne.osol";
01913                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01914                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01915                 solver = new CouenneSolver();
01916                 solver->osil = osil;
01917                 solver->osol = osol; 
01918                 cout << "call the COIN - Couenne Solver for wayneQuadratic.osil" << endl;
01919                 solver->buildSolverInstance();
01920         
01921                 std::cout << " CALL SOLVE " << std::endl;
01922                 solver->solve();
01923         
01924                 cout << "Here is the Couenne solver solution for wayneQuadratic" << endl;
01925 
01926 //              OSrLWriter *tmp_writer;
01927                 tmp_writer = new OSrLWriter();
01928                 solver->osrl = tmp_writer->writeOSrL(solver->osresult);
01929                 delete tmp_writer;
01930                 tmp_writer = NULL;
01931                 
01932                 string::size_type pos;
01933                 pos = solver->osrl.find( "LIMIT_EXCEEDED[COUENNE]");
01934                 if(pos == std::string::npos)  
01935                 {       cout << solver->osrl << endl << endl;
01936                         throw ErrorClass(" Error with wayneQuadratic running on Couenne");
01937                 }
01938 #ifdef DEBUG
01939                 else
01940                 {
01941                         cout << solver->osrl << endl << endl;
01942                 }
01943 #endif
01944                 delete solver;
01945                 solver = NULL;
01946                 unitTestResult << "Solved problem wayneQuadratic with Couenne" << std::endl;
01947                 delete osilreader;
01948                 osilreader = NULL;
01949                 delete osolreader;
01950                 osolreader = NULL;
01951                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
01952                 
01953 
01954 } //end of if (THOROUGH)
01955 
01956         }
01957         catch(const ErrorClass& eclass){
01958                 cout << "OSrL =  " <<  solver->osrl <<  endl;
01959                 cout << endl << endl << endl;
01960                 unitTestResultFailure  << "Sorry Unit Test Failed Testing the Couenne Solver:"  + eclass.errormsg << endl;
01961         
01962         }       
01963 #endif // end of #ifdef COIN_HAS_COUENNE
01964 
01965 //#endif // end of #if 0
01966 
01967         
01968 #ifdef COIN_HAS_LINDO
01969         try{
01970                 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on lindoapiaddins.osil" << endl << endl;
01971                 ok = true;
01972                 osilFileName = dataDir  + "osilFiles" + dirsep + "lindoapiaddins.osil";
01973                 osolFileName = dataDir  + "osolFiles" + dirsep + "lindoapiaddins_lindo.osol";
01974                 osil = fileUtil->getFileAsString( osilFileName.c_str());
01975                 osol = fileUtil->getFileAsString( osolFileName.c_str());
01976                 osilreader = new OSiLReader(); 
01977                 cout << "create a new LINDO Solver for OSiL string solution" << endl;
01978                 solver = new LindoSolver();     
01979                 solver->osinstance = osilreader->readOSiL( osil);
01980                 solver->osol = osol;
01981                 cout << "call the LINDO Solver" << endl;
01982                 solver->buildSolverInstance();
01983                 solver->solve();
01984                 check = 99;
01985                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
01986                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
01987                 if (ok)
01988                 {       
01989 #ifdef DEBUG
01990                         cout << solver->osrl << endl;
01991 #endif
01992                         cout << "LINDO solver solution for lindoapiaddins checks." << endl;
01993                 }
01994                 else
01995                 {       cout << "LINDO solver solution for lindoapiaddins in error:" << endl;
01996                         cout << solver->osrl << endl;
01997                 }
01998                 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on lindoapiaddins.osil");
01999                 solver->osinstance = NULL;
02000                 delete solver;
02001                 solver = NULL;
02002                 osilreader = NULL;      
02003                 delete osolreader;
02004                 unitTestResult << "Solved problem lindoapiaddins.osil with Lindo" << std::endl;
02005                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02006 
02007 #ifdef THOUROUGH
02008                 // now solve the rosenbrock problem from the OSiL paper
02009                 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on rosenbrockmod.osil" << endl << endl;
02010                 osilFileName = dataDir  + "osilFiles" + dirsep + "rosenbrockmod.osil";
02011                 osolFileName = dataDir  + "osolFiles" + dirsep + "rosenbrockmod_lindo.osol";
02012                 osil = fileUtil->getFileAsString( osilFileName.c_str());
02013                 osol = fileUtil->getFileAsString( osolFileName.c_str());
02014                 solver = new LindoSolver();     
02015                 solver->osil = osil;
02016                 solver->osol = osol;
02017                 solver->osinstance = NULL;
02018                 cout << "call the LINDO Solver" << endl;
02019                 solver->buildSolverInstance();
02020                 solver->solve();
02021                 check = 6.7279;
02022                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
02023                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02024                 if (ok)
02025                 {       
02026 #ifdef DEBUG
02027                         cout << solver->osrl << endl;
02028 #endif
02029                         cout << "LINDO solver solution for rosenbrockmod checks." << endl;
02030                 }
02031                 else
02032                 {       cout << "LINDO solver solution for rosenbrockmod in error:" << endl;
02033                         cout << solver->osrl << endl;
02034                 }
02035                 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on rosenbrockmod.osil");
02036                 solver->osinstance = NULL;
02037                 delete solver;
02038                 solver = NULL;
02039                 unitTestResult << "Solved problem rosenbrockmod.osil with Lindo" << std::endl;
02040                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02041 
02042                 // now solve a pure quadratic
02043                 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on parincQuadratic.osil" << endl << endl;
02044                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincQuadratic.osil";
02045                 osolFileName = dataDir  + "osolFiles" + dirsep + "parincQuadratic_lindo.osol";
02046                 osil = fileUtil->getFileAsString( osilFileName.c_str());
02047                 osol = fileUtil->getFileAsString( osolFileName.c_str());
02048                 osolreader = new OSoLReader(); 
02049                 solver = new LindoSolver();     
02050                 solver->osil = osil;
02051                 solver->osol = osol;
02052                 solver->osinstance = NULL;
02053                 solver->osoption   = osolreader->readOSoL( osol);
02054                 cout << "call the LINDO Solver" << endl;
02055                 solver->buildSolverInstance();
02056                 solver->solve();
02057                 check = 49920.5;
02058                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
02059                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02060                 if (ok)
02061                 {       
02062 #ifdef DEBUG
02063                         cout << solver->osrl << endl;
02064 #endif
02065                         cout << "LINDO solver solution for parincQuadratic checks." << endl;
02066                 }
02067                 else
02068                 {       cout << "LINDO solver solution for parincQuadratic in error:" << endl;
02069                         cout << solver->osrl << endl;
02070                 }
02071                 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on parincQuadratic.osil");
02072                 delete solver;
02073                 solver = NULL;
02074                 delete osolreader;
02075                 osolreader = NULL;      
02076                 unitTestResult << "Solved problem parincQuadratic.osil with Lindo" << std::endl;
02077                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02078 
02079                 // now solve a quadratic binary problem
02080                 // wayneQuadratic.osil
02081                 /*
02082                 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on wayneQuadratic.osil" << endl << endl;
02083                 osilFileName = dataDir  + "osilFiles" + dirsep + "wayneQuadratic.osil";
02084                 osolFileName = dataDir  + "osolFiles" + dirsep + "wayneQuadratic_lindo.osol";
02085                 osil = fileUtil->getFileAsString( osilFileName.c_str());
02086                 osol = fileUtil->getFileAsString( osolFileName.c_str());
02087                 osilreader = new OSiLReader(); 
02088                 solver = new LindoSolver();     
02089                 solver->osil = osil;
02090                 solver->osol = osol;
02091                 solver->osinstance = osilreader->readOSiL( osil);
02092                 cout << "call the LINDO Solver" << endl;
02093                 solver->buildSolverInstance();
02094                 solver->solve();
02095                 check = 2.925;
02096                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-10 , 1e-10);
02097                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02098                 if (ok)
02099                 {       
02100 #ifdef DEBUG
02101                         cout << solver->osrl << endl;
02102 #endif
02103                         cout << "LINDO solver solution for wayneQuadratic checks." << endl;
02104                 }
02105                 else
02106                 {       cout << "LINDO solver solution for wayneQuadratic in error:" << endl;
02107                         cout << solver->osrl << endl;
02108                 }
02109                 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on wayneQuadratic.osil");
02110                 delete solver;
02111                 solver = NULL;
02112                 osilreader = NULL;      
02113                 delete osolreader;
02114                 unitTestResult << "Solved problem wayneQuadratic.osil with Lindo" << std::endl;
02115                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02116                 */
02117 #endif          
02118         }
02119         catch(const ErrorClass& eclass){
02120                 //cout << "OSrL =  " <<  solver->osrl <<  endl;
02121                 cout << endl << endl << endl;
02122                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing the LINDO Solver:"  + eclass.errormsg << endl << endl;
02123         }
02124 #endif
02125 } // end of if(SOLVER_TESTS)
02126 
02127 
02128 
02129 // now solve with an OSInstance created from an MPS file
02130 if (OTHER_TESTS){
02131         try{
02132                 cout << endl << "TEST " << ++nOfTest << ": Cbc solver using MPS file" << endl << endl;
02133                 ok = true;
02134 //              cout << endl;
02135 //              cout << "START MPS TESTING" << endl << endl;
02136                 cout << "create a COIN Solver for MPS - OSInstance solution" << endl;
02137                 solver = new CoinSolver();
02138                 solver->sSolverName = "cbc";
02139                 mps2osil = new OSmps2osil( mpsFileName);
02140                 mps2osil->createOSInstance() ;
02141                 solver->osinstance = mps2osil->osinstance;
02142                 osol = "<osol></osol>";
02143                 solver->osol = osol;
02144                 cout << "call COIN Solve" << endl;
02145                 solver->buildSolverInstance();
02146                 solver->solve();
02147                 check = -7668;
02148                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-1 , 1e-1);
02149                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02150                 if (ok)
02151                 {       
02152 #ifdef DEBUG
02153                         cout << solver->osrl << endl;
02154 #endif
02155                         cout << "COIN solver solution for parinc.mps checks." << endl;
02156                 }
02157                 else
02158                 {       cout << "COIN solver solution for parinc.mps in error:" << endl;
02159                         cout << solver->osrl << endl;
02160                 }
02161                 if(ok == false) throw ErrorClass(" Fail unit test with COIN Solver on MPS test problem parincLinear.mps");
02162                 delete solver;
02163                 solver = NULL;
02164                 delete mps2osil; 
02165                 mps2osil = NULL;
02166 //              cout << endl;
02167 //              cout << "DONE WITH MPS TESTING" << endl;
02168                 unitTestResult << "Test the MPS -> OSiL converter on parinc.mps using Cbc" << std::endl;
02169                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02170         }
02171         catch(const ErrorClass& eclass){
02172                 cout << "OSrL =  " <<  solver->osrl <<  endl;
02173                 cout << endl << endl << endl;
02174                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing the MPS converter:"  + eclass.errormsg << endl;
02175         }
02176 
02177 // now solve with an OSInstance created from an AMPL nl file
02178         try{
02179 #ifdef COIN_HAS_ASL
02180                 cout << endl << "TEST " << ++nOfTest << ": AMPL solver interface" << endl << endl;
02181                 ok = true;
02182                 cout << "create a cbc Solver for AMPL nl - OSInstance solution" << endl;
02183                 solver = new CoinSolver();
02184                 solver->sSolverName = "cbc";
02185                 nl2osil = new OSnl2osil( nlFileName); 
02186                 nl2osil->createOSInstance() ;
02187                 solver->osinstance = nl2osil->osinstance;       
02188 
02189                 OSiLWriter tmp_osil_writer;
02190                 tmp_osil_writer.m_bWhiteSpace = true;
02191                 std::cout << tmp_osil_writer.writeOSiL( solver->osinstance) << std::endl;
02192 
02193                 osol = "";  //<osol></osol>";
02194                 solver->osol = osol;
02195                 cout << "call Cbc Solve" << endl;
02196                 solver->buildSolverInstance();
02197                 solver->solve();
02198                 check = 7668;
02199                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-1 , 1e-1);
02200                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02201                 if (ok)
02202                 {       
02203 #ifdef DEBUG
02204                         cout << solver->osrl << endl;
02205 #endif
02206                         cout << "COIN cbc solver solution for parinc.nl checks." << endl;
02207                 }
02208                 else
02209                 {       cout << "COIN cbc solver solution for parinc.nl in error:" << endl;
02210                         cout << solver->osrl << endl;
02211                 }
02212                 if(ok == false) throw ErrorClass(" Fail unit test with OSnl2osil on problem parinc.nl");
02213                 solver->osinstance = NULL;
02214                 delete solver;
02215                 solver = NULL;
02216                 cout << "call delete nl2osil" << endl;
02217                 delete nl2osil;
02218                 nl2osil = NULL; 
02219                 unitTestResult << "Test the AMPL nl -> OSiL converter on parinc.nl using Cbc" << std::endl; 
02220                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02221 #endif
02222         }       
02223         catch(const ErrorClass& eclass){
02224                 cout << "OSrL =  " <<  solver->osrl <<  endl;
02225                 cout << endl << endl << endl;
02226                 unitTestResultFailure  <<"Sorry Unit Test Failed Testing AMPL:"  + eclass.errormsg << endl;
02227         }
02228 
02229         //
02230         // Now test the mps feature
02231         //
02232         try{
02233                 cout << endl << "TEST " << ++nOfTest << ": b64 operations" << endl << endl;
02234                 ok = true;
02235                 OSiLWriter osilwriter;
02236                 osilwriter.m_bWriteBase64 = true;
02237                 solver = new CoinSolver();
02238                 solver->sSolverName = "cbc";
02239                 mps2osil = new OSmps2osil( mpsFileName);
02240                 solver->osinstance = NULL;
02241                 osol = "<osol></osol>";
02242                 solver->osol = osol;
02243                 mps2osil->createOSInstance() ;
02244                 solver->osil = osilwriter.writeOSiL( mps2osil->osinstance) ;
02245                 std::cout << solver->osil << std::endl;
02246                 solver->buildSolverInstance();
02247                 solver->solve();
02248                 cout << endl << endl;
02249                 check = -7668;
02250                 //ok &= NearEqual(getObjVal( solver->osrl) , check,  1e-1 , 1e-1);
02251                 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02252                 if (ok)
02253                 {       cout << "COIN solution of a OSiL string in b64 format." << endl;
02254 #ifdef DEBUG
02255                         cout << solver->osrl << endl;
02256 #endif                  
02257                 }
02258                 else
02259                 {       cout << "COIN solution of a OSiL string in b64 format:" << endl;
02260                         cout << solver->osrl << endl;
02261                 }
02262                 if(ok == false) throw ErrorClass(" Fail unit test with COIN Cbc Solver on b64 test problem parincLinear.mps");
02263                 solver->osinstance = NULL;
02264                 delete solver;
02265                 solver = NULL;
02266                 delete mps2osil;
02267                 mps2osil = NULL;
02268                 unitTestResult << "Test a problem written in b64 and then converted to OSInstance" << std::endl;
02269                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02270         }       
02271         catch(const ErrorClass& eclass){
02272                 cout << endl << endl;
02273                 cout << eclass.errormsg <<  endl << endl;
02274                 cout << "OSrL =  " <<  solver->osrl <<  endl;
02275                 cout << endl << endl << endl;
02276                 unitTestResultFailure   << "Sorry Unit Test Failed Testing Use of Base 64" << endl;
02277 
02278         }  
02279 
02280 
02281         // now test postfix and prefix routines
02282         try{
02283                 cout << endl << "TEST " << ++nOfTest << ": postfix and prefix routines" << endl << endl;
02284                 std::string expTreeTest =  dataDir  + "osilFiles" + dirsep + "rosenbrockmod.osil";
02285                 osil = fileUtil->getFileAsString( expTreeTest.c_str() ) ;
02286                 OSInstance *osinstance = NULL;
02287                 //osinstance = new OSInstance();
02288                 OSiLReader *osilreader = NULL;
02289                 osilreader = new OSiLReader();
02290                 //create an osinstance
02291                 osinstance = osilreader->readOSiL( osil);
02292                 OSExpressionTree* expTree = osinstance->getNonlinearExpressionTree( -1);
02293                 if(expTree == NULL) throw ErrorClass(" Null expression tree when testing prefix and postfix routines");
02294                 std::vector<OSnLNode*> postfixVec;
02295                 //postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
02296                 postfixVec = osinstance->getNonlinearExpressionTreeInPostfix( -1);
02297         
02298                 unsigned int n = postfixVec.size();
02299                 unsigned int i;
02300                 std::string *nodeNames1 = new std::string[ n];
02301                 std::string *nodeNames2 = new std::string[ n];
02302                 for (i = 0 ; i < n; i++){
02303                         std::cout << postfixVec[i]->snodeName << std::endl;
02304                         nodeNames1[i] = postfixVec[i]->snodeName;
02305                 }
02306                 
02307                 // now create back the expression tree 
02308                 expTree->m_treeRoot = postfixVec[ n - 1]->createExpressionTreeFromPostfix( postfixVec);
02309         
02310                 // now get in prefix
02311                 std::vector<OSnLNode*> prefixVec;
02312                 //prefixVec = expTree->m_treeRoot->getPrefixFromExpressionTree();
02313                 prefixVec = osinstance->getNonlinearExpressionTreeInPrefix( -1);
02314                 
02315                 // now create back the expression tree
02316                 expTree->m_treeRoot = prefixVec[ 0]->createExpressionTreeFromPrefix( prefixVec);
02317                 
02318                 // now get postfix vector again and compare with original
02319                 postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
02320                 //postfixVec = osinstance->getNonlinearExpressionTreeInPostfix( -1);
02321                 if(postfixVec.size() != n) throw ErrorClass(" Problem with creating expression trees");
02322                 std::cout << std::endl << std::endl;
02323                 for (i = 0 ; i < n; i++){
02324                         //std::cout << postfixVec[i]->snodeName << std::endl;
02325                         nodeNames2[i] = postfixVec[i]->snodeName;
02326                         if( nodeNames1[i] != nodeNames2[ i]) throw ErrorClass(" Problem with creating expression trees");
02327                 }       
02328                 
02329                 //delete osinstance;
02330                 delete[] nodeNames1;
02331                 delete[] nodeNames2; 
02332 
02333                 delete osilreader;
02334                 osilreader = NULL;
02335                 osinstance = NULL;              
02336                 unitTestResult << "Successful test of prefix and postfix conversion routines" << std::endl;
02337                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02338                 
02339         }
02340         catch(const ErrorClass& eclass){
02341                 cout << endl << endl << endl;
02342                 unitTestResultFailure << eclass.errormsg << endl;
02343         }
02344         // now test the nonlinear operators     
02345         try{
02346                 cout << endl << "TEST " << ++nOfTest << ": nonlinear operators" << endl << endl;
02347                 ok = true;
02348                 std::string operatorTest =  dataDir  + "osilFiles" + dirsep + "testOperators.osil";
02349                 osil = fileUtil->getFileAsString( operatorTest.c_str() );
02350                 OSInstance *osinstance = NULL;
02351                 //osinstance = new OSInstance();
02352                 OSiLReader *osilreader = NULL;
02353                 osilreader = new OSiLReader();
02354                 OSiLWriter *osilwriter = NULL;
02355                 osilwriter = new OSiLWriter();
02356 //              cout << "Read testOperators.osil...";
02357                 osinstance = osilreader->readOSiL( osil);
02358                 
02359                 cout << "Done" << endl;
02360                 OSExpressionTree* expTree = osinstance->getNonlinearExpressionTree( -1);
02361                 std::vector<OSnLNode*> postfixVec;
02362                 postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
02363                 int n = postfixVec.size();
02364                 std::string *nodeNames1 = new std::string[ n];
02365                 for (int i = 0 ; i < n; i++){
02366                         std::cout << postfixVec[i]->snodeName << std::endl;
02367                         nodeNames1[i] = postfixVec[i]->snodeName;
02368                 }
02369                 std::cout << std::endl << std::endl;
02370                 std::cout << osilwriter->writeOSiL( osinstance) << std::endl;
02371                 // now test value
02372                 double *x = NULL;
02373                 x = new double[2];
02374                 x[0] = 1;
02375                 x[1] = 2;
02376                 double parserTestVal = expTree->m_treeRoot->calculateFunction( x);
02377                 std::cout << "ParserTest Val = " << parserTestVal << std::endl;
02378                 check = 11;
02379                 //ok &= NearEqual(expTree->m_treeRoot->calculateFunction( x) , check,  1e-10 , 1e-10);
02380                 ok = ( fabs(check -  expTree->m_treeRoot->calculateFunction( x))/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02381                 if(ok == false) throw ErrorClass(" Problem evaluating expression tree");
02382                 delete[] x;
02383                 delete[] nodeNames1;
02384                 delete osilreader;
02385                 osilreader = NULL;
02386                 delete osilwriter;
02387                 osilwriter = NULL;
02388                 osinstance = NULL;
02389                 //create an osinstance
02390                 unitTestResult << "Successful test of nonlinear operators using file testOperators.osil" << std::endl;
02391                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02392         }
02393         catch(const ErrorClass& eclass){
02394                 cout << endl << endl << endl;
02395                 unitTestResultFailure << eclass.errormsg << endl;
02396         }
02397 // Automatic differentiation
02398         try{
02399                 cout << endl << "TEST " << ++nOfTest << ": Automatic differentiation" << endl << endl;
02400 //              std::cout << std::endl << std::endl;
02401 //              std::cout << "Testing AD Features " << std::endl;
02402                 std::string expTreeTest =  dataDir  + "osilFiles" + dirsep + "CppADTestLag.osil";
02403                 /*
02404                 min x0^2 + 9*x1   -- w[0]
02405                 s.t. 
02406                 33 - 105 + 1.37*x1 + 2*x3 + 5*x1 <= 10  -- y[0]
02407                 ln(x0*x3)  + 7*x2 >= 10  -- y[1]
02408                 Note: in the first constraint 33 is a constant term and 105 
02409                 is part of the nl node
02410                 */
02411                 osil = fileUtil->getFileAsString( expTreeTest.c_str() );
02412                 OSInstance *osinstance = NULL;
02413                 //osinstance = new OSInstance();
02414                 OSiLReader *osilreader = NULL;
02415                 osilreader = new OSiLReader();
02416                 //create an osinstance
02417                 osinstance = osilreader->readOSiL( osil);
02418                 double *x;
02419                 x = new double[ 4];
02420                 x[0] = 1;
02421                 x[1] = 5;
02422                 x[2] = 10;
02423                 x[3] = 5;
02424                 SparseVector *sp;
02425                 // get the gradient for constraint 1
02426                 osinstance->getJacobianSparsityPattern();
02427                 sp = osinstance->calculateConstraintFunctionGradient(x, 1, true);
02428                 for(int i = 0; i < sp->number; i++){
02429                         std::cout << "gradient value " << sp->values[i] << std::endl;
02430                 }
02431                 ok = true;
02432                 //check gradient for constraint with index 1
02433                 double checkPartial2Con1 = 7.0 ;
02434                 //ok &= NearEqual( sp->values[ 0], checkPartial2Con1, 1e-10, 1e-10); 
02435                 ok = ( fabs(checkPartial2Con1 - sp->values[ 0] )/(fabs( checkPartial2Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02436                 if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
02437                 double checkPartial0Con1 = (1./x[0])  ;
02438                 //ok &= NearEqual(sp->values[ 1], checkPartial0Con1, 1e-10, 1e-10); 
02439                 ok = ( fabs(checkPartial0Con1 - sp->values[ 1] )/(fabs( checkPartial0Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02440                 if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
02441                 double checkPartial3Con1 = (1./x[3]) ;
02442                 //ok &= NearEqual( sp->values[ 2], checkPartial3Con1, 1e-10, 1e-10); 
02443                 ok = ( fabs(checkPartial3Con1 - sp->values[ 2] )/(fabs( checkPartial3Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02444                 if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
02445                 delete sp;
02446                 SparseHessianMatrix *sh;
02447                 // calcuate Hessian of objective function (index = -1)
02448                 osinstance->getLagrangianHessianSparsityPattern( );
02449                 sh = osinstance->calculateHessian(x, -1, true);
02450                 for(int i = 0; i < sh->hessDimension; i++){
02451                         std::cout << "Hessian value " << sh->hessValues[i] << std::endl;
02452                 }
02453                 //ok &= NearEqual( sh->hessValues[ 0], 2., 1e-10, 1e-10);
02454                 ok = ( fabs(2. - sh->hessValues[0] )/(2. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02455                 if(ok == false) throw ErrorClass(" Fail testing Hessian calculation"); 
02456                 //ok &= NearEqual( sh->hessValues[ 1], 0., 1e-10, 1e-10);
02457                 ok = ( fabs(0. - sh->hessValues[ 1] )/(0. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02458                 if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
02459                 //ok &= NearEqual( sh->hessValues[ 2], 0., 1e-10, 1e-10);
02460                 ok = ( fabs(0. - sh->hessValues[2] )/(0. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
02461                 if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
02462                 unitTestResult << "Successful test of AD gradient and Hessian calculations" << std::endl;
02463                 delete[] x;
02464                 delete osilreader;
02465                 osilreader = NULL;
02466                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02467         }       
02468         catch(const ErrorClass& eclass){
02469                 cout << endl << endl << endl;
02470                 unitTestResultFailure << eclass.errormsg << endl;
02471         }
02472 } //end of if (OTHER_TESTS)
02473 
02474         //
02475         // Now test the parsers --- OSiL parser first
02476 if (PARSER_TESTS){
02477         try{ 
02478                 cout << endl << "TEST " << ++nOfTest << ":  OSiL parser" << endl << endl;
02479                 clock_t start, finish;
02480                 double duration;
02481                 OSiLWriter *osilwriter = NULL;
02482                 osilwriter = new OSiLWriter();
02483                 //delete fileUtil;
02484                 //fileUtil = NULL;
02485                 //fileUtil = new FileUtil();
02486                 cout << "TEST PARSING A MODEL" << endl;
02487                 cout << "FIRST READ THE FILE INTO A STRING" << endl;
02488                 start = clock();
02489                 osilFileName = dataDir  + "osilFiles" + dirsep + "parincLinear.osil";
02490                 osil = fileUtil->getFileAsString( osilFileName.c_str());
02491                 finish = clock();
02492                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
02493                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
02494                 OSiLReader *osilreader = NULL;
02495                 osilreader = new OSiLReader(); 
02496                 start = clock();
02497                 cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
02498                 osilreader->readOSiL( osil);
02499                 //cout << osilwriter->writeOSiL( osilreader->readOSiL( osil)) << endl;
02500                 delete osilreader;
02501                 osilreader = 0;
02502                 delete osilwriter;
02503                 osilwriter = NULL;
02504                 finish = clock();
02505                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
02506                 cout << "Parsing took (seconds): "<< duration << endl;
02507                 unitTestResult << "Successful test of OSiL parser on problem parincLinear.osil" << std::endl;
02508                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02509         }       
02510         catch(const ErrorClass& eclass){
02511                 cout << endl << endl << endl;
02512                 cout << eclass.errormsg << endl;
02513                 unitTestResultFailure << "Sorry Unit Test Failed Testing An OSiL Parser" << endl;
02514                 
02515         }       
02516 
02517         //
02518         // Now test the extensions to the OSiL format: <timeDomain>, etc.
02519 
02520         try{ 
02521                 cout << endl << "TEST " << ++nOfTest << ": Stochastic extensions to OSiL" << endl << endl;
02522                 clock_t start, finish;
02523                 double duration;
02524                 OSiLWriter *osilwriter = NULL;
02525                 osilwriter = new OSiLWriter();
02526                 //delete fileUtil;
02527                 //fileUtil = NULL;
02528                 //fileUtil = new FileUtil();
02529                 cout << "\nTEST PARSING A STOCHASTIC MODEL" << endl;
02530                 cout << "FIRST READ THE FILE INTO A STRING" << endl;
02531                 start = clock();
02532                 osilFileName = dataDir  + "osilFiles" + dirsep + "finplan1.osil";
02533                 osil = fileUtil->getFileAsString( &osilFileName[0]);
02534                 finish = clock();
02535                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
02536                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
02537                 OSiLReader *osilreader = NULL;
02538                 osilreader = new OSiLReader(); 
02539                 start = clock();
02540                 cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
02541                 osilreader->readOSiL( osil);
02542                 //cout << osilwriter->writeOSiL( osilreader->readOSiL( &osil)) << endl;
02543                 delete osilreader;
02544                 osilreader = 0;
02545                 delete osilwriter;
02546                 osilwriter = NULL;
02547                 finish = clock();
02548                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
02549                 cout << "Parsing took (seconds): "<< duration << endl;
02550                 unitTestResult << "Successful test of OSiL parser on problem finplan1.osil" << std::endl;
02551                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02552         }       
02553         catch(const ErrorClass& eclass){
02554                 cout << endl << endl << endl;
02555                 cout << eclass.errormsg << endl;
02556                 unitTestResultFailure << "Error parsing an osil file with time domain information" << endl;             
02557         }       
02561         try{ 
02562                 cout << endl << "TEST " << ++nOfTest << ": GET() AND SET() METHODS FOR TimeDomain OBJECT" << endl << endl;
02563                 OSInstance *osinstance = NULL;
02564                 //osinstance = new OSInstance();
02565                 //OSiLReader *osilreader = NULL;
02566                 osilreader = new OSiLReader();
02567                 //create an osinstance
02568                 osinstance = osilreader->readOSiL( osil);
02569                 std::string f = osinstance->getTimeDomainFormat();
02570                 ok = (f == "stages");
02571                 int n = osinstance->getTimeDomainStageNumber();
02572                 ok &= (n == 6);
02573 
02574                 std::string* sncheck = new std::string[6];
02575                 sncheck[0] = "";
02576                 sncheck[1] = "";
02577                 sncheck[2] = "";
02578                 sncheck[3] = "test";
02579                 sncheck[4] = "Wha'zzup?";
02580                 sncheck[5] = "";
02581 
02582                 std::string* sn = osinstance->getTimeDomainStageNames();
02583 
02584                 for (int i = 0; i < 6; i++)
02585                         ok &= (sn[i] == sncheck[i]);
02586 
02587                 int* nv = osinstance->getTimeDomainStageNumberOfVariables();
02588 
02589                 int* nvcheck = new int[6];
02590                 nvcheck[0] = 2;
02591                 nvcheck[1] = 2;
02592                 nvcheck[2] = 0;
02593                 nvcheck[3] = 0;
02594                 nvcheck[4] = 2;
02595                 nvcheck[5] = 2;
02596 
02597                 for (int i = 0; i < 6; i++)
02598                         ok &= (nv[i] == nvcheck[i]);
02599 
02600                 int* nc = osinstance->getTimeDomainStageNumberOfConstraints();
02601 
02602                 int* nccheck = new int[6];
02603                 nccheck[0] = 1;
02604                 nccheck[1] = 1;
02605                 nccheck[2] = 0;
02606                 nccheck[3] = 0;
02607                 nccheck[4] = 1;
02608                 nccheck[5] = 1;
02609 
02610                 for (int i = 0; i < 6; i++)
02611                         ok &= (nc[i] == nccheck[i]);
02612 
02613                 int* no = osinstance->getTimeDomainStageNumberOfObjectives();
02614 
02615                 int* nocheck = new int[6];
02616                 nocheck[0] = 1;
02617                 nocheck[1] = 1;
02618                 nocheck[2] = 1;
02619                 nocheck[3] = 0;
02620                 nocheck[4] = 1;
02621                 nocheck[5] = 1;
02622 
02623                 for (int i = 0; i < 6; i++)
02624                         ok &= (no[i] == nocheck[i]);
02625 
02626                 int** lv = osinstance->getTimeDomainStageVarList();
02627                 int** lc = osinstance->getTimeDomainStageConList();
02628                 int** lo = osinstance->getTimeDomainStageObjList();
02629 
02630                 int** lvcheck = new int*[6];
02631                 int** lccheck = new int*[6];
02632                 int** locheck = new int*[6];
02633                 for (int i = 0; i < 6; i++) {
02634                         lvcheck[i] = new int[2];
02635                         lccheck[i] = new int[2];
02636                         locheck[i] = new int[2];
02637                 };
02638                 lvcheck[0][0] = 0;
02639                 lvcheck[0][1] = 1;
02640                 lvcheck[1][0] = 2;
02641                 lvcheck[1][1] = 3;
02642                 lvcheck[4][0] = 4;
02643                 lvcheck[4][1] = 5;
02644                 lvcheck[5][0] = 6;
02645                 lvcheck[5][1] = 7;
02646                 lccheck[0][0] = 0;
02647                 lccheck[1][0] = 1;
02648                 lccheck[4][0] = 2;
02649                 lccheck[5][0] = 3;
02650                 locheck[0][0] = -1;
02651                 locheck[1][0] = -1;
02652                 locheck[2][0] = -1;
02653                 locheck[4][0] = -1;
02654                 locheck[5][0] = -1;
02655 
02656                 for (int i = 0; i < 6; i++) {
02657                         for (int j = 0; j < nv[i]; j++) 
02658                                 ok &= (lvcheck[i][j] == lv[i][j]);
02659                         for (int j = 0; j < nc[i]; j++) 
02660                                 ok &= (lccheck[i][j] == lc[i][j]);
02661                         for (int j = 0; j < no[i]; j++) 
02662                                 ok &= (locheck[i][j] == lo[i][j]);
02663                 };
02664 
02665                 std::string* sn1 = new std::string[6];
02666                 int* nv1 = new int[6];
02667                 int* nc1 = new int[6];
02668                 int* no1 = new int[6];
02669                 int** lv1 = new int*[6];
02670                 int** lc1 = new int*[6];
02671                 int** lo1 = new int*[6];
02672                 for (int i = 0; i < 6; i++) {
02673                         lv1[i] = new int[2];
02674                         lc1[i] = new int[2];
02675                         lo1[i] = new int[2];
02676                 };
02677                 for (int i = 0; i < 6; i++) {
02678                         sn1[i] = sn[i];
02679                         nv1[i] = nv[i];
02680                         nc1[i] = nc[i];
02681                         no1[i] = no[i];
02682                         for (int j = 0; j < nv[i]; j++) {
02683                                 lv1[i][j] = lv[i][j];
02684                         };
02685                         for (int j = 0; j < nc[i]; j++) {
02686                                 lc1[i][j] = lc[i][j];
02687                         };
02688                         for (int j = 0; j < no[i]; j++) {
02689                                 lo1[i][j] = lo[i][j];
02690                         };
02691                 };
02692 
02693                 ok &= osinstance->setTimeDomain("none");
02694                 n = 0;
02695                 ok &= osinstance->setTimeDomainStages(n,NULL);
02696                 ok &= osinstance->setTimeDomainStages(4,NULL);
02697 
02698                 n = osinstance->getTimeDomainStageNumber();
02699                 ok &= (n == 4);
02700 
02701                 int *nelem, *startIdx, **VI;
02702                 nelem = new int[4];
02703                 startIdx = new int[4];
02704                 VI = new int*[4];
02705                 for (int i = 0; i < 4; i++)
02706                 {       nelem[i] = 2;
02707                         startIdx[i] = 2*i;
02708                         VI[i] = new int[2];
02709                         VI[i][0] = 2*i;
02710                         VI[i][1] = 2*i + 1;
02711                 };
02712                 ok &= osinstance->setTimeDomainStageVariablesUnordered(4,nelem,VI);
02713 
02714                 for (int i = 0; i < 4; i++)
02715                 {       nelem[i] = 1;
02716                         startIdx[i] = i;
02717                 };
02718                 ok &= osinstance->setTimeDomainStageConstraintsOrdered(4,nelem,startIdx);
02719 
02720                 for (int i = 0; i < 4; i++)
02721                 {       nelem[i] = 1;
02722                         startIdx[i] = -1;
02723                 };
02724                 ok &= osinstance->setTimeDomainStageObjectivesOrdered(4,nelem,startIdx);
02725 
02726                 ok &= osinstance->setTimeDomain("none");
02727 
02728                 ok &= osinstance->setTimeDomain("interval");
02729 
02730                 ok &= osinstance->setTimeDomainInterval(0.0, 1.0);
02731                 double lower = osinstance->getTimeDomainIntervalStart();
02732                 ok &= (lower == 0.0);
02733                 double upper = osinstance->getTimeDomainIntervalHorizon();
02734                 ok &= (upper == 1.0);
02735 
02736                 ok &= osinstance->setTimeDomain("none");
02737 
02738                 ok &= osinstance->setTimeDomainStages(6,sncheck);
02739                 ok &= osinstance->setTimeDomainStageVariablesUnordered(6,nvcheck,lvcheck);
02740                 ok &= osinstance->setTimeDomainStageObjectivesUnordered(6,nocheck,locheck);
02741                 ok &= osinstance->setTimeDomainStageConstraintsUnordered(6,nccheck,lccheck);
02742                 int n2 = osinstance->getTimeDomainStageNumber();
02743                 ok &= (n2 == 6);
02744                 std::string* sn2 = osinstance->getTimeDomainStageNames();
02745                 int* nv2 = osinstance->getTimeDomainStageNumberOfVariables();
02746                 int* nc2 = osinstance->getTimeDomainStageNumberOfConstraints();
02747                 int* no2 = osinstance->getTimeDomainStageNumberOfObjectives();
02748                 int** lv2 = osinstance->getTimeDomainStageVarList();
02749                 int** lc2 = osinstance->getTimeDomainStageConList();
02750                 int** lo2 = osinstance->getTimeDomainStageObjList();
02751                 for (int i = 0; i < n2; i++)
02752                 {       ok &= (sn2[i] == sncheck[i]);
02753                         ok &= (nv2[i] == nvcheck[i]);
02754                         ok &= (nc2[i] == nccheck[i]);
02755                         ok &= (no2[i] == nocheck[i]);
02756                         for (int j = 0; j < nv2[i]; j++)
02757                                 ok &= (lv2[i][j] == lvcheck[i][j]);
02758                         for (int j = 0; j < nc2[i]; j++)
02759                                 ok &= (lc2[i][j] == lccheck[i][j]);
02760                         for (int j = 0; j < no2[i]; j++)
02761                                 ok &= (lo2[i][j] == locheck[i][j]);
02762                 };
02763                 delete [] sncheck;
02764                 sncheck = NULL;
02765                 delete [] nvcheck;
02766                 nvcheck = NULL;
02767                 delete [] nccheck;
02768                 nccheck = NULL;
02769                 delete [] nocheck;
02770                 nocheck = NULL;
02771                 for (int i = 0; i < 6; i++) {
02772                         delete [] lvcheck[i];
02773                         delete [] lccheck[i];
02774                         delete [] locheck[i];
02775                         delete [] lv1[i];
02776                         delete [] lc1[i];
02777                         delete [] lo1[i];
02778                 };
02779                 delete [] lvcheck;
02780                 lvcheck = NULL;
02781                 delete [] lccheck;
02782                 lccheck = NULL;
02783                 delete [] locheck;
02784                 locheck = NULL;
02785                 delete [] lv1;
02786                 lv1 = NULL;
02787                 delete [] lc1;
02788                 lc1 = NULL;
02789                 delete [] lo1;
02790                 lo1 = NULL;
02791                 delete [] sn1;
02792                 sn1 = NULL;
02793                 delete[] nv1;
02794                 nv1 = NULL;
02795                 delete[] nc1;
02796                 nc1 = NULL;
02797                 delete[] no1;
02798                 no1 = NULL;
02799                 delete [] nelem;
02800                 nelem = NULL;
02801                 delete [] startIdx;
02802                 startIdx = NULL;
02803                 for (int i = 0; i < 4; i++) {
02804                         delete [] VI[i];
02805                 };
02806                 delete [] VI;
02807                 VI = NULL;
02808                 delete osilreader;
02809                 unitTestResult << "Successful test of osinstance get() and set() methods" << std::endl;
02810                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
02811         }       
02812         catch(const ErrorClass& eclass){
02813                 cout << endl << endl << endl;
02814                 cout << eclass.errormsg << endl;
02815                 unitTestResultFailure << "Sorry Unit Test Failed osinstance get() and set() Methods" << endl;           
02816         }       
02817 
02818         //
02819         // Now test the OSoL parser
02820         OSoLWriter *osolwriter = NULL;
02821 //      OSoLReader *osolreader = NULL;
02822         //osolwriter = new OSoLWriter();
02823         //osolreader = new OSoLReader();
02824 
02825         try{ 
02839                 cout << endl << "TEST " << ++nOfTest << ": OSoL parser" << endl << endl;
02840                 std::string tmpOSoL;
02841                 clock_t start, finish;
02842                 double duration;
02843                 osolwriter = new OSoLWriter();
02844                 osolreader = new OSoLReader();
02845                 OSOption *osoption = NULL;
02846                 //osoption = new OSOption(); 
02847                 cout << "TEST PARSING AN OSoL FILE" << endl;
02848                 cout << "FIRST READ THE OSoL FILE INTO A STRING" << endl;
02849                 osolFileName = dataDir  + "osolFiles" + dirsep + "parsertest.osol"; 
02850                 start = clock();
02851                 std::string osol = fileUtil->getFileAsString( osolFileName.c_str() );
02852                 finish = clock();
02853                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
02854                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
02855                 start = clock();
02856                 cout << "PARSE THE OSOL STRING INTO AN OSOPTION OBJECT" << endl;
02857                 osoption = osolreader->readOSoL( osol);
02858 
02859                 //Pad all the arrays
02860                 cout << endl << "Test the add() methods" << endl;
02861                 
02862                 ok = osoption->setAnOtherGeneralOption("testing","one","two  three");
02863                 ok = osoption->setOtherSystemOptions(0,NULL) && ok; 
02864                 ok = osoption->setAnOtherSystemOption("Ho Ho Ho","","") && ok;
02865                 ok = osoption->setAnOtherServiceOption("OneMore","Option","To Go") && ok;
02866                 ok = osoption->setAnotherJobDependency("DoReMi") && ok;
02867                 ok = osoption->setAnotherRequiredDirectory("C:\\MSYS") && ok;
02868                 ok = osoption->setAnotherRequiredFile("C:\\MSYS\\junk.tmp") && ok;
02869                 ok = osoption->setAnotherDirectoryToMake("C:\\tempdir") && ok;
02870                 ok = osoption->setAnotherFileToMake("C:\\tempdir\\temp.tmp") && ok;
02871                 ok = osoption->setAnotherInputDirectoryToMove("C:\\tempdir","C:\\OS\\calc",true) && ok;
02872                 ok = osoption->setAnotherInputFileToMove("C:\\OS\\parinc.osil","C:\\OS\\calc\\input.osil",true) && ok;
02873                 ok = osoption->setAnotherOutputFileToMove("C:\\OS\\calc\\putput.osrl","C:\\OS\\parinc.osol",false) && ok;
02874                 ok = osoption->setAnotherOutputDirectoryToMove("C:\\OS\\calc","C:\\OS\\save",false) && ok;
02875                 ok = osoption->setAnotherFileToDelete("C:\\OS\\calc\\input.osil") && ok;
02876                 ok = osoption->setAnotherDirectoryToDelete("C:\\tempdir") && ok;
02877                 ok = osoption->setAnotherProcessToKill("ABC123") && ok;
02878                 ok = osoption->setAnOtherJobOption("DoReMi","ABC","One Two Three") && ok;
02879                 ok = osoption->setAnotherInitVarValue(5,12.3) && ok;
02880                 ok = osoption->setAnotherInitVarValueString(6,"BLUE") && ok;
02881                 ok = osoption->setAnotherInitBasisStatus(6,"unknown") && ok;
02882                 ok = osoption->setAnotherIntegerVariableBranchingWeight(5,100.) && ok;
02883 
02884                 int SOS3idx[2];
02885                 double SOS3val[2];
02886                 SOS3idx[0] = 3;
02887                 SOS3idx[1] = 6;
02888                 SOS3val[0] = 1.0;
02889                 SOS3val[1] = 2.0;
02890                 int tnvar;
02891                 tnvar = osoption->getNumberOfSOS(); 
02892                 ok = osoption->setAnotherSOSVariableBranchingWeight(3,2,1.0,SOS3idx,SOS3val) && ok;
02893                 assert (osoption->getNumberOfSOS() == (tnvar + 1));
02894                 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[0]->idx == 3);
02895                 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[1]->idx == 6);
02896                 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[0]->value == 1.0);
02897                 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[1]->value == 2.0);
02898 #ifdef DEBUG
02899                 cout << endl << "another SOS has been added" << endl << endl;
02900 #endif
02901 
02902                 OtherVariableOption *varopt;
02903                 varopt = new OtherVariableOption();
02904                 varopt->name = "testVarOpt";
02905                 varopt->numberOfVar = 0;
02906                 ok = osoption->setAnOtherVariableOption(varopt) && ok;
02907                 delete varopt;
02908                 varopt = NULL;
02909 
02910                 OtherObjectiveOption *objopt;
02911                 objopt = new OtherObjectiveOption();
02912                 objopt->name = "testObjOpt";
02913                 objopt->numberOfObj = 0;
02914                 ok = osoption->setAnOtherObjectiveOption(objopt) && ok;
02915                 delete objopt;
02916                 objopt = NULL;
02917 
02918                 ok = osoption->setAnotherInitConValue(2,17.0) && ok;
02919                 ok = osoption->setAnotherInitDualVarValue(2,0.0,DBL_MAX) && ok;
02920 
02921                 OtherConstraintOption *conopt;
02922                 conopt = new OtherConstraintOption();
02923                 conopt->name = "testObjOpt";
02924                 conopt->numberOfCon = 2;
02925                 conopt->con = new OtherConOption*[2];
02926                 conopt->con[0] = new OtherConOption();
02927                 conopt->con[0]->idx = 0;
02928                 conopt->con[0]->value = "3.0";
02929                 conopt->con[1] = new OtherConOption();
02930                 conopt->con[1]->idx = 1;
02931                 conopt->con[1]->lbValue = "0.0";
02932                 conopt->con[1]->ubValue = "10.0";
02933                 ok = osoption->setAnOtherConstraintOption(conopt) && ok;
02934                 delete conopt;
02935                 conopt = NULL;
02936 
02937                 ok = osoption->setAnotherSolverOption("HoHum","gus","PhoNY","","test","") && ok;
02938 
02939                 if (!ok)
02940                         throw ErrorClass(" Could not add to osoption data structure");
02941 
02942                 //Now transfer to another osoption using get() and set() methods
02943                 std::string optionstring;
02944                 int option_i;
02945                 double option_d;
02946                 OSOption* osoption2 = new OSOption();
02947 
02948                 cout << endl << "transfer osoption to another OSOption object" << endl;
02949 
02950                 optionstring = osoption->getServiceURI();
02951                 ok = osoption2->setServiceURI(optionstring);
02952 #ifdef DEBUG
02953                 if (!ok)
02954                         throw ErrorClass(" error in get/set ServiceURI");
02955 #endif
02956 
02957                 optionstring = osoption->getServiceName();
02958                 ok = osoption2->setServiceName(optionstring) && ok;
02959 #ifdef DEBUG
02960                 if (!ok)
02961                         throw ErrorClass(" error in get/set ServiceName");
02962 #endif
02963 
02964                 optionstring = osoption->getInstanceName();
02965                 ok = osoption2->setInstanceName(optionstring) && ok;
02966 #ifdef DEBUG
02967                 if (!ok)
02968                         throw ErrorClass(" error in get/set InstanceName");
02969 #endif
02970 
02971                 optionstring = osoption->getInstanceLocation();
02972                 ok = osoption2->setInstanceLocation(optionstring) && ok;
02973 #ifdef DEBUG
02974                 if (!ok)
02975                         throw ErrorClass(" error in get/set InstanceLocation");
02976 #endif
02977 
02978                 optionstring = osoption->getInstanceLocationType();
02979                 ok = osoption2->setInstanceLocationType(optionstring) && ok;
02980 #ifdef DEBUG
02981                 if (!ok)
02982                         throw ErrorClass(" error in get/set InstanceLocationtype");
02983 #endif
02984 
02985                 optionstring = osoption->getJobID();
02986                 ok = osoption2->setJobID(optionstring) && ok;
02987 #ifdef DEBUG
02988                 if (!ok)
02989                         throw ErrorClass(" error in get/set JobID");
02990 #endif
02991 
02992                 optionstring = osoption->getSolverToInvoke();
02993                 ok = osoption2->setSolverToInvoke(optionstring) && ok;
02994 #ifdef DEBUG
02995                 if (!ok)
02996                         throw ErrorClass(" error in get/set SolverToInvoke");
02997 #endif
02998 
02999                 optionstring = osoption->getInstanceLocationType();
03000                 ok = osoption2->setInstanceLocationType(optionstring) && ok;
03001 #ifdef DEBUG
03002                 if (!ok)
03003                         throw ErrorClass(" error in get/set InstanceLocationType");
03004 #endif
03005 
03006                 optionstring = osoption->getUserName();
03007                 ok = osoption2->setUserName(optionstring) && ok;
03008 #ifdef DEBUG
03009                 if (!ok)
03010                         throw ErrorClass(" error in get/set UserName");
03011 #endif
03012 
03013                 optionstring = osoption->getPassword();
03014 #ifdef DEBUG
03015                 if (!ok)
03016                         throw ErrorClass(" error in get/set Password");
03017 #endif
03018                 ok = osoption2->setPassword(optionstring) && ok;
03019 
03020                 optionstring = osoption->getContact();
03021                 ok = osoption2->setContact(optionstring) && ok;
03022 #ifdef DEBUG
03023                 if (!ok)
03024                         throw ErrorClass(" error in get/set Contact");
03025 #endif
03026                 
03027                 optionstring = osoption->getContactTransportType();
03028                 ok = osoption2->setContactTransportType(optionstring) && ok;
03029 #ifdef DEBUG
03030                 if (!ok)
03031                         throw ErrorClass(" error in get/set TransportType");
03032 #endif
03033 
03034                 int nopt;
03035                 OtherOption** otherOpt;
03036                 nopt = osoption->getNumberOfOtherGeneralOptions();
03037                 otherOpt = osoption->getOtherGeneralOptions();
03038                 ok = osoption2->setOtherGeneralOptions(nopt, otherOpt) && ok;
03039 #ifdef DEBUG
03040                 if (!ok)
03041                         throw ErrorClass(" error in get/set OtherGeneralOption");
03042 #endif
03043 
03044                 option_d = osoption->getMinDiskSpace();
03045                 ok = osoption2->setMinDiskSpace(option_d) && ok;
03046 #ifdef DEBUG
03047                 if (!ok)
03048                         throw ErrorClass(" error in get/set MinDiskSpace");
03049 #endif
03050 
03051                 optionstring = osoption->getMinDiskSpaceUnit();
03052                 ok = osoption2->setMinDiskSpaceUnit(optionstring) && ok;
03053 #ifdef DEBUG
03054                 if (!ok)
03055                         throw ErrorClass(" error in get/set MinDiskSpaceUnit");
03056 #endif
03057 
03058                 option_d = osoption->getMinMemorySize();
03059                 ok = osoption2->setMinMemorySize(option_d) && ok;
03060 #ifdef DEBUG
03061                 if (!ok)
03062                         throw ErrorClass(" error in get/set MinMemorySize");
03063 #endif
03064 
03065                 optionstring = osoption->getMinMemoryUnit();
03066                 ok = osoption2->setMinMemoryUnit(optionstring) && ok;
03067 #ifdef DEBUG
03068                 if (!ok)
03069                         throw ErrorClass(" error in get/set MinMemoryUnit");
03070 #endif
03071 
03072                 option_d = osoption->getMinCPUSpeed();
03073                 ok = osoption2->setMinCPUSpeed(option_d) && ok;
03074 #ifdef DEBUG
03075                 if (!ok)
03076                         throw ErrorClass(" error in get/set MinCPUSpeed");
03077 #endif
03078 
03079                 optionstring = osoption->getMinCPUSpeedUnit();
03080                 ok = osoption2->setMinCPUSpeedUnit(optionstring) && ok;
03081 #ifdef DEBUG
03082                 if (!ok)
03083                         throw ErrorClass(" error in get/set MinCPUSpeedUnit");
03084 #endif
03085 
03086                 option_i = osoption->getMinCPUNumber();
03087                 ok = osoption2->setMinCPUNumber(option_i) && ok;
03088 #ifdef DEBUG
03089                 if (!ok)
03090                         throw ErrorClass(" error in get/set MinCPUNumber");
03091 #endif
03092 
03093                 OtherOption** otherOpt2;
03094                 nopt = osoption->getNumberOfOtherSystemOptions();
03095                 otherOpt2 = osoption->getOtherSystemOptions();
03096                 ok = osoption2->setOtherSystemOptions(nopt, otherOpt2) && ok;
03097 #ifdef DEBUG
03098                 if (!ok)
03099                         throw ErrorClass(" error in get/set OtherSystemOptions");
03100 #endif
03101 
03102 
03103                 optionstring = osoption->getServiceType();
03104                 ok = osoption2->setServiceType(optionstring) && ok;
03105 #ifdef DEBUG
03106                 if (!ok)
03107                         throw ErrorClass(" error in get/set ServiceType");
03108 #endif
03109 
03110                 OtherOption** otherOpt3;
03111                 nopt = osoption->getNumberOfOtherServiceOptions();
03112                 otherOpt3 = osoption->getOtherServiceOptions();
03113                 ok = osoption2->setOtherServiceOptions(nopt, otherOpt3) && ok;
03114 #ifdef DEBUG
03115                 if (!ok)
03116                         throw ErrorClass(" error in get/set OtherServiceOptions");
03117 #endif
03118 
03119 
03120                 option_d = osoption->getMaxTime();
03121                 ok = osoption2->setMaxTime(option_d) && ok;
03122 #ifdef DEBUG
03123                 if (!ok)
03124                         throw ErrorClass(" error in get/set MaxTime");
03125 #endif
03126 
03127                 optionstring = osoption->getMaxTimeUnit();
03128                 ok = osoption2->setMaxTimeUnit(optionstring) && ok;
03129 #ifdef DEBUG
03130                 if (!ok)
03131                         throw ErrorClass(" error in get/set MaxTimeUnit");
03132 #endif
03133 
03134                 optionstring = osoption->getRequestedStartTime();
03135                 ok = osoption2->setRequestedStartTime(optionstring) && ok;
03136 #ifdef DEBUG
03137                 if (!ok)
03138                         throw ErrorClass(" error in get/set RequestedStartTime");
03139 #endif
03140 
03141                 nopt = osoption->getNumberOfJobDependencies();
03142                 std::string* tJobID = osoption->getJobDependencies();
03143                 ok = osoption2->setJobDependencies(nopt, tJobID) && ok;
03144 #ifdef DEBUG
03145                 if (!ok)
03146                         throw ErrorClass(" error in get/set JobDependencies");
03147 #endif
03148 
03149                 nopt = osoption->getNumberOfRequiredDirectories();
03150                 std::string* reqDir = osoption->getRequiredDirectories();
03151                 ok = osoption2->setRequiredDirectories(nopt, reqDir) && ok;
03152 #ifdef DEBUG
03153                 if (!ok)
03154                         throw ErrorClass(" error in get/set RequiredDirectories");
03155 #endif
03156 
03157                 nopt = osoption->getNumberOfRequiredFiles();
03158                 std::string* reqFil = osoption->getRequiredFiles();
03159                 ok = osoption2->setRequiredFiles(nopt, reqFil) && ok;
03160 #ifdef DEBUG
03161                 if (!ok)
03162                         throw ErrorClass(" error in get/set RequiredFiles");
03163 #endif
03164 
03165                 nopt = osoption->getNumberOfDirectoriesToMake();
03166                 std::string* mkDir = osoption->getDirectoriesToMake();
03167                 ok = osoption2->setDirectoriesToMake(nopt, mkDir) && ok;
03168 #ifdef DEBUG
03169                 if (!ok)
03170                         throw ErrorClass(" error in get/set DirectoriesToMake");
03171 #endif
03172 
03173                 nopt = osoption->getNumberOfFilesToMake();
03174                 std::string* mkFil = osoption->getFilesToMake();
03175                 ok = osoption2->setFilesToMake(nopt, mkFil) && ok;
03176 #ifdef DEBUG
03177                 if (!ok)
03178                         throw ErrorClass(" error in get/set FilesToMake");
03179 #endif
03180 
03181                 nopt = osoption->getNumberOfInputDirectoriesToMove();
03182                 PathPair** inDMv = osoption->getInputDirectoriesToMove();
03183                 ok = osoption2->setInputDirectoriesToMove(nopt, inDMv) && ok;
03184 #ifdef DEBUG
03185                 if (!ok)
03186                         throw ErrorClass(" error in get/set InputDirectoriesToMove");
03187 #endif
03188 
03189                 nopt = osoption->getNumberOfInputFilesToMove();
03190                 PathPair** inFMv = osoption->getInputFilesToMove();
03191                 ok = osoption2->setInputFilesToMove(nopt, inFMv) && ok;
03192 #ifdef DEBUG
03193                 if (!ok)
03194                         throw ErrorClass(" error in get/set InputFilesToMove");
03195 #endif
03196 
03197                 nopt = osoption->getNumberOfOutputFilesToMove();
03198                 PathPair** outFMv = osoption->getOutputFilesToMove();
03199                 ok = osoption2->setOutputFilesToMove(nopt, outFMv) && ok;
03200 #ifdef DEBUG
03201                 if (!ok)
03202                         throw ErrorClass(" error in get/set OutputFilesToMove");
03203 #endif
03204 
03205                 nopt = osoption->getNumberOfOutputDirectoriesToMove();
03206                 PathPair** outDMv = osoption->getOutputDirectoriesToMove();
03207                 ok = osoption2->setOutputDirectoriesToMove(nopt, outDMv) && ok;
03208 #ifdef DEBUG
03209                 if (!ok)
03210                         throw ErrorClass(" error in get/set OutputDirectoriesToMove");
03211 #endif
03212 
03213                 nopt = osoption->getNumberOfFilesToDelete();
03214                 std::string* rmFil = osoption->getFilesToDelete();
03215                 ok = osoption2->setFilesToDelete(nopt, rmFil) && ok;
03216 #ifdef DEBUG
03217                 if (!ok)
03218                         throw ErrorClass(" error in get/set FilesToDelete");
03219 #endif
03220 
03221                 nopt = osoption->getNumberOfDirectoriesToDelete();
03222                 std::string* rmDir = osoption->getDirectoriesToDelete();
03223                 ok = osoption2->setDirectoriesToDelete(nopt, rmDir) && ok;
03224 #ifdef DEBUG
03225                 if (!ok)
03226                         throw ErrorClass(" error in get/set DirectoriesToDelete");
03227 #endif
03228 
03229                 nopt = osoption->getNumberOfProcessesToKill();
03230                 std::string* rmProc = osoption->getProcessesToKill();
03231                 ok = osoption2->setProcessesToKill(nopt, rmProc) && ok;
03232 #ifdef DEBUG
03233                 if (!ok)
03234                         throw ErrorClass(" error in get/set ProcessesToKill");
03235 #endif
03236 
03237                 OtherOption** otherOpt4;
03238                 nopt = osoption->getNumberOfOtherJobOptions();
03239                 otherOpt4 = osoption->getOtherJobOptions();
03240                 ok = osoption2->setOtherJobOptions(nopt, otherOpt4) && ok;
03241 #ifdef DEBUG
03242                 if (!ok)
03243                         throw ErrorClass(" error in get/set OtherJobOptions");
03244 #endif
03245 
03246                 int nvar, nobj, ncon;
03247                 //nvar = osoption->getOptionInt("numberOfVariables");
03248                 //ok = osoption2->setNumberOfVariables(nvar) && ok;
03249                 //nobj = osoption->getOptionInt("numberOfObjectives");
03250                 //ok = osoption2->setNumberOfObjectives(nobj) && ok;
03251                 //ncon = osoption->getOptionInt("numberOfConstraints");
03252                 //ok = osoption2->setNumberOfConstraints(ncon) && ok;
03253                 // eliminate references to numberOfVariables
03254                 nvar = 10; 
03255                 nobj = 1; 
03256                 ncon = 4; 
03257 #ifdef DEBUG
03258                 if (!ok)
03259                         throw ErrorClass(" error in get/set problem dimensions");
03260 #endif
03261  
03262 // for the variables, objectives and constraints use a mixture of dense and sparse methods
03263                 double* IVV;
03264                 IVV = osoption->getInitVarValuesDense(nvar);
03265                 ok = osoption2->setInitVarValuesDense(nvar, IVV) && ok;
03266 #ifdef DEBUG
03267                 if (!ok)
03268                         throw ErrorClass(" error in get/set InitVarValues");
03269 #endif
03270 
03271                 nopt = osoption->getNumberOfInitVarValuesString();
03272                 InitVarValueString** IVV2;
03273                 IVV2 = osoption->getInitVarValuesStringSparse();
03274                 ok = osoption2->setInitVarValuesStringSparse(nopt, IVV2) && ok;         
03275 #ifdef DEBUG
03276                 if (!ok)
03277                         throw ErrorClass(" error in get/set InitVarValuesString");
03278 #endif
03279 
03280                 std::string*  IBS;
03281                 IBS = osoption->getInitBasisStatusDense(nvar);
03282                 ok = osoption2->setInitBasisStatusDense(nvar, IBS) && ok;               
03283 #ifdef DEBUG
03284                 if (!ok)
03285                         throw ErrorClass(" error in get/set InitBasisStatus");
03286 #endif
03287 
03288                 double* IVBW;
03289                 IVBW = osoption->getIntegerVariableBranchingWeightsDense(nvar);
03290                 ok = osoption2->setIntegerVariableBranchingWeightsDense(nvar, IVBW) && ok;              
03291 #ifdef DEBUG
03292                 if (!ok)
03293                         throw ErrorClass(" error in get/set IntegerVariableBranchingWeights");
03294 #endif
03295 
03296                 SOSWeights** sos;
03297                 sos = osoption->getSOSVariableBranchingWeightsSparse();
03298                 nopt = osoption->getNumberOfSOS();
03299                 ok = osoption2->setSOSVariableBranchingWeights(nopt, sos) && ok;
03300 #ifdef DEBUG
03301                 if (!ok)
03302                         throw ErrorClass(" error in get/set SOSVariableBranchingWeights");
03303 #endif
03304 
03305                 OtherVariableOption** otherV;
03306                 otherV = osoption->getAllOtherVariableOptions();
03307                 nopt = osoption->getNumberOfOtherVariableOptions();
03308                 ok = osoption2->setOtherVariableOptions(nopt, otherV) && ok;
03309 #ifdef DEBUG
03310                 if (!ok)
03311                         throw ErrorClass(" error in get/set OtherVariableOptions");
03312 #endif
03313 
03314                 double* IOV;
03315                 IOV = osoption->getInitObjValuesDense(nobj);
03316                 ok = osoption2->setInitObjValuesDense(nobj, IOV) && ok;         
03317 #ifdef DEBUG
03318                 if (!ok)
03319                         throw ErrorClass(" error in get/set InitObjValues");
03320 #endif
03321 
03322                 nopt = osoption->getNumberOfInitObjBounds();
03323                 InitObjBound** IOB;
03324                 IOB = osoption->getInitObjBoundsSparse();
03325                 ok = osoption2->setInitObjBoundsSparse(nopt, IOB) && ok;                
03326 #ifdef DEBUG
03327                 if (!ok)
03328                         throw ErrorClass(" error in get/set InitObjBounds");
03329 #endif
03330 
03331                 OtherObjectiveOption** otherO;
03332                 otherO = osoption->getAllOtherObjectiveOptions();
03333                 nopt = osoption->getNumberOfOtherObjectiveOptions();
03334                 ok = osoption2->setOtherObjectiveOptions(nopt, otherO) && ok;
03335 #ifdef DEBUG
03336                 if (!ok)
03337                         throw ErrorClass(" error in get/set OtherObjectiveOptions");
03338 #endif
03339 
03340                 
03341                 double* ICV;
03342                 ICV = osoption->getInitConValuesDense(ncon);
03343                 ok = osoption2->setInitConValuesDense(ncon, ICV) && ok;         
03344 #ifdef DEBUG
03345                 if (!ok)
03346                         throw ErrorClass(" error in get/set InitConValues");
03347 #endif
03348 
03349                 nopt = osoption->getNumberOfInitDualVarValues();
03350                 InitDualVarValue** IDV;
03351                 IDV = osoption->getInitDualVarValuesSparse();
03352                 ok = osoption2->setInitDualVarValuesSparse(nopt, IDV) && ok;            
03353 #ifdef DEBUG
03354                 if (!ok)
03355                         throw ErrorClass(" error in get/set InitDualVarValues");
03356 #endif
03357 
03358                 OtherConstraintOption** otherC;
03359                 otherC = osoption->getAllOtherConstraintOptions();
03360                 nopt = osoption->getNumberOfOtherConstraintOptions();
03361                 ok = osoption2->setOtherConstraintOptions(nopt, otherC) && ok;
03362 #ifdef DEBUG
03363                 if (!ok)
03364                         throw ErrorClass(" error in get/set OtherConstraintOptions");
03365 #endif
03366 
03367                 SolverOption** SO;
03368                 SO = osoption->getAllSolverOptions();
03369                 nopt = osoption->getNumberOfSolverOptions();
03370                 ok = osoption2->setSolverOptions(nopt, SO) && ok;
03371 #ifdef DEBUG
03372                 if (!ok)
03373                         throw ErrorClass(" error in get/set SolverOptions");
03374 #endif
03375 
03376                 ok = osoption->IsEqual(osoption2) && ok;
03377                 if (!ok)
03378                         throw ErrorClass(" OSOption get() and  set() methods do not work correctly");
03379 
03380                 cout << endl << "delete osoption2" << endl;
03381                 delete osoption2;
03382                 osoption2 = NULL;
03383                 cout << "osoption2 deleted" << endl << endl;
03384 
03385                 cout << "Write the content to a new file" <<endl;               
03386                 tmpOSoL = osolwriter->writeOSoL( osoption);
03387                 cout << endl << "Here is tmpOSoL:" <<endl;
03388                 cout << endl << endl << tmpOSoL << endl;
03389                 cout << "-----------------------------------------" << endl << endl;
03390 //              delete osolreader;
03391 //              osolreader = NULL;
03392 
03393                 // make sure we can parse without error
03394                 OSoLReader *osolreader2;
03395                 osolreader2 = new OSoLReader();
03396                 cout << "Read the string back" << endl;
03397 
03398                 OSOption *osoption3 = NULL;
03399                 osoption3 = osolreader2->readOSoL( tmpOSoL);
03400 
03401                 ok = osoption->IsEqual(osoption3);
03402                 if (!ok)
03403                         throw ErrorClass(" Loss of information in OSoL write/read");
03404                 delete osolreader2;
03405                 osolreader2 = NULL;
03406 
03407 
03408                 delete osolwriter;
03409                 osolwriter = NULL;
03410                 delete osolreader;
03411                 osolreader = NULL;
03412                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
03413 
03414 
03415                 // now a second example
03416                 cout << endl << "TEST " << ++nOfTest << ": Parse another .osol file" << endl << endl;
03417                 osolwriter = new OSoLWriter();
03418                 osolreader = new OSoLReader();
03419                 cout << "First read the OSoL file into a string" << endl;
03420                 osolFileName = dataDir  + "osolFiles" + dirsep + "parsertest2.osol"; 
03421                 osol = fileUtil->getFileAsString( osolFileName.c_str() );
03422                 finish = clock();
03423                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
03424                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
03425                 cout << "Parse the OSoL string into an OSOption object" << endl;
03426                 osoption = osolreader->readOSoL( osol);
03427                 tmpOSoL = osolwriter->writeOSoL( osoption) ;
03428                 delete osolreader;
03429                 osolreader = NULL;
03430                 osolreader = new OSoLReader();
03431                 osolreader->readOSoL( tmpOSoL);
03432                 delete osolwriter;
03433                 osolwriter = NULL;
03434                 delete osolreader;
03435                 osolreader = NULL;
03436 
03437                 // and a third example
03438                 cout << "Test parsing another OSoL file" << endl;
03439                 osolwriter = new OSoLWriter();
03440                 osolreader = new OSoLReader();
03441                 cout << "First read the OSoL file into a string" << endl;
03442                 osolFileName = dataDir  + "osolFiles" + dirsep + "parsertest3.osol"; 
03443                 osol = fileUtil->getFileAsString( osolFileName.c_str() );
03444                 finish = clock();
03445                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
03446                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
03447                 cout << "Parse the OSoL string into an OSOption object" << endl;
03448                 osoption = osolreader->readOSoL( osol);
03449                 tmpOSoL = osolwriter->writeOSoL( osoption) ;
03450                 delete osolreader;
03451                 osolreader = NULL;
03452                 osolreader = new OSoLReader();
03453                 osolreader->readOSoL( tmpOSoL);
03454                 delete osolwriter;
03455                 osolwriter = NULL;
03456                 delete osolreader;
03457                 osolreader = NULL;
03458 
03459 
03460                 // a trivial string
03461                 cout << "Test parsing a trivial string" << endl;
03462                 osolreader = new OSoLReader();
03463                 osol = "<osol></osol>";
03464                 cout << "Parse the OSoL string into an OSOption object" << endl;
03465                 osoption = osolreader->readOSoL( osol);
03466                 delete osolreader;
03467                 osolreader = NULL;
03468 
03469 
03470                 unitTestResult << 
03471                      "Successful test of OSoL parser on file parsertest.osol" 
03472                       << std::endl;
03473                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
03474 
03475 
03476         }       
03477         
03478         catch(const ErrorClass& eclass){
03479                 cout << endl << endl << endl;
03480                 if(osolwriter != NULL) delete osolwriter;
03481                 if(osolreader != NULL) delete osolreader;
03482                 // " Problem with the test reading OSoL data";
03483                 unitTestResultFailure << eclass.errormsg << endl;
03484                 unitTestResultFailure << "There was a failure in the test for reading OSoL" << endl;
03485         }
03486 
03487 
03488 
03489         //
03490         // Now just test the OSrL parser
03491         try{ 
03500                 cout << endl << "TEST " << ++nOfTest << ": OSrL parser" << endl << endl;
03501                 std::string tmpOSrL;
03502                 clock_t start, finish;
03503                 double duration;
03504                 osrlwriter = new OSrLWriter();
03505                 osrlreader = new OSrLReader();
03506                 OSResult *osresult = NULL;
03507                 //osresult = new OSResult(); 
03508                 cout << "TEST PARSING AN OSrL FILE" << endl;
03509                 cout << "FIRST READ THE OSrL FILE INTO A STRING" << endl;
03510 //              osrlFileName = dataDir  + "osrlFiles" + dirsep + "parincLinear.osrl"; 
03511                 osrlFileName = dataDir  + "osrlFiles" + dirsep + "parserTest.osrl"; 
03512 //              osrlFileName = dataDir  + "osrlFiles" + dirsep + "ipoptResult.osrl"; 
03513                 start = clock();
03514                 std::string osrl = fileUtil->getFileAsString( osrlFileName.c_str() );
03515                 finish = clock();
03516                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
03517                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
03518                 cout << osrl << endl;
03519                 start = clock();
03520                 cout << "PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
03521                 osresult = osrlreader->readOSrL( osrl);
03522                 cout << "Finished read; write OSResult object to temporary string" << endl;
03523 
03524                 tmpOSrL = osrlwriter->writeOSrL( osresult) ;
03525                 cout << tmpOSrL << endl;
03526 
03527 
03528                 // make sure we can parse without error
03529                 delete osrlreader;
03530                 osrlreader = NULL;
03531                 osrlreader = new OSrLReader();
03532                 cout << "Parse temporary string" << endl;
03533                 osrlreader->readOSrL( tmpOSrL);
03534                 delete osrlwriter;
03535                 osrlwriter = NULL;
03536                 delete osrlreader;
03537                 osrlreader = NULL;
03538 /*
03539                 // now a second example
03540                 cout << endl << "TEST PARSING ANOTHER OSrL FILE" << endl;
03541                 osrlwriter = new OSrLWriter();
03542                 osrlreader = new OSrLReader();
03543                 cout << "FIRST READ THE OSrL FILE INTO A STRING" << endl;
03544                 //errorExample.osrl -- check to see if we read an error message correct;
03545                 osrlFileName = dataDir  + "osrlFiles" + dirsep + "errorExample.osrl"; 
03546                 osrl = fileUtil->getFileAsString( osrlFileName.c_str() );
03547                 finish = clock();
03548                 duration = (double) (finish - start) / CLOCKS_PER_SEC;
03549                 cout << "Reading the file into a string took (seconds): "<< duration << endl;
03550                 cout << "PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
03551                 osresult = osrlreader->readOSrL( osrl);
03552                 tmpOSrL = osrlwriter->writeOSrL( osresult) ;
03553                 delete osrlreader;
03554                 osrlreader = NULL;
03555                 osrlreader = new OSrLReader();
03556                 osrlreader->readOSrL( tmpOSrL);
03557                 delete osrlwriter;
03558                 osrlwriter = NULL;
03559                 delete osrlreader;
03560                 osrlreader = NULL;
03561 */
03562                 unitTestResult << 
03563                      "Successful test of OSrL parser on problems parincLinear.osrl and errorExample.osrl" 
03564                       << std::endl;
03565                 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
03566         }       
03567         catch(const ErrorClass& eclass){
03568 
03569                 cout << endl << endl << endl;
03570                 if(osrlwriter != NULL) delete osrlwriter;
03571                 if(osrlreader != NULL) delete osrlreader;
03572                 // " Problem with the test reading OSrL data";
03573                 unitTestResultFailure << eclass.errormsg << endl;
03574                 unitTestResultFailure << "There was a failure in the test for reading OSrL" << endl;
03575         }
03576 
03577 }       // PARSER_TESTS
03578 
03579         delete fileUtil;
03580         fileUtil = NULL;
03581             
03582         if(unitTestResultFailure.str().length() > 0){
03583                 cout << endl << "THE UNIT TEST PASSED THE FOLLOWING:" << endl << endl;
03584                 cout << unitTestResult.str() << endl << endl;
03585                 cout << "UNFORTUNATELY, YOU FAILED ON THE FOLLOWING:" << endl << endl;
03586                 cout << unitTestResultFailure.str() << endl << endl;
03587                 cout << "Conclusion: FAILURE" << endl;
03588                 return 1;
03589         }
03590         else{
03591                 cout << endl << "THE UNIT TEST PASSED THE FOLLOWING:" << endl << endl;
03592                 cout << unitTestResult.str() << endl << endl;
03593                 cout << "All tests completed successfully" <<  endl <<  endl;
03594                 return 0;
03595         }
03596 }//end main
03597 
03598 double getObjVal( std::string osrl){
03599         std::string sObjVal;
03600         double dObjVal;
03601         string::size_type pos2;
03602         string::size_type pos1 = osrl.find( "<obj ");
03603         if(pos1 != std::string::npos){
03604                 // get the end of the obj start tag
03605                 pos1 = osrl.find(">", pos1 + 1);
03606                 if(pos1 != std::string::npos){
03607                         // get the start of obj end tag
03608                         pos2 = osrl.find( "</obj", pos1 + 1);
03609                         if( pos2 != std::string::npos){
03610                                 // get the substring
03611                                 sObjVal = osrl.substr( pos1 + 1, pos2 - pos1 - 1);
03612                                 //std::cout << "HERE IS THE OBJECTIVE FUNCTION VALUE SUBSTRING  " << sObjVal<< std::endl; 
03613                                 // return dObjVal = strtod(sObjVal.c_str(), NULL);
03614                                 return dObjVal = os_strtod(sObjVal.c_str(), NULL); 
03615                         }
03616                         else return OSNAN;
03617                 }
03618                 else return OSNAN;
03619         }
03620         else return OSNAN;
03621 }

Generated on Mon Aug 3 03:02:25 2009 by  doxygen 1.4.7