107#define COMPONENT_DEBUG
110#include <cppad/cppad.hpp>
125#include "CoinError.hpp"
133#include "OSCommonUtil.h"
137#include <CoinMpsIO.hpp>
138#include <CoinPackedMatrix.hpp>
144#include <OsiGlpkSolverInterface.hpp>
147#ifdef COIN_HAS_COUENNE
152#include "OSnl2osil.h"
163#ifdef COIN_HAS_BONMIN
176# error "don't have header file for time"
197# error "don't have header file for stdio"
207using std::ostringstream;
212int main(
int argC,
char* argV[])
217 WindowsErrorPopupBlocker();
224 cout <<
"START UNIT TEST" << endl;
229 OSnl2osil *nl2osil = NULL;
239 std::string osilFileName;
240 std::string osolFileName;
241 std::string osrlFileName;
242 std::string nlFileName;
243 std::string mpsFileName;
246 ostringstream unitTestResult;
247 ostringstream unitTestResultFailure;
249 const char dirsep = CoinFindDirSeparator();
252 dataDir = dirsep ==
'/' ?
"../data/" :
"..\\data\\";
253 nlFileName = dataDir +
"amplFiles" + dirsep +
"parinc.nl";
254 mpsFileName = dataDir +
"mpsFiles" + dirsep +
"parinc.mps";
258#ifdef INSTALLATION_TEST
262 std::cout << endl <<
"TEST " << ++nOfTest <<
": Try to read a sample file" << endl << endl;
263 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincLinearByRow.osil";
265 std::cout <<
"The file is: " ;
266 std::cout << osilFileName << std::endl;
268 std::cout <<
"Done reading the test file" << std::endl;
272 unitTestResult <<
"Reading files successfully" << std::endl;
273 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
313 cout << endl <<
"TEST " << ++nOfTest <<
": Lossless I/O" << endl << endl;
315 mpsFileName = dataDir +
"mpsFiles" + dirsep +
"parinc.mps";
321 std::string sOSiL = osilwriter.
writeOSiL( osinstance1 );
329 double theDiff, theMax;
332 for(
int i = 0; i < nvals; i++){
335 if(theDiff > theMax){
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;
345 { unitTestResult <<
"Passed lossless IO test" << std::endl;
346 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
411 unitTestResultFailure <<
"Sorry Unit Test Failed Reading a file: " + eclass.
errormsg<< endl;
413 unitTestResultFailure <<
"Since we can't read files we are terminating" << endl;
414 cout << unitTestResultFailure.str() << endl << endl;
415 cout <<
"Conclusion: FAILURE" << endl;
420 cout << endl <<
"TEST " << ++nOfTest <<
": Clp solver on parincLinearByRow.osil" << endl << endl;
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";
428 std::cout <<
"create a new Solver object" << std::endl;
434 std::cout <<
" Done reading the OSiL" << std::endl;
439 std::cout <<
" Write the OSiL" << std::endl;
442 std::cout <<
" Done writing the OSiL" << std::endl;
444 cout <<
"call the COIN - clp Solver for parincLinearbyRow" << endl;
447 cout <<
"Here is the COIN clp solver solution for parincLinearByRow" << endl;
448 cout << solver->
osrl << endl;
452 if(ok ==
false)
throw ErrorClass(
" Fail unit test with clp on parincLinearByRow.osil");
455 cout <<
"First osrl file\n" << solver->
osrl << endl;
457 cout <<
"read successfully" << endl;
459 cout <<
"osilreader successfully deleted" << endl;
462 cout <<
"osolreader successfully deleted" << endl;
465 cout <<
"solver successfully deleted" << endl;
468 cout <<
"osilwriter successfully deleted" << endl;
471 cout <<
"osrlreader successfully deleted" << endl;
473 unitTestResult <<
"Solved problem parincLinearByRow.osil with Clp" << std::endl;
474 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
477 unitTestResultFailure <<
"Sorry Unit Test Failed Testing Clp Solver:" + eclass.
errormsg<< endl;
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;
485 osilFileName = dataDir +
"osilFiles" + dirsep +
"p0033.osil";
486 osolFileName = dataDir +
"osolFiles" + dirsep +
"p0033_cbc.osol";
497 cout <<
"call the COIN - Cbc Solver for p0033" << endl;
500 cout <<
"Here is the COIN Cbc solver solution for p0033" << endl;
505 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Cbc on p0033.osil");
512 unitTestResult <<
"Solved problem p0033.osil with Cbc" << std::endl;
513 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
516 unitTestResultFailure <<
"Sorry Unit Test Failed Testing Cbc Solver:" + eclass.
errormsg<< endl;
522 cout << endl <<
"TEST " << ++nOfTest <<
": Cbc solver on p0201.osil" << endl << endl;
524 osilFileName = dataDir +
"osilFiles" + dirsep +
"p0201.osil";
525 osolFileName = dataDir +
"osolFiles" + dirsep +
"p0201_cbc.osol";
536 cout <<
"call the COIN - Cbc Solver for p0201" << endl;
538 cout <<
"Here is the COIN Cbc solver solution for p0201" << endl;
542 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Cbc on p0201.osil");
549 unitTestResult <<
"Solved problem p0201.osil with Cbc" << std::endl;
550 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
553 unitTestResultFailure <<
"Sorry Unit Test Failed Testing Cbc Solver:" + eclass.
errormsg<< endl;
556 cout << endl <<
"TEST " << ++nOfTest <<
": Cbc solver on parincInteger.osil" << endl << endl;
558 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincInteger.osil";
559 osolFileName = dataDir +
"osolFiles" + dirsep +
"parincInteger_cbc.osol";
569 cout <<
"call the COIN - Cbc Solver for parincInteger" << endl;
572 cout <<
"Here is the Cbc solver solution for parincInteger" << endl;
576 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Cbc on parincInteger.osil");
577 unitTestResult <<
"Solved problem parincInteger.osil with Cbc" << std::endl;
584 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
592 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver with avion2.osil" << endl << endl;
594 cout <<
"create a new IPOPT Solver for OSiL string solution" << endl;
600 osilFileName = dataDir +
"osilFiles" + dirsep +
"avion2.osil";
601 osolFileName = dataDir +
"osolFiles" + dirsep +
"avion2_ipopt.osol";
604 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
605 ipoptSolver->
osol = osol;
609 ipoptSolver->
osol = osol;
610 cout <<
"call the IPOPT Solver" << endl;
612 ipoptSolver->
solve();
613 cout <<
"Here is the IPOPT solver solution for avion2" << endl;
617 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Ipopt on avion2.osil");
624 unitTestResult <<
"Solved problem avion2.osil with Ipopt" << std::endl;
625 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
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;
634 osilFileName = dataDir +
"osilFiles" + dirsep +
"HS071_NLPMod.osil";
635 osolFileName = dataDir +
"osolFiles" + dirsep +
"HS071_NLPMod_ipopt.osol";
638 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
644 ipoptSolver->
osol = osol;
646 ipoptSolver->
solve();
647 cout <<
"Here is the IPOPT solver solution for HS071_NLP" << endl;
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;
661 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on rosenbrockmod.osil" << endl << endl;
662 cout <<
"create a new IPOPT Solver for OSiL string solution" << endl;
666 osilFileName = dataDir +
"osilFiles" + dirsep +
"rosenbrockmod.osil";
667 osolFileName = dataDir +
"osolFiles" + dirsep +
"rosenbrockmod_ipopt.osol";
670 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
673 ipoptSolver->
osil = osil;
675 cout <<
"call the IPOPT Solver" << endl;
677 ipoptSolver->
solve();
682 throw ErrorClass(
" Fail unit test with Ipopt on rosenbrockmod.osil");
687 unitTestResult <<
"Solved problem rosenbrockmod.osil with Ipopt" << std::endl;
690 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
692 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on parincQuadratic.osil" << endl << endl;
693 cout <<
"create a new IPOPT Solver for OSiL string solution" << endl;
697 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincQuadratic.osil";
698 osolFileName = dataDir +
"osolFiles" + dirsep +
"parincQuadratic_ipopt.osol";
701 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
705 ipoptSolver->
osil = osil;
706 ipoptSolver->
osol = osol;
707 cout <<
"call the IPOPT Solver" << endl;
709 ipoptSolver->
solve();
710 cout <<
"Here is the IPOPT solver solution for parincQuadratic" << endl;
714 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Ipopt on parincQuadradic.osil");
719 unitTestResult <<
"Solved problem parincQuadratic.osil with Ipopt" << std::endl;
722 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
724 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on parincLinear.osil" << endl << endl;
725 cout <<
"create a new IPOPT Solver for OSiL string solution" << endl;
729 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincLinear.osil";
730 osolFileName = dataDir +
"osolFiles" + dirsep +
"parincLinear_ipopt.osol";
733 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
738 ipoptSolver->
osol =
"";
739 cout <<
"call the IPOPT Solver" << endl;
741 ipoptSolver->
solve();
742 cout <<
"Here is the IPOPT solver solution for parincLinear" << endl;
746 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Ipopt on parincLinear.osil");
747 unitTestResult <<
"Solved problem parincLinear.osil with Ipopt" << std::endl;
754 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
756 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on callBackTest.osil" << endl << endl;
757 cout <<
"create a new IPOPT Solver for OSiL string solution" << endl;
761 osilFileName = dataDir +
"osilFiles" + dirsep +
"callBackTest.osil";
762 osolFileName = dataDir +
"osolFiles" + dirsep +
"callBackTest_ipopt.osol";
765 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
770 ipoptSolver->
osol = osol;
771 cout <<
"call the IPOPT Solver" << endl;
773 ipoptSolver->
solve();
774 cout <<
"Here is the IPOPT solver solution for callBackTest" << endl;
778 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Ipopt on callBackTest.osil");
779 unitTestResult <<
"Solved problem callBackTest.osil with Ipopt" << std::endl;
786 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
788 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on callBackTestRowMajor.osil" << endl << endl;
789 cout <<
"create a new IPOPT Solver for OSiL string solution" << endl;
793 osilFileName = dataDir +
"osilFiles" + dirsep +
"callBackTestRowMajor.osil";
794 osolFileName = dataDir +
"osolFiles" + dirsep +
"callBackTestRowMajor_ipopt.osol";
797 cout <<
"IPOPT Solver created for OSiL string solution" << endl;
802 ipoptSolver->
osil = osil;
803 ipoptSolver->
osol = osol;
804 cout <<
"call the IPOPT Solver" << endl;
806 ipoptSolver->
solve();
807 cout <<
"Here is the IPOPT solver solution for callBackTestRowMajor" << endl;
811 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Ipopt on callBackTestRowMajor.osil");
818 unitTestResult <<
"Solved problem callBackRowMajor.osil with Ipopt" << std::endl;
819 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
821 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on nonconvex.osil" << endl << endl;
826 osilFileName = dataDir +
"osilFiles" + dirsep +
"nonconvex.osil";
837 cout <<
"call the COIN - Ipopt Solver for nonconvex.osil" << endl;
840 std::cout <<
" CALL SOLVE " << std::endl;
843 cout <<
"Here is the Ipopt solver solution for nonconvex.osil" << endl;
851 cout << solver->
osrl << endl << endl;
860 unitTestResult <<
"Solved problem nonconvex.osil with Ipopt" << std::endl;
867 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
869 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on rosenbrockorig.osil" << endl << endl;
874 osilFileName = dataDir +
"osilFiles" + dirsep +
"rosenbrockorig.osil";
885 cout <<
"call the COIN - Ipopt Solver for rosenbrockorig" << endl;
888 std::cout <<
" CALL SOLVE " << std::endl;
891 cout <<
"Here is the Ipopt solver solution for rosenbrockorig" << endl;
899 cout << solver->
osrl << endl << endl;
908 unitTestResult <<
"Solved problem rosenbrockorig.osil with Ipopt" << std::endl;
915 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
917 cout << endl <<
"TEST " << ++nOfTest <<
": Ipopt solver on HS071_feas.osil" << endl << endl;
922 osilFileName = dataDir +
"osilFiles" + dirsep +
"HS071_feas.osil";
933 cout <<
"call the COIN - Ipopt Solver for HS071_feas.osil" << endl;
936 std::cout <<
" CALL SOLVE " << std::endl;
942 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Ipopt on HS071_feas.osil");
945 cout <<
"Received error message from Ipopt: \"Ipopt NEEDS AN OBJECTIVE FUNCTION\"" << endl;
946 unitTestResult <<
"Correctly diagnosed problem HS071_feas with Ipopt" << std::endl;
955 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
960 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the Ipopt Solver:" + eclass.
errormsg<< endl;
965#ifdef COIN_HAS_BONMIN
967 cout << endl <<
"TEST " << ++nOfTest <<
": Bonmin solver on bonminEx1.osil" << endl << endl;
972 osilFileName = dataDir +
"osilFiles" + dirsep +
"bonminEx1.osil";
973 osolFileName = dataDir +
"osolFiles" + dirsep +
"bonminEx1_Bonmin.osol";
981 cout <<
"call the COIN - Bonmin Solver for bonminEx1" << endl;
984 cout <<
"Here is the Bonmin solver solution for bonminEx1" << endl;
985 cout << solver->
osrl << endl;
989 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Bonmin on bonminEx1.osil");
992 unitTestResult <<
"Solved problem bonminEx1.osil with Bonmin" << std::endl;
997 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1000 cout << endl <<
"TEST " << ++nOfTest <<
": Bonmin solver on wayneQuadratic.osil" << endl << endl;
1002 osilFileName = dataDir +
"osilFiles" + dirsep +
"wayneQuadratic.osil";
1003 osolFileName = dataDir +
"osolFiles" + dirsep +
"wayneQuadratic_Bonmin1.osol";
1008 solver->
osol = osol;
1010 cout <<
"call the Bonmin Solver for wayneQuadratic" << endl;
1014 cout <<
"Here is the Bonmin solver solution" << endl;
1015 cout << solver->
osrl << endl;
1017 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1020 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1021 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Bonmin on wayneQuadratic.osil");
1026 unitTestResult <<
"Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
1027 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1029 cout << endl <<
"TEST " << ++nOfTest <<
": Bonmin solver on wayneQuadratic.osil" << endl << endl;
1031 osilFileName = dataDir +
"osilFiles" + dirsep +
"wayneQuadratic.osil";
1032 osolFileName = dataDir +
"osolFiles" + dirsep +
"wayneQuadratic_Bonmin2.osol";
1038 solver->
osol = osol;
1041 cout <<
"call the Bonmin Solver for wayneQuadratic" << endl;
1045 cout <<
"Here is the Bonmin solver solution" << endl;
1046 cout << solver->
osrl << endl;
1048 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1051 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1052 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Bonmin on wayneQuadratic.osil");
1059 unitTestResult <<
"Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
1060 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1065 cout << endl <<
"TEST " << ++nOfTest <<
": Bonmin solver on rosenbrockorig.osil" << endl << endl;
1067 osilFileName = dataDir +
"osilFiles" + dirsep +
"rosenbrockorig.osil";
1077 cout <<
"call the Bonmin Solver for rosenbrockorig" << endl;
1080 cout <<
"Here is the Bonmin solver solution" << endl;
1081 cout << solver->
osrl << endl;
1083 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1086 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1087 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Bonmin on rosenbrockorig.osil");
1094 unitTestResult <<
"Solved problem rosenbrockorig.osil with Bonmin" << std::endl;
1095 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1099 cout << endl <<
"TEST " << ++nOfTest <<
": Bonmin solver on rosenbrockinteger.osil" << endl << endl;
1101 osilFileName = dataDir +
"osilFiles" + dirsep +
"rosenbrockinteger.osil";
1111 cout <<
"call the Bonmin Solver for rosenbrockinteger" << endl;
1114 cout <<
"Here is the Bonmin solver solution" << endl;
1115 cout << solver->
osrl << endl;
1117 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1120 std::cout <<
"CALL NEAR_EQUAL" << std::endl;
1121 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Bonmin on rosenbrockinteger.osil");
1128 unitTestResult <<
"Solved problem rosenbrockinteger.osil with Bonmin" << std::endl;
1129 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1134 cout <<
"OSrL = " << solver->
osrl << endl;
1135 cout << endl << endl << endl;
1136 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the Bonmin Solver:" + eclass.
errormsg << endl;
1141#ifdef COIN_HAS_COUENNE
1143 cout << endl <<
"TEST " << ++nOfTest <<
": Couenne solver on bonminEx1.osil" << endl << endl;
1150 osilFileName = dataDir +
"osilFiles" + dirsep +
"bonminEx1.osil";
1151 osolFileName = dataDir +
"osolFiles" + dirsep +
"bonminEx1_Couenne.osol";
1156 solver->
osil = osil;
1157 solver->
osol = osol;
1160 cout <<
"call the COIN - Couenne Solver for bonminEx1" << endl;
1163 std::cout <<
" CALL SOLVE " << std::endl;
1166 cout <<
"Here is the Couenne solver solution for bonminEx1" << endl;
1176 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Couenne on bonminEx1.osil");
1180 unitTestResult <<
"Solved problem bonminEx1.osil with Couenne" << std::endl;
1187 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1190 cout << endl <<
"TEST " << ++nOfTest <<
": Couenne solver on bonminEx1_Nonlinear.osil" << endl << endl;
1195 osilFileName = dataDir +
"osilFiles" + dirsep +
"bonminEx1_Nonlinear.osil";
1202 solver->
osil = osil;
1203 solver->
osol = osol;
1206 cout <<
"call the COIN - Couenne Solver for bonminEx1_Nonlinear" << endl;
1209 std::cout <<
" CALL SOLVE " << std::endl;
1212 cout <<
"Here is the Couenne solver solution for bonminEx1_Nonlinear.osil" << endl;
1220 cout << solver->
osrl << endl << endl;
1229 unitTestResult <<
"Solved problem bonminEx1_Nonlinear with Couenne" << std::endl;
1236 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1239 cout << endl <<
"TEST " << ++nOfTest <<
": Couenne solver on nonconvex.osil" << endl << endl;
1244 osilFileName = dataDir +
"osilFiles" + dirsep +
"nonconvex.osil";
1251 solver->
osil = osil;
1252 solver->
osol = osol;
1255 cout <<
"call the COIN - Couenne Solver for nonconvex.osil" << endl;
1258 std::cout <<
" CALL SOLVE " << std::endl;
1261 cout <<
"Here is the Couenne solver solution for nonconvex.osil" << endl;
1269 cout << solver->
osrl << endl << endl;
1278 unitTestResult <<
"Solved problem nonconvex.osil with Couenne" << std::endl;
1285 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1287 cout << endl <<
"TEST " << ++nOfTest <<
": Couenne solver on rosenbrockorig.osil" << endl << endl;
1292 osilFileName = dataDir +
"osilFiles" + dirsep +
"rosenbrockorig.osil";
1299 solver->
osil = osil;
1300 solver->
osol = osol;
1303 cout <<
"call the COIN - Couenne Solver for rosenbrockorig" << endl;
1306 std::cout <<
" CALL SOLVE " << std::endl;
1309 cout <<
"Here is the Couenne solver solution for rosenbrockorig" << endl;
1317 cout << solver->
osrl << endl << endl;
1326 unitTestResult <<
"Solved problem rosenbrockorig.osil with Couenne" << std::endl;
1333 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1337 cout << endl <<
"TEST " << ++nOfTest <<
": Couenne solver on rosenbrockinteger.osil" << endl << endl;
1342 osilFileName = dataDir +
"osilFiles" + dirsep +
"rosenbrockinteger.osil";
1349 solver->
osil = osil;
1350 solver->
osol = osol;
1353 cout <<
"call the COIN - Couenne Solver for rosenbrockinteger" << endl;
1356 std::cout <<
" CALL SOLVE " << std::endl;
1359 cout <<
"Here is the Couenne solver solution for rosenbrockinteger" << endl;
1367 cout << solver->
osrl << endl << endl;
1376 unitTestResult <<
"Solved problem rosenbrockinteger.osil with Couenne" << std::endl;
1383 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1386 cout << endl <<
"TEST " << ++nOfTest <<
": Couenne solver on HS071_feas.osil" << endl << endl;
1391 osilFileName = dataDir +
"osilFiles" + dirsep +
"HS071_feas.osil";
1398 solver->
osil = osil;
1399 solver->
osol = osol;
1402 cout <<
"call the COIN - Couenne Solver for HS071_feas.osil" << endl;
1405 std::cout <<
" CALL SOLVE " << std::endl;
1408 cout <<
"Here is the Couenne solver solution for HS071_feas" << endl;
1416 cout << solver->
osrl << endl << endl;
1425 unitTestResult <<
"Solved problem HS071_feas with Couenne" << std::endl;
1432 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1438 cout <<
"OSrL = " << solver->
osrl << endl;
1439 cout << endl << endl << endl;
1440 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the Couenne Solver:" + eclass.
errormsg << endl;
1447#ifdef COIN_HAS_SYMPHONY
1449 cout << endl <<
"TEST " << ++nOfTest <<
": SYMPHONY solver on p0033.osil" << endl << endl;
1451 osilFileName = dataDir +
"osilFiles" + dirsep +
"p0033.osil";
1452 osolFileName = dataDir +
"osolFiles" + dirsep +
"p0033_sym.osol";
1458 solver->
osil = osil;
1461 cout <<
"build the solver instance for COIN - SYMPHONY" << endl;
1465 cout <<
"Here is the COIN SYMPHONY solver solution for p0033" << endl;
1466 cout << solver->
osrl << endl;
1470 if(ok ==
false)
throw ErrorClass(
" Fail unit test with SYMPHONY on p0033.osil");
1475 unitTestResult <<
"Solved problem p0033.osil with SYMPHONY" << std::endl;
1476 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1479 cout <<
"OSrL = " << solver->
osrl << endl;
1480 cout << endl << endl << endl;
1481 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the SYMPHONY Solver:" + eclass.
errormsg << endl;
1489 cout << endl <<
"TEST " << ++nOfTest <<
": DyLP solver on parincLinear.osil" << endl << endl;
1491 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincLinear.osil";
1492 osolFileName = dataDir +
"osolFiles" + dirsep +
"parincLinear_dylp.osol";
1498 solver->
osol = osol;
1500 cout <<
"call the COIN - DyLP solver for parincLinear" << endl;
1503 cout <<
"Here is the COIN - DyLP solver solution for parincLinear" << endl;
1504 cout << solver->
osrl << endl;
1508 if(ok ==
false)
throw ErrorClass(
" Fail unit test with DyLP on parincLinear.osil");
1513 unitTestResult <<
"Solved problem parincLinear.osil with DyLP" << std::endl;
1514 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1517 cout <<
"OSrL = " << solver->
osrl << endl;
1518 cout << endl << endl << endl;
1519 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the DyLP Solver:" + eclass.
errormsg << endl;
1526 cout << endl <<
"TEST " << ++nOfTest <<
": Vol solver on volumeTest.osil" << endl << endl;
1528 osilFileName = dataDir +
"osilFiles" + dirsep +
"volumeTest.osil";
1529 osolFileName = dataDir +
"osolFiles" + dirsep +
"volumeTest_vol.osol";
1535 solver->
osil = osil;
1538 cout <<
"call the COIN - Vol solver for volumeTest" << endl;
1541 cout <<
"Here is the COIN - Vol solver solution for parincLinear" << endl;
1542 cout << solver->
osrl << endl;
1546 if(ok ==
false)
throw ErrorClass(
" Fail unit test with Vol on volumeTest.osil");
1551 unitTestResult <<
"Solved problem volumeTest.osil with Vol" << std::endl;
1552 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1555 cout <<
"OSrL = " << solver->
osrl << endl;
1556 cout << endl << endl << endl;
1557 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the Vol Solver:" + eclass.
errormsg << endl;
1563 cout << endl <<
"TEST " << ++nOfTest <<
": GLPK solver on p0033.osil" << endl << endl;
1565 osilFileName = dataDir +
"osilFiles" + dirsep +
"p0033.osil";
1566 osolFileName = dataDir +
"osolFiles" + dirsep +
"p0033_glpk.osol";
1575 cout <<
"call the GLPK Solver for p0033" << endl;
1578 cout <<
"Here is the GLPK solver solution for p0033" << endl;
1579 cout << solver->
osrl << endl;
1583 if(ok ==
false)
throw ErrorClass(
" Fail unit test with GLPK on p0033.osil");
1590 unitTestResult <<
"Solved problem p0033.osil with GLPK" << std::endl;
1591 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1594 cout <<
"OSrL = " << solver->
osrl << endl;
1595 cout << endl << endl << endl;
1596 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the Glpk Solver:" + eclass.
errormsg << endl;
1604 cout << endl <<
"TEST " << ++nOfTest <<
": Cplex solver on p0033.osil" << endl << endl;
1606 osilFileName = dataDir +
"osilFiles" + dirsep +
"p0033.osil";
1607 osolFileName = dataDir +
"osolFiles" + dirsep +
"p0033_cpx.osol";
1612 solver->
osil = osil;
1613 solver->
osol = osol;
1615 cout <<
"call the CPLEX Solver for p0033" << endl;
1618 cout <<
"Here is the CPLEX solver solution for p0033" << endl;
1619 cout << solver->
osrl << endl;
1623 if(ok ==
false)
throw ErrorClass(
" Fail unit test with CPLEX on p0033.osil");
1626 unitTestResult <<
"Solved problem p0033.osil with CPLEX" << std::endl;
1627 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1630 cout <<
"OSrL = " << solver->
osrl << endl;
1631 cout << endl << endl << endl;
1632 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the Cplex Solver:" + eclass.
errormsg << endl;
1637#ifdef COIN_HAS_LINDO
1639 cout << endl <<
"TEST " << ++nOfTest <<
": Lindo solver on lindoapiaddins.osil" << endl << endl;
1641 osilFileName = dataDir +
"osilFiles" + dirsep +
"lindoapiaddins.osil";
1642 osolFileName = dataDir +
"osolFiles" + dirsep +
"lindoapiaddins_lindo.osol";
1646 cout <<
"create a new LINDO Solver for OSiL string solution" << endl;
1649 solver->
osol = osol;
1650 cout <<
"call the LINDO Solver" << endl;
1653 cout <<
"Here is the LINDO solver solution" << endl;
1654 cout << solver->
osrl << endl;
1658 if(ok ==
false)
throw ErrorClass(
" Fail unit test with LINDO on lindoapiaddins.osil");
1664 unitTestResult <<
"Solved problem lindoapiaddins.osil with Lindo" << std::endl;
1665 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
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";
1675 solver->
osil = osil;
1676 solver->
osol = osol;
1678 cout <<
"call the LINDO Solver" << endl;
1681 cout <<
"Here is the LINDO solver solution" << endl;
1682 cout << solver->
osrl << endl;
1686 if(ok ==
false)
throw ErrorClass(
" Fail unit test with LINDO on rosenbrockmod.osil");
1690 unitTestResult <<
"Solved problem rosenbrockmod.osil with Lindo" << std::endl;
1691 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
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";
1701 solver->
osil = osil;
1702 solver->
osol = osol;
1705 cout <<
"call the LINDO Solver" << endl;
1708 cout <<
"Here is the LINDO solver solution" << endl;
1709 cout << solver->
osrl << endl;
1713 if(ok ==
false)
throw ErrorClass(
" Fail unit test with LINDO on parincQuadratic.osil");
1718 unitTestResult <<
"Solved problem parincQuadratic.osil with Lindo" << std::endl;
1719 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1756 cout << endl << endl << endl;
1757 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the LINDO Solver:" + eclass.
errormsg << endl << endl;
1766 cout << endl <<
"TEST " << ++nOfTest <<
": Cbc solver using MPS file" << endl << endl;
1770 cout <<
"create a COIN Solver for MPS - OSInstance solution" << endl;
1776 osol =
"<osol t></osol>";
1777 solver->
osol = osol;
1778 cout <<
"call COIN Solve" << endl;
1781 cout <<
"Here is the COIN solver solution" << endl;
1782 cout << solver->
osrl << endl;
1786 if(ok ==
false)
throw ErrorClass(
" Fail unit test with COIN Solver on MPS test problem parincLinear.mps");
1793 unitTestResult <<
"Test the MPS -> OSiL converter on parinc.mps using Cbc" << std::endl;
1794 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1797 cout <<
"OSrL = " << solver->
osrl << endl;
1798 cout << endl << endl << endl;
1799 unitTestResultFailure <<
"Sorry Unit Test Failed Testing the MPS converter:" + eclass.
errormsg << endl;
1805 cout << endl <<
"TEST " << ++nOfTest <<
": AMPL solver interface" << endl << endl;
1807 cout <<
"create a cbc Solver for AMPL nl - OSInstance solution" << endl;
1810 nl2osil =
new OSnl2osil( nlFileName);
1811 nl2osil->createOSInstance() ;
1814 solver->
osol = osol;
1815 cout <<
"call Cbc Solve" << endl;
1818 cout <<
"Here is the Cbc solver solution" << endl;
1819 cout << solver->
osrl << endl;
1823 if(ok ==
false)
throw ErrorClass(
" Fail unit test with OSnl2osil on problem parinc.nl");
1827 cout <<
"call delete nl2osil" << endl;
1830 unitTestResult <<
"Test the AMPL nl -> OSiL converter on parinc.nl using Cbc" << std::endl;
1831 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1835 cout <<
"OSrL = " << solver->
osrl << endl;
1836 cout << endl << endl << endl;
1837 unitTestResultFailure <<
"Sorry Unit Test Failed Testing AMPL:" + eclass.
errormsg << endl;
1844 cout << endl <<
"TEST " << ++nOfTest <<
": b64 operations" << endl << endl;
1852 osol =
"<osol></osol>";
1853 solver->
osol = osol;
1856 std::cout << solver->
osil << std::endl;
1859 cout << endl << endl;
1860 cout <<
"COIN solution of a OSiL string in b64 format" << endl;
1861 cout << solver->
osrl;
1865 if(ok ==
false)
throw ErrorClass(
" Fail unit test with COIN Cbc cSolver on b64 test problem parincLinear.mps");
1871 unitTestResult <<
"Test a problem written in b64 and then converted to OSInstance" << std::endl;
1872 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
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;
1885#ifdef COMPONENT_DEBUG
1889 cout << endl <<
"TEST " << ++nOfTest <<
": postfix and prefix routines" << endl << endl;
1890 std::string expTreeTest = dataDir +
"osilFiles" + dirsep +
"rosenbrockmod.osil";
1897 osinstance = osilreader->
readOSiL( osil);
1899 if(expTree == NULL)
throw ErrorClass(
" Null expression tree when testing prefix and postfix routines");
1900 std::vector<OSnLNode*> postfixVec;
1904 unsigned int n = postfixVec.size();
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;
1914 expTree->m_treeRoot = postfixVec[ n - 1]->createExpressionTreeFromPostfix( postfixVec);
1917 std::vector<OSnLNode*> prefixVec;
1922 expTree->m_treeRoot = prefixVec[ 0]->createExpressionTreeFromPrefix( prefixVec);
1925 postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
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++){
1931 nodeNames2[i] = postfixVec[i]->snodeName;
1932 if( nodeNames1[i] != nodeNames2[ i])
throw ErrorClass(
" Problem with creating expression trees");
1936 delete[] nodeNames1;
1937 delete[] nodeNames2;
1942 unitTestResult <<
"Successful test of prefix and postfix conversion routines" << std::endl;
1943 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1947 cout << endl << endl << endl;
1948 unitTestResultFailure << eclass.
errormsg << endl;
1952 cout << endl <<
"TEST " << ++nOfTest <<
": nonlinear operators" << endl << endl;
1954 std::string operatorTest = dataDir +
"osilFiles" + dirsep +
"testOperators.osil";
1963 osinstance = osilreader->
readOSiL( osil);
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;
1974 std::cout << std::endl << std::endl;
1975 std::cout << osilwriter->
writeOSiL( osinstance) << std::endl;
1981 double parserTestVal = expTree->m_treeRoot->calculateFunction( x);
1982 std::cout <<
"ParserTest Val = " << parserTestVal << std::endl;
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");
1988 delete[] nodeNames1;
1995 unitTestResult <<
"Successful test of nonlinear operators using file testOperators.osil" << std::endl;
1996 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
1999 cout << endl << endl << endl;
2000 unitTestResultFailure << eclass.
errormsg << endl;
2004 cout << endl <<
"TEST " << ++nOfTest <<
": Automatic differentiation" << endl << endl;
2007 std::string expTreeTest = dataDir +
"osilFiles" + dirsep +
"CppADTestLag.osil";
2022 osinstance = osilreader->
readOSiL( osil);
2033 for(
int i = 0; i < sp->
number; i++){
2034 std::cout <<
"gradient value " << sp->
values[i] << std::endl;
2038 double checkPartial2Con1 = 7.0 ;
2041 if(ok ==
false)
throw ErrorClass(
" Fail testing gradient calculation");
2042 double checkPartial0Con1 = (1./x[0]) ;
2045 if(ok ==
false)
throw ErrorClass(
" Fail testing gradient calculation");
2046 double checkPartial3Con1 = (1./x[3]) ;
2049 if(ok ==
false)
throw ErrorClass(
" Fail testing gradient calculation");
2056 std::cout <<
"Hessian value " << sh->
hessValues[i] << std::endl;
2060 if(ok ==
false)
throw ErrorClass(
" Fail testing Hessian calculation");
2063 if(ok ==
false)
throw ErrorClass(
" Fail testing Hessian calculation");
2066 if(ok ==
false)
throw ErrorClass(
" Fail testing Hessian calculation");
2067 unitTestResult <<
"Successful test of AD gradient and Hessian calculations" << std::endl;
2071 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
2074 cout << endl << endl << endl;
2075 unitTestResultFailure << eclass.
errormsg << endl;
2080 cout << endl <<
"TEST " << ++nOfTest <<
": OSiL parser" << endl << endl;
2081 clock_t start, finish;
2088 cout <<
"TEST PARSING A MODEL" << endl;
2089 cout <<
"FIRST READ THE FILE INTO A STRING" << endl;
2091 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincLinear.osil";
2094 duration = (double) (finish - start) / CLOCKS_PER_SEC;
2095 cout <<
"Reading the file into a string took (seconds): "<< duration << endl;
2099 cout <<
"PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
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;
2113 cout << endl << endl << endl;
2115 unitTestResultFailure <<
"Sorry Unit Test Failed Testing An OSiL Parser" << endl;
2123 cout << endl <<
"TEST " << ++nOfTest <<
": Stochastic extensions to OSiL" << endl << endl;
2124 clock_t start, finish;
2131 cout <<
"\nTEST PARSING A STOCHASTIC MODEL" << endl;
2132 cout <<
"FIRST READ THE FILE INTO A STRING" << endl;
2134 osilFileName = dataDir +
"osilFiles" + dirsep +
"finplan1.osil";
2137 duration = (double) (finish - start) / CLOCKS_PER_SEC;
2138 cout <<
"Reading the file into a string took (seconds): "<< duration << endl;
2142 cout <<
"PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
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;
2156 cout << endl << endl << endl;
2158 unitTestResultFailure <<
"Error parsing an osil file with time domain information" << endl;
2164 cout << endl <<
"TEST " << ++nOfTest <<
": GET() AND SET() METHODS FOR TimeDomain OBJECT" << endl << endl;
2170 osinstance = osilreader->
readOSiL( osil);
2172 ok = (f ==
"stages");
2176 std::string* sncheck =
new std::string[6];
2180 sncheck[3] =
"test";
2181 sncheck[4] =
"Wha'zzup?";
2186 for (
int i = 0; i < 6; i++)
2187 ok &= (sn[i] == sncheck[i]);
2191 int* nvcheck =
new int[6];
2199 for (
int i = 0; i < 6; i++)
2200 ok &= (nv[i] == nvcheck[i]);
2204 int* nccheck =
new int[6];
2212 for (
int i = 0; i < 6; i++)
2213 ok &= (nc[i] == nccheck[i]);
2217 int* nocheck =
new int[6];
2225 for (
int i = 0; i < 6; i++)
2226 ok &= (no[i] == nocheck[i]);
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];
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]);
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];
2279 for (
int i = 0; i < 6; i++) {
2284 for (
int j = 0; j < nv[i]; j++) {
2285 lv1[i][j] = lv[i][j];
2287 for (
int j = 0; j < nc[i]; j++) {
2288 lc1[i][j] = lc[i][j];
2290 for (
int j = 0; j < no[i]; j++) {
2291 lo1[i][j] = lo[i][j];
2303 int *nelem, *startIdx, **VI;
2305 startIdx =
new int[4];
2307 for (
int i = 0; i < 4; i++)
2316 for (
int i = 0; i < 4; i++)
2322 for (
int i = 0; i < 4; i++)
2334 ok &= (lower == 0.0);
2336 ok &= (upper == 1.0);
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]);
2373 for (
int i = 0; i < 6; i++) {
2374 delete [] lvcheck[i];
2375 delete [] lccheck[i];
2376 delete [] locheck[i];
2405 for (
int i = 0; i < 4; i++) {
2411 unitTestResult <<
"Successful test of osinstance get() and set() methods" << std::endl;
2412 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
2415 cout << endl << endl << endl;
2417 unitTestResultFailure <<
"Sorry Unit Test Failed osinstance get() and set() Methods" << endl;
2441 cout << endl <<
"TEST " << ++nOfTest <<
": OSoL parser" << endl << endl;
2442 std::string tmpOSoL;
2443 clock_t start, finish;
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";
2455 duration = (double) (finish - start) / CLOCKS_PER_SEC;
2456 cout <<
"Reading the file into a string took (seconds): "<< duration << endl;
2458 cout <<
"PARSE THE OSOL STRING INTO AN OSOPTION OBJECT" << endl;
2462 cout << endl <<
"Test the add() methods" << endl;
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;
2484 ok =
osoption->setAnotherIntegerVariableBranchingWeight(5,100.) && ok;
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);
2500 cout << endl <<
"another SOS has been added" << endl << endl;
2505 varopt->
name =
"testVarOpt";
2507 ok =
osoption->setAnOtherVariableOption(varopt) && ok;
2513 objopt->
name =
"testObjOpt";
2515 ok =
osoption->setAnOtherObjectiveOption(objopt) && ok;
2519 ok =
osoption->setAnotherInitConValue(2,17.0) && ok;
2520 ok =
osoption->setAnotherInitDualVarValue(2,0.0,DBL_MAX) && ok;
2524 conopt->
name =
"testObjOpt";
2534 ok =
osoption->setAnOtherConstraintOption(conopt) && ok;
2538 ok =
osoption->setAnotherSolverOption(
"HoHum",
"gus",
"PhoNY",
"",
"test",
"") && ok;
2541 throw ErrorClass(
" Could not add to osoption data structure");
2544 std::string optionstring;
2549 cout << endl <<
"transfer osoption to another OSOption object" << endl;
2551 optionstring =
osoption->getServiceURI();
2555 throw ErrorClass(
" error in get/set ServiceURI");
2558 optionstring =
osoption->getServiceName();
2562 throw ErrorClass(
" error in get/set ServiceName");
2565 optionstring =
osoption->getInstanceName();
2569 throw ErrorClass(
" error in get/set InstanceName");
2572 optionstring =
osoption->getInstanceLocation();
2576 throw ErrorClass(
" error in get/set InstanceLocation");
2579 optionstring =
osoption->getInstanceLocationType();
2583 throw ErrorClass(
" error in get/set InstanceLocationtype");
2586 optionstring =
osoption->getJobID();
2587 ok = osoption2->
setJobID(optionstring) && ok;
2593 optionstring =
osoption->getSolverToInvoke();
2597 throw ErrorClass(
" error in get/set SolverToInvoke");
2600 optionstring =
osoption->getInstanceLocationType();
2604 throw ErrorClass(
" error in get/set InstanceLocationType");
2607 optionstring =
osoption->getUserName();
2611 throw ErrorClass(
" error in get/set UserName");
2614 optionstring =
osoption->getPassword();
2617 throw ErrorClass(
" error in get/set Password");
2621 optionstring =
osoption->getContact();
2622 ok = osoption2->
setContact(optionstring) && ok;
2625 throw ErrorClass(
" error in get/set Contact");
2628 optionstring =
osoption->getContactTransportType();
2632 throw ErrorClass(
" error in get/set TransportType");
2637 nopt =
osoption->getNumberOfOtherGeneralOptions();
2638 otherOpt =
osoption->getOtherGeneralOptions();
2642 throw ErrorClass(
" error in get/set OtherGeneralOption");
2645 option_d =
osoption->getMinDiskSpace();
2649 throw ErrorClass(
" error in get/set MinDiskSpace");
2652 optionstring =
osoption->getMinDiskSpaceUnit();
2656 throw ErrorClass(
" error in get/set MinDiskSpaceUnit");
2659 option_d =
osoption->getMinMemorySize();
2663 throw ErrorClass(
" error in get/set MinMemorySize");
2666 optionstring =
osoption->getMinMemoryUnit();
2670 throw ErrorClass(
" error in get/set MinMemoryUnit");
2673 option_d =
osoption->getMinCPUSpeed();
2677 throw ErrorClass(
" error in get/set MinCPUSpeed");
2680 optionstring =
osoption->getMinCPUSpeedUnit();
2684 throw ErrorClass(
" error in get/set MinCPUSpeedUnit");
2687 option_i =
osoption->getMinCPUNumber();
2691 throw ErrorClass(
" error in get/set MinCPUNumber");
2695 nopt =
osoption->getNumberOfOtherSystemOptions();
2696 otherOpt2 =
osoption->getOtherSystemOptions();
2700 throw ErrorClass(
" error in get/set OtherSystemOptions");
2704 optionstring =
osoption->getServiceType();
2708 throw ErrorClass(
" error in get/set ServiceType");
2712 nopt =
osoption->getNumberOfOtherServiceOptions();
2713 otherOpt3 =
osoption->getOtherServiceOptions();
2717 throw ErrorClass(
" error in get/set OtherServiceOptions");
2725 throw ErrorClass(
" error in get/set MaxTime");
2728 optionstring =
osoption->getMaxTimeUnit();
2732 throw ErrorClass(
" error in get/set MaxTimeUnit");
2735 optionstring =
osoption->getRequestedStartTime();
2739 throw ErrorClass(
" error in get/set RequestedStartTime");
2742 nopt =
osoption->getNumberOfJobDependencies();
2743 std::string* tJobID =
osoption->getJobDependencies();
2747 throw ErrorClass(
" error in get/set JobDependencies");
2750 nopt =
osoption->getNumberOfRequiredDirectories();
2751 std::string* reqDir =
osoption->getRequiredDirectories();
2755 throw ErrorClass(
" error in get/set RequiredDirectories");
2758 nopt =
osoption->getNumberOfRequiredFiles();
2759 std::string* reqFil =
osoption->getRequiredFiles();
2763 throw ErrorClass(
" error in get/set RequiredFiles");
2766 nopt =
osoption->getNumberOfDirectoriesToMake();
2767 std::string* mkDir =
osoption->getDirectoriesToMake();
2771 throw ErrorClass(
" error in get/set DirectoriesToMake");
2774 nopt =
osoption->getNumberOfFilesToMake();
2775 std::string* mkFil =
osoption->getFilesToMake();
2779 throw ErrorClass(
" error in get/set FilesToMake");
2782 nopt =
osoption->getNumberOfInputDirectoriesToMove();
2787 throw ErrorClass(
" error in get/set InputDirectoriesToMove");
2790 nopt =
osoption->getNumberOfInputFilesToMove();
2795 throw ErrorClass(
" error in get/set InputFilesToMove");
2798 nopt =
osoption->getNumberOfOutputFilesToMove();
2803 throw ErrorClass(
" error in get/set OutputFilesToMove");
2806 nopt =
osoption->getNumberOfOutputDirectoriesToMove();
2811 throw ErrorClass(
" error in get/set OutputDirectoriesToMove");
2814 nopt =
osoption->getNumberOfFilesToDelete();
2815 std::string* rmFil =
osoption->getFilesToDelete();
2819 throw ErrorClass(
" error in get/set FilesToDelete");
2822 nopt =
osoption->getNumberOfDirectoriesToDelete();
2823 std::string* rmDir =
osoption->getDirectoriesToDelete();
2827 throw ErrorClass(
" error in get/set DirectoriesToDelete");
2830 nopt =
osoption->getNumberOfProcessesToKill();
2831 std::string* rmProc =
osoption->getProcessesToKill();
2835 throw ErrorClass(
" error in get/set ProcessesToKill");
2839 nopt =
osoption->getNumberOfOtherJobOptions();
2840 otherOpt4 =
osoption->getOtherJobOptions();
2844 throw ErrorClass(
" error in get/set OtherJobOptions");
2847 int nvar, nobj, ncon;
2848 nvar =
osoption->getOptionInt(
"numberOfVariables");
2850 nobj =
osoption->getOptionInt(
"numberOfObjectives");
2852 ncon =
osoption->getOptionInt(
"numberOfConstraints");
2856 throw ErrorClass(
" error in get/set problem dimensions");
2861 IVV =
osoption->getInitVarValuesDense();
2865 throw ErrorClass(
" error in get/set InitVarValues");
2868 nopt =
osoption->getNumberOfInitVarValuesString();
2870 IVV2 =
osoption->getInitVarValuesStringSparse();
2874 throw ErrorClass(
" error in get/set InitVarValuesString");
2878 IBS =
osoption->getInitBasisStatusDense();
2882 throw ErrorClass(
" error in get/set InitBasisStatus");
2886 IVBW =
osoption->getIntegerVariableBranchingWeightsDense();
2890 throw ErrorClass(
" error in get/set IntegerVariableBranchingWeights");
2894 sos =
osoption->getSOSVariableBranchingWeightsSparse();
2899 throw ErrorClass(
" error in get/set SOSVariableBranchingWeights");
2903 otherV =
osoption->getAllOtherVariableOptions();
2904 nopt =
osoption->getNumberOfOtherVariableOptions();
2908 throw ErrorClass(
" error in get/set OtherVariableOptions");
2912 IOV =
osoption->getInitObjValuesDense();
2916 throw ErrorClass(
" error in get/set InitObjValues");
2919 nopt =
osoption->getNumberOfInitObjBounds();
2921 IOB =
osoption->getInitObjBoundsSparse();
2925 throw ErrorClass(
" error in get/set InitObjBounds");
2929 otherO =
osoption->getAllOtherObjectiveOptions();
2930 nopt =
osoption->getNumberOfOtherObjectiveOptions();
2934 throw ErrorClass(
" error in get/set OtherObjectiveOptions");
2939 ICV =
osoption->getInitConValuesDense();
2943 throw ErrorClass(
" error in get/set InitConValues");
2946 nopt =
osoption->getNumberOfInitDualVarValues();
2948 IDV =
osoption->getInitDualVarValuesSparse();
2952 throw ErrorClass(
" error in get/set InitDualVarValues");
2956 otherC =
osoption->getAllOtherConstraintOptions();
2957 nopt =
osoption->getNumberOfOtherConstraintOptions();
2961 throw ErrorClass(
" error in get/set OtherConstraintOptions");
2965 SO =
osoption->getAllSolverOptions();
2966 nopt =
osoption->getNumberOfSolverOptions();
2970 throw ErrorClass(
" error in get/set SolverOptions");
2973 ok =
osoption->IsEqual(osoption2) && ok;
2975 throw ErrorClass(
" OSOption get() and set() methods do not work correctly");
2977 cout << endl <<
"delete osoption2" << endl;
2980 cout <<
"osoption2 deleted" << endl << endl;
2982 cout <<
"Write the content to a new file" <<endl;
2984 cout << endl <<
"Here is tmpOSoL:" <<endl;
2985 cout << endl << endl << tmpOSoL << endl;
2986 cout <<
"-----------------------------------------" << endl << endl;
2993 cout <<
"Read the string back" << endl;
2996 osoption3 = osolreader2->
readOSoL( tmpOSoL);
3000 throw ErrorClass(
" Loss of information in OSoL write/read");
3009 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
3013 cout << endl <<
"TEST " << ++nOfTest <<
": Parse another .osol file" << endl << endl;
3016 cout <<
"First read the OSoL file into a string" << endl;
3017 osolFileName = dataDir +
"osolFiles" + dirsep +
"parsertest2.osol";
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;
3035 cout <<
"Test parsing another OSoL file" << endl;
3038 cout <<
"First read the OSoL file into a string" << endl;
3039 osolFileName = dataDir +
"osolFiles" + dirsep +
"parsertest3.osol";
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;
3058 cout <<
"Test parsing a trivial string" << endl;
3060 osol =
"<osol></osol>";
3061 cout <<
"Parse the OSoL string into an OSOption object" << endl;
3068 "Successful test of OSoL parser on file parsertest.osol"
3070 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
3076 cout << endl << endl << endl;
3077 if(osolwriter != NULL)
delete osolwriter;
3078 if(osolreader != NULL)
delete osolreader;
3080 unitTestResultFailure << eclass.
errormsg << endl;
3081 unitTestResultFailure <<
"There was a failure in the test for reading OSoL" << endl;
3097 cout << endl <<
"TEST " << ++nOfTest <<
": OSrL parser" << endl << endl;
3098 std::string tmpOSrL;
3099 clock_t start, finish;
3105 cout <<
"TEST PARSING AN OSrL FILE" << endl;
3106 cout <<
"FIRST READ THE OSrL FILE INTO A STRING" << endl;
3108 osrlFileName = dataDir +
"osrlFiles" + dirsep +
"parserTest.osrl";
3112 duration = (double) (finish - start) / CLOCKS_PER_SEC;
3113 cout <<
"Reading the file into a string took (seconds): "<< duration << endl;
3114 cout << osrl << endl;
3116 cout <<
"PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
3118 cout <<
"Finished read; write OSResult object to temporary string" << endl;
3120 cout << tmpOSrL << endl;
3125 cout <<
"Parse temporary string" << endl;
3156 "Successful test of OSrL parser on problems parincLinear.osrl and errorExample.osrl"
3158 cout << endl <<
"TEST " << nOfTest <<
": Completed successfully" << endl << endl;
3161 cout << endl << endl << endl;
3162 if(osrlwriter != NULL)
delete osrlwriter;
3163 if(osrlreader != NULL)
delete osrlreader;
3165 unitTestResultFailure << eclass.
errormsg << endl;
3166 unitTestResultFailure <<
"There was a failure in the test for reading OSrL" << endl;
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;
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;
3200 std::string sObjVal;
3202 string::size_type pos2;
3203 string::size_type pos1 = osrl.find(
"<obj ");
3204 if(pos1 != std::string::npos){
3206 pos1 = osrl.find(
">", pos1 + 1);
3207 if(pos1 != std::string::npos){
3209 pos2 = osrl.find(
"</obj", pos1 + 1);
3210 if( pos2 != std::string::npos){
3212 sObjVal = osrl.substr( pos1 + 1, pos2 - pos1 - 1);
3215 return dObjVal =
os_strtod(sObjVal.c_str(), NULL);
double os_strtod(const char *s00, char **se)
The BonminSolver class solves problems using Ipopt.
Implements a solve method for the Coin solvers.
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
used for throwing exceptions.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
class used to make it easy to read and write files.
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
the InitDualVarValue class.
the InitVarValueString class.
LinearConstraintCoefficients * linearConstraintCoefficients
linearConstraintCoefficients is a pointer to a LinearConstraintCoefficients object
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.
DoubleVector * value
a pointer to the array of nonzero values being stored
int numberOfValues
numberOfValues is the number of nonzero elements stored in the <linearConstraintCoefficients> element
Used to hold the instance in memory.
The in-memory representation of an OSiL instance..
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.
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.
bool setDirectoriesToDelete(int numberOfPaths, std::string *paths)
bool setInstanceLocationType(std::string locationType)
Set the instance location type.
bool setMinMemorySize(std::string unit, std::string description, double value)
Set the minimum memory size required for the current job.
bool setMinDiskSpace(std::string unit, std::string description, double value)
Set the minimum disk space required for the current job.
bool setIntegerVariableBranchingWeightsDense(int numberOfVar, double *value)
bool setInstanceName(std::string instanceName)
Set the instance name.
bool setInitObjBoundsSparse(int numberOfObj, InitObjBound **obj)
bool setOtherObjectiveOptions(int numberOfObj, OtherObjectiveOption **obj)
bool setServiceURI(std::string serviceURI)
Set the serviceURI.
bool setSolverToInvoke(std::string solverToInvoke)
Set the solver to be invoked.
bool setFilesToDelete(int numberOfPaths, std::string *paths)
bool setInputFilesToMove(int numberOfPathPairs, PathPair **pathPair)
bool setInputDirectoriesToMove(int numberOfPathPairs, PathPair **pathPair)
bool setInstanceLocation(std::string instanceLocation)
Set the instance location.
bool setMaxTime(double value, std::string unit)
bool setMaxTimeUnit(std::string unit)
bool setInitObjValuesDense(int numberOfObj, double *value)
bool setMinCPUSpeedUnit(std::string unit)
bool setJobID(std::string jobID)
Set the job ID.
bool setOtherJobOptions(int numberOfOptions, OtherOption **other)
bool setContact(std::string contact)
Set the contact information.
bool setInitVarValuesStringSparse(int numberOfVar, InitVarValueString **var)
bool setMinMemoryUnit(std::string unit)
bool setOtherServiceOptions(int numberOfOptions, OtherOption **other)
bool setRequiredFiles(int numberOfPaths, std::string *paths)
bool setSolverOptions(int numberOfSolverOptions, SolverOption **solverOption)
bool setInitBasisStatusDense(int numberOfVar, std::string *var)
bool setOtherVariableOptions(int numberOfVar, OtherVariableOption **var)
bool setInitDualVarValuesSparse(int numberOfCon, InitDualVarValue **con)
bool setOutputDirectoriesToMove(int numberOfPathPairs, PathPair **pathPair)
bool setInitVarValuesDense(int numberOfVar, double *value)
bool setNumberOfObjectives(int numberOfObjectives)
bool setDirectoriesToMake(int numberOfPaths, std::string *paths)
bool setUserName(std::string userName)
Set the username.
bool setOutputFilesToMove(int numberOfPathPairs, PathPair **pathPair)
bool setFilesToMake(int numberOfPaths, std::string *paths)
bool setNumberOfVariables(int numberOfVariables)
bool setOtherSystemOptions(int numberOfOptions, OtherOption **other)
bool setInitConValuesDense(int numberOfCon, double *value)
bool setContactTransportType(std::string transportType)
Set the transport type for contact.
bool setMinCPUSpeed(std::string unit, std::string description, double value)
Set the minimum CPU speed required for the current job.
bool setMinCPUNumber(int number, std::string description)
Set the minimum number of CPU cores required for the current job.
bool setRequiredDirectories(int numberOfPaths, std::string *paths)
bool setProcessesToKill(int numberOfProcesses, std::string *processes)
bool setServiceName(std::string serviceName)
Set the service name.
bool setPassword(std::string password)
Set the password.
bool setOtherGeneralOptions(int numberOfOptions, OtherOption **other)
Set the other general options as an entire array.
bool setSOSVariableBranchingWeights(int numberOfSOS, SOSWeights **sos)
bool setRequestedStartTime(std::string time)
bool setServiceType(std::string serviceType)
set() options in the <service> element
bool setMinDiskSpaceUnit(std::string unit)
bool setNumberOfConstraints(int numberOfConstraints)
bool setOtherConstraintOptions(int numberOfOptions, OtherConstraintOption **other)
bool setJobDependencies(int numberOfDependencies, std::string *jobDependencies)
std::string getGeneralMessage()
Get the general message.
Used to read an OSiL string.
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Take an OSInstance object and write a string that validates against the OSiL schema.
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
bool m_bWriteBase64
m_bWriteBase64 is set to true if we encode the linear constraint coefficients in base64 binary
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
bool createOSInstance()
create an OSInstance from the MPS instance representation
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the instance represented in N...
Used to read an OSoL string.
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
Take an OSOption object and write a string that validates against the OSoL schema.
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
OSResult * readOSrL(const std::string &posrl)
Get an OSResult object from an OSrL string.
Take an OSResult object and write a string that validates against OSrL.
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
the OtherConOption class.
std::string lbValue
lower bound of the option
std::string ubValue
upper bound of the option
std::string value
value of the option
the OtherConstraintOption class.
std::string name
name of the option
int numberOfCon
number of <con> children
OtherConOption ** con
array of option values
the OtherObjectiveOption class.
int numberOfObj
number of <obj> children
std::string name
name of the option
the OtherVariableOption class.
int numberOfVar
number of child elements
std::string name
name of the option
The in-memory representation of a SparseHessianMatrix..
int hessDimension
hessDimension is the number of nonzeros in each array.
double * hessValues
hessValues is a double array of the Hessian values.
a sparse vector data structure
double * values
values holds a double array of nonzero values.
int number
number is the number of elements in the indexes and values arrays.
#define OS_NEAR_EQUAL
we use OS_NEAR_EQUAL in unitTest to see if we are close to the optimal obj value
double getObjVal(std::string osrl)
int main(int argC, char *argV[])
This file defines the OSInstance class along with its supporting classes.