My Project
unitTest.cpp
Go to the documentation of this file.
1 
104 #define DEBUG
105 //#define INSTALLATION_TEST // minimal functionality test
106 //#define THOROUGH // multiple problems for some solvers
107 #define COMPONENT_DEBUG // program logic, especially parser testing
108 
109 
110 #include <cppad/cppad.hpp>
111 //#include "CoinUtilsConfig.h"
112 #include "OSCoinSolver.h"
113 #include "OSConfig.h"
114 #include "OSmps2osil.h"
115 #include "OSResult.h"
116 #include "OSOption.h"
117 #include "OSiLReader.h"
118 #include "OSiLWriter.h"
119 #include "OSoLReader.h"
120 #include "OSoLWriter.h"
121 #include "OSrLReader.h"
122 #include "OSrLWriter.h"
123 #include "OSInstance.h"
124 #include "OSFileUtil.h"
125 #include "CoinError.hpp"
126 
127 #include "OSDefaultSolver.h"
128 #include "OSWSUtil.h"
129 #include "OSSolverAgent.h"
130 #include "OShL.h"
131 #include "OSErrorClass.h"
132 #include "OSBase64.h"
133 #include "OSCommonUtil.h"
134 #include "OSMathUtil.h"
135 
136 
137 #include <CoinMpsIO.hpp>
138 #include <CoinPackedMatrix.hpp>
139 
140 
141 
142 
143 #ifdef COIN_HAS_GLPK
144 #include <OsiGlpkSolverInterface.hpp>
145 #endif
146 
147 #ifdef COIN_HAS_COUENNE
148 #include "OSCouenneSolver.h"
149 #endif
150 
151 #ifdef COIN_HAS_ASL
152 #include "OSnl2osil.h"
153 #endif
154 
155 #ifdef COIN_HAS_LINDO
156 #include "OSLindoSolver.h"
157 #endif
158 
159 #ifdef COIN_HAS_IPOPT
160 #include "OSIpoptSolver.h"
161 #endif
162 
163 #ifdef COIN_HAS_BONMIN
164 #include "OSBonminSolver.h"
165 #endif
166 
167 
168 
169 
170 #ifdef HAVE_CTIME
171 # include <ctime>
172 #else
173 # ifdef HAVE_TIME_H
174 # include <time.h>
175 # else
176 # error "don't have header file for time"
177 # endif
178 #endif
179 
180 
181 #ifdef HAVE_CMATH
182 # include <cmath>
183 #else
184 # ifdef HAVE_CMATH_H
185 # include <cmath.h>
186 # endif
187 #endif
188 
189 
190 
191 #ifdef HAVE_CSTDIO
192 # include <cstdio>
193 #else
194 # ifdef HAVE_STDIO_H
195 # include <stdio.h>
196 # else
197 # error "don't have header file for stdio"
198 # endif
199 #endif
200 
201 //#ifdef HAVE_WINDOWS_H
202 //#include <windows.h>
203 //#endif
204 
205 using std::cout;
206 using std::endl;
207 using std::ostringstream;
208 
209 
210 
211 
212 int main(int argC, char* argV[])
213 {
214 //#ifdef HAVE_WINDOWS_H
215 // SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
216 //#endif
217  WindowsErrorPopupBlocker();
218  double getObjVal(std::string osrl);
219  //using CppAD::NearEqual;
220  bool ok;
221  double check;
222 
223  //return 0;
224  cout << "START UNIT TEST" << endl;
225  int nOfTest = 0;
226  // define the classes
227  FileUtil *fileUtil = NULL;
228  #ifdef COIN_HAS_ASL
229  OSnl2osil *nl2osil = NULL;
230  #endif
231  OSmps2osil *mps2osil = NULL;
232  DefaultSolver *solver = NULL;
233  OSiLReader *osilreader = NULL;
234  OSoLReader *osolreader = NULL;
235  OSrLReader *osrlreader = NULL;
236  OSrLWriter *osrlwriter = NULL;
237  OSrLWriter *tmp_writer = NULL;
238  // end classes
239  std::string osilFileName;
240  std::string osolFileName;
241  std::string osrlFileName;
242  std::string nlFileName;
243  std::string mpsFileName;
244  std::string osil;
245  std::string osol;
246  ostringstream unitTestResult;
247  ostringstream unitTestResultFailure;
248  // get the input files
249  const char dirsep = CoinFindDirSeparator();
250  // Set directory containing mps data files.
251  std::string dataDir;
252  dataDir = dirsep == '/' ? "../data/" : "..\\data\\";
253  nlFileName = dataDir + "amplFiles" + dirsep + "parinc.nl";
254  mpsFileName = dataDir + "mpsFiles" + dirsep + "parinc.mps";
255  fileUtil = new FileUtil();
256  //
257 
258 #ifdef INSTALLATION_TEST
259 
260  //first make sure we can read files
261  try{
262  std::cout << endl << "TEST " << ++nOfTest << ": Try to read a sample file" << endl << endl;
263  osilFileName = dataDir + "osilFiles" + dirsep + "parincLinearByRow.osil";
264  //osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
265  std::cout << "The file is: " ;
266  std::cout << osilFileName << std::endl;
267  osil = fileUtil->getFileAsString( osilFileName.c_str() );
268  std::cout << "Done reading the test file" << std::endl;
269  osilreader = new OSiLReader();
270  //OSInstance *osinstance = osilreader->readOSiL( osil);
271  //osinstance->initForAlgDiff();
272  unitTestResult << "Reading files successfully" << std::endl;
273  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
274  OSiLWriter osilwriter;
275  osilwriter.m_bWhiteSpace = true;
276  //std::cout << osilwriter.writeOSiL( osinstance) << std::endl;
277  delete osilreader;
278  osilreader = NULL;
279  //cout << "The unitTest passed the following" << endl << endl;
280  //cout << unitTestResult.str() << endl << endl;
281  /*
282  // below is just a bunch of misc. stuff kipp is testing
283  //
284  // Create a problem pointer. We use the base class here.
285  OsiSolverInterface *si, *si2;
286  // When we instantiate the object, we need a specific derived class.
287  si = new OsiCbcSolverInterface;
288  // Read in an mps file. This one's from the MIPLIB library.
289  si->readMps( mpsFileName.c_str());
290  // get the problem
291  // variable upper and lower bounds
292  const double *collb = si->getColLower();
293  const double *colub = si->getColUpper();
294  // constraint upper and lower bound
295  const double *rowlb = si->getRowLower();
296  const double *rowub = si->getRowUpper();
297  //the Coin packed matrix
298  const CoinPackedMatrix *m_CoinPackedMatrix = si->getMatrixByCol();
299  //finally the objective function coefficieCnts
300  const double *objcoef = si->getObjCoefficients();
301  //delete si;
302  si2 = new OsiCbcSolverInterface;
303  std::cout << objcoef[ 0] << std::endl;
304  // now load the problem
305  si2->loadProblem(*m_CoinPackedMatrix, collb, colub, objcoef, rowlb, rowub);
306  // Solve the (relaxation of the) problem
307  //si2->branchAndBound();
308  delete si;
309  delete si2;
310  */
311 
312 
313  cout << endl << "TEST " << ++nOfTest << ": Lossless I/O" << endl << endl;
314  //mpsFileName = dataDir + "mpsFiles" + dirsep + "testfile2.mps";
315  mpsFileName = dataDir + "mpsFiles" + dirsep + "parinc.mps";
316  mps2osil = new OSmps2osil( mpsFileName);
317  // create the first in-memory OSInstance
318  mps2osil->createOSInstance() ;
319  // write the instance to a string
320  OSInstance *osinstance1 = mps2osil->osinstance;
321  std::string sOSiL = osilwriter.writeOSiL( osinstance1 );
322  //cout << sOSiL << endl;
324  // now create a second object
325  osilreader = new OSiLReader();
326  OSInstance *osinstance2 = osilreader->readOSiL( sOSiL);
327  // now compare the elements in the A matrix for the two intances
328  int nvals = osinstance1->instanceData->linearConstraintCoefficients->numberOfValues;
329  double theDiff, theMax;
330  int theIndex = -1;
331  theMax = 0;
332  for(int i = 0; i < nvals; i++){
333  theDiff = fabs(osinstance1->instanceData->linearConstraintCoefficients->value->el[ i] -
334  osinstance2->instanceData->linearConstraintCoefficients->value->el[ i])/ fabs(osinstance1->instanceData->linearConstraintCoefficients->value->el[ i]);
335  if(theDiff > theMax){
336  theMax = theDiff;
337  theIndex = i;
338  }
339  //std::cout << theDiff << std::endl;
340  }
341  std::cout << "MAXIMUM DIFF = " << theMax << std::endl;
342  std::cout << "MAXIMUM DIFF INDEX = " << theIndex << std::endl;
343  if(theMax > 0) unitTestResult << "WARNING: you do not have lossless IO" << std::endl;
344  else
345  { unitTestResult << "Passed lossless IO test" << std::endl;
346  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
347  }
348  delete mps2osil;
349  delete osilreader;
350  osilreader = NULL;
351 
352 
353  //nl2osil = new OSnl2osil( nlFileName);
354  //return 0;
355  /*
356  //using os_dtoa_format
357  MathUtil *mathUtil = new MathUtil();
358  int decimalPoint; // where the decimal point goes
359  int sign; // 1 if negative, 0 if positive
360  double d ;
361  d = -2./3.;
362  //d = 123.4567;
363  d = 1.23456589e-2;
364  d = .00001123;
365  char *result = os_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
366  for(int kj = 5; kj < 9; kj++){
367  d = pow(10. ,kj) + pow(10., (kj-1));
368  //d = 57.7;
369  result =os_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
370  printf("HERE IS THE RESULT %s\n\n", result);
371  printf("HERE IS THE RESULT of sign %d\n\n", sign);
372  printf("HERE IS THE RESULT decimal point %i\n\n", decimalPoint);
373  printf("HERE IS THE LENGTH OF THE RESULT %d\n\n", strlen(result));
374  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format: " << os_dtoa_format( d) << std::endl;
375  }
376  d = .00001123;
377  d = -2./3.;
378  d = 100;
379  result = os_dtoa(DBL_MAX, 0, 0, &decimalPoint, &sign, NULL);
380  printf("HERE IS THE RESULT %s\n\n", result);
381  printf("HERE IS THE RESULT of sign %d\n\n", sign);
382  printf("HERE IS THE RESULT decimal point %i\n\n", decimalPoint);
383  printf("HERE IS THE LENGTH OF THE RESULT %d\n\n", strlen(result));
384  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format: " << os_dtoa_format( OSDBL_MAX) << std::endl;
385  d = .000234;
386  result = os_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
387  printf("HERE IS THE RESULT %s\n\n", result);
388  printf("HERE IS THE RESULT of sign %d\n\n", sign);
389  printf("HERE IS THE RESULT decimal point %i\n\n", decimalPoint);
390  printf("HERE IS THE LENGTH OF THE RESULT %d\n\n", strlen(result));
391  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format: " << os_dtoa_format( d) << std::endl;
392  //
393  char sInput[] = "77.77 99.99";
394  char *pEnd;
395  double d1, d2;
396  d1 = os_strtod (sInput, &pEnd);
397  d2 = os_strtod (pEnd,NULL);
398  std::cout << d1 << std::endl;
399  std::cout << d2 << std::endl;
400 
401  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format OSDBL_MAX: " << os_dtoa_format( OSDBL_MAX) << std::endl;
402  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format OSDBL_MAX: " << OSDBL_MAX << std::endl;
403  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format DBL_MAX: " << os_dtoa_format( DBL_MAX) << std::endl;
404  std::cout << "HERE IS THE RESULT OF OS os_dtoa_format DBL_MAX: " << DBL_MAX << std::endl;
405  d1 = os_strtod(os_dtoa_format( OSDBL_MAX).c_str(), NULL);
406  if(d1 == DBL_MAX )std::cout << "SUCCESS" << endl;
407  else std::cout << "FAILURE" << endl;
408  */
409  }
410  catch(const ErrorClass& eclass){
411  unitTestResultFailure << "Sorry Unit Test Failed Reading a file: " + eclass.errormsg<< endl;
412  //no point continuing we can't even read a file
413  unitTestResultFailure << "Since we can't read files we are terminating" << endl;
414  cout << unitTestResultFailure.str() << endl << endl;
415  cout << "Conclusion: FAILURE" << endl;
416  return 1;
417  }
418 
419  try{
420  cout << endl << "TEST " << ++nOfTest << ": Clp solver on parincLinearByRow.osil" << endl << endl;
421  ok = true;
422  std::cout << "create a new COIN Clp for OSiL string solution" << std::endl;
423  osilFileName = dataDir + "osilFiles" + dirsep + "parincLinearByRow.osil";
424  osolFileName = dataDir + "osolFiles" + dirsep + "parincLinearByRow_clp.osol";
425  osil = fileUtil->getFileAsString( osilFileName.c_str());
426  osol = fileUtil->getFileAsString( osolFileName.c_str());
427 
428  std::cout << "create a new Solver object" << std::endl;
429  osilreader = new OSiLReader();
430  osolreader = new OSoLReader();
431  solver = new CoinSolver();
432  solver->sSolverName = "clp";
433  solver->osinstance = osilreader->readOSiL( osil);
434  std::cout << " Done reading the OSiL" << std::endl;
435  // now write it again as a string
436  OSiLWriter *osilwriter;
437  osilwriter = new OSiLWriter();
438  osilwriter->m_bWhiteSpace = true;
439  std::cout << " Write the OSiL" << std::endl;
440  osil = osilwriter->writeOSiL( solver->osinstance) ;
441  //std::cout << osil << std::endl;
442  std::cout << " Done writing the OSiL" << std::endl;
443  solver->osoption = osolreader->readOSoL( osol);
444  cout << "call the COIN - clp Solver for parincLinearbyRow" << endl;
445  //solver->buildSolverInstance();
446  solver->solve();
447  cout << "Here is the COIN clp solver solution for parincLinearByRow" << endl;
448  cout << solver->osrl << endl;
449  check = 7668;
450  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
451  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
452  if(ok == false) throw ErrorClass(" Fail unit test with clp on parincLinearByRow.osil");
453  // parse the osrl file
454  osrlreader = new OSrLReader();
455  cout << "First osrl file\n" << solver->osrl << endl;
456  osrlreader->readOSrL( solver->osrl);
457  cout << "read successfully" << endl;
458  delete osilreader;
459  cout << "osilreader successfully deleted" << endl;
460  osilreader = NULL;
461  delete osolreader;
462  cout << "osolreader successfully deleted" << endl;
463  osolreader = NULL;
464  delete solver;
465  cout << "solver successfully deleted" << endl;
466  solver = NULL;
467  delete osilwriter;
468  cout << "osilwriter successfully deleted" << endl;
469  osilwriter = NULL;
470  delete osrlreader;
471  cout << "osrlreader successfully deleted" << endl;
472  osrlreader = NULL;
473  unitTestResult << "Solved problem parincLinearByRow.osil with Clp" << std::endl;
474  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
475  }
476  catch(const ErrorClass& eclass){
477  unitTestResultFailure << "Sorry Unit Test Failed Testing Clp Solver:" + eclass.errormsg<< endl;
478  }
479 
480  // now solve another problem -- try an integer program
481  try{
482  cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0033.osil" << endl << endl;
483  std::cout << "create a new COIN Cbc for OSiL string solution" << std::endl;
484  ok = true;
485  osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
486  osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cbc.osol";
487  osil = fileUtil->getFileAsString( osilFileName.c_str());
488  osol = fileUtil->getFileAsString( osolFileName.c_str());
489  osilreader = new OSiLReader();
490  osolreader = new OSoLReader();
491  solver = new CoinSolver();
492  solver->sSolverName ="cbc";
493  solver->osil = osil;
494  solver->osol = osol;
495  solver->osinstance = NULL;
496  solver->osoption = NULL;
497  cout << "call the COIN - Cbc Solver for p0033" << endl;
498  solver->buildSolverInstance();
499  solver->solve();
500  cout << "Here is the COIN Cbc solver solution for p0033" << endl;
501  //cout << solver->osrl << endl;
502  check = 3089;
503  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
504  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
505  if(ok == false) throw ErrorClass(" Fail unit test with Cbc on p0033.osil");
506  delete solver;
507  solver = NULL;
508  delete osilreader;
509  osilreader = NULL;
510  delete osolreader;
511  osolreader = NULL;
512  unitTestResult << "Solved problem p0033.osil with Cbc" << std::endl;
513  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
514  }
515  catch(const ErrorClass& eclass){
516  unitTestResultFailure << "Sorry Unit Test Failed Testing Cbc Solver:" + eclass.errormsg<< endl;
517  }
518 
519 #ifdef THOROUGH
520  // now test p0201.osil
521  try{
522  cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0201.osil" << endl << endl;
523  ok = true;
524  osilFileName = dataDir + "osilFiles" + dirsep + "p0201.osil";
525  osolFileName = dataDir + "osolFiles" + dirsep + "p0201_cbc.osol";
526  osil = fileUtil->getFileAsString( osilFileName.c_str());
527  osol = fileUtil->getFileAsString( osolFileName.c_str());
528  solver = new CoinSolver();
529  solver->sSolverName ="cbc";
530  solver->osil = osil;
531  osilreader = new OSiLReader();
532  osolreader = new OSoLReader();
533  solver->osol = "";
534  solver->osinstance = NULL;
535  solver->osoption = NULL;
536  cout << "call the COIN - Cbc Solver for p0201" << endl;
537  solver->solve();
538  cout << "Here is the COIN Cbc solver solution for p0201" << endl;
539  check = 7615;
540  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
541  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
542  if(ok == false) throw ErrorClass(" Fail unit test with Cbc on p0201.osil");
543  delete solver;
544  solver = NULL;
545  delete osilreader;
546  osilreader = NULL;
547  delete osolreader;
548  osolreader = NULL;
549  unitTestResult << "Solved problem p0201.osil with Cbc" << std::endl;
550  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
551  }
552  catch(const ErrorClass& eclass){
553  unitTestResultFailure << "Sorry Unit Test Failed Testing Cbc Solver:" + eclass.errormsg<< endl;
554  }
555 
556  cout << endl << "TEST " << ++nOfTest << ": Cbc solver on parincInteger.osil" << endl << endl;
557  ok = true;
558  osilFileName = dataDir + "osilFiles" + dirsep + "parincInteger.osil";
559  osolFileName = dataDir + "osolFiles" + dirsep + "parincInteger_cbc.osol";
560  osil = fileUtil->getFileAsString( osilFileName.c_str());
561  osol = fileUtil->getFileAsString( osolFileName.c_str());
562  osilreader = new OSiLReader();
563  osolreader = new OSoLReader();
564 
565  solver = new CoinSolver();
566  solver->sSolverName ="cbc";
567  solver->osinstance = osilreader->readOSiL( osil);
568  solver->osol = osol;
569  cout << "call the COIN - Cbc Solver for parincInteger" << endl;
570 // solver->buildSolverInstance();
571  solver->solve();
572  cout << "Here is the Cbc solver solution for parincInteger" << endl;
573  check = 7668;
574  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
575  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
576  if(ok == false) throw ErrorClass(" Fail unit test with Cbc on parincInteger.osil");
577  unitTestResult << "Solved problem parincInteger.osil with Cbc" << std::endl;
578  delete osilreader;
579  osilreader = NULL;
580  delete osolreader;
581  osolreader = NULL;
582  delete solver;
583  solver = NULL;
584  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
585 
586 
587 #endif
588 
589 #ifdef COIN_HAS_IPOPT
590  IpoptSolver *ipoptSolver = NULL;
591  try{
592  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver with avion2.osil" << endl << endl;
593  ipoptSolver = new IpoptSolver();
594  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
595  ok = true;
596 // OSiLReader *osilreader = NULL;
597 // OSoLReader *osolreader = NULL;
598  // avion does not work with Mumps on AIX xlC compiler
599 #ifndef XLC_
600  osilFileName = dataDir + "osilFiles" + dirsep + "avion2.osil";
601  osolFileName = dataDir + "osolFiles" + dirsep + "avion2_ipopt.osol";
602  osil = fileUtil->getFileAsString( osilFileName.c_str());
603  osol = fileUtil->getFileAsString( osolFileName.c_str());
604  cout << "IPOPT Solver created for OSiL string solution" << endl;
605  ipoptSolver->osol = osol;
606  osilreader = new OSiLReader();
607  osolreader = new OSoLReader();
608  ipoptSolver->osinstance = osilreader->readOSiL( osil);
609  ipoptSolver->osol = osol;
610  cout << "call the IPOPT Solver" << endl;
611  ipoptSolver->buildSolverInstance();
612  ipoptSolver->solve();
613  cout << "Here is the IPOPT solver solution for avion2" << endl;
614  check = 9.46801e+07;
615  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
616  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
617  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on avion2.osil");
618  delete osilreader;
619  osilreader = NULL;
620  delete osolreader;
621  osolreader = NULL;
622  delete ipoptSolver;
623  ipoptSolver = NULL;
624  unitTestResult << "Solved problem avion2.osil with Ipopt" << std::endl;
625  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
626 #endif
627 
628 #ifdef THOROUGH
629  // solve another problem
630  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver with HS071_NLPMod.osil" << endl << endl;
631  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
632  ipoptSolver = new IpoptSolver();
633  // a problem with all nonlinear terms no linear terms
634  osilFileName = dataDir + "osilFiles" + dirsep + "HS071_NLPMod.osil";
635  osolFileName = dataDir + "osolFiles" + dirsep + "HS071_NLPMod_ipopt.osol";
636  osil = fileUtil->getFileAsString( osilFileName.c_str());
637  osol = fileUtil->getFileAsString( osolFileName.c_str());
638  cout << "IPOPT Solver created for OSiL string solution" << endl;
639 // osol = "<osol></osol>";
640  osilreader = new OSiLReader();
641  osolreader = new OSoLReader();
642  ipoptSolver->osinstance = osilreader->readOSiL( osil);
643  ipoptSolver->osoption = osolreader->readOSoL( osol);
644  ipoptSolver->osol = osol;
645  ipoptSolver->buildSolverInstance();
646  ipoptSolver->solve();
647  cout << "Here is the IPOPT solver solution for HS071_NLP" << endl;
648  check = 17.014;
649  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
650  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
651  delete osilreader;
652  osilreader = NULL;
653  delete osolreader;
654  osolreader = NULL;
655  delete ipoptSolver;
656  ipoptSolver = NULL;
657  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on HS071_NLP.osil");
658  unitTestResult << "Solved problem HS071.osil with Ipopt" << std::endl;
659  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
660 
661  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on rosenbrockmod.osil" << endl << endl;
662  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
663  ipoptSolver = new IpoptSolver();
664  // solve another problem
665  // a problem with both quadratic terms and general nonlinear terms
666  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
667  osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockmod_ipopt.osol";
668  osil = fileUtil->getFileAsString( osilFileName.c_str());
669  osol = fileUtil->getFileAsString( osolFileName.c_str());
670  cout << "IPOPT Solver created for OSiL string solution" << endl;
671  osilreader = new OSiLReader();
672  osolreader = new OSoLReader();
673  ipoptSolver->osil = osil;
674  ipoptSolver->osoption = osolreader->readOSoL( osol);
675  cout << "call the IPOPT Solver" << endl;
676  ipoptSolver->buildSolverInstance();
677  ipoptSolver->solve();
678  check = 6.7279;
679  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
680  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
681  if(ok == false)
682  throw ErrorClass(" Fail unit test with Ipopt on rosenbrockmod.osil");
683  delete osilreader;
684  osilreader = NULL;
685  delete osolreader;
686  osolreader = NULL;
687  unitTestResult << "Solved problem rosenbrockmod.osil with Ipopt" << std::endl;
688  delete ipoptSolver;
689  ipoptSolver = NULL;
690  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
691 
692  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincQuadratic.osil" << endl << endl;
693  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
694  ipoptSolver = new IpoptSolver();
695  // solve another problem
696  // a problem that is a pure quadratic
697  osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
698  osolFileName = dataDir + "osolFiles" + dirsep + "parincQuadratic_ipopt.osol";
699  osil = fileUtil->getFileAsString( osilFileName.c_str());
700  osol = fileUtil->getFileAsString( osolFileName.c_str());
701  cout << "IPOPT Solver created for OSiL string solution" << endl;
702  osilreader = new OSiLReader();
703  osolreader = new OSoLReader();
704  ipoptSolver->osinstance = osilreader->readOSiL( osil);
705  ipoptSolver->osil = osil;
706  ipoptSolver->osol = osol;
707  cout << "call the IPOPT Solver" << endl;
708  ipoptSolver->buildSolverInstance();
709  ipoptSolver->solve();
710  cout << "Here is the IPOPT solver solution for parincQuadratic" << endl;
711  check = 49920.5;
712  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
713  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
714  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincQuadradic.osil");
715  delete osilreader;
716  osilreader = NULL;
717  delete osolreader;
718  osolreader = NULL;
719  unitTestResult << "Solved problem parincQuadratic.osil with Ipopt" << std::endl;
720  delete ipoptSolver;
721  ipoptSolver = NULL;
722  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
723 
724  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincLinear.osil" << endl << endl;
725  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
726  ipoptSolver = new IpoptSolver();
727  // solve another problem
728  // try a pure linear program
729  osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
730  osolFileName = dataDir + "osolFiles" + dirsep + "parincLinear_ipopt.osol";
731  osil = fileUtil->getFileAsString( osilFileName.c_str());
732  osol = fileUtil->getFileAsString( osolFileName.c_str());
733  cout << "IPOPT Solver created for OSiL string solution" << endl;
734  osilreader = new OSiLReader();
735  osolreader = new OSoLReader();
736  ipoptSolver->osinstance = osilreader->readOSiL( osil);
737  ipoptSolver->osoption = NULL;
738  ipoptSolver->osol = "";
739  cout << "call the IPOPT Solver" << endl;
740  ipoptSolver->buildSolverInstance();
741  ipoptSolver->solve();
742  cout << "Here is the IPOPT solver solution for parincLinear" << endl;
743  check = 7668;
744  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-1 , 1e-1);
745  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
746  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincLinear.osil");
747  unitTestResult << "Solved problem parincLinear.osil with Ipopt" << std::endl;
748  delete osilreader;
749  osilreader = NULL;
750  delete osolreader;
751  osolreader = NULL;
752  delete ipoptSolver;
753  ipoptSolver = NULL;
754  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
755 
756  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on callBackTest.osil" << endl << endl;
757  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
758  ipoptSolver = new IpoptSolver();
759  // solve another problem
760  // callBackTest.osil
761  osilFileName = dataDir + "osilFiles" + dirsep + "callBackTest.osil";
762  osolFileName = dataDir + "osolFiles" + dirsep + "callBackTest_ipopt.osol";
763  osil = fileUtil->getFileAsString( osilFileName.c_str());
764  osol = fileUtil->getFileAsString( osolFileName.c_str());
765  cout << "IPOPT Solver created for OSiL string solution" << endl;
766  osilreader = new OSiLReader();
767  osolreader = new OSoLReader();
768  ipoptSolver->osinstance = osilreader->readOSiL( osil);
769  ipoptSolver->osoption = osolreader->readOSoL( osol);
770  ipoptSolver->osol = osol;
771  cout << "call the IPOPT Solver" << endl;
772  ipoptSolver->buildSolverInstance();
773  ipoptSolver->solve();
774  cout << "Here is the IPOPT solver solution for callBackTest" << endl;
775  check = 1.00045e+06;
776  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
777  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
778  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on callBackTest.osil");
779  unitTestResult << "Solved problem callBackTest.osil with Ipopt" << std::endl;
780  delete osilreader;
781  osilreader = NULL;
782  delete osolreader;
783  osolreader = NULL;
784  delete ipoptSolver;
785  ipoptSolver = NULL;
786  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
787 
788  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on callBackTestRowMajor.osil" << endl << endl;
789  cout << "create a new IPOPT Solver for OSiL string solution" << endl;
790  ipoptSolver = new IpoptSolver();
791  // solve another problem
792  // callBackTest.osil
793  osilFileName = dataDir + "osilFiles" + dirsep + "callBackTestRowMajor.osil";
794  osolFileName = dataDir + "osolFiles" + dirsep + "callBackTestRowMajor_ipopt.osol";
795  osil = fileUtil->getFileAsString( osilFileName.c_str());
796  osol = fileUtil->getFileAsString( osolFileName.c_str());
797  cout << "IPOPT Solver created for OSiL string solution" << endl;
798  osilreader = new OSiLReader();
799  osolreader = new OSoLReader();
800  ipoptSolver->osinstance = NULL;
801  ipoptSolver->osoption = NULL;
802  ipoptSolver->osil = osil;
803  ipoptSolver->osol = osol;
804  cout << "call the IPOPT Solver" << endl;
805 // ipoptSolver->buildSolverInstance();
806  ipoptSolver->solve();
807  cout << "Here is the IPOPT solver solution for callBackTestRowMajor" << endl;
808  check = 1.00045e+06;
809  //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
810  ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
811  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on callBackTestRowMajor.osil");
812  delete osilreader;
813  osilreader = NULL;
814  delete osolreader;
815  osolreader = NULL;
816  delete ipoptSolver;
817  ipoptSolver = NULL;
818  unitTestResult << "Solved problem callBackRowMajor.osil with Ipopt" << std::endl;
819  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
820 
821  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on nonconvex.osil" << endl << endl;
822 // OSiLReader *osilreader = NULL;
823  osilreader = new OSiLReader();
824  osolreader = new OSoLReader();
825  ok = true;
826  osilFileName = dataDir + "osilFiles" + dirsep + "nonconvex.osil";
827 // osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
828  osil = fileUtil->getFileAsString( osilFileName.c_str());
829 // osol = fileUtil->getFileAsString( osolFileName.c_str());
830  osol = "";
831  solver = new IpoptSolver();
832  solver->sSolverName = "ipopt";
833  solver->osil = osil;
834  solver->osol = osol;
835 // solver->osinstance = osilreader->readOSiL( osil);
836 // solver->osoption = osolreader->readOSoL( osol);
837  cout << "call the COIN - Ipopt Solver for nonconvex.osil" << endl;
838  solver->buildSolverInstance();
839 
840  std::cout << " CALL SOLVE " << std::endl;
841  solver->solve();
842 
843  cout << "Here is the Ipopt solver solution for nonconvex.osil" << endl;
844 
845 // OSrLWriter *tmp_writer;
846  tmp_writer = new OSrLWriter();
847  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
848  delete tmp_writer;
849  tmp_writer = NULL;
850 
851  cout << solver->osrl << endl << endl;
852 
853 // check = -1.70711;
854 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
855 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
856 // if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on nonconvex.osil");
857 
858  delete solver;
859  solver = NULL;
860  unitTestResult << "Solved problem nonconvex.osil with Ipopt" << std::endl;
861 
862 
863  delete osilreader;
864  osilreader = NULL;
865  delete osolreader;
866  osolreader = NULL;
867  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
868 
869  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on rosenbrockorig.osil" << endl << endl;
870 // OSiLReader *osilreader = NULL;
871  osilreader = new OSiLReader();
872  osolreader = new OSoLReader();
873  ok = true;
874  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorig.osil";
875 // osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockorig_Ipopt.osol";
876  osil = fileUtil->getFileAsString( osilFileName.c_str());
877 // osol = fileUtil->getFileAsString( osolFileName.c_str());
878  osol = "";
879  solver = new IpoptSolver();
880  solver->sSolverName = "ipopt";
881  solver->osil = osil;
882  solver->osol = osol;
883 // solver->osinstance = osilreader->readOSiL( osil);
884 // solver->osoption = osolreader->readOSoL( osol);
885  cout << "call the COIN - Ipopt Solver for rosenbrockorig" << endl;
886  solver->buildSolverInstance();
887 
888  std::cout << " CALL SOLVE " << std::endl;
889  solver->solve();
890 
891  cout << "Here is the Ipopt solver solution for rosenbrockorig" << endl;
892 
893 // OSrLWriter *tmp_writer;
894  tmp_writer = new OSrLWriter();
895  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
896  delete tmp_writer;
897  tmp_writer = NULL;
898 
899  cout << solver->osrl << endl << endl;
900 
901 // check = -1.70711;
902 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
903 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
904 // if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on rosenbrockorig.osil");
905 
906  delete solver;
907  solver = NULL;
908  unitTestResult << "Solved problem rosenbrockorig.osil with Ipopt" << std::endl;
909 
910 
911  delete osilreader;
912  osilreader = NULL;
913  delete osolreader;
914  osolreader = NULL;
915  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
916 
917  cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on HS071_feas.osil" << endl << endl;
918  try {
919  osilreader = new OSiLReader();
920  osolreader = new OSoLReader();
921  ok = true;
922  osilFileName = dataDir + "osilFiles" + dirsep + "HS071_feas.osil";
923 // osolFileName = dataDir + "osolFiles" + dirsep + "HS071_feas_Ipopt.osol";
924  osil = fileUtil->getFileAsString( osilFileName.c_str());
925 // osol = fileUtil->getFileAsString( osolFileName.c_str());
926  osol = "";
927  solver = new IpoptSolver();
928  solver->sSolverName = "ipopt";
929  solver->osil = osil;
930  solver->osol = osol;
931 // solver->osinstance = osilreader->readOSiL( osil);
932 // solver->osoption = osolreader->readOSoL( osol);
933  cout << "call the COIN - Ipopt Solver for HS071_feas.osil" << endl;
934  solver->buildSolverInstance();
935 
936  std::cout << " CALL SOLVE " << std::endl;
937  solver->solve();
938  }
939  catch(const ErrorClass& eclass)
940  {
941  ok = (solver->osresult->getGeneralMessage() == "Ipopt NEEDS AN OBJECTIVE FUNCTION");
942  if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on HS071_feas.osil");
943  }
944 
945  cout << "Received error message from Ipopt: \"Ipopt NEEDS AN OBJECTIVE FUNCTION\"" << endl;
946  unitTestResult << "Correctly diagnosed problem HS071_feas with Ipopt" << std::endl;
947 
948  delete solver;
949  solver = NULL;
950  delete osilreader;
951  osilreader = NULL;
952  delete osolreader;
953  osolreader = NULL;
954 
955  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
956 
957 #endif // end of #ifdef THOROUGH
958  }
959  catch(const ErrorClass& eclass){
960  unitTestResultFailure << "Sorry Unit Test Failed Testing the Ipopt Solver:" + eclass.errormsg<< endl;
961  }
962 #endif // end of #ifdef COIN_HAS_IPOPT
963 
964 
965 #ifdef COIN_HAS_BONMIN
966  try{
967  cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on bonminEx1.osil" << endl << endl;
968 // OSiLReader *osilreader = NULL;
969  osilreader = new OSiLReader();
970  osolreader = new OSoLReader();
971  ok = true;
972  osilFileName = dataDir + "osilFiles" + dirsep + "bonminEx1.osil";
973  osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Bonmin.osol";
974  osil = fileUtil->getFileAsString( osilFileName.c_str());
975  osol = fileUtil->getFileAsString( osolFileName.c_str());
976  solver = new BonminSolver();
977  //solver->sSolverName = "bonmin";
978 // solver->osinstance = osilreader->readOSiL( osil);
979  solver->osil = osil;
980  solver->osoption = osolreader->readOSoL( osol);
981  cout << "call the COIN - Bonmin Solver for bonminEx1" << endl;
982 // solver->buildSolverInstance();
983  solver->solve();
984  cout << "Here is the Bonmin solver solution for bonminEx1" << endl;
985  cout << solver->osrl << endl;
986  check = -1.70711;
987  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
988  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
989  if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on bonminEx1.osil");
990  delete solver;
991  solver = NULL;
992  unitTestResult << "Solved problem bonminEx1.osil with Bonmin" << std::endl;
993  delete osilreader;
994  osilreader = NULL;
995  delete osolreader;
996  osolreader = NULL;
997  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
998 
999 #ifdef THOROUGH
1000  cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on wayneQuadratic.osil" << endl << endl;
1001  ok = true;
1002  osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
1003  osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Bonmin1.osol";
1004  osil = fileUtil->getFileAsString( osilFileName.c_str());
1005  osol = fileUtil->getFileAsString( osolFileName.c_str());
1006  osilreader = new OSiLReader();
1007  solver = new BonminSolver();
1008  solver->osol = osol;
1009  solver->osinstance = osilreader->readOSiL( osil);
1010  cout << "call the Bonmin Solver for wayneQuadratic" << endl;
1011  solver->buildSolverInstance();
1012  // Do this one with two different osol files!!!
1013  solver->solve();
1014  cout << "Here is the Bonmin solver solution" << endl;
1015  cout << solver->osrl << endl;
1016  check = 2.925;
1017  std::cout << "CALL NEAR_EQUAL" << std::endl;
1018  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1019  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1020  std::cout << "CALL NEAR_EQUAL" << std::endl;
1021  if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on wayneQuadratic.osil");
1022  delete solver;
1023  solver = NULL;
1024  delete osilreader;
1025  osilreader = NULL;
1026  unitTestResult << "Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
1027  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1028 
1029  cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on wayneQuadratic.osil" << endl << endl;
1030  ok = true;
1031  osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
1032  osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
1033  osil = fileUtil->getFileAsString( osilFileName.c_str());
1034  osol = fileUtil->getFileAsString( osolFileName.c_str());
1035  osilreader = new OSiLReader();
1036  osolreader = new OSoLReader();
1037  solver = new BonminSolver();
1038  solver->osol = osol;
1039  solver->osinstance = osilreader->readOSiL( osil);
1040  solver->osoption = osolreader->readOSoL( osol);
1041  cout << "call the Bonmin Solver for wayneQuadratic" << endl;
1042  solver->buildSolverInstance();
1043  // Do this one with two different osol files!!!
1044  solver->solve();
1045  cout << "Here is the Bonmin solver solution" << endl;
1046  cout << solver->osrl << endl;
1047  check = 2.925;
1048  std::cout << "CALL NEAR_EQUAL" << std::endl;
1049  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1050  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1051  std::cout << "CALL NEAR_EQUAL" << std::endl;
1052  if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on wayneQuadratic.osil");
1053  delete solver;
1054  solver = NULL;
1055  delete osilreader;
1056  osilreader = NULL;
1057  delete osolreader;
1058  osolreader = NULL;
1059  unitTestResult << "Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
1060  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1061 
1062 
1063 
1064 
1065  cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on rosenbrockorig.osil" << endl << endl;
1066  ok = true;
1067  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorig.osil";
1068 // osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
1069  osil = fileUtil->getFileAsString( osilFileName.c_str());
1070 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1071  osilreader = new OSiLReader();
1072 // osolreader = new OSoLReader();
1073  solver = new BonminSolver();
1074  solver->osol = "";
1075  solver->osinstance = osilreader->readOSiL( osil);
1076 // solver->osoption = osolreader->readOSoL( osol);
1077  cout << "call the Bonmin Solver for rosenbrockorig" << endl;
1078  solver->buildSolverInstance();
1079  solver->solve();
1080  cout << "Here is the Bonmin solver solution" << endl;
1081  cout << solver->osrl << endl;
1082  check = 2.925;
1083  std::cout << "CALL NEAR_EQUAL" << std::endl;
1084  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1085  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1086  std::cout << "CALL NEAR_EQUAL" << std::endl;
1087  if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on rosenbrockorig.osil");
1088  delete solver;
1089  solver = NULL;
1090  delete osilreader;
1091  osilreader = NULL;
1092  delete osolreader;
1093  osolreader = NULL;
1094  unitTestResult << "Solved problem rosenbrockorig.osil with Bonmin" << std::endl;
1095  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1096 
1097 
1098 
1099  cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on rosenbrockinteger.osil" << endl << endl;
1100  ok = true;
1101  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockinteger.osil";
1102 // osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
1103  osil = fileUtil->getFileAsString( osilFileName.c_str());
1104 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1105  osilreader = new OSiLReader();
1106 // osolreader = new OSoLReader();
1107  solver = new BonminSolver();
1108  solver->osol = "";
1109  solver->osinstance = osilreader->readOSiL( osil);
1110 // solver->osoption = osolreader->readOSoL( osol);
1111  cout << "call the Bonmin Solver for rosenbrockinteger" << endl;
1112  solver->buildSolverInstance();
1113  solver->solve();
1114  cout << "Here is the Bonmin solver solution" << endl;
1115  cout << solver->osrl << endl;
1116  check = 2.925;
1117  std::cout << "CALL NEAR_EQUAL" << std::endl;
1118  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1119  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1120  std::cout << "CALL NEAR_EQUAL" << std::endl;
1121  if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on rosenbrockinteger.osil");
1122  delete solver;
1123  solver = NULL;
1124  delete osilreader;
1125  osilreader = NULL;
1126  delete osolreader;
1127  osolreader = NULL;
1128  unitTestResult << "Solved problem rosenbrockinteger.osil with Bonmin" << std::endl;
1129  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1130 
1131 #endif // end of #ifdef THOROUGH
1132  }
1133  catch(const ErrorClass& eclass){
1134  cout << "OSrL = " << solver->osrl << endl;
1135  cout << endl << endl << endl;
1136  unitTestResultFailure << "Sorry Unit Test Failed Testing the Bonmin Solver:" + eclass.errormsg << endl;
1137  }
1138 #endif // end of #ifdef COIN_HAS_BONMIN
1139 
1140 
1141 #ifdef COIN_HAS_COUENNE
1142  try{
1143  cout << endl << "TEST " << ++nOfTest << ": Couenne solver on bonminEx1.osil" << endl << endl;
1144  CouenneSolver *solver = NULL;
1145 
1146 // OSiLReader *osilreader = NULL;
1147  osilreader = new OSiLReader();
1148  osolreader = new OSoLReader();
1149  ok = true;
1150  osilFileName = dataDir + "osilFiles" + dirsep + "bonminEx1.osil";
1151  osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
1152  osil = fileUtil->getFileAsString( osilFileName.c_str());
1153  osol = fileUtil->getFileAsString( osolFileName.c_str());
1154  solver = new CouenneSolver();
1155  solver->sSolverName = "bonmin";
1156  solver->osil = osil;
1157  solver->osol = osol;
1158 // solver->osinstance = osilreader->readOSiL( osil);
1159 // solver->osoption = osolreader->readOSoL( osol);
1160  cout << "call the COIN - Couenne Solver for bonminEx1" << endl;
1161  solver->buildSolverInstance();
1162 
1163  std::cout << " CALL SOLVE " << std::endl;
1164  solver->solve();
1165 
1166  cout << "Here is the Couenne solver solution for bonminEx1" << endl;
1167 
1168  tmp_writer = new OSrLWriter();
1169  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
1170  delete tmp_writer;
1171  tmp_writer = NULL;
1172 
1173  check = -1.70711;
1174  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1175  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1176  if(ok == false) throw ErrorClass(" Fail unit test with Couenne on bonminEx1.osil");
1177 
1178  delete solver;
1179  solver = NULL;
1180  unitTestResult << "Solved problem bonminEx1.osil with Couenne" << std::endl;
1181 
1182 
1183  delete osilreader;
1184  osilreader = NULL;
1185  delete osolreader;
1186  osolreader = NULL;
1187  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1188 
1189 #ifdef THOROUGH
1190  cout << endl << "TEST " << ++nOfTest << ": Couenne solver on bonminEx1_Nonlinear.osil" << endl << endl;
1191 // OSiLReader *osilreader = NULL;
1192  osilreader = new OSiLReader();
1193  osolreader = new OSoLReader();
1194  ok = true;
1195  osilFileName = dataDir + "osilFiles" + dirsep + "bonminEx1_Nonlinear.osil";
1196 // osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
1197  osil = fileUtil->getFileAsString( osilFileName.c_str());
1198 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1199  osol = "";
1200  solver = new CouenneSolver();
1201  solver->sSolverName = "bonmin";
1202  solver->osil = osil;
1203  solver->osol = osol;
1204 // solver->osinstance = osilreader->readOSiL( osil);
1205 // solver->osoption = osolreader->readOSoL( osol);
1206  cout << "call the COIN - Couenne Solver for bonminEx1_Nonlinear" << endl;
1207  solver->buildSolverInstance();
1208 
1209  std::cout << " CALL SOLVE " << std::endl;
1210  solver->solve();
1211 
1212  cout << "Here is the Couenne solver solution for bonminEx1_Nonlinear.osil" << endl;
1213 
1214 // OSrLWriter *tmp_writer;
1215  tmp_writer = new OSrLWriter();
1216  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
1217  delete tmp_writer;
1218  tmp_writer = NULL;
1219 
1220  cout << solver->osrl << endl << endl;
1221 
1222 // check = -1.70711;
1223 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1224 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1225 // if(ok == false) throw ErrorClass(" Fail unit test with Couenne on bonminEx1_Nonlinear.osil");
1226 
1227  delete solver;
1228  solver = NULL;
1229  unitTestResult << "Solved problem bonminEx1_Nonlinear with Couenne" << std::endl;
1230 
1231 
1232  delete osilreader;
1233  osilreader = NULL;
1234  delete osolreader;
1235  osolreader = NULL;
1236  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1237 
1238 
1239  cout << endl << "TEST " << ++nOfTest << ": Couenne solver on nonconvex.osil" << endl << endl;
1240 // OSiLReader *osilreader = NULL;
1241  osilreader = new OSiLReader();
1242  osolreader = new OSoLReader();
1243  ok = true;
1244  osilFileName = dataDir + "osilFiles" + dirsep + "nonconvex.osil";
1245 // osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
1246  osil = fileUtil->getFileAsString( osilFileName.c_str());
1247 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1248  osol = "";
1249  solver = new CouenneSolver();
1250  solver->sSolverName = "bonmin";
1251  solver->osil = osil;
1252  solver->osol = osol;
1253 // solver->osinstance = osilreader->readOSiL( osil);
1254 // solver->osoption = osolreader->readOSoL( osol);
1255  cout << "call the COIN - Couenne Solver for nonconvex.osil" << endl;
1256  solver->buildSolverInstance();
1257 
1258  std::cout << " CALL SOLVE " << std::endl;
1259  solver->solve();
1260 
1261  cout << "Here is the Couenne solver solution for nonconvex.osil" << endl;
1262 
1263 // OSrLWriter *tmp_writer;
1264  tmp_writer = new OSrLWriter();
1265  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
1266  delete tmp_writer;
1267  tmp_writer = NULL;
1268 
1269  cout << solver->osrl << endl << endl;
1270 
1271 // check = -1.70711;
1272 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1273 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1274 // if(ok == false) throw ErrorClass(" Fail unit test with Couenne on nonconvex.osil");
1275 
1276  delete solver;
1277  solver = NULL;
1278  unitTestResult << "Solved problem nonconvex.osil with Couenne" << std::endl;
1279 
1280 
1281  delete osilreader;
1282  osilreader = NULL;
1283  delete osolreader;
1284  osolreader = NULL;
1285  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1286 
1287  cout << endl << "TEST " << ++nOfTest << ": Couenne solver on rosenbrockorig.osil" << endl << endl;
1288 // OSiLReader *osilreader = NULL;
1289  osilreader = new OSiLReader();
1290  osolreader = new OSoLReader();
1291  ok = true;
1292  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorig.osil";
1293 // osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockorig_Couenne.osol";
1294  osil = fileUtil->getFileAsString( osilFileName.c_str());
1295 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1296  osol = "";
1297  solver = new CouenneSolver();
1298  solver->sSolverName = "bonmin";
1299  solver->osil = osil;
1300  solver->osol = osol;
1301 // solver->osinstance = osilreader->readOSiL( osil);
1302 // solver->osoption = osolreader->readOSoL( osol);
1303  cout << "call the COIN - Couenne Solver for rosenbrockorig" << endl;
1304  solver->buildSolverInstance();
1305 
1306  std::cout << " CALL SOLVE " << std::endl;
1307  solver->solve();
1308 
1309  cout << "Here is the Couenne solver solution for rosenbrockorig" << endl;
1310 
1311 // OSrLWriter *tmp_writer;
1312  tmp_writer = new OSrLWriter();
1313  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
1314  delete tmp_writer;
1315  tmp_writer = NULL;
1316 
1317  cout << solver->osrl << endl << endl;
1318 
1319 // check = -1.70711;
1320 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1321 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1322 // if(ok == false) throw ErrorClass(" Fail unit test with Couenne on rosenbrockorig.osil");
1323 
1324  delete solver;
1325  solver = NULL;
1326  unitTestResult << "Solved problem rosenbrockorig.osil with Couenne" << std::endl;
1327 
1328 
1329  delete osilreader;
1330  osilreader = NULL;
1331  delete osolreader;
1332  osolreader = NULL;
1333  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1334 
1335 
1336 
1337  cout << endl << "TEST " << ++nOfTest << ": Couenne solver on rosenbrockinteger.osil" << endl << endl;
1338 // OSiLReader *osilreader = NULL;
1339  osilreader = new OSiLReader();
1340  osolreader = new OSoLReader();
1341  ok = true;
1342  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockinteger.osil";
1343 // osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockinteger_Couenne.osol";
1344  osil = fileUtil->getFileAsString( osilFileName.c_str());
1345 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1346  osol = "";
1347  solver = new CouenneSolver();
1348  solver->sSolverName = "bonmin";
1349  solver->osil = osil;
1350  solver->osol = osol;
1351 // solver->osinstance = osilreader->readOSiL( osil);
1352 // solver->osoption = osolreader->readOSoL( osol);
1353  cout << "call the COIN - Couenne Solver for rosenbrockinteger" << endl;
1354  solver->buildSolverInstance();
1355 
1356  std::cout << " CALL SOLVE " << std::endl;
1357  solver->solve();
1358 
1359  cout << "Here is the Couenne solver solution for rosenbrockinteger" << endl;
1360 
1361 // OSrLWriter *tmp_writer;
1362  tmp_writer = new OSrLWriter();
1363  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
1364  delete tmp_writer;
1365  tmp_writer = NULL;
1366 
1367  cout << solver->osrl << endl << endl;
1368 
1369 // check = -1.70711;
1370 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1371 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1372 // if(ok == false) throw ErrorClass(" Fail unit test with Couenne on rosenbrockinteger.osil");
1373 
1374  delete solver;
1375  solver = NULL;
1376  unitTestResult << "Solved problem rosenbrockinteger.osil with Couenne" << std::endl;
1377 
1378 
1379  delete osilreader;
1380  osilreader = NULL;
1381  delete osolreader;
1382  osolreader = NULL;
1383  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1384 
1385 
1386  cout << endl << "TEST " << ++nOfTest << ": Couenne solver on HS071_feas.osil" << endl << endl;
1387 // OSiLReader *osilreader = NULL;
1388  osilreader = new OSiLReader();
1389  osolreader = new OSoLReader();
1390  ok = true;
1391  osilFileName = dataDir + "osilFiles" + dirsep + "HS071_feas.osil";
1392 // osolFileName = dataDir + "osolFiles" + dirsep + "HS071_feas_Couenne.osol";
1393  osil = fileUtil->getFileAsString( osilFileName.c_str());
1394 // osol = fileUtil->getFileAsString( osolFileName.c_str());
1395  osol = "";
1396  solver = new CouenneSolver();
1397  solver->sSolverName = "bonmin";
1398  solver->osil = osil;
1399  solver->osol = osol;
1400 // solver->osinstance = osilreader->readOSiL( osil);
1401 // solver->osoption = osolreader->readOSoL( osol);
1402  cout << "call the COIN - Couenne Solver for HS071_feas.osil" << endl;
1403  solver->buildSolverInstance();
1404 
1405  std::cout << " CALL SOLVE " << std::endl;
1406  solver->solve();
1407 
1408  cout << "Here is the Couenne solver solution for HS071_feas" << endl;
1409 
1410 // OSrLWriter *tmp_writer;
1411  tmp_writer = new OSrLWriter();
1412  solver->osrl = tmp_writer->writeOSrL(solver->osresult);
1413  delete tmp_writer;
1414  tmp_writer = NULL;
1415 
1416  cout << solver->osrl << endl << endl;
1417 
1418 // check = -1.70711;
1419 // //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1420 // ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1421 // if(ok == false) throw ErrorClass(" Fail unit test with Couenne on HS071_feas.osil");
1422 
1423  delete solver;
1424  solver = NULL;
1425  unitTestResult << "Solved problem HS071_feas with Couenne" << std::endl;
1426 
1427 
1428  delete osilreader;
1429  osilreader = NULL;
1430  delete osolreader;
1431  osolreader = NULL;
1432  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1433 
1434 #endif
1435 
1436  }
1437  catch(const ErrorClass& eclass){
1438  cout << "OSrL = " << solver->osrl << endl;
1439  cout << endl << endl << endl;
1440  unitTestResultFailure << "Sorry Unit Test Failed Testing the Couenne Solver:" + eclass.errormsg << endl;
1441 
1442  }
1443 #endif
1444 
1445 
1446 
1447 #ifdef COIN_HAS_SYMPHONY
1448  try{
1449  cout << endl << "TEST " << ++nOfTest << ": SYMPHONY solver on p0033.osil" << endl << endl;
1450  ok = true;
1451  osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
1452  osolFileName = dataDir + "osolFiles" + dirsep + "p0033_sym.osol";
1453  osil = fileUtil->getFileAsString( osilFileName.c_str());
1454  osol = fileUtil->getFileAsString( osolFileName.c_str());
1455  osolreader = new OSoLReader();
1456  solver = new CoinSolver();
1457  solver->sSolverName = "symphony";
1458  solver->osil = osil;
1459  solver->osinstance = NULL;
1460  solver->osoption = osolreader->readOSoL( osol);
1461  cout << "build the solver instance for COIN - SYMPHONY" << endl;
1462  solver->buildSolverInstance();
1463 // cout << "call the COIN - SYMPHONY Solver for p0033" << endl;
1464  solver->solve();
1465  cout << "Here is the COIN SYMPHONY solver solution for p0033" << endl;
1466  cout << solver->osrl << endl;
1467  check = 3089;
1468  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1469  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1470  if(ok == false) throw ErrorClass(" Fail unit test with SYMPHONY on p0033.osil");
1471  delete solver;
1472  solver = NULL;
1473  delete osolreader;
1474  osolreader = NULL;
1475  unitTestResult << "Solved problem p0033.osil with SYMPHONY" << std::endl;
1476  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1477  }
1478  catch(const ErrorClass& eclass){
1479  cout << "OSrL = " << solver->osrl << endl;
1480  cout << endl << endl << endl;
1481  unitTestResultFailure << "Sorry Unit Test Failed Testing the SYMPHONY Solver:" + eclass.errormsg << endl;
1482  }
1483 #endif
1484 
1485 
1486 
1487 #ifdef COIN_HAS_DYLP
1488  try{
1489  cout << endl << "TEST " << ++nOfTest << ": DyLP solver on parincLinear.osil" << endl << endl;
1490  ok = true;
1491  osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
1492  osolFileName = dataDir + "osolFiles" + dirsep + "parincLinear_dylp.osol";
1493  osil = fileUtil->getFileAsString( osilFileName.c_str());
1494  osol = fileUtil->getFileAsString( osolFileName.c_str());
1495  osilreader = new OSiLReader();
1496  solver = new CoinSolver();
1497  solver->sSolverName = "dylp";
1498  solver->osol = osol;
1499  solver->osinstance = osilreader->readOSiL( osil);
1500  cout << "call the COIN - DyLP solver for parincLinear" << endl;
1501  solver->buildSolverInstance();
1502  solver->solve();
1503  cout << "Here is the COIN - DyLP solver solution for parincLinear" << endl;
1504  cout << solver->osrl << endl;
1505  check = 7668;
1506  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
1507  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1508  if(ok == false) throw ErrorClass(" Fail unit test with DyLP on parincLinear.osil");
1509  delete solver;
1510  solver = NULL;
1511  delete osilreader;
1512  osilreader = NULL;
1513  unitTestResult << "Solved problem parincLinear.osil with DyLP" << std::endl;
1514  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1515  }
1516  catch(const ErrorClass& eclass){
1517  cout << "OSrL = " << solver->osrl << endl;
1518  cout << endl << endl << endl;
1519  unitTestResultFailure <<"Sorry Unit Test Failed Testing the DyLP Solver:" + eclass.errormsg << endl;
1520  }
1521  #endif
1522 
1523 
1524 #ifdef COIN_HAS_VOL
1525  try{
1526  cout << endl << "TEST " << ++nOfTest << ": Vol solver on volumeTest.osil" << endl << endl;
1527  ok = true;
1528  osilFileName = dataDir + "osilFiles" + dirsep + "volumeTest.osil";
1529  osolFileName = dataDir + "osolFiles" + dirsep + "volumeTest_vol.osol";
1530  osil = fileUtil->getFileAsString( osilFileName.c_str());
1531  osol = fileUtil->getFileAsString( osolFileName.c_str());
1532  osolreader = new OSoLReader();
1533  solver = new CoinSolver();
1534  solver->sSolverName = "vol";
1535  solver->osil = osil;
1536  solver->osinstance = NULL;
1537  solver->osoption = osolreader->readOSoL( osol);
1538  cout << "call the COIN - Vol solver for volumeTest" << endl;
1539  solver->buildSolverInstance();
1540  solver->solve();
1541  cout << "Here is the COIN - Vol solver solution for parincLinear" << endl;
1542  cout << solver->osrl << endl;
1543  check = 7;
1544  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
1545  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1546  if(ok == false) throw ErrorClass(" Fail unit test with Vol on volumeTest.osil");
1547  delete solver;
1548  solver = NULL;
1549  delete osolreader;
1550  osolreader = NULL;
1551  unitTestResult << "Solved problem volumeTest.osil with Vol" << std::endl;
1552  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1553  }
1554  catch(const ErrorClass& eclass){
1555  cout << "OSrL = " << solver->osrl << endl;
1556  cout << endl << endl << endl;
1557  unitTestResultFailure <<"Sorry Unit Test Failed Testing the Vol Solver:" + eclass.errormsg << endl;
1558  }
1559 #endif
1560 
1561 #ifdef COIN_HAS_GLPK
1562  try{
1563  cout << endl << "TEST " << ++nOfTest << ": GLPK solver on p0033.osil" << endl << endl;
1564  ok = true;
1565  osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
1566  osolFileName = dataDir + "osolFiles" + dirsep + "p0033_glpk.osol";
1567  osil = fileUtil->getFileAsString( osilFileName.c_str());
1568  osol = fileUtil->getFileAsString( osolFileName.c_str());
1569  osilreader = new OSiLReader();
1570  osolreader = new OSoLReader();
1571  solver = new CoinSolver();
1572  solver->sSolverName = "glpk";
1573  solver->osinstance = osilreader->readOSiL( osil);
1574  solver->osoption = osolreader->readOSoL( osol);
1575  cout << "call the GLPK Solver for p0033" << endl;
1576  solver->buildSolverInstance();
1577  solver->solve();
1578  cout << "Here is the GLPK solver solution for p0033" << endl;
1579  cout << solver->osrl << endl;
1580  check = 3089;
1581  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1582  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1583  if(ok == false) throw ErrorClass(" Fail unit test with GLPK on p0033.osil");
1584  delete solver;
1585  solver = NULL;
1586  delete osilreader;
1587  osilreader = NULL;
1588  delete osolreader;
1589  osolreader = NULL;
1590  unitTestResult << "Solved problem p0033.osil with GLPK" << std::endl;
1591  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1592  }
1593  catch(const ErrorClass& eclass){
1594  cout << "OSrL = " << solver->osrl << endl;
1595  cout << endl << endl << endl;
1596  unitTestResultFailure <<"Sorry Unit Test Failed Testing the Glpk Solver:" + eclass.errormsg << endl;
1597  }
1598  #endif
1599 
1600 
1601 
1602 #ifdef COIN_HAS_CPX
1603  try{
1604  cout << endl << "TEST " << ++nOfTest << ": Cplex solver on p0033.osil" << endl << endl;
1605  ok = true;
1606  osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
1607  osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cpx.osol";
1608  osil = fileUtil->getFileAsString( osilFileName.c_str());
1609  osol = fileUtil->getFileAsString( osolFileName.c_str());
1610  solver = new CoinSolver();
1611  solver->sSolverName = "cplex";
1612  solver->osil = osil;
1613  solver->osol = osol;
1614  solver->osinstance = NULL;
1615  cout << "call the CPLEX Solver for p0033" << endl;
1616  solver->buildSolverInstance();
1617  solver->solve();
1618  cout << "Here is the CPLEX solver solution for p0033" << endl;
1619  cout << solver->osrl << endl;
1620  check = 3089;
1621  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1622  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1623  if(ok == false) throw ErrorClass(" Fail unit test with CPLEX on p0033.osil");
1624  delete solver;
1625  solver = NULL;
1626  unitTestResult << "Solved problem p0033.osil with CPLEX" << std::endl;
1627  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1628  }
1629  catch(const ErrorClass& eclass){
1630  cout << "OSrL = " << solver->osrl << endl;
1631  cout << endl << endl << endl;
1632  unitTestResultFailure <<"Sorry Unit Test Failed Testing the Cplex Solver:" + eclass.errormsg << endl;
1633  }
1634 #endif
1635 
1636 
1637 #ifdef COIN_HAS_LINDO
1638  try{
1639  cout << endl << "TEST " << ++nOfTest << ": Lindo solver on lindoapiaddins.osil" << endl << endl;
1640  ok = true;
1641  osilFileName = dataDir + "osilFiles" + dirsep + "lindoapiaddins.osil";
1642  osolFileName = dataDir + "osolFiles" + dirsep + "lindoapiaddins_lindo.osol";
1643  osil = fileUtil->getFileAsString( osilFileName.c_str());
1644  osol = fileUtil->getFileAsString( osolFileName.c_str());
1645  osilreader = new OSiLReader();
1646  cout << "create a new LINDO Solver for OSiL string solution" << endl;
1647  solver = new LindoSolver();
1648  solver->osinstance = osilreader->readOSiL( osil);
1649  solver->osol = osol;
1650  cout << "call the LINDO Solver" << endl;
1651  solver->buildSolverInstance();
1652  solver->solve();
1653  cout << "Here is the LINDO solver solution" << endl;
1654  cout << solver->osrl << endl;
1655  check = 99;
1656  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1657  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1658  if(ok == false) throw ErrorClass(" Fail unit test with LINDO on lindoapiaddins.osil");
1659  solver->osinstance = NULL;
1660  delete solver;
1661  solver = NULL;
1662  osilreader = NULL;
1663  delete osolreader;
1664  unitTestResult << "Solved problem lindoapiaddins.osil with Lindo" << std::endl;
1665  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1666 
1667 #ifdef THOUROUGH
1668  // now solve the rosenbrock problem from the OSiL paper
1669  cout << endl << "TEST " << ++nOfTest << ": Lindo solver on rosenbrockmod.osil" << endl << endl;
1670  osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
1671  osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockmod_lindo.osol";
1672  osil = fileUtil->getFileAsString( osilFileName.c_str());
1673  osol = fileUtil->getFileAsString( osolFileName.c_str());
1674  solver = new LindoSolver();
1675  solver->osil = osil;
1676  solver->osol = osol;
1677  solver->osinstance = NULL;
1678  cout << "call the LINDO Solver" << endl;
1679  solver->buildSolverInstance();
1680  solver->solve();
1681  cout << "Here is the LINDO solver solution" << endl;
1682  cout << solver->osrl << endl;
1683  check = 6.7279;
1684  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1685  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1686  if(ok == false) throw ErrorClass(" Fail unit test with LINDO on rosenbrockmod.osil");
1687  solver->osinstance = NULL;
1688  delete solver;
1689  solver = NULL;
1690  unitTestResult << "Solved problem rosenbrockmod.osil with Lindo" << std::endl;
1691  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1692 
1693  // now solve a pure quadratic
1694  cout << endl << "TEST " << ++nOfTest << ": Lindo solver on parincQuadratic.osil" << endl << endl;
1695  osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
1696  osolFileName = dataDir + "osolFiles" + dirsep + "parincQuadratic_lindo.osol";
1697  osil = fileUtil->getFileAsString( osilFileName.c_str());
1698  osol = fileUtil->getFileAsString( osolFileName.c_str());
1699  osolreader = new OSoLReader();
1700  solver = new LindoSolver();
1701  solver->osil = osil;
1702  solver->osol = osol;
1703  solver->osinstance = NULL;
1704  solver->osoption = osolreader->readOSoL( osol);
1705  cout << "call the LINDO Solver" << endl;
1706  solver->buildSolverInstance();
1707  solver->solve();
1708  cout << "Here is the LINDO solver solution" << endl;
1709  cout << solver->osrl << endl;
1710  check = 49920.5;
1711  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1712  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1713  if(ok == false) throw ErrorClass(" Fail unit test with LINDO on parincQuadratic.osil");
1714  delete solver;
1715  solver = NULL;
1716  delete osolreader;
1717  osolreader = NULL;
1718  unitTestResult << "Solved problem parincQuadratic.osil with Lindo" << std::endl;
1719  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1720 
1721  // now solve a quadratic binary problem
1722  // wayneQuadratic.osil
1723  /*
1724  cout << endl << "TEST " << ++nOfTest << ": Lindo solver on wayneQuadratic.osil" << endl << endl;
1725  osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
1726  osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_lindo.osol";
1727  osil = fileUtil->getFileAsString( osilFileName.c_str());
1728  osol = fileUtil->getFileAsString( osolFileName.c_str());
1729  osilreader = new OSiLReader();
1730  solver = new LindoSolver();
1731  solver->osil = osil;
1732  solver->osol = osol;
1733  solver->osinstance = osilreader->readOSiL( osil);
1734  cout << "call the LINDO Solver" << endl;
1735  solver->buildSolverInstance();
1736  solver->solve();
1737  cout << "Here is the LINDO solver solution" << endl;
1738  cout << solver->osrl << endl;
1739  check = 2.925;
1740  std::cout << "CALL NEAR_EQUAL" << std::endl;
1741  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
1742  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1743  std::cout << "CALL NEAR_EQUAL" << std::endl;
1744  if(ok == false) throw ErrorClass(" Fail unit test with LINDO on wayneQuadratic.osil");
1745  delete solver;
1746  solver = NULL;
1747  osilreader = NULL;
1748  delete osolreader;
1749  unitTestResult << "Solved problem wayneQuadratic.osil with Lindo" << std::endl;
1750  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1751  */
1752 #endif
1753  }
1754  catch(const ErrorClass& eclass){
1755  //cout << "OSrL = " << solver->osrl << endl;
1756  cout << endl << endl << endl;
1757  unitTestResultFailure <<"Sorry Unit Test Failed Testing the LINDO Solver:" + eclass.errormsg << endl << endl;
1758  }
1759 #endif
1760 // end solving using the osil file
1761 
1762 
1763 
1764 // now solve with an OSInstance created from an MPS file
1765  try{
1766  cout << endl << "TEST " << ++nOfTest << ": Cbc solver using MPS file" << endl << endl;
1767  ok = true;
1768 // cout << endl;
1769 // cout << "START MPS TESTING" << endl << endl;
1770  cout << "create a COIN Solver for MPS - OSInstance solution" << endl;
1771  solver = new CoinSolver();
1772  solver->sSolverName = "cbc";
1773  mps2osil = new OSmps2osil( mpsFileName);
1774  mps2osil->createOSInstance() ;
1775  solver->osinstance = mps2osil->osinstance;
1776  osol = "<osol t></osol>";
1777  solver->osol = osol;
1778  cout << "call COIN Solve" << endl;
1779  solver->buildSolverInstance();
1780  solver->solve();
1781  cout << "Here is the COIN solver solution" << endl;
1782  cout << solver->osrl << endl;
1783  check = -7668;
1784  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
1785  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1786  if(ok == false) throw ErrorClass(" Fail unit test with COIN Solver on MPS test problem parincLinear.mps");
1787  delete solver;
1788  solver = NULL;
1789  delete mps2osil;
1790  mps2osil = NULL;
1791 // cout << endl;
1792 // cout << "DONE WITH MPS TESTING" << endl;
1793  unitTestResult << "Test the MPS -> OSiL converter on parinc.mps using Cbc" << std::endl;
1794  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1795  }
1796  catch(const ErrorClass& eclass){
1797  cout << "OSrL = " << solver->osrl << endl;
1798  cout << endl << endl << endl;
1799  unitTestResultFailure <<"Sorry Unit Test Failed Testing the MPS converter:" + eclass.errormsg << endl;
1800  }
1801 
1802 // now solve with an OSInstance created from an AMPL nl file
1803  try{
1804 #ifdef COIN_HAS_ASL
1805  cout << endl << "TEST " << ++nOfTest << ": AMPL solver interface" << endl << endl;
1806  ok = true;
1807  cout << "create a cbc Solver for AMPL nl - OSInstance solution" << endl;
1808  solver = new CoinSolver();
1809  solver->sSolverName = "cbc";
1810  nl2osil = new OSnl2osil( nlFileName);
1811  nl2osil->createOSInstance() ;
1812  solver->osinstance = nl2osil->osinstance;
1813  osol = ""; //<osol t></osol>";
1814  solver->osol = osol;
1815  cout << "call Cbc Solve" << endl;
1816  solver->buildSolverInstance();
1817  solver->solve();
1818  cout << "Here is the Cbc solver solution" << endl;
1819  cout << solver->osrl << endl;
1820  check = 7668;
1821  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
1822  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1823  if(ok == false) throw ErrorClass(" Fail unit test with OSnl2osil on problem parinc.nl");
1824  solver->osinstance = NULL;
1825  delete solver;
1826  solver = NULL;
1827  cout << "call delete nl2osil" << endl;
1828  delete nl2osil;
1829  nl2osil = NULL;
1830  unitTestResult << "Test the AMPL nl -> OSiL converter on parinc.nl using Cbc" << std::endl;
1831  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1832 #endif
1833  }
1834  catch(const ErrorClass& eclass){
1835  cout << "OSrL = " << solver->osrl << endl;
1836  cout << endl << endl << endl;
1837  unitTestResultFailure <<"Sorry Unit Test Failed Testing AMPL:" + eclass.errormsg << endl;
1838  }
1839 
1840  //
1841  // Now test the mps feature
1842  //
1843  try{
1844  cout << endl << "TEST " << ++nOfTest << ": b64 operations" << endl << endl;
1845  ok = true;
1846  OSiLWriter osilwriter;
1847  osilwriter.m_bWriteBase64 = true;
1848  solver = new CoinSolver();
1849  solver->sSolverName = "cbc";
1850  mps2osil = new OSmps2osil( mpsFileName);
1851  solver->osinstance = NULL;
1852  osol = "<osol></osol>";
1853  solver->osol = osol;
1854  mps2osil->createOSInstance() ;
1855  solver->osil = osilwriter.writeOSiL( mps2osil->osinstance) ;
1856  std::cout << solver->osil << std::endl;
1857  solver->buildSolverInstance();
1858  solver->solve();
1859  cout << endl << endl;
1860  cout << "COIN solution of a OSiL string in b64 format" << endl;
1861  cout << solver->osrl;
1862  check = -7668;
1863  //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
1864  ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1865  if(ok == false) throw ErrorClass(" Fail unit test with COIN Cbc cSolver on b64 test problem parincLinear.mps");
1866  solver->osinstance = NULL;
1867  delete solver;
1868  solver = NULL;
1869  delete mps2osil;
1870  mps2osil = NULL;
1871  unitTestResult << "Test a problem written in b64 and then converted to OSInstance" << std::endl;
1872  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1873  }
1874  catch(const ErrorClass& eclass){
1875  cout << endl << endl;
1876  cout << eclass.errormsg << endl << endl;
1877  cout << "OSrL = " << solver->osrl << endl;
1878  cout << endl << endl << endl;
1879  unitTestResultFailure << "Sorry Unit Test Failed Testing Use of Base 64" << endl;
1880 
1881  }
1882 #endif //INSTALLATION_TEST
1883 
1884 
1885 #ifdef COMPONENT_DEBUG
1886 
1887  // now test postfix and prefix routines
1888  try{
1889  cout << endl << "TEST " << ++nOfTest << ": postfix and prefix routines" << endl << endl;
1890  std::string expTreeTest = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
1891  osil = fileUtil->getFileAsString( expTreeTest.c_str() ) ;
1892  OSInstance *osinstance = NULL;
1893  //osinstance = new OSInstance();
1894  OSiLReader *osilreader = NULL;
1895  osilreader = new OSiLReader();
1896  //create an osinstance
1897  osinstance = osilreader->readOSiL( osil);
1898  OSExpressionTree* expTree = osinstance->getNonlinearExpressionTree( -1);
1899  if(expTree == NULL) throw ErrorClass(" Null expression tree when testing prefix and postfix routines");
1900  std::vector<OSnLNode*> postfixVec;
1901  //postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
1902  postfixVec = osinstance->getNonlinearExpressionTreeInPostfix( -1);
1903 
1904  unsigned int n = postfixVec.size();
1905  //unsigned int i;
1906  std::string *nodeNames1 = new std::string[ n];
1907  std::string *nodeNames2 = new std::string[ n];
1908  for (int i = 0 ; i < n; i++){
1909  std::cout << postfixVec[i]->snodeName << std::endl;
1910  nodeNames1[i] = postfixVec[i]->snodeName;
1911  }
1912 
1913  // now create back the expression tree
1914  expTree->m_treeRoot = postfixVec[ n - 1]->createExpressionTreeFromPostfix( postfixVec);
1915 
1916  // now get in prefix
1917  std::vector<OSnLNode*> prefixVec;
1918  //prefixVec = expTree->m_treeRoot->getPrefixFromExpressionTree();
1919  prefixVec = osinstance->getNonlinearExpressionTreeInPrefix( -1);
1920 
1921  // now create back the expression tree
1922  expTree->m_treeRoot = prefixVec[ 0]->createExpressionTreeFromPrefix( prefixVec);
1923 
1924  // now get postfix vector again and compare with original
1925  postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
1926  //postfixVec = osinstance->getNonlinearExpressionTreeInPostfix( -1);
1927  if(postfixVec.size() != n) throw ErrorClass(" Problem with creating expression trees");
1928  std::cout << std::endl << std::endl;
1929  for (int i = 0 ; i < n; i++){
1930  //std::cout << postfixVec[i]->snodeName << std::endl;
1931  nodeNames2[i] = postfixVec[i]->snodeName;
1932  if( nodeNames1[i] != nodeNames2[ i]) throw ErrorClass(" Problem with creating expression trees");
1933  }
1934 
1935  //delete osinstance;
1936  delete[] nodeNames1;
1937  delete[] nodeNames2;
1938 
1939  delete osilreader;
1940  osilreader = NULL;
1941  osinstance = NULL;
1942  unitTestResult << "Successful test of prefix and postfix conversion routines" << std::endl;
1943  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1944 
1945  }
1946  catch(const ErrorClass& eclass){
1947  cout << endl << endl << endl;
1948  unitTestResultFailure << eclass.errormsg << endl;
1949  }
1950  // now test the nonlinear operators
1951  try{
1952  cout << endl << "TEST " << ++nOfTest << ": nonlinear operators" << endl << endl;
1953  ok = true;
1954  std::string operatorTest = dataDir + "osilFiles" + dirsep + "testOperators.osil";
1955  osil = fileUtil->getFileAsString( operatorTest.c_str() );
1956  OSInstance *osinstance = NULL;
1957  //osinstance = new OSInstance();
1958  OSiLReader *osilreader = NULL;
1959  osilreader = new OSiLReader();
1960  OSiLWriter *osilwriter = NULL;
1961  osilwriter = new OSiLWriter();
1962 // cout << "Read testOperators.osil...";
1963  osinstance = osilreader->readOSiL( osil);
1964 // cout << "Done" << endl;
1965  OSExpressionTree* expTree = osinstance->getNonlinearExpressionTree( -1);
1966  std::vector<OSnLNode*> postfixVec;
1967  postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
1968  int n = postfixVec.size();
1969  std::string *nodeNames1 = new std::string[ n];
1970  for (int i = 0 ; i < n; i++){
1971  std::cout << postfixVec[i]->snodeName << std::endl;
1972  nodeNames1[i] = postfixVec[i]->snodeName;
1973  }
1974  std::cout << std::endl << std::endl;
1975  std::cout << osilwriter->writeOSiL( osinstance) << std::endl;
1976  // now test value
1977  double *x = NULL;
1978  x = new double[2];
1979  x[0] = 1;
1980  x[1] = 2;
1981  double parserTestVal = expTree->m_treeRoot->calculateFunction( x);
1982  std::cout << "ParserTest Val = " << parserTestVal << std::endl;
1983  check = 11;
1984  //ok &= NearEqual(expTree->m_treeRoot->calculateFunction( x) , check, 1e-10 , 1e-10);
1985  ok = ( fabs(check - expTree->m_treeRoot->calculateFunction( x))/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
1986  if(ok == false) throw ErrorClass(" Problem evaluating expression tree");
1987  delete[] x;
1988  delete[] nodeNames1;
1989  delete osilreader;
1990  osilreader = NULL;
1991  delete osilwriter;
1992  osilwriter = NULL;
1993  osinstance = NULL;
1994  //create an osinstance
1995  unitTestResult << "Successful test of nonlinear operators using file testOperators.osil" << std::endl;
1996  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1997  }
1998  catch(const ErrorClass& eclass){
1999  cout << endl << endl << endl;
2000  unitTestResultFailure << eclass.errormsg << endl;
2001  }
2002 // Automatic differentiation
2003  try{
2004  cout << endl << "TEST " << ++nOfTest << ": Automatic differentiation" << endl << endl;
2005 // std::cout << std::endl << std::endl;
2006 // std::cout << "Testing AD Features " << std::endl;
2007  std::string expTreeTest = dataDir + "osilFiles" + dirsep + "CppADTestLag.osil";
2008  /*
2009  min x0^2 + 9*x1 -- w[0]
2010  s.t.
2011  33 - 105 + 1.37*x1 + 2*x3 + 5*x1 <= 10 -- y[0]
2012  ln(x0*x3) + 7*x2 >= 10 -- y[1]
2013  Note: in the first constraint 33 is a constant term and 105
2014  is part of the nl node
2015  */
2016  osil = fileUtil->getFileAsString( expTreeTest.c_str() );
2017  OSInstance *osinstance = NULL;
2018  //osinstance = new OSInstance();
2019  OSiLReader *osilreader = NULL;
2020  osilreader = new OSiLReader();
2021  //create an osinstance
2022  osinstance = osilreader->readOSiL( osil);
2023  double *x;
2024  x = new double[ 4];
2025  x[0] = 1;
2026  x[1] = 5;
2027  x[2] = 10;
2028  x[3] = 5;
2029  SparseVector *sp;
2030  // get the gradient for constraint 1
2031  osinstance->getJacobianSparsityPattern();
2032  sp = osinstance->calculateConstraintFunctionGradient(x, 1, true);
2033  for(int i = 0; i < sp->number; i++){
2034  std::cout << "gradient value " << sp->values[i] << std::endl;
2035  }
2036  ok = true;
2037  //check gradient for constraint with index 1
2038  double checkPartial2Con1 = 7.0 ;
2039  //ok &= NearEqual( sp->values[ 0], checkPartial2Con1, 1e-10, 1e-10);
2040  ok = ( fabs(checkPartial2Con1 - sp->values[ 0] )/(fabs( checkPartial2Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
2041  if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
2042  double checkPartial0Con1 = (1./x[0]) ;
2043  //ok &= NearEqual(sp->values[ 1], checkPartial0Con1, 1e-10, 1e-10);
2044  ok = ( fabs(checkPartial0Con1 - sp->values[ 1] )/(fabs( checkPartial0Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
2045  if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
2046  double checkPartial3Con1 = (1./x[3]) ;
2047  //ok &= NearEqual( sp->values[ 2], checkPartial3Con1, 1e-10, 1e-10);
2048  ok = ( fabs(checkPartial3Con1 - sp->values[ 2] )/(fabs( checkPartial3Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
2049  if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
2050  delete sp;
2051  SparseHessianMatrix *sh;
2052  // calcuate Hessian of objective function (index = -1)
2053  osinstance->getLagrangianHessianSparsityPattern( );
2054  sh = osinstance->calculateHessian(x, -1, true);
2055  for(int i = 0; i < sh->hessDimension; i++){
2056  std::cout << "Hessian value " << sh->hessValues[i] << std::endl;
2057  }
2058  //ok &= NearEqual( sh->hessValues[ 0], 2., 1e-10, 1e-10);
2059  ok = ( fabs(2. - sh->hessValues[0] )/(2. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
2060  if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
2061  //ok &= NearEqual( sh->hessValues[ 1], 0., 1e-10, 1e-10);
2062  ok = ( fabs(0. - sh->hessValues[ 1] )/(0. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
2063  if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
2064  //ok &= NearEqual( sh->hessValues[ 2], 0., 1e-10, 1e-10);
2065  ok = ( fabs(0. - sh->hessValues[2] )/(0. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
2066  if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
2067  unitTestResult << "Successful test of AD gradient and Hessian calculations" << std::endl;
2068  delete[] x;
2069  delete osilreader;
2070  osilreader = NULL;
2071  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2072  }
2073  catch(const ErrorClass& eclass){
2074  cout << endl << endl << endl;
2075  unitTestResultFailure << eclass.errormsg << endl;
2076  }
2077  //
2078  // Now just test the OSiL parser
2079  try{
2080  cout << endl << "TEST " << ++nOfTest << ": OSiL parser" << endl << endl;
2081  clock_t start, finish;
2082  double duration;
2083  OSiLWriter *osilwriter = NULL;
2084  osilwriter = new OSiLWriter();
2085  //delete fileUtil;
2086  //fileUtil = NULL;
2087  //fileUtil = new FileUtil();
2088  cout << "TEST PARSING A MODEL" << endl;
2089  cout << "FIRST READ THE FILE INTO A STRING" << endl;
2090  start = clock();
2091  osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
2092  osil = fileUtil->getFileAsString( osilFileName.c_str());
2093  finish = clock();
2094  duration = (double) (finish - start) / CLOCKS_PER_SEC;
2095  cout << "Reading the file into a string took (seconds): "<< duration << endl;
2096  OSiLReader *osilreader = NULL;
2097  osilreader = new OSiLReader();
2098  start = clock();
2099  cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
2100  osilreader->readOSiL( osil);
2101  //cout << osilwriter->writeOSiL( osilreader->readOSiL( osil)) << endl;
2102  delete osilreader;
2103  osilreader = 0;
2104  delete osilwriter;
2105  osilwriter = NULL;
2106  finish = clock();
2107  duration = (double) (finish - start) / CLOCKS_PER_SEC;
2108  cout << "Parsing took (seconds): "<< duration << endl;
2109  unitTestResult << "Successful test of OSiL parser on problem parincLinear.osil" << std::endl;
2110  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2111  }
2112  catch(const ErrorClass& eclass){
2113  cout << endl << endl << endl;
2114  cout << eclass.errormsg << endl;
2115  unitTestResultFailure << "Sorry Unit Test Failed Testing An OSiL Parser" << endl;
2116 
2117  }
2118 
2119  //
2120  // Now test the extensions to the OSiL format: <timeDomain>, etc.
2121 
2122  try{
2123  cout << endl << "TEST " << ++nOfTest << ": Stochastic extensions to OSiL" << endl << endl;
2124  clock_t start, finish;
2125  double duration;
2126  OSiLWriter *osilwriter = NULL;
2127  osilwriter = new OSiLWriter();
2128  //delete fileUtil;
2129  //fileUtil = NULL;
2130  //fileUtil = new FileUtil();
2131  cout << "\nTEST PARSING A STOCHASTIC MODEL" << endl;
2132  cout << "FIRST READ THE FILE INTO A STRING" << endl;
2133  start = clock();
2134  osilFileName = dataDir + "osilFiles" + dirsep + "finplan1.osil";
2135  osil = fileUtil->getFileAsString( &osilFileName[0]);
2136  finish = clock();
2137  duration = (double) (finish - start) / CLOCKS_PER_SEC;
2138  cout << "Reading the file into a string took (seconds): "<< duration << endl;
2139  OSiLReader *osilreader = NULL;
2140  osilreader = new OSiLReader();
2141  start = clock();
2142  cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
2143  osilreader->readOSiL( osil);
2144  //cout << osilwriter->writeOSiL( osilreader->readOSiL( &osil)) << endl;
2145  delete osilreader;
2146  osilreader = 0;
2147  delete osilwriter;
2148  osilwriter = NULL;
2149  finish = clock();
2150  duration = (double) (finish - start) / CLOCKS_PER_SEC;
2151  cout << "Parsing took (seconds): "<< duration << endl;
2152  unitTestResult << "Successful test of OSiL parser on problem finplan1.osil" << std::endl;
2153  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2154  }
2155  catch(const ErrorClass& eclass){
2156  cout << endl << endl << endl;
2157  cout << eclass.errormsg << endl;
2158  unitTestResultFailure << "Error parsing an osil file with time domain information" << endl;
2159  }
2163  try{
2164  cout << endl << "TEST " << ++nOfTest << ": GET() AND SET() METHODS FOR TimeDomain OBJECT" << endl << endl;
2165  OSInstance *osinstance = NULL;
2166  //osinstance = new OSInstance();
2167  //OSiLReader *osilreader = NULL;
2168  osilreader = new OSiLReader();
2169  //create an osinstance
2170  osinstance = osilreader->readOSiL( osil);
2171  std::string f = osinstance->getTimeDomainFormat();
2172  ok = (f == "stages");
2173  int n = osinstance->getTimeDomainStageNumber();
2174  ok &= (n == 6);
2175 
2176  std::string* sncheck = new std::string[6];
2177  sncheck[0] = "";
2178  sncheck[1] = "";
2179  sncheck[2] = "";
2180  sncheck[3] = "test";
2181  sncheck[4] = "Wha'zzup?";
2182  sncheck[5] = "";
2183 
2184  std::string* sn = osinstance->getTimeDomainStageNames();
2185 
2186  for (int i = 0; i < 6; i++)
2187  ok &= (sn[i] == sncheck[i]);
2188 
2189  int* nv = osinstance->getTimeDomainStageNumberOfVariables();
2190 
2191  int* nvcheck = new int[6];
2192  nvcheck[0] = 2;
2193  nvcheck[1] = 2;
2194  nvcheck[2] = 0;
2195  nvcheck[3] = 0;
2196  nvcheck[4] = 2;
2197  nvcheck[5] = 2;
2198 
2199  for (int i = 0; i < 6; i++)
2200  ok &= (nv[i] == nvcheck[i]);
2201 
2202  int* nc = osinstance->getTimeDomainStageNumberOfConstraints();
2203 
2204  int* nccheck = new int[6];
2205  nccheck[0] = 1;
2206  nccheck[1] = 1;
2207  nccheck[2] = 0;
2208  nccheck[3] = 0;
2209  nccheck[4] = 1;
2210  nccheck[5] = 1;
2211 
2212  for (int i = 0; i < 6; i++)
2213  ok &= (nc[i] == nccheck[i]);
2214 
2215  int* no = osinstance->getTimeDomainStageNumberOfObjectives();
2216 
2217  int* nocheck = new int[6];
2218  nocheck[0] = 1;
2219  nocheck[1] = 1;
2220  nocheck[2] = 1;
2221  nocheck[3] = 0;
2222  nocheck[4] = 1;
2223  nocheck[5] = 1;
2224 
2225  for (int i = 0; i < 6; i++)
2226  ok &= (no[i] == nocheck[i]);
2227 
2228  int** lv = osinstance->getTimeDomainStageVarList();
2229  int** lc = osinstance->getTimeDomainStageConList();
2230  int** lo = osinstance->getTimeDomainStageObjList();
2231 
2232  int** lvcheck = new int*[6];
2233  int** lccheck = new int*[6];
2234  int** locheck = new int*[6];
2235  for (int i = 0; i < 6; i++) {
2236  lvcheck[i] = new int[2];
2237  lccheck[i] = new int[2];
2238  locheck[i] = new int[2];
2239  };
2240  lvcheck[0][0] = 0;
2241  lvcheck[0][1] = 1;
2242  lvcheck[1][0] = 2;
2243  lvcheck[1][1] = 3;
2244  lvcheck[4][0] = 4;
2245  lvcheck[4][1] = 5;
2246  lvcheck[5][0] = 6;
2247  lvcheck[5][1] = 7;
2248  lccheck[0][0] = 0;
2249  lccheck[1][0] = 1;
2250  lccheck[4][0] = 2;
2251  lccheck[5][0] = 3;
2252  locheck[0][0] = -1;
2253  locheck[1][0] = -1;
2254  locheck[2][0] = -1;
2255  locheck[4][0] = -1;
2256  locheck[5][0] = -1;
2257 
2258  for (int i = 0; i < 6; i++) {
2259  for (int j = 0; j < nv[i]; j++)
2260  ok &= (lvcheck[i][j] == lv[i][j]);
2261  for (int j = 0; j < nc[i]; j++)
2262  ok &= (lccheck[i][j] == lc[i][j]);
2263  for (int j = 0; j < no[i]; j++)
2264  ok &= (locheck[i][j] == lo[i][j]);
2265  };
2266 
2267  std::string* sn1 = new std::string[6];
2268  int* nv1 = new int[6];
2269  int* nc1 = new int[6];
2270  int* no1 = new int[6];
2271  int** lv1 = new int*[6];
2272  int** lc1 = new int*[6];
2273  int** lo1 = new int*[6];
2274  for (int i = 0; i < 6; i++) {
2275  lv1[i] = new int[2];
2276  lc1[i] = new int[2];
2277  lo1[i] = new int[2];
2278  };
2279  for (int i = 0; i < 6; i++) {
2280  sn1[i] = sn[i];
2281  nv1[i] = nv[i];
2282  nc1[i] = nc[i];
2283  no1[i] = no[i];
2284  for (int j = 0; j < nv[i]; j++) {
2285  lv1[i][j] = lv[i][j];
2286  };
2287  for (int j = 0; j < nc[i]; j++) {
2288  lc1[i][j] = lc[i][j];
2289  };
2290  for (int j = 0; j < no[i]; j++) {
2291  lo1[i][j] = lo[i][j];
2292  };
2293  };
2294 
2295  ok &= osinstance->setTimeDomain("none");
2296  n = 0;
2297  ok &= osinstance->setTimeDomainStages(n,NULL);
2298  ok &= osinstance->setTimeDomainStages(4,NULL);
2299 
2300  n = osinstance->getTimeDomainStageNumber();
2301  ok &= (n == 4);
2302 
2303  int *nelem, *startIdx, **VI;
2304  nelem = new int[4];
2305  startIdx = new int[4];
2306  VI = new int*[4];
2307  for (int i = 0; i < 4; i++)
2308  { nelem[i] = 2;
2309  startIdx[i] = 2*i;
2310  VI[i] = new int[2];
2311  VI[i][0] = 2*i;
2312  VI[i][1] = 2*i + 1;
2313  };
2314  ok &= osinstance->setTimeDomainStageVariablesUnordered(4,nelem,VI);
2315 
2316  for (int i = 0; i < 4; i++)
2317  { nelem[i] = 1;
2318  startIdx[i] = i;
2319  };
2320  ok &= osinstance->setTimeDomainStageConstraintsOrdered(4,nelem,startIdx);
2321 
2322  for (int i = 0; i < 4; i++)
2323  { nelem[i] = 1;
2324  startIdx[i] = -1;
2325  };
2326  ok &= osinstance->setTimeDomainStageObjectivesOrdered(4,nelem,startIdx);
2327 
2328  ok &= osinstance->setTimeDomain("none");
2329 
2330  ok &= osinstance->setTimeDomain("interval");
2331 
2332  ok &= osinstance->setTimeDomainInterval(0.0, 1.0);
2333  double lower = osinstance->getTimeDomainIntervalStart();
2334  ok &= (lower == 0.0);
2335  double upper = osinstance->getTimeDomainIntervalHorizon();
2336  ok &= (upper == 1.0);
2337 
2338  ok &= osinstance->setTimeDomain("none");
2339 
2340  ok &= osinstance->setTimeDomainStages(6,sncheck);
2341  ok &= osinstance->setTimeDomainStageVariablesUnordered(6,nvcheck,lvcheck);
2342  ok &= osinstance->setTimeDomainStageObjectivesUnordered(6,nocheck,locheck);
2343  ok &= osinstance->setTimeDomainStageConstraintsUnordered(6,nccheck,lccheck);
2344  int n2 = osinstance->getTimeDomainStageNumber();
2345  ok &= (n2 == 6);
2346  std::string* sn2 = osinstance->getTimeDomainStageNames();
2347  int* nv2 = osinstance->getTimeDomainStageNumberOfVariables();
2348  int* nc2 = osinstance->getTimeDomainStageNumberOfConstraints();
2349  int* no2 = osinstance->getTimeDomainStageNumberOfObjectives();
2350  int** lv2 = osinstance->getTimeDomainStageVarList();
2351  int** lc2 = osinstance->getTimeDomainStageConList();
2352  int** lo2 = osinstance->getTimeDomainStageObjList();
2353  for (int i = 0; i < n2; i++)
2354  { ok &= (sn2[i] == sncheck[i]);
2355  ok &= (nv2[i] == nvcheck[i]);
2356  ok &= (nc2[i] == nccheck[i]);
2357  ok &= (no2[i] == nocheck[i]);
2358  for (int j = 0; j < nv2[i]; j++)
2359  ok &= (lv2[i][j] == lvcheck[i][j]);
2360  for (int j = 0; j < nc2[i]; j++)
2361  ok &= (lc2[i][j] == lccheck[i][j]);
2362  for (int j = 0; j < no2[i]; j++)
2363  ok &= (lo2[i][j] == locheck[i][j]);
2364  };
2365  delete [] sncheck;
2366  sncheck = NULL;
2367  delete [] nvcheck;
2368  nvcheck = NULL;
2369  delete [] nccheck;
2370  nccheck = NULL;
2371  delete [] nocheck;
2372  nocheck = NULL;
2373  for (int i = 0; i < 6; i++) {
2374  delete [] lvcheck[i];
2375  delete [] lccheck[i];
2376  delete [] locheck[i];
2377  delete [] lv1[i];
2378  delete [] lc1[i];
2379  delete [] lo1[i];
2380  };
2381  delete [] lvcheck;
2382  lvcheck = NULL;
2383  delete [] lccheck;
2384  lccheck = NULL;
2385  delete [] locheck;
2386  locheck = NULL;
2387  delete [] lv1;
2388  lv1 = NULL;
2389  delete [] lc1;
2390  lc1 = NULL;
2391  delete [] lo1;
2392  lo1 = NULL;
2393  delete [] sn1;
2394  sn1 = NULL;
2395  delete[] nv1;
2396  nv1 = NULL;
2397  delete[] nc1;
2398  nc1 = NULL;
2399  delete[] no1;
2400  no1 = NULL;
2401  delete [] nelem;
2402  nelem = NULL;
2403  delete [] startIdx;
2404  startIdx = NULL;
2405  for (int i = 0; i < 4; i++) {
2406  delete [] VI[i];
2407  };
2408  delete [] VI;
2409  VI = NULL;
2410  delete osilreader;
2411  unitTestResult << "Successful test of osinstance get() and set() methods" << std::endl;
2412  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2413  }
2414  catch(const ErrorClass& eclass){
2415  cout << endl << endl << endl;
2416  cout << eclass.errormsg << endl;
2417  unitTestResultFailure << "Sorry Unit Test Failed osinstance get() and set() Methods" << endl;
2418  }
2419 //#endif
2420  //
2421  // Now test the OSoL parser
2422  OSoLWriter *osolwriter = NULL;
2423 // OSoLReader *osolreader = NULL;
2424  //osolwriter = new OSoLWriter();
2425  //osolreader = new OSoLReader();
2426 
2427  try{
2441  cout << endl << "TEST " << ++nOfTest << ": OSoL parser" << endl << endl;
2442  std::string tmpOSoL;
2443  clock_t start, finish;
2444  double duration;
2445  osolwriter = new OSoLWriter();
2446  osolreader = new OSoLReader();
2447  OSOption *osoption = NULL;
2448  //osoption = new OSOption();
2449  cout << "TEST PARSING AN OSoL FILE" << endl;
2450  cout << "FIRST READ THE OSoL FILE INTO A STRING" << endl;
2451  osolFileName = dataDir + "osolFiles" + dirsep + "parsertest.osol";
2452  start = clock();
2453  std::string osol = fileUtil->getFileAsString( osolFileName.c_str() );
2454  finish = clock();
2455  duration = (double) (finish - start) / CLOCKS_PER_SEC;
2456  cout << "Reading the file into a string took (seconds): "<< duration << endl;
2457  start = clock();
2458  cout << "PARSE THE OSOL STRING INTO AN OSOPTION OBJECT" << endl;
2459  osoption = osolreader->readOSoL( osol);
2460 
2461  //Pad all the arrays
2462  cout << endl << "Test the add() methods" << endl;
2463 
2464  ok = osoption->setAnOtherGeneralOption("testing","one","two three");
2465  ok = osoption->setOtherSystemOptions(0,NULL) && ok;
2466  ok = osoption->setAnOtherSystemOption("Ho Ho Ho","","") && ok;
2467  ok = osoption->setAnOtherServiceOption("OneMore","Option","To Go") && ok;
2468  ok = osoption->setAnotherJobDependency("DoReMi") && ok;
2469  ok = osoption->setAnotherRequiredDirectory("C:\\MSYS") && ok;
2470  ok = osoption->setAnotherRequiredFile("C:\\MSYS\\junk.tmp") && ok;
2471  ok = osoption->setAnotherDirectoryToMake("C:\\tempdir") && ok;
2472  ok = osoption->setAnotherFileToMake("C:\\tempdir\\temp.tmp") && ok;
2473  ok = osoption->setAnotherInputDirectoryToMove("C:\\tempdir","C:\\OS\\calc",true) && ok;
2474  ok = osoption->setAnotherInputFileToMove("C:\\OS\\parinc.osil","C:\\OS\\calc\\input.osil",true) && ok;
2475  ok = osoption->setAnotherOutputFileToMove("C:\\OS\\calc\\putput.osrl","C:\\OS\\parinc.osol",false) && ok;
2476  ok = osoption->setAnotherOutputDirectoryToMove("C:\\OS\\calc","C:\\OS\\save",false) && ok;
2477  ok = osoption->setAnotherFileToDelete("C:\\OS\\calc\\input.osil") && ok;
2478  ok = osoption->setAnotherDirectoryToDelete("C:\\tempdir") && ok;
2479  ok = osoption->setAnotherProcessToKill("ABC123") && ok;
2480  ok = osoption->setAnOtherJobOption("DoReMi","ABC","One Two Three") && ok;
2481  ok = osoption->setAnotherInitVarValue(5,12.3) && ok;
2482  ok = osoption->setAnotherInitVarValueString(6,"BLUE") && ok;
2483  ok = osoption->setAnotherInitBasisStatus(6,"unknown") && ok;
2485 
2486  int SOS3idx[2];
2487  double SOS3val[2];
2488  SOS3idx[0] = 3;
2489  SOS3idx[1] = 6;
2490  SOS3val[0] = 1.0;
2491  SOS3val[1] = 2.0;
2492  int tnvar = osoption->getNumberOfSOS();
2493  ok = osoption->setAnotherSOSVariableBranchingWeight(3,2,1.0,SOS3idx,SOS3val) && ok;
2494  assert (osoption->getNumberOfSOS() == (tnvar + 1));
2495  assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[0]->idx == 3);
2496  assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[1]->idx == 6);
2497  assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[0]->value == 1.0);
2498  assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[1]->value == 2.0);
2499 #ifdef DEBUG
2500  cout << endl << "another SOS has been added" << endl << endl;
2501 #endif
2502 
2503  OtherVariableOption *varopt;
2504  varopt = new OtherVariableOption();
2505  varopt->name = "testVarOpt";
2506  varopt->numberOfVar = 0;
2507  ok = osoption->setAnOtherVariableOption(varopt) && ok;
2508  delete varopt;
2509  varopt = NULL;
2510 
2511  OtherObjectiveOption *objopt;
2512  objopt = new OtherObjectiveOption();
2513  objopt->name = "testObjOpt";
2514  objopt->numberOfObj = 0;
2515  ok = osoption->setAnOtherObjectiveOption(objopt) && ok;
2516  delete objopt;
2517  objopt = NULL;
2518 
2519  ok = osoption->setAnotherInitConValue(2,17.0) && ok;
2520  ok = osoption->setAnotherInitDualVarValue(2,0.0,DBL_MAX) && ok;
2521 
2522  OtherConstraintOption *conopt;
2523  conopt = new OtherConstraintOption();
2524  conopt->name = "testObjOpt";
2525  conopt->numberOfCon = 2;
2526  conopt->con = new OtherConOption*[2];
2527  conopt->con[0] = new OtherConOption();
2528  conopt->con[0]->idx = 0;
2529  conopt->con[0]->value = "3.0";
2530  conopt->con[1] = new OtherConOption();
2531  conopt->con[1]->idx = 1;
2532  conopt->con[1]->lbValue = "0.0";
2533  conopt->con[1]->ubValue = "10.0";
2534  ok = osoption->setAnOtherConstraintOption(conopt) && ok;
2535  delete conopt;
2536  conopt = NULL;
2537 
2538  ok = osoption->setAnotherSolverOption("HoHum","gus","PhoNY","","test","") && ok;
2539 
2540  if (!ok)
2541  throw ErrorClass(" Could not add to osoption data structure");
2542 
2543  //Now transfer to another osoption using get() and set() methods
2544  std::string optionstring;
2545  int option_i;
2546  double option_d;
2547  OSOption* osoption2 = new OSOption();
2548 
2549  cout << endl << "transfer osoption to another OSOption object" << endl;
2550 
2551  optionstring = osoption->getServiceURI();
2552  ok = osoption2->setServiceURI(optionstring);
2553 #ifdef DEBUG
2554  if (!ok)
2555  throw ErrorClass(" error in get/set ServiceURI");
2556 #endif
2557 
2558  optionstring = osoption->getServiceName();
2559  ok = osoption2->setServiceName(optionstring) && ok;
2560 #ifdef DEBUG
2561  if (!ok)
2562  throw ErrorClass(" error in get/set ServiceName");
2563 #endif
2564 
2565  optionstring = osoption->getInstanceName();
2566  ok = osoption2->setInstanceName(optionstring) && ok;
2567 #ifdef DEBUG
2568  if (!ok)
2569  throw ErrorClass(" error in get/set InstanceName");
2570 #endif
2571 
2572  optionstring = osoption->getInstanceLocation();
2573  ok = osoption2->setInstanceLocation(optionstring) && ok;
2574 #ifdef DEBUG
2575  if (!ok)
2576  throw ErrorClass(" error in get/set InstanceLocation");
2577 #endif
2578 
2579  optionstring = osoption->getInstanceLocationType();
2580  ok = osoption2->setInstanceLocationType(optionstring) && ok;
2581 #ifdef DEBUG
2582  if (!ok)
2583  throw ErrorClass(" error in get/set InstanceLocationtype");
2584 #endif
2585 
2586  optionstring = osoption->getJobID();
2587  ok = osoption2->setJobID(optionstring) && ok;
2588 #ifdef DEBUG
2589  if (!ok)
2590  throw ErrorClass(" error in get/set JobID");
2591 #endif
2592 
2593  optionstring = osoption->getSolverToInvoke();
2594  ok = osoption2->setSolverToInvoke(optionstring) && ok;
2595 #ifdef DEBUG
2596  if (!ok)
2597  throw ErrorClass(" error in get/set SolverToInvoke");
2598 #endif
2599 
2600  optionstring = osoption->getInstanceLocationType();
2601  ok = osoption2->setInstanceLocationType(optionstring) && ok;
2602 #ifdef DEBUG
2603  if (!ok)
2604  throw ErrorClass(" error in get/set InstanceLocationType");
2605 #endif
2606 
2607  optionstring = osoption->getUserName();
2608  ok = osoption2->setUserName(optionstring) && ok;
2609 #ifdef DEBUG
2610  if (!ok)
2611  throw ErrorClass(" error in get/set UserName");
2612 #endif
2613 
2614  optionstring = osoption->getPassword();
2615 #ifdef DEBUG
2616  if (!ok)
2617  throw ErrorClass(" error in get/set Password");
2618 #endif
2619  ok = osoption2->setPassword(optionstring) && ok;
2620 
2621  optionstring = osoption->getContact();
2622  ok = osoption2->setContact(optionstring) && ok;
2623 #ifdef DEBUG
2624  if (!ok)
2625  throw ErrorClass(" error in get/set Contact");
2626 #endif
2627 
2628  optionstring = osoption->getContactTransportType();
2629  ok = osoption2->setContactTransportType(optionstring) && ok;
2630 #ifdef DEBUG
2631  if (!ok)
2632  throw ErrorClass(" error in get/set TransportType");
2633 #endif
2634 
2635  int nopt;
2636  OtherOption** otherOpt;
2638  otherOpt = osoption->getOtherGeneralOptions();
2639  ok = osoption2->setOtherGeneralOptions(nopt, otherOpt) && ok;
2640 #ifdef DEBUG
2641  if (!ok)
2642  throw ErrorClass(" error in get/set OtherGeneralOption");
2643 #endif
2644 
2645  option_d = osoption->getMinDiskSpace();
2646  ok = osoption2->setMinDiskSpace(option_d) && ok;
2647 #ifdef DEBUG
2648  if (!ok)
2649  throw ErrorClass(" error in get/set MinDiskSpace");
2650 #endif
2651 
2652  optionstring = osoption->getMinDiskSpaceUnit();
2653  ok = osoption2->setMinDiskSpaceUnit(optionstring) && ok;
2654 #ifdef DEBUG
2655  if (!ok)
2656  throw ErrorClass(" error in get/set MinDiskSpaceUnit");
2657 #endif
2658 
2659  option_d = osoption->getMinMemorySize();
2660  ok = osoption2->setMinMemorySize(option_d) && ok;
2661 #ifdef DEBUG
2662  if (!ok)
2663  throw ErrorClass(" error in get/set MinMemorySize");
2664 #endif
2665 
2666  optionstring = osoption->getMinMemoryUnit();
2667  ok = osoption2->setMinMemoryUnit(optionstring) && ok;
2668 #ifdef DEBUG
2669  if (!ok)
2670  throw ErrorClass(" error in get/set MinMemoryUnit");
2671 #endif
2672 
2673  option_d = osoption->getMinCPUSpeed();
2674  ok = osoption2->setMinCPUSpeed(option_d) && ok;
2675 #ifdef DEBUG
2676  if (!ok)
2677  throw ErrorClass(" error in get/set MinCPUSpeed");
2678 #endif
2679 
2680  optionstring = osoption->getMinCPUSpeedUnit();
2681  ok = osoption2->setMinCPUSpeedUnit(optionstring) && ok;
2682 #ifdef DEBUG
2683  if (!ok)
2684  throw ErrorClass(" error in get/set MinCPUSpeedUnit");
2685 #endif
2686 
2687  option_i = osoption->getMinCPUNumber();
2688  ok = osoption2->setMinCPUNumber(option_i) && ok;
2689 #ifdef DEBUG
2690  if (!ok)
2691  throw ErrorClass(" error in get/set MinCPUNumber");
2692 #endif
2693 
2694  OtherOption** otherOpt2;
2696  otherOpt2 = osoption->getOtherSystemOptions();
2697  ok = osoption2->setOtherSystemOptions(nopt, otherOpt2) && ok;
2698 #ifdef DEBUG
2699  if (!ok)
2700  throw ErrorClass(" error in get/set OtherSystemOptions");
2701 #endif
2702 
2703 
2704  optionstring = osoption->getServiceType();
2705  ok = osoption2->setServiceType(optionstring) && ok;
2706 #ifdef DEBUG
2707  if (!ok)
2708  throw ErrorClass(" error in get/set ServiceType");
2709 #endif
2710 
2711  OtherOption** otherOpt3;
2713  otherOpt3 = osoption->getOtherServiceOptions();
2714  ok = osoption2->setOtherServiceOptions(nopt, otherOpt3) && ok;
2715 #ifdef DEBUG
2716  if (!ok)
2717  throw ErrorClass(" error in get/set OtherServiceOptions");
2718 #endif
2719 
2720 
2721  option_d = osoption->getMaxTime();
2722  ok = osoption2->setMaxTime(option_d) && ok;
2723 #ifdef DEBUG
2724  if (!ok)
2725  throw ErrorClass(" error in get/set MaxTime");
2726 #endif
2727 
2728  optionstring = osoption->getMaxTimeUnit();
2729  ok = osoption2->setMaxTimeUnit(optionstring) && ok;
2730 #ifdef DEBUG
2731  if (!ok)
2732  throw ErrorClass(" error in get/set MaxTimeUnit");
2733 #endif
2734 
2735  optionstring = osoption->getRequestedStartTime();
2736  ok = osoption2->setRequestedStartTime(optionstring) && ok;
2737 #ifdef DEBUG
2738  if (!ok)
2739  throw ErrorClass(" error in get/set RequestedStartTime");
2740 #endif
2741 
2743  std::string* tJobID = osoption->getJobDependencies();
2744  ok = osoption2->setJobDependencies(nopt, tJobID) && ok;
2745 #ifdef DEBUG
2746  if (!ok)
2747  throw ErrorClass(" error in get/set JobDependencies");
2748 #endif
2749 
2751  std::string* reqDir = osoption->getRequiredDirectories();
2752  ok = osoption2->setRequiredDirectories(nopt, reqDir) && ok;
2753 #ifdef DEBUG
2754  if (!ok)
2755  throw ErrorClass(" error in get/set RequiredDirectories");
2756 #endif
2757 
2759  std::string* reqFil = osoption->getRequiredFiles();
2760  ok = osoption2->setRequiredFiles(nopt, reqFil) && ok;
2761 #ifdef DEBUG
2762  if (!ok)
2763  throw ErrorClass(" error in get/set RequiredFiles");
2764 #endif
2765 
2767  std::string* mkDir = osoption->getDirectoriesToMake();
2768  ok = osoption2->setDirectoriesToMake(nopt, mkDir) && ok;
2769 #ifdef DEBUG
2770  if (!ok)
2771  throw ErrorClass(" error in get/set DirectoriesToMake");
2772 #endif
2773 
2774  nopt = osoption->getNumberOfFilesToMake();
2775  std::string* mkFil = osoption->getFilesToMake();
2776  ok = osoption2->setFilesToMake(nopt, mkFil) && ok;
2777 #ifdef DEBUG
2778  if (!ok)
2779  throw ErrorClass(" error in get/set FilesToMake");
2780 #endif
2781 
2784  ok = osoption2->setInputDirectoriesToMove(nopt, inDMv) && ok;
2785 #ifdef DEBUG
2786  if (!ok)
2787  throw ErrorClass(" error in get/set InputDirectoriesToMove");
2788 #endif
2789 
2791  PathPair** inFMv = osoption->getInputFilesToMove();
2792  ok = osoption2->setInputFilesToMove(nopt, inFMv) && ok;
2793 #ifdef DEBUG
2794  if (!ok)
2795  throw ErrorClass(" error in get/set InputFilesToMove");
2796 #endif
2797 
2799  PathPair** outFMv = osoption->getOutputFilesToMove();
2800  ok = osoption2->setOutputFilesToMove(nopt, outFMv) && ok;
2801 #ifdef DEBUG
2802  if (!ok)
2803  throw ErrorClass(" error in get/set OutputFilesToMove");
2804 #endif
2805 
2808  ok = osoption2->setOutputDirectoriesToMove(nopt, outDMv) && ok;
2809 #ifdef DEBUG
2810  if (!ok)
2811  throw ErrorClass(" error in get/set OutputDirectoriesToMove");
2812 #endif
2813 
2815  std::string* rmFil = osoption->getFilesToDelete();
2816  ok = osoption2->setFilesToDelete(nopt, rmFil) && ok;
2817 #ifdef DEBUG
2818  if (!ok)
2819  throw ErrorClass(" error in get/set FilesToDelete");
2820 #endif
2821 
2823  std::string* rmDir = osoption->getDirectoriesToDelete();
2824  ok = osoption2->setDirectoriesToDelete(nopt, rmDir) && ok;
2825 #ifdef DEBUG
2826  if (!ok)
2827  throw ErrorClass(" error in get/set DirectoriesToDelete");
2828 #endif
2829 
2831  std::string* rmProc = osoption->getProcessesToKill();
2832  ok = osoption2->setProcessesToKill(nopt, rmProc) && ok;
2833 #ifdef DEBUG
2834  if (!ok)
2835  throw ErrorClass(" error in get/set ProcessesToKill");
2836 #endif
2837 
2838  OtherOption** otherOpt4;
2840  otherOpt4 = osoption->getOtherJobOptions();
2841  ok = osoption2->setOtherJobOptions(nopt, otherOpt4) && ok;
2842 #ifdef DEBUG
2843  if (!ok)
2844  throw ErrorClass(" error in get/set OtherJobOptions");
2845 #endif
2846 
2847  int nvar, nobj, ncon;
2848  nvar = osoption->getOptionInt("numberOfVariables");
2849  ok = osoption2->setNumberOfVariables(nvar) && ok;
2850  nobj = osoption->getOptionInt("numberOfObjectives");
2851  ok = osoption2->setNumberOfObjectives(nobj) && ok;
2852  ncon = osoption->getOptionInt("numberOfConstraints");
2853  ok = osoption2->setNumberOfConstraints(ncon) && ok;
2854 #ifdef DEBUG
2855  if (!ok)
2856  throw ErrorClass(" error in get/set problem dimensions");
2857 #endif
2858 
2859 // for the variables, objectives and constraints use a mixture of dense and sparse methods
2860  double* IVV;
2862  ok = osoption2->setInitVarValuesDense(nvar, IVV) && ok;
2863 #ifdef DEBUG
2864  if (!ok)
2865  throw ErrorClass(" error in get/set InitVarValues");
2866 #endif
2867 
2869  InitVarValueString** IVV2;
2871  ok = osoption2->setInitVarValuesStringSparse(nopt, IVV2) && ok;
2872 #ifdef DEBUG
2873  if (!ok)
2874  throw ErrorClass(" error in get/set InitVarValuesString");
2875 #endif
2876 
2877  std::string* IBS;
2879  ok = osoption2->setInitBasisStatusDense(nvar, IBS) && ok;
2880 #ifdef DEBUG
2881  if (!ok)
2882  throw ErrorClass(" error in get/set InitBasisStatus");
2883 #endif
2884 
2885  double* IVBW;
2887  ok = osoption2->setIntegerVariableBranchingWeightsDense(nvar, IVBW) && ok;
2888 #ifdef DEBUG
2889  if (!ok)
2890  throw ErrorClass(" error in get/set IntegerVariableBranchingWeights");
2891 #endif
2892 
2893  SOSWeights** sos;
2895  nopt = osoption->getNumberOfSOS();
2896  ok = osoption2->setSOSVariableBranchingWeights(nopt, sos) && ok;
2897 #ifdef DEBUG
2898  if (!ok)
2899  throw ErrorClass(" error in get/set SOSVariableBranchingWeights");
2900 #endif
2901 
2902  OtherVariableOption** otherV;
2905  ok = osoption2->setOtherVariableOptions(nopt, otherV) && ok;
2906 #ifdef DEBUG
2907  if (!ok)
2908  throw ErrorClass(" error in get/set OtherVariableOptions");
2909 #endif
2910 
2911  double* IOV;
2913  ok = osoption2->setInitObjValuesDense(nobj, IOV) && ok;
2914 #ifdef DEBUG
2915  if (!ok)
2916  throw ErrorClass(" error in get/set InitObjValues");
2917 #endif
2918 
2920  InitObjBound** IOB;
2922  ok = osoption2->setInitObjBoundsSparse(nopt, IOB) && ok;
2923 #ifdef DEBUG
2924  if (!ok)
2925  throw ErrorClass(" error in get/set InitObjBounds");
2926 #endif
2927 
2928  OtherObjectiveOption** otherO;
2931  ok = osoption2->setOtherObjectiveOptions(nopt, otherO) && ok;
2932 #ifdef DEBUG
2933  if (!ok)
2934  throw ErrorClass(" error in get/set OtherObjectiveOptions");
2935 #endif
2936 
2937 
2938  double* ICV;
2940  ok = osoption2->setInitConValuesDense(ncon, ICV) && ok;
2941 #ifdef DEBUG
2942  if (!ok)
2943  throw ErrorClass(" error in get/set InitConValues");
2944 #endif
2945 
2947  InitDualVarValue** IDV;
2949  ok = osoption2->setInitDualVarValuesSparse(nopt, IDV) && ok;
2950 #ifdef DEBUG
2951  if (!ok)
2952  throw ErrorClass(" error in get/set InitDualVarValues");
2953 #endif
2954 
2955  OtherConstraintOption** otherC;
2958  ok = osoption2->setOtherConstraintOptions(nopt, otherC) && ok;
2959 #ifdef DEBUG
2960  if (!ok)
2961  throw ErrorClass(" error in get/set OtherConstraintOptions");
2962 #endif
2963 
2964  SolverOption** SO;
2965  SO = osoption->getAllSolverOptions();
2967  ok = osoption2->setSolverOptions(nopt, SO) && ok;
2968 #ifdef DEBUG
2969  if (!ok)
2970  throw ErrorClass(" error in get/set SolverOptions");
2971 #endif
2972 
2973  ok = osoption->IsEqual(osoption2) && ok;
2974  if (!ok)
2975  throw ErrorClass(" OSOption get() and set() methods do not work correctly");
2976 
2977  cout << endl << "delete osoption2" << endl;
2978  delete osoption2;
2979  osoption2 = NULL;
2980  cout << "osoption2 deleted" << endl << endl;
2981 
2982  cout << "Write the content to a new file" <<endl;
2983  tmpOSoL = osolwriter->writeOSoL( osoption);
2984  cout << endl << "Here is tmpOSoL:" <<endl;
2985  cout << endl << endl << tmpOSoL << endl;
2986  cout << "-----------------------------------------" << endl << endl;
2987 // delete osolreader;
2988 // osolreader = NULL;
2989 
2990  // make sure we can parse without error
2991  OSoLReader *osolreader2;
2992  osolreader2 = new OSoLReader();
2993  cout << "Read the string back" << endl;
2994 
2995  OSOption *osoption3 = NULL;
2996  osoption3 = osolreader2->readOSoL( tmpOSoL);
2997 
2998  ok = osoption->IsEqual(osoption3);
2999  if (!ok)
3000  throw ErrorClass(" Loss of information in OSoL write/read");
3001  delete osolreader2;
3002  osolreader2 = NULL;
3003 
3004 
3005  delete osolwriter;
3006  osolwriter = NULL;
3007  delete osolreader;
3008  osolreader = NULL;
3009  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
3010 
3011 
3012  // now a second example
3013  cout << endl << "TEST " << ++nOfTest << ": Parse another .osol file" << endl << endl;
3014  osolwriter = new OSoLWriter();
3015  osolreader = new OSoLReader();
3016  cout << "First read the OSoL file into a string" << endl;
3017  osolFileName = dataDir + "osolFiles" + dirsep + "parsertest2.osol";
3018  osol = fileUtil->getFileAsString( osolFileName.c_str() );
3019  finish = clock();
3020  duration = (double) (finish - start) / CLOCKS_PER_SEC;
3021  cout << "Reading the file into a string took (seconds): "<< duration << endl;
3022  cout << "Parse the OSoL string into an OSOption object" << endl;
3023  osoption = osolreader->readOSoL( osol);
3024  tmpOSoL = osolwriter->writeOSoL( osoption) ;
3025  delete osolreader;
3026  osolreader = NULL;
3027  osolreader = new OSoLReader();
3028  osolreader->readOSoL( tmpOSoL);
3029  delete osolwriter;
3030  osolwriter = NULL;
3031  delete osolreader;
3032  osolreader = NULL;
3033 
3034  // and a third example
3035  cout << "Test parsing another OSoL file" << endl;
3036  osolwriter = new OSoLWriter();
3037  osolreader = new OSoLReader();
3038  cout << "First read the OSoL file into a string" << endl;
3039  osolFileName = dataDir + "osolFiles" + dirsep + "parsertest3.osol";
3040  osol = fileUtil->getFileAsString( osolFileName.c_str() );
3041  finish = clock();
3042  duration = (double) (finish - start) / CLOCKS_PER_SEC;
3043  cout << "Reading the file into a string took (seconds): "<< duration << endl;
3044  cout << "Parse the OSoL string into an OSOption object" << endl;
3045  osoption = osolreader->readOSoL( osol);
3046  tmpOSoL = osolwriter->writeOSoL( osoption) ;
3047  delete osolreader;
3048  osolreader = NULL;
3049  osolreader = new OSoLReader();
3050  osolreader->readOSoL( tmpOSoL);
3051  delete osolwriter;
3052  osolwriter = NULL;
3053  delete osolreader;
3054  osolreader = NULL;
3055 
3056 
3057  // a trivial string
3058  cout << "Test parsing a trivial string" << endl;
3059  osolreader = new OSoLReader();
3060  osol = "<osol></osol>";
3061  cout << "Parse the OSoL string into an OSOption object" << endl;
3062  osoption = osolreader->readOSoL( osol);
3063  delete osolreader;
3064  osolreader = NULL;
3065 
3066 
3067  unitTestResult <<
3068  "Successful test of OSoL parser on file parsertest.osol"
3069  << std::endl;
3070  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
3071 
3072 
3073  }
3074 
3075  catch(const ErrorClass& eclass){
3076  cout << endl << endl << endl;
3077  if(osolwriter != NULL) delete osolwriter;
3078  if(osolreader != NULL) delete osolreader;
3079  // " Problem with the test reading OSoL data";
3080  unitTestResultFailure << eclass.errormsg << endl;
3081  unitTestResultFailure << "There was a failure in the test for reading OSoL" << endl;
3082  }
3083 
3084 
3085 
3086  //
3087  // Now just test the OSrL parser
3088  try{
3097  cout << endl << "TEST " << ++nOfTest << ": OSrL parser" << endl << endl;
3098  std::string tmpOSrL;
3099  clock_t start, finish;
3100  double duration;
3101  osrlwriter = new OSrLWriter();
3102  osrlreader = new OSrLReader();
3103  OSResult *osresult = NULL;
3104  //osresult = new OSResult();
3105  cout << "TEST PARSING AN OSrL FILE" << endl;
3106  cout << "FIRST READ THE OSrL FILE INTO A STRING" << endl;
3107 // osrlFileName = dataDir + "osrlFiles" + dirsep + "parincLinear.osrl";
3108  osrlFileName = dataDir + "osrlFiles" + dirsep + "parserTest.osrl";
3109  start = clock();
3110  std::string osrl = fileUtil->getFileAsString( osrlFileName.c_str() );
3111  finish = clock();
3112  duration = (double) (finish - start) / CLOCKS_PER_SEC;
3113  cout << "Reading the file into a string took (seconds): "<< duration << endl;
3114  cout << osrl << endl;
3115  start = clock();
3116  cout << "PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
3117  osresult = osrlreader->readOSrL( osrl);
3118  cout << "Finished read; write OSResult object to temporary string" << endl;
3119  tmpOSrL = osrlwriter->writeOSrL( osresult) ;
3120  cout << tmpOSrL << endl;
3121  // make sure we can parse without error
3122  delete osrlreader;
3123  osrlreader = NULL;
3124  osrlreader = new OSrLReader();
3125  cout << "Parse temporary string" << endl;
3126  osrlreader->readOSrL( tmpOSrL);
3127  delete osrlwriter;
3128  osrlwriter = NULL;
3129  delete osrlreader;
3130  osrlreader = NULL;
3131 /*
3132  // now a second example
3133  cout << endl << "TEST PARSING ANOTHER OSrL FILE" << endl;
3134  osrlwriter = new OSrLWriter();
3135  osrlreader = new OSrLReader();
3136  cout << "FIRST READ THE OSrL FILE INTO A STRING" << endl;
3137  //errorExample.osrl -- check to see if we read an error message correct;
3138  osrlFileName = dataDir + "osrlFiles" + dirsep + "errorExample.osrl";
3139  osrl = fileUtil->getFileAsString( osrlFileName.c_str() );
3140  finish = clock();
3141  duration = (double) (finish - start) / CLOCKS_PER_SEC;
3142  cout << "Reading the file into a string took (seconds): "<< duration << endl;
3143  cout << "PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
3144  osresult = osrlreader->readOSrL( osrl);
3145  tmpOSrL = osrlwriter->writeOSrL( osresult) ;
3146  delete osrlreader;
3147  osrlreader = NULL;
3148  osrlreader = new OSrLReader();
3149  osrlreader->readOSrL( tmpOSrL);
3150  delete osrlwriter;
3151  osrlwriter = NULL;
3152  delete osrlreader;
3153  osrlreader = NULL;
3154 */
3155  unitTestResult <<
3156  "Successful test of OSrL parser on problems parincLinear.osrl and errorExample.osrl"
3157  << std::endl;
3158  cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
3159  }
3160  catch(const ErrorClass& eclass){
3161  cout << endl << endl << endl;
3162  if(osrlwriter != NULL) delete osrlwriter;
3163  if(osrlreader != NULL) delete osrlreader;
3164  // " Problem with the test reading OSrL data";
3165  unitTestResultFailure << eclass.errormsg << endl;
3166  unitTestResultFailure << "There was a failure in the test for reading OSrL" << endl;
3167  }
3168 
3169 
3170 
3171 
3172 
3173 #endif // COMPONENT_DEBUG
3174 
3175 
3176 
3177 
3178 
3179 //
3180  delete fileUtil;
3181  fileUtil = NULL;
3182 
3183  if(unitTestResultFailure.str().length() > 0){
3184  cout << endl << "THE UNIT TEST PASSED THE FOLLOWING:" << endl << endl;
3185  cout << unitTestResult.str() << endl << endl;
3186  cout << "UNFORTUNATELY, YOU FAILED ON THE FOLLOWING:" << endl << endl;
3187  cout << unitTestResultFailure.str() << endl << endl;
3188  cout << "Conclusion: FAILURE" << endl;
3189  return 1;
3190  }
3191  else{
3192  cout << endl << "THE UNIT TEST PASSED THE FOLLOWING:" << endl << endl;
3193  cout << unitTestResult.str() << endl << endl;
3194  cout << "All tests completed successfully" << endl << endl;
3195  return 0;
3196  }
3197 }//end main
3198 
3199 double getObjVal( std::string osrl){
3200  std::string sObjVal;
3201  double dObjVal;
3202  string::size_type pos2;
3203  string::size_type pos1 = osrl.find( "<obj ");
3204  if(pos1 != std::string::npos){
3205  // get the end of the obj start tag
3206  pos1 = osrl.find(">", pos1 + 1);
3207  if(pos1 != std::string::npos){
3208  // get the start of obj end tag
3209  pos2 = osrl.find( "</obj", pos1 + 1);
3210  if( pos2 != std::string::npos){
3211  // get the substring
3212  sObjVal = osrl.substr( pos1 + 1, pos2 - pos1 - 1);
3213  //std::cout << "HERE IS THE OBJECTIVE FUNCTION VALUE SUBSTRING " << sObjVal<< std::endl;
3214  // return dObjVal = strtod(sObjVal.c_str(), NULL);
3215  return dObjVal = os_strtod(sObjVal.c_str(), NULL);
3216  }
3217  else return OSNAN;
3218  }
3219  else return OSNAN;
3220  }
3221  else return OSNAN;
3222 }
OSOption * osoption
double os_strtod(const char *s00, char **se)
Definition: OSdtoa.cpp:2541
The BonminSolver class solves problems using Ipopt.
double value
branching weight
Definition: OSOption.h:1622
int idx
index of the variable
Definition: OSOption.h:1616
Implements a solve method for the Coin solvers.
Definition: OSCoinSolver.h:38
The CouenneSolver class solves problems using Ipopt.
virtual void solve()
solve results in an instance being read into the Couenne data structrues and optimized
virtual void buildSolverInstance()
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverIn...
The Default Solver Class.
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
std::string osol
osol holds the options for the solver
virtual void solve()=0
solve is a virtual function – the actual solvers will implement their own solve method
virtual void buildSolverInstance()=0
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverIn...
std::string osrl
osrl holds the solution or result of the model
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
std::string osil
osil holds the problem instance as a std::string
OSOption * osoption
osoption holds the solver options in-memory as an OSOption object
OSResult * osresult
osresult holds the solution or result of the model in-memory as an OSResult object
double * el
Definition: OSGeneral.h:621
used for throwing exceptions.
Definition: OSErrorClass.h:32
std::string errormsg
errormsg is the error that is causing the exception to be thrown
Definition: OSErrorClass.h:42
class used to make it easy to read and write files.
Definition: OSFileUtil.h:38
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
Definition: OSFileUtil.cpp:35
the InitDualVarValue class.
Definition: OSOption.h:2925
the InitObjBound class.
Definition: OSOption.h:2344
the InitVarValueString class.
Definition: OSOption.h:1321
LinearConstraintCoefficients * linearConstraintCoefficients
linearConstraintCoefficients is a pointer to a LinearConstraintCoefficients object
Definition: OSInstance.h:2196
The IpoptSolver class solves problems using Ipopt.
virtual void solve()
solve results in an instance being read into the Ipopt data structures and optimize
virtual void buildSolverInstance()
The implementation of the virtual functions.
the LindoSolver class solves problems using Lindo.
Definition: OSLindoSolver.h:50
DoubleVector * value
a pointer to the array of nonzero values being stored
Definition: OSInstance.h:315
int numberOfValues
numberOfValues is the number of nonzero elements stored in the <linearConstraintCoefficients> element
Definition: OSInstance.h:301
Used to hold the instance in memory.
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2263
bool setTimeDomain(std::string format)
This sets the format of the time domain ("stages"/"interval"/"none")
std::string getTimeDomainFormat()
Get the format of the time domain ("stages"/"interval")
int ** getTimeDomainStageVarList()
Get the list of variables in each stage.
bool setTimeDomainStages(int number, std::string *names)
This sets the number (and optionally names) of the time stages.
SparseJacobianMatrix * getJacobianSparsityPattern()
bool setTimeDomainStageConstraintsUnordered(int numberOfStages, int *numberOfConstraints, int **conIndex)
This sets the constraints associated with each time domain stage in srbitrary order.
int getTimeDomainStageNumber()
Get the number of stages that make up the time domain.
int * getTimeDomainStageNumberOfObjectives()
Get the number of objectives contained in each time stage.
double getTimeDomainIntervalHorizon()
Get the horizon for the time domain interval.
std::vector< ExprNode * > getNonlinearExpressionTreeInPrefix(int rowIdx)
Get the prefix tokens for a given row index.
int * getTimeDomainStageNumberOfVariables()
Get the number of variables contained in each time stage.
int ** getTimeDomainStageObjList()
Get the list of objectives in each stage.
int * getTimeDomainStageNumberOfConstraints()
Get the number of constraints contained in each time stage.
double getTimeDomainIntervalStart()
Get the start for the time domain interval.
std::string * getTimeDomainStageNames()
Get the names of the stages (NULL or empty string ("") if a stage has not been given a name.
SparseVector * calculateConstraintFunctionGradient(double *x, double *objLambda, double *conLambda, int idx, bool new_x, int highestOrder)
Calculate the gradient of the constraint function indexed by idx.
bool setTimeDomainStageConstraintsOrdered(int numberOfStages, int *numberOfConstraints, int *startIdx)
This sets the constraints associated with each time domain stage in temporal order.
bool setTimeDomainStageVariablesUnordered(int numberOfStages, int *numberOfVariables, int **varIndex)
This sets the variables associated with each time domain stage in srbitrary order.
InstanceData * instanceData
A pointer to an InstanceData object.
Definition: OSInstance.h:2278
SparseHessianMatrix * getLagrangianHessianSparsityPattern()
SparseHessianMatrix * calculateHessian(double *x, int idx, bool new_x)
Calculate the Hessian of a constraint or objective function.
int ** getTimeDomainStageConList()
Get the list of constraints in each stage.
std::vector< ExprNode * > getNonlinearExpressionTreeInPostfix(int rowIdx)
Get the postfix tokens for a given row index.
bool setTimeDomainStageObjectivesOrdered(int numberOfStages, int *numberOfObjectives, int *startIdx)
This sets the objectives associated with each time domain stage in temporal order.
bool setTimeDomainInterval(double start, double horizon)
This sets the start and end of the time interval.
ScalarExpressionTree * getNonlinearExpressionTree(int rowIdx)
Get the expression tree for a given row index.
bool setTimeDomainStageObjectivesUnordered(int numberOfStages, int *numberOfObjectives, int **varIndex)
This sets the objectives associated with each time domain stage in arbitrary order.
The Option Class.
Definition: OSOption.h:3565
SolverOption ** getAllSolverOptions()
Get all solver options.
Definition: OSOption.cpp:4567
double getMinDiskSpace()
Get the minimum required disk space.
Definition: OSOption.cpp:1739
bool setAnotherSOSVariableBranchingWeight(int sosIdx, int nvar, double weight, int *idx, double *value, std::string *name)
Definition: OSOption.cpp:8731
bool setDirectoriesToDelete(int numberOfPaths, std::string *paths)
Definition: OSOption.cpp:8288
bool setInstanceLocationType(std::string locationType)
Set the instance location type.
Definition: OSOption.cpp:7591
bool setMinMemorySize(std::string unit, std::string description, double value)
Set the minimum memory size required for the current job.
Definition: OSOption.cpp:7778
std::string getInstanceLocationType()
Get the location type.
Definition: OSOption.cpp:1461
double * getInitConValuesDense()
Get the initial values associated with the constraints in dense form.
Definition: OSOption.cpp:4002
bool setAnOtherConstraintOption(OtherConstraintOption *optionValue)
Definition: OSOption.cpp:9438
InitDualVarValue ** getInitDualVarValuesSparse()
Get the initial bounds associated with the dual variables in sparse form.
Definition: OSOption.cpp:4100
int getMinCPUNumber()
Get the minimum required number of CPUs.
Definition: OSOption.cpp:1814
std::string * getJobDependencies()
Get the array of job dependencies.
Definition: OSOption.cpp:2499
int getNumberOfRequiredDirectories()
Get the number of required directories.
Definition: OSOption.cpp:1885
OtherConstraintOption ** getAllOtherConstraintOptions()
Get all <other> constraint options.
Definition: OSOption.cpp:4461
bool setMinDiskSpace(std::string unit, std::string description, double value)
Set the minimum disk space required for the current job.
Definition: OSOption.cpp:7731
bool setAnotherDirectoryToMake(std::string path)
Definition: OSOption.cpp:8109
int getNumberOfDirectoriesToMake()
Get the number of directories to make.
Definition: OSOption.cpp:1909
bool setIntegerVariableBranchingWeightsDense(int numberOfVar, double *value)
Definition: OSOption.cpp:8677
bool setAnOtherSystemOption(std::string name, std::string value, std::string description)
Definition: OSOption.cpp:7911
PathPair ** getOutputFilesToMove()
Get the array of output files to move.
Definition: OSOption.cpp:2626
bool setAnotherInitDualVarValue(int idx, double lbValue, double ubValue)
Definition: OSOption.cpp:9325
bool setAnOtherJobOption(std::string name, std::string value, std::string description)
Definition: OSOption.cpp:8349
bool setInstanceName(std::string instanceName)
Set the instance name.
Definition: OSOption.cpp:7559
bool IsEqual(OSOption *that)
A function to check for the equality of two objects.
Definition: OSOption.cpp:9614
OptimizationOption * optimization
optimizationOption holds the fifth child of the OSOption specified by the OSoL Schema.
Definition: OSOption.h:3596
bool setInitObjBoundsSparse(int numberOfObj, InitObjBound **obj)
Definition: OSOption.cpp:9006
bool setOtherObjectiveOptions(int numberOfObj, OtherObjectiveOption **obj)
Definition: OSOption.cpp:9152
std::string getContactTransportType()
Get the transport type.
Definition: OSOption.cpp:1540
int getNumberOfSOS()
Get the number of special ordered sets for which branching weights are provided.
Definition: OSOption.cpp:2094
bool setServiceURI(std::string serviceURI)
Set the serviceURI.
Definition: OSOption.cpp:7540
bool setAnotherInitBasisStatus(int type, int idx, int status)
Set the basis status for another variable, objective or constraint/slack.
Definition: OSOption.cpp:8595
bool setSolverToInvoke(std::string solverToInvoke)
Set the solver to be invoked.
Definition: OSOption.cpp:7621
bool setFilesToDelete(int numberOfPaths, std::string *paths)
Definition: OSOption.cpp:8266
bool setInputFilesToMove(int numberOfPathPairs, PathPair **pathPair)
Definition: OSOption.cpp:8200
int getNumberOfOtherSystemOptions()
Get the number of <other> options in the <system> element.
Definition: OSOption.cpp:1837
int getNumberOfOutputDirectoriesToMove()
Get the number of output directories to move.
Definition: OSOption.cpp:1957
int getNumberOfInputDirectoriesToMove()
Get the number of input directories to move.
Definition: OSOption.cpp:1933
double * getInitObjValuesDense()
Get the initial values associated with the objectives in dense form.
Definition: OSOption.cpp:3411
bool setInputDirectoriesToMove(int numberOfPathPairs, PathPair **pathPair)
Definition: OSOption.cpp:8178
PathPair ** getOutputDirectoriesToMove()
Get the array of output directories to move.
Definition: OSOption.cpp:2644
bool setInstanceLocation(std::string instanceLocation)
Set the instance location.
Definition: OSOption.cpp:7567
bool setMaxTime(double value, std::string unit)
Definition: OSOption.cpp:7985
std::string * getDirectoriesToMake()
Get the array of directories to make.
Definition: OSOption.cpp:2554
bool setMaxTimeUnit(std::string unit)
Definition: OSOption.cpp:8000
std::string getMinCPUSpeedUnit()
Get the CPU speed unit.
Definition: OSOption.cpp:1600
bool setInitObjValuesDense(int numberOfObj, double *value)
Definition: OSOption.cpp:8957
std::string getSolverToInvoke()
Get the solver name.
Definition: OSOption.cpp:1484
bool setMinCPUSpeedUnit(std::string unit)
Definition: OSOption.cpp:7850
InitObjBound ** getInitObjBoundsSparse()
Get the initial bounds associated with the objectives in sparse form.
Definition: OSOption.cpp:3513
bool setJobID(std::string jobID)
Set the job ID.
Definition: OSOption.cpp:7613
int getNumberOfRequiredFiles()
Get the number of required files.
Definition: OSOption.cpp:1897
bool setOtherJobOptions(int numberOfOptions, OtherOption **other)
Definition: OSOption.cpp:8332
std::string getMaxTimeUnit()
Get the time unit.
Definition: OSOption.cpp:1647
bool setContact(std::string contact)
Set the contact information.
Definition: OSOption.cpp:7653
double getMinCPUSpeed()
Get the minimum required CPU speed.
Definition: OSOption.cpp:1763
std::string getJobID()
Get the job ID.
Definition: OSOption.cpp:1473
bool setInitVarValuesStringSparse(int numberOfVar, InitVarValueString **var)
Definition: OSOption.cpp:8478
bool setAnotherInputFileToMove(std::string fromPath, std::string toPath, bool makeCopy)
Definition: OSOption.cpp:8212
double getMinMemorySize()
Get the minimum required memory.
Definition: OSOption.cpp:1751
std::string * getRequiredDirectories()
Get the array of required directories.
Definition: OSOption.cpp:2518
std::string getServiceType()
Get the service type.
Definition: OSOption.cpp:1636
bool setAnOtherGeneralOption(std::string name, std::string value, std::string description)
Add another general option to the <other> option array.
Definition: OSOption.cpp:7716
bool setMinMemoryUnit(std::string unit)
Definition: OSOption.cpp:7803
bool setOtherServiceOptions(int numberOfOptions, OtherOption **other)
Definition: OSOption.cpp:7945
std::string getPassword()
Get the password.
Definition: OSOption.cpp:1517
bool setRequiredFiles(int numberOfPaths, std::string *paths)
Definition: OSOption.cpp:8075
bool setSolverOptions(int numberOfSolverOptions, SolverOption **solverOption)
Definition: OSOption.cpp:9492
InitVarValueString ** getInitVarValuesStringSparse()
Get the initial value strings associated with the variables in sparse form.
Definition: OSOption.cpp:2849
OtherVariableOption ** getAllOtherVariableOptions()
Get all <other> variable options.
Definition: OSOption.cpp:3341
bool setInitBasisStatusDense(int numberOfVar, std::string *var)
std::string getContact()
Get the contact information.
Definition: OSOption.cpp:1528
int getNumberOfInitObjBounds()
Get the number of initial objective bounds.
Definition: OSOption.cpp:2147
bool setOtherVariableOptions(int numberOfVar, OtherVariableOption **var)
Definition: OSOption.cpp:8887
int getNumberOfProcessesToKill()
Get the number of processes to kill.
Definition: OSOption.cpp:2005
bool setAnotherInitVarValueString(int idx, std::string value)
Definition: OSOption.cpp:8533
OtherOption ** getOtherServiceOptions()
Get the array of other options associated with the <service> element.
Definition: OSOption.cpp:2357
int getNumberOfOtherServiceOptions()
Get the number of <other> options in the <service> element.
Definition: OSOption.cpp:1849
bool setAnOtherServiceOption(std::string name, std::string value, std::string description)
Definition: OSOption.cpp:7962
bool setInitDualVarValuesSparse(int numberOfCon, InitDualVarValue **con)
Definition: OSOption.cpp:9272
bool setOutputDirectoriesToMove(int numberOfPathPairs, PathPair **pathPair)
Definition: OSOption.cpp:8244
bool setAnotherProcessToKill(std::string process)
Definition: OSOption.cpp:8322
OtherOption ** getOtherGeneralOptions()
Get the array of other options associated with the <general> element.
Definition: OSOption.cpp:2331
std::string getMinMemoryUnit()
Get the memory unit.
Definition: OSOption.cpp:1576
OtherOption ** getOtherJobOptions()
Get the array of other options associated with the <job> element.
Definition: OSOption.cpp:2370
bool setInitVarValuesDense(int numberOfVar, double *value)
Definition: OSOption.cpp:8429
bool setAnOtherObjectiveOption(OtherObjectiveOption *objOption)
Definition: OSOption.cpp:9169
bool setNumberOfObjectives(int numberOfObjectives)
Definition: OSOption.cpp:8368
std::string * getFilesToDelete()
Get the array of files to delete.
Definition: OSOption.cpp:2662
PathPair ** getInputFilesToMove()
Get the array of input files to move.
Definition: OSOption.cpp:2608
std::string getInstanceName()
Get the instance name.
Definition: OSOption.cpp:1438
bool setAnotherInitVarValue(int idx, double value)
Definition: OSOption.cpp:8453
PathPair ** getInputDirectoriesToMove()
Get the array of input directories to move.
Definition: OSOption.cpp:2590
bool setDirectoriesToMake(int numberOfPaths, std::string *paths)
Definition: OSOption.cpp:8097
bool setAnotherOutputDirectoryToMove(std::string fromPath, std::string toPath, bool makeCopy)
Definition: OSOption.cpp:8256
int getNumberOfFilesToDelete()
Get the number of files to delete.
Definition: OSOption.cpp:1981
bool setAnotherFileToMake(std::string path)
Definition: OSOption.cpp:8131
int getNumberOfDirectoriesToDelete()
Get the number of directories to delete.
Definition: OSOption.cpp:1993
std::string * getFilesToMake()
Get the array of files to make.
Definition: OSOption.cpp:2572
bool setUserName(std::string userName)
Set the username.
Definition: OSOption.cpp:7637
std::string * getInitBasisStatusDense()
Get the initial basis information in dense form.
bool setOutputFilesToMove(int numberOfPathPairs, PathPair **pathPair)
Definition: OSOption.cpp:8222
bool setFilesToMake(int numberOfPaths, std::string *paths)
Definition: OSOption.cpp:8119
bool setAnotherOutputFileToMove(std::string fromPath, std::string toPath, bool makeCopy)
Definition: OSOption.cpp:8234
bool setAnotherInputDirectoryToMove(std::string fromPath, std::string toPath, bool makeCopy)
Definition: OSOption.cpp:8190
bool setNumberOfVariables(int numberOfVariables)
Definition: OSOption.cpp:8360
double * getInitVarValuesDense()
Get the initial values associated with the variables in dense form.
Definition: OSOption.cpp:2744
std::string getServiceURI()
Get the service URI.
Definition: OSOption.cpp:1416
bool setAnotherRequiredDirectory(std::string path)
Definition: OSOption.cpp:8065
bool setAnotherRequiredFile(std::string path)
Definition: OSOption.cpp:8087
bool setOtherSystemOptions(int numberOfOptions, OtherOption **other)
Definition: OSOption.cpp:7893
int getNumberOfOtherVariableOptions()
Get the number of other variable options.
Definition: OSOption.cpp:2122
std::string getUserName()
Get the user name.
Definition: OSOption.cpp:1506
bool setInitConValuesDense(int numberOfCon, double *value)
Definition: OSOption.cpp:9224
double getMaxTime()
Get the maximum allowed time.
Definition: OSOption.cpp:1775
bool setAnOtherVariableOption(OtherVariableOption *varOption)
Definition: OSOption.cpp:8904
bool setContactTransportType(std::string transportType)
Set the transport type for contact.
Definition: OSOption.cpp:7677
int getNumberOfOtherJobOptions()
Get the number of <other> options in the <job> element.
Definition: OSOption.cpp:1861
bool setAnotherJobDependency(std::string jobID)
Definition: OSOption.cpp:8043
OtherObjectiveOption ** getAllOtherObjectiveOptions()
Get all <other> objective options.
Definition: OSOption.cpp:3957
bool setMinCPUSpeed(std::string unit, std::string description, double value)
Set the minimum CPU speed required for the current job.
Definition: OSOption.cpp:7835
bool setAnotherDirectoryToDelete(std::string path)
Definition: OSOption.cpp:8300
bool setMinCPUNumber(int number, std::string description)
Set the minimum number of CPU cores required for the current job.
Definition: OSOption.cpp:7882
bool setRequiredDirectories(int numberOfPaths, std::string *paths)
Definition: OSOption.cpp:8053
bool setProcessesToKill(int numberOfProcesses, std::string *processes)
Definition: OSOption.cpp:8310
bool setServiceName(std::string serviceName)
Set the service name.
Definition: OSOption.cpp:7548
int getOptionInt(std::string optionName)
Get any of the integer-valued options.
Definition: OSOption.cpp:2222
bool setAnotherFileToDelete(std::string path)
Definition: OSOption.cpp:8278
std::string getRequestedStartTime()
Get the requested starting time.
Definition: OSOption.cpp:1659
SOSWeights ** getSOSVariableBranchingWeightsSparse()
Get the SOS branching weights in sparse form.
Definition: OSOption.cpp:3289
bool setPassword(std::string password)
Set the password.
Definition: OSOption.cpp:7645
int getNumberOfInputFilesToMove()
Get the number of input files to move.
Definition: OSOption.cpp:1945
int getNumberOfInitDualVarValues()
Get the number of initial dual variable values.
Definition: OSOption.cpp:2182
bool setAnotherIntegerVariableBranchingWeight(int idx, double value)
Definition: OSOption.cpp:8700
std::string * getProcessesToKill()
Get the array of processes to kill.
Definition: OSOption.cpp:2698
std::string getInstanceLocation()
Get the instance location.
Definition: OSOption.cpp:1449
bool setOtherGeneralOptions(int numberOfOptions, OtherOption **other)
Set the other general options as an entire array.
Definition: OSOption.cpp:7699
std::string * getRequiredFiles()
Get the array of required files.
Definition: OSOption.cpp:2536
bool setSOSVariableBranchingWeights(int numberOfSOS, SOSWeights **sos)
Definition: OSOption.cpp:8712
int getNumberOfInitVarValuesString()
Get the number of initial variable strings.
Definition: OSOption.cpp:2069
int getNumberOfJobDependencies()
Get the number of job dependencies.
Definition: OSOption.cpp:1873
int getNumberOfOtherConstraintOptions()
Get the number of other constraint options.
Definition: OSOption.cpp:2195
bool setRequestedStartTime(std::string time)
Definition: OSOption.cpp:8022
OtherOption ** getOtherSystemOptions()
Get the array of other options associated with the <system> element.
Definition: OSOption.cpp:2344
bool setAnotherSolverOption(std::string name, std::string value, std::string solver, std::string category, std::string type, std::string description)
Definition: OSOption.cpp:9509
int getNumberOfOtherGeneralOptions()
Get the number of <other> options in the <general> element.
Definition: OSOption.cpp:1825
int getNumberOfFilesToMake()
Get the number of files to make.
Definition: OSOption.cpp:1921
std::string getMinDiskSpaceUnit()
Get the disk space unit.
Definition: OSOption.cpp:1552
bool setServiceType(std::string serviceType)
set() options in the <service> element
Definition: OSOption.cpp:7925
double * getIntegerVariableBranchingWeightsDense()
Get the integer branching weights in dense form.
Definition: OSOption.cpp:3190
int getNumberOfSolverOptions()
Get the number of solver options.
Definition: OSOption.cpp:2207
bool setMinDiskSpaceUnit(std::string unit)
Definition: OSOption.cpp:7756
bool setAnotherInitConValue(int idx, double value)
Definition: OSOption.cpp:9247
int getNumberOfOutputFilesToMove()
Get the number of output files to move.
Definition: OSOption.cpp:1969
std::string * getDirectoriesToDelete()
Get the array of directories to delete.
Definition: OSOption.cpp:2680
bool setNumberOfConstraints(int numberOfConstraints)
Definition: OSOption.cpp:8376
std::string getServiceName()
Get the service name.
Definition: OSOption.cpp:1427
int getNumberOfOtherObjectiveOptions()
Get the number of other objective options.
Definition: OSOption.cpp:2159
bool setOtherConstraintOptions(int numberOfOptions, OtherConstraintOption **other)
Definition: OSOption.cpp:9421
bool setJobDependencies(int numberOfDependencies, std::string *jobDependencies)
Definition: OSOption.cpp:8031
The Result Class.
Definition: OSResult.h:2549
std::string getGeneralMessage()
Get the general message.
Definition: OSResult.cpp:1520
Used to read an OSiL string.
Definition: OSiLReader.h:38
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Definition: OSiLReader.cpp:53
Take an OSInstance object and write a string that validates against the OSiL schema.
Definition: OSiLWriter.h:30
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
Definition: OSiLWriter.cpp:40
bool m_bWriteBase64
m_bWriteBase64 is set to true if we encode the linear constraint coefficients in base64 binary
Definition: OSiLWriter.h:64
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
Definition: OSiLWriter.h:68
The OSmps2osil Class.
Definition: OSmps2osil.h:40
bool createOSInstance()
create an OSInstance from the MPS instance representation
Definition: OSmps2osil.cpp:143
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the instance represented in N...
Definition: OSmps2osil.h:58
Used to read an OSoL string.
Definition: OSoLReader.h:38
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
Definition: OSoLReader.cpp:76
Take an OSOption object and write a string that validates against the OSoL schema.
Definition: OSoLWriter.h:30
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
Definition: OSoLWriter.cpp:45
The OSrLReader Class.
Definition: OSrLReader.h:43
OSResult * readOSrL(const std::string &posrl)
Get an OSResult object from an OSrL string.
Definition: OSrLReader.cpp:97
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:31
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
Definition: OSrLWriter.cpp:45
VariableOption * variables
the options for the variables
Definition: OSOption.h:3509
the OtherConOption class.
Definition: OSOption.h:3092
std::string lbValue
lower bound of the option
Definition: OSOption.h:3105
std::string ubValue
upper bound of the option
Definition: OSOption.h:3108
int idx
variable index
Definition: OSOption.h:3096
std::string value
value of the option
Definition: OSOption.h:3102
the OtherConstraintOption class.
Definition: OSOption.h:3157
std::string name
name of the option
Definition: OSOption.h:3167
int numberOfCon
number of <con> children
Definition: OSOption.h:3161
OtherConOption ** con
array of option values
Definition: OSOption.h:3185
the OtherObjectiveOption class.
Definition: OSOption.h:2575
int numberOfObj
number of <obj> children
Definition: OSOption.h:2579
std::string name
name of the option
Definition: OSOption.h:2585
the OtherOption class.
Definition: OSOption.h:153
the OtherVariableOption class.
Definition: OSOption.h:1990
int numberOfVar
number of child elements
Definition: OSOption.h:1994
std::string name
name of the option
Definition: OSOption.h:2000
the PathPair class.
Definition: OSOption.h:852
SOSWeights ** sos
branching weights for the SOS
Definition: OSOption.h:1861
the SOSWeights class.
Definition: OSOption.h:1776
BranchingWeight ** var
branching weights for individual variables
Definition: OSOption.h:1789
the SolverOption class.
Definition: OSOption.h:3345
The in-memory representation of a SparseHessianMatrix..
Definition: OSGeneral.h:377
int hessDimension
hessDimension is the number of nonzeros in each array.
Definition: OSGeneral.h:389
double * hessValues
hessValues is a double array of the Hessian values.
Definition: OSGeneral.h:404
a sparse vector data structure
Definition: OSGeneral.h:123
double * values
values holds a double array of nonzero values.
Definition: OSGeneral.h:164
int number
number is the number of elements in the indexes and values arrays.
Definition: OSGeneral.h:154
SOSVariableBranchingWeights * sosVariableBranchingWeights
branching weights for SOS variables and groups
Definition: OSOption.h:2116
#define OS_NEAR_EQUAL
we use OS_NEAR_EQUAL in unitTest to see if we are close to the optimal obj value
Definition: OSParameters.h:89
double getObjVal(std::string osrl)
Definition: unitTest.cpp:10398
int main(int argC, char *argV[])
Definition: unitTest.cpp:269
This file defines the OSInstance class along with its supporting classes.
#define OSNAN
Definition: OSParameters.h:106
OSResult * osresult