My Project
unitTest.cpp
Go to the documentation of this file.
1/* $Id$ */
135//#define DEBUG
136//#define GUS_DEBUG
137
138#include "OSConfig.h"
139
140#ifdef OS_HAS_CPPAD
141#include <cppad/cppad.hpp>
142#endif
143
144#include "OSCoinSolver.h"
145#include "OSmps2OS.h"
146#include "OSResult.h"
147#include "OSOption.h"
148#include "OSiLReader.h"
149#include "OSiLWriter.h"
150#include "OSoLReader.h"
151#include "OSoLWriter.h"
152#include "OSrLReader.h"
153#include "OSrLWriter.h"
154#include "OSInstance.h"
155#include "OSFileUtil.h"
156#include "OSOutput.h"
157#include "CoinError.hpp"
158
159#include "OSDefaultSolver.h"
160#include "OSWSUtil.h"
161#include "OSSolverAgent.h"
162#include "OShL.h"
163#include "OSErrorClass.h"
164#include "OSBase64.h"
165#include "OSMathUtil.h"
166
167#include <CoinMpsIO.hpp>
168#include <CoinPackedMatrix.hpp>
169#include "CoinError.hpp"
170#include "CoinHelperFunctions.hpp"
171#include "OsiSolverInterface.hpp"
172
173#ifdef COIN_HAS_GLPK
174#include <OsiGlpkSolverInterface.hpp>
175#endif
176
177#ifdef COIN_HAS_COUENNE
178#include "OSCouenneSolver.h"
179#endif
180
181#ifdef COIN_HAS_ASL
182#include "OSnl2OS.h"
183#include "OSosrl2ampl.h"
184#endif
185
186#ifdef COIN_HAS_LINDO
187#include "OSLindoSolver.h"
188#endif
189
190#ifdef COIN_HAS_IPOPT
191#include "OSIpoptSolver.h"
192#endif
193
194#ifdef COIN_HAS_BONMIN
195#include "OSBonminSolver.h"
196#endif
197
198#ifdef COIN_HAS_CSDP
199#include "OSCsdpSolver.h"
200#endif
201
202#ifdef COIN_HAS_CPX
203#include "OsiCpxSolverInterface.hpp"
204#endif
205
206#ifdef COIN_HAS_GRB
207#include "OsiGrbSolverInterface.hpp"
208#endif
209
210#ifdef COIN_HAS_MSK
211#include "OsiMskSolverInterface.hpp"
212#endif
213
214#ifdef COIN_HAS_SOPLEX
215#include "OsiSpxSolverInterface.hpp"
216#endif
217
218#ifdef COIN_HAS_XPR
219#include "OsiXprSolverInterface.hpp"
220#endif
221
222#ifdef COIN_HAS_GAMSUTILS
223#include "OSgams2osil.hpp"
224#endif
225
226#ifdef HAVE_CTIME
227# include <ctime>
228#else
229# ifdef HAVE_TIME_H
230# include <time.h>
231# else
232# error "don't have header file for time"
233# endif
234#endif
235
236#ifdef HAVE_CMATH
237# include <cmath>
238#else
239# ifdef HAVE_CMATH_H
240# include <cmath.h>
241# endif
242#endif
243
244#ifdef HAVE_CSTDIO
245# include <cstdio>
246#else
247# ifdef HAVE_STDIO_H
248# include <stdio.h>
249# else
250# error "don't have header file for stdio"
251# endif
252#endif
253
254//#ifdef HAVE_WINDOWS_H
255//#include <windows.h>
256//#endif
257
258#ifdef COIN_HAS_ASL
259#include <asl.h>
260#endif
261
262
263using std::cout;
264using std::endl;
265using std::ostringstream;
266using std::string;
267
268
269int main(int argC, char* argV[])
270{
271
272 WindowsErrorPopupBlocker();
273 double getObjVal(std::string osrl);
274 int getItCount(std::string osrl);
275 void tempPrintArrays(OSResult* os); // OSrl parser development only
276 //using CppAD::NearEqual;
277 bool ok;
278 double check;
279
280
281 bool BASIC_TESTS; // minimal functionality tests
282 bool SOLVER_TESTS; // at least one problem for each solver
283 bool THOROUGH; // multiple problems for some solvers
284 bool PARSER_TESTS; // test parser logic
285 bool OTHER_TESTS; // other input formats, b64 conversion, etc.
286
287 //set level of testing
288
289 std::string testConfig = "install";
290 int testLevel = 1;
291 if( argC > 2){
292 std::cout << "Too Many Input Parameters" << std::endl;
293 return 1;
294 }
295 if(argC == 2){
296 testConfig = argV[ 1];
297 std::cout << "test configuration = \'" << testConfig << "\'"<< std::endl;
298 }
299
300#ifdef GUS_DEBUG
301 testConfig = "parser";
302#endif
303
304 if (testConfig == "install") testLevel = 1;
305 if (testConfig == "parser" ) testLevel = 2;
306 if (testConfig == "parsers") testLevel = 2;
307 if (testConfig == "solver" ) testLevel = 3;
308 if (testConfig == "solvers") testLevel = 3;
309 if (testConfig == "release") testLevel = 4;
310 if (testConfig == "nightlyBuild") testLevel = 4;
311 if (testConfig == "all") testLevel = 4;
312 if (testConfig == "NB") testLevel = 4;
313 if (testConfig == "nb") testLevel = 4;
314
315 switch (testLevel){
316 case 1:
317 BASIC_TESTS = true;
318 SOLVER_TESTS = true;
319 THOROUGH = false;
320 PARSER_TESTS = false;
321 OTHER_TESTS = false;
322 break;
323 case 2:
324 BASIC_TESTS = false;
325 SOLVER_TESTS = false;
326 THOROUGH = false;
327 PARSER_TESTS = true;
328 OTHER_TESTS = false;
329 break;
330 case 3:
331 BASIC_TESTS = false;
332 SOLVER_TESTS = true;
333 THOROUGH = true;
334 PARSER_TESTS = false;
335 OTHER_TESTS = false;
336 break;
337 case 4:
338 default:
339 BASIC_TESTS = true;
340 SOLVER_TESTS = true;
341 THOROUGH = true;
342 PARSER_TESTS = true;
343 OTHER_TESTS = true;
344 break;
345 }
346
347 if (BASIC_TESTS) std::cout << "Perform basic tests" << std::endl;
348 if (SOLVER_TESTS) {
349 if (THOROUGH)
350 std::cout << "Perform thorough solver tests" << std::endl;
351 else
352 std::cout << "Perform simple solver tests" << std::endl;
353 }
354 if (PARSER_TESTS) std::cout << "Perform parser tests" << std::endl;
355 if (OTHER_TESTS) std::cout << "Perform other tests" << std::endl;
356 std::cout << std::endl << std::endl;
357
358 // end level of testing
359
360 cout << "START UNIT TEST" << endl;
361 int nOfTest = 0;
362
369 FileUtil *fileUtil = NULL;
370#ifdef COIN_HAS_ASL
371 OSnl2OS *nl2osil = NULL;
372#endif
373 OSmps2OS *mps2osil = NULL;
374 DefaultSolver *solver = NULL;
375 OSiLReader *osilreader = NULL;
376 OSiLReader *osilreader2 = NULL;
377 OSiLWriter *osilwriter = NULL;
378 OSoLReader *osolreader = NULL;
379 OSoLReader *osolreader2 = NULL;
380 OSoLWriter *osolwriter = NULL;
381 OSrLReader *osrlreader = NULL;
382 OSrLWriter *osrlwriter = NULL;
383 OSInstance *osinstance = NULL;
384 OSOption *osoption = NULL;
385 OSOption *osoption2 = NULL;
386 OSOption *osoption3 = NULL;
387 OSResult *osresult = NULL;
388 OSResult *osresult1 = NULL;
389 OSResult *osresult2 = NULL;
390 OSResult *osresult3 = NULL;
391
392
393 //common arrays
394 std::string *nodeNames1 = NULL;
395 std::string *nodeNames2 = NULL;
396 double *x = NULL;
397
398 //other common variables
399 std::string osilFileName;
400 std::string osolFileName;
401 std::string osrlFileName;
402 std::string nlFileName;
403 std::string mpsFileName;
404 std::string osil;
405 std::string osol;
406 ostringstream unitTestResult;
407 ostringstream unitTestResultFailure;
408
409 // get the input files
410 const char dirsep = CoinFindDirSeparator();
411 // Set directory containing data files.
412 std::string dataDir;
413 dataDir = dirsep == '/' ? "../data/" : "..\\data\\";
414#ifdef GUS_DEBUG
415 dataDir = "C:\\datafiles\\research\\OS\\OS-trunk-work\\OS\\data\\";
416#endif
417
418
419// BASIC_TESTS include file-handling, numerical calculations and algorithmic differentiation
420if(BASIC_TESTS == true){
421
422 //first make sure we can read files
423 try{
424 std::cout << endl << "TEST " << ++nOfTest << ": Try to read a sample file" << endl << endl;
425
426 fileUtil = new FileUtil();
427 osilreader = new OSiLReader();
428 osilwriter = new OSiLWriter();
429
430 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinearByRow.osil";
431 //osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
432 std::cout << "The file is: " ;
433 std::cout << osilFileName << std::endl;
434 osil = fileUtil->getFileAsString( osilFileName.c_str() );
435 std::cout << "Done reading the test file" << std::endl;
436 osinstance = osilreader->readOSiL( osil);
437 //osinstance->initForAlgDiff();
438 unitTestResult << "TEST " << nOfTest << ": Reading files successfully" << std::endl;
439 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
440
441 delete fileUtil;
442 fileUtil = NULL;
443 delete osilreader;
444 osilreader = NULL;
445 delete osilwriter;
446 osilwriter = NULL;
447 }
448 catch(const ErrorClass& eclass){
449 unitTestResultFailure << "Sorry Unit Test Failed Test " << nOfTest << ": Reading from file " + eclass.errormsg << endl;
450 //no point continuing -- we can't even read a file
451 unitTestResultFailure << "Since we can't read files we are terminating" << endl;
452 cout << unitTestResultFailure.str() << endl << endl;
453 cout << "Conclusion: FAILURE" << endl;
454 if (fileUtil != NULL)
455 {
456 delete fileUtil;
457 fileUtil = NULL;
458 }
459 if (osilreader != NULL)
460 {
461 delete osilreader;
462 osilreader = NULL;
463 }
464 if (osilwriter != NULL)
465 {
466 delete osilwriter;
467 osilwriter = NULL;
468 }
469 return 1;
470 }
471
472// Make sure we can read and write without loss of precision
473 try{
474 cout << endl << "TEST " << ++nOfTest << ": Lossless I/O" << endl << endl;
475
476 osilwriter = new OSiLWriter();
477 osilreader = new OSiLReader();
478
479 mpsFileName = dataDir + "mpsFiles" + dirsep + "parinc.mps";
480 mps2osil = new OSmps2OS( mpsFileName);
481
482 // create the first in-memory OSInstance (OSOption will be empty)
483 mps2osil->createOSObjects();
484 // write the instance to a string
485 OSInstance *osinstance1 = mps2osil->osinstance;
486 std::string sOSiL = osilwriter->writeOSiL( osinstance1 );
487#ifdef DEBUG
488 cout << sOSiL << endl;
489#endif
490
491 // now create a second object
492 OSInstance *osinstance2 = osilreader->readOSiL( sOSiL);
493 // now compare the elements in the A matrix for the two instances
495 double theDiff, theMax;
496 int theIndex = -1;
497 theMax = 0;
498 for(int i = 0; i < nvals; i++){
499 theDiff = fabs(osinstance1->instanceData->linearConstraintCoefficients->value->el[ i] -
501 if(theDiff > theMax){
502 theMax = theDiff;
503 theIndex = i;
504 }
505 }
506 std::cout << "MAXIMUM DIFF = " << theMax << std::endl;
507 if(theMax > 0)
508 {
509 ostringstream temp;
510 std::cout << "MAXIMUM DIFF INDEX = " << theIndex << std::endl;
511 unitTestResult << "WARNING: you do not have lossless IO" << std::endl;
512 temp << "Large discrepancy at position " << theIndex << ": " << theMax << std::endl;
513 throw ErrorClass(temp.str());
514 }
515 else
516 {
517 unitTestResult << "TEST " << nOfTest << ": Passed lossless IO test" << std::endl;
518 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
519 }
520 delete mps2osil;
521 mps2osil = NULL;
522 delete osilreader;
523 osilreader = NULL;
524 delete osilwriter;
525 osilwriter = NULL;
526
527 }
528 catch(const ErrorClass& eclass){
529 unitTestResultFailure << "Unit Test Failed Lossless I/O test -- Test " << nOfTest << ": " + eclass.errormsg<< endl;
530 if (mps2osil != NULL)
531 delete mps2osil;
532 mps2osil = NULL;
533 if (osilreader != NULL)
534 delete osilreader;
535 osilreader = NULL;
536 if (osilwriter != NULL)
537 delete osilwriter;
538 osilwriter = NULL;
539 }
540
541 // now test the nonlinear operators
542 try{
543 cout << endl << "TEST " << ++nOfTest << ": nonlinear operators" << endl << endl;
544
545 osilreader = new OSiLReader();
546 osilwriter = new OSiLWriter();
547 fileUtil = new FileUtil();
548
549 ok = true;
550 std::string operatorTest = dataDir + "osilFiles" + dirsep + "testOperators.osil";
551 osil = fileUtil->getFileAsString( operatorTest.c_str() );
552 cout << "Read testOperators.osil...";
553 osinstance = osilreader->readOSiL( osil);
554 cout << "Done" << endl;
555
556 std::string osil2 = osilwriter->writeOSiL( osinstance);
557 std::cout << osil2 << endl;
558 cout << "Read osil again...";
559 osilreader->readOSiL( osil2);
560 cout << "Done" << endl;
561
562 ScalarExpressionTree* expTree = osinstance->getNonlinearExpressionTree( -1);
563 std::vector<ExprNode*> postfixVec;
564 postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
565 int n = postfixVec.size();
566 nodeNames1 = new std::string[ n];
567 for (int i = 0 ; i < n; i++)
568 {
569 std::cout << "node " << i << "@" << postfixVec[i] <<": " << postfixVec[i]->getTokenName();
570 std::cout << " scalar kids = " << postfixVec[i]->inumberOfChildren;
571 std::cout << " matrix kids = " << postfixVec[i]->inumberOfMatrixChildren << std::endl;
572 nodeNames1[i] = postfixVec[i]->getTokenName();
573 }
574 // now test value
575 x = new double[2];
576 x[0] = 1;
577 x[1] = 2;
578 check = 11;
579 ok = ( fabs(check - expTree->m_treeRoot->calculateFunction( x))/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
580 delete[] x;
581 x = NULL;
582 delete[] nodeNames1;
583 nodeNames1 = NULL;
584 delete osilreader;
585 osilreader = NULL;
586 delete osilwriter;
587 osilwriter = NULL;
588 delete fileUtil;
589 fileUtil = NULL;
590
591 if (ok == false) throw ErrorClass(" Problem evaluating expression tree");
592 unitTestResult << "TEST " << nOfTest << ": Successful test of nonlinear operators using file testOperators.osil" << std::endl;
593 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
594 }
595 catch(const ErrorClass& eclass)
596 {
597 unitTestResultFailure << "Sorry Unit Test Failed Test " << nOfTest << ": nonlinear operators " + eclass.errormsg << endl;
598 cout << endl << endl << endl;
599 unitTestResultFailure << eclass.errormsg << endl;
600 if (x != NULL)
601 delete[] x;
602 x = NULL;
603 if (nodeNames1 != NULL)
604 delete[] nodeNames1;
605 nodeNames1 = NULL;
606 if (osilreader != NULL)
607 delete osilreader;
608 osilreader = NULL;
609 if (osilwriter != NULL)
610 delete osilwriter;
611 osilwriter = NULL;
612 if (fileUtil != NULL)
613 delete fileUtil;
614 fileUtil = NULL;
615 }
616
617
618 // Automatic differentiation
619 try{
620 cout << endl << "TEST " << ++nOfTest << ": Automatic differentiation" << endl << endl;
621
622 fileUtil = new FileUtil();
623 osilreader = new OSiLReader();
624
625 std::string expTreeTest = dataDir + "osilFiles" + dirsep + "CppADTestLag.osil";
626 /*
627 min x0^2 + 9*x1 -- w[0]
628 s.t.
629 33 - 105 + 1.37*x1 + 2*x3 + 5*x1 <= 10 -- y[0]
630 ln(x0*x3) + 7*x2 >= 10 -- y[1]
631 Note: in the first constraint 33 is a constant term and 105
632 is part of the nl node
633 */
634 osil = fileUtil->getFileAsString( expTreeTest.c_str() );
635 //create an osinstance
636 cout << "Read file" << endl;
637 osinstance = osilreader->readOSiL( osil);
638 double *x;
639 x = new double[ 4];
640 x[0] = 1;
641 x[1] = 5;
642 x[2] = 10;
643 x[3] = 5;
644 SparseVector *sp;
645 // get the gradient for constraint 1
646 cout << "Perform gradient computations" << endl;
647 osinstance->getJacobianSparsityPattern();
648 sp = osinstance->calculateConstraintFunctionGradient(x, 1, true);
649 ok = true;
650 //check gradient for constraint with index 1
651 double checkPartial2Con1 = 7.0 ;
652 ok = ( fabs(checkPartial2Con1 - sp->values[ 0] )/(fabs( checkPartial2Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
653 if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
654 double checkPartial0Con1 = (1./x[0]) ;
655 ok = ( fabs(checkPartial0Con1 - sp->values[ 1] )/(fabs( checkPartial0Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
656 if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
657 double checkPartial3Con1 = (1./x[3]) ;
658 ok = ( fabs(checkPartial3Con1 - sp->values[ 2] )/(fabs( checkPartial3Con1) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
659 if(ok == false) throw ErrorClass(" Fail testing gradient calculation");
660 delete sp;
661 sp = NULL;
663 // calcuate Hessian of objective function (index = -1)
664 cout << "Perform Hessian computations" << endl;
666 sh = osinstance->calculateHessian(x, -1, true);
667 ok = ( fabs(2. - sh->hessValues[0] )/(2. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
668 if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
669 ok = ( fabs(0. - sh->hessValues[ 1] )/(0. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
670 if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
671 ok = ( fabs(0. - sh->hessValues[2] )/(0. + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
672 if(ok == false) throw ErrorClass(" Fail testing Hessian calculation");
673 delete[] x;
674 x = NULL;
675 delete osilreader;
676 osilreader = NULL;
677 delete fileUtil;
678 fileUtil = NULL;
679 unitTestResult << "TEST " << nOfTest << ": Successful test of AD gradient and Hessian calculations" << std::endl;
680 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
681 }
682 catch(const ErrorClass& eclass)
683 {
684 unitTestResultFailure << "Sorry Unit Test Failed Test " << nOfTest << ": Automatic differentiation " + eclass.errormsg << endl;
685 cout << endl << endl << endl;
686 unitTestResultFailure << "Failed test " << nOfTest << endl << eclass.errormsg << endl;
687 if (x != NULL)
688 delete[] x;
689 x = NULL;
690 if (osilreader != NULL)
691 delete osilreader;
692 osilreader = NULL;
693 if (fileUtil != NULL)
694 delete fileUtil;
695 fileUtil = NULL;
696 }
697} // end of if (BASIC_TESTS)
698
699
700// PARSER_TESTS: OSiL, OSoL, OSrL and various set() and get() methods
701if (PARSER_TESTS)
702{
703 try{
704 cout << endl << "TEST " << ++nOfTest << ": Test parsing an OSiL file (parincLinear.osil)" << endl << endl;
705
706 fileUtil = new FileUtil();
707 osilreader = new OSiLReader();
708 osilwriter = new OSiLWriter();
709
710 clock_t start, finish;
711 double duration;
712 cout << "Test parsing a model" << endl;
713 cout << "First read the file into a string" << endl;
714 start = clock();
715 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
716 osil = fileUtil->getFileAsString( osilFileName.c_str());
717 finish = clock();
718 duration = (double) (finish - start) / CLOCKS_PER_SEC;
719 cout << "Reading the file into a string took (seconds): "<< duration << endl;
720 start = clock();
721 cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
722 osilreader->readOSiL( osil);
723 //cout << osilwriter->writeOSiL( osilreader->readOSiL( osil)) << endl;
724
725 delete osilreader;
726 osilreader = NULL;
727 delete osilwriter;
728 osilwriter = NULL;
729 delete fileUtil;
730 fileUtil = NULL;
731
732 finish = clock();
733 duration = (double) (finish - start) / CLOCKS_PER_SEC;
734 cout << "Parsing took (seconds): "<< duration << endl;
735 unitTestResult << "TEST " << nOfTest << ": Successful test of OSiL parser on problem parincLinear.osil" << std::endl;
736 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
737 }
738 catch(const ErrorClass& eclass)
739 {
740 unitTestResultFailure << "Sorry Unit Test Failed Test " << nOfTest << ": OSiL parser " + eclass.errormsg << endl;
741 cout << endl << endl << endl;
742 cout << eclass.errormsg << endl;
743 unitTestResultFailure << "Sorry Unit Test Failed Testing An OSiL Parser (Test " << nOfTest << ")" << endl;
744
745 if (osilreader != NULL)
746 delete osilreader;
747 osilreader = NULL;
748 if (osilwriter != NULL)
749 delete osilwriter;
750 osilwriter = NULL;
751 if (fileUtil != NULL)
752 delete fileUtil;
753 fileUtil = NULL;
754 }
755
756
757 // now test the get() and set() methods in OSInstance
758 // use get() and set() methods to create a second OSInstance object (deep copy)
759 OSInstance *osinstance2 = new OSInstance();
760
761 try{
762 cout << endl << "TEST " << ++nOfTest << ": OSInstance get() and set() methods" << endl << endl;
763
764 fileUtil = new FileUtil();
765 osilreader = new OSiLReader();
766
767 cout << "Read file" << endl;
768 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
769 osil = fileUtil->getFileAsString( osilFileName.c_str() );
770 osinstance = osilreader->readOSiL( osil);
771
772
773 // first copy header information
774 cout << "Copy header information" << endl;
775 std::string name, source, description, fileCreator, licence;
776
777 name = osinstance->getInstanceName();
778 source = osinstance->getInstanceSource();
779 description = osinstance->getInstanceDescription();
780 fileCreator = osinstance->getInstanceCreator();
781 licence = osinstance->getInstanceLicence();
782
783 if (!osinstance2->setInstanceName(name)) throw ErrorClass("Error duplicating header information");
784 if (!osinstance2->setInstanceSource(source)) throw ErrorClass("Error duplicating header information");
785 if (!osinstance2->setInstanceDescription(description)) throw ErrorClass("Error duplicating header information");
786 if (!osinstance2->setInstanceCreator(fileCreator)) throw ErrorClass("Error duplicating header information");
787 if (!osinstance2->setInstanceLicence(licence)) throw ErrorClass("Error duplicating header information");
788
789 // copy variables
790 cout << "Copy variables" << endl;
791 if (osinstance->instanceData->variables != NULL)
792 {
793 int nvar = osinstance->getVariableNumber();
794
795 std::string *varname = osinstance->getVariableNames();
796 char *vartype = osinstance->getVariableTypes();
797 double *varlb = osinstance->getVariableLowerBounds();
798 double *varub = osinstance->getVariableUpperBounds();
799
800 osinstance2->instanceData->variables = new Variables();
801 osinstance2->instanceData->variables->numberOfVariables = nvar;
802 osinstance2->instanceData->variables->var = new Variable*[nvar];
803
804 if (!osinstance2->setVariables(nvar, varname, varlb, varub, vartype)) throw ErrorClass("Error duplicating variable information");
805 }
806
807 // copy objectives
808 cout << "Copy objectives" << endl;
809 if (osinstance->instanceData->objectives != NULL)
810 {
811 int nobj = osinstance->getObjectiveNumber();
812
813 std::string *objname = osinstance->getObjectiveNames();
814 std::string *objdir = osinstance->getObjectiveMaxOrMins();
815 double *objconst = osinstance->getObjectiveConstants();
816 double *objweight = osinstance->getObjectiveWeights();
817 SparseVector **objcoeff = osinstance->getObjectiveCoefficients();
818
819 osinstance2->instanceData->objectives = new Objectives();
820 osinstance2->instanceData->objectives->numberOfObjectives = nobj;
821 osinstance2->instanceData->objectives->obj = new Objective*[nobj];
822
823 if (!osinstance2->setObjectives(nobj, objname, objdir, objconst, objweight, objcoeff)) throw ErrorClass("Error duplicating objective information");
824 }
825
826 // copy constraints
827 cout << "Copy constraints" << endl;
828 if (osinstance->instanceData->constraints != NULL)
829 {
830 int ncon = osinstance->getConstraintNumber();
831
832 std::string *conname = osinstance->getConstraintNames();
833 double *conlb = osinstance->getConstraintLowerBounds();
834 double *conub = osinstance->getConstraintUpperBounds();
835 double *con_c = osinstance->getConstraintConstants();
836
837 osinstance2->instanceData->constraints = new Constraints();
838 osinstance2->instanceData->constraints->numberOfConstraints = ncon;
839 osinstance2->instanceData->constraints->con = new Constraint*[ncon];
840
841 if (!osinstance2->setConstraints(ncon, conname, conlb, conub, con_c)) throw ErrorClass("Error duplicating constraint information");
842 }
843
844 // copy linear constraint coefficient matrix
845 cout << "Copy linear constraint coefficient matrix" << endl;
846
847 if (osinstance->instanceData->linearConstraintCoefficients != NULL)
848 {
849 int ncoef = osinstance->getLinearConstraintCoefficientNumber();
850 bool isColMajor = osinstance->getLinearConstraintCoefficientMajor();
851 int nstart;
852 SparseMatrix* coeff;
853
854 // getLinearConstraintCoefficients returns a pointer to a sparse matrix structure
855 if (isColMajor)
856 {
857 nstart = osinstance->getVariableNumber();
859 }
860 else
861 {
862 nstart = osinstance->getConstraintNumber();
863 coeff = osinstance->getLinearConstraintCoefficientsInRowMajor();
864 }
865
866 if (!osinstance2->copyLinearConstraintCoefficients(ncoef, isColMajor,
867 coeff->values, 0, ncoef-1,
868 coeff->indexes, 0, ncoef-1,
869 coeff->starts, 0, nstart))
870 throw ErrorClass("Error duplicating linear constraint coefficients");
871 }
872
873 // copy quadratic terms
874 cout << "Copy quadratic terms" << endl;
875 if (osinstance->instanceData->quadraticCoefficients != NULL)
876 {
877 int nquad = osinstance->getNumberOfQuadraticTerms();
878 QuadraticTerms* qcoef = osinstance->getQuadraticTerms();
879
880 if (!osinstance2->setQuadraticCoefficients(nquad,
881 qcoef->rowIndexes, qcoef->varOneIndexes,
882 qcoef->varTwoIndexes, qcoef->coefficients,
883 0, nquad-1))
884 throw ErrorClass("Error duplicating quadratic coefficients");
885 }
886
887 // copy nonlinear expressions
888 cout << "Copy nonlinear expressions" << endl;
889 Nl** root = NULL;
890
891 if (osinstance->instanceData->nonlinearExpressions != NULL)
892 {
893 int nexpr = osinstance->getNumberOfNonlinearExpressions();
894// root = osinstance->getNonlinearExpressions();
895 root = new Nl*[osinstance->getNumberOfNonlinearExpressions()];
896 for (int i=0; i < osinstance->getNumberOfNonlinearExpressions(); i++)
897 {
898 root[i] = osinstance->instanceData->nonlinearExpressions->nl[i];
899 }
900
901 if (!osinstance2->setNonlinearExpressions(nexpr, root))
902 throw ErrorClass("Error duplicating nonlinear expressions");
903 }
904
905 // now compare the two instances
906 cout << "Compare the two instances" << endl;
907 if (!osinstance2->IsEqual(osinstance)) throw ErrorClass("Loss of data during duplication");
908
909 delete osinstance2;
910 osinstance2 = NULL;
911
912 unitTestResult << "TEST " << nOfTest << ": Passed OSInstance get() and set() methods" << std::endl;
913 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
914
915 delete osilreader;
916 osilreader = NULL;
917 delete osilwriter;
918 osilwriter = NULL;
919 delete fileUtil;
920 fileUtil = NULL;
921
922 if (root != NULL)
923 {
924// for (int i=0; i < osinstance->getNumberOfNonlinearExpressions(); i++)
925// if (root[i] != NULL) delete root[i];
926 delete [] root;
927 root = NULL;
928 }
929 }
930 catch(const ErrorClass& eclass)
931 {
932 unitTestResultFailure << "Unit Test Failed OSInstance get() and set() methods (Test "
933 << nOfTest << "): " + eclass.errormsg<< endl;
934 if (osinstance2 != NULL)
935 delete osinstance2;
936 osinstance2 = NULL;
937 if (osilreader != NULL)
938 delete osilreader;
939 osilreader = NULL;
940 if (osilwriter != NULL)
941 delete osilwriter;
942 osilwriter = NULL;
943 if (fileUtil != NULL)
944 delete fileUtil;
945 fileUtil = NULL;
946 }
947
948// Here we test extensions to the "core": <matrices>, <cones>, stochastic programming, etc.
949 if( THOROUGH == true)
950 {
951 try{
952 cout << endl << "TEST " << ++nOfTest << ": Test parsing another OSiL file (testMatricesAndCones.osil)" << endl << endl;
953
954 fileUtil = new FileUtil();
955 osilreader = new OSiLReader();
956 osilwriter = new OSiLWriter();
957
958 OSInstance *instance1, *instance2;
959
960 cout << "First read the file into a string" << endl;
961 osilFileName = dataDir + "osilFiles" + dirsep + "testMatricesAndCones.osil";
962 osil = fileUtil->getFileAsString( osilFileName.c_str());
963 cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
964 instance1 = osilreader->readOSiL( osil);
965
966 cout << "Write the OSInstance object to a temporary file (i.e., string)" << endl;
967 std::string temposil = osilwriter->writeOSiL(instance1);
968cout << temposil << endl;
969 cout << "Parse the temporary string again" << endl;
970 osilreader2 = new OSiLReader;
971 instance2 = osilreader2->readOSiL( temposil);
972
973 cout << "compare the two objects" << endl;
974 if (!instance2->IsEqual(instance1))
975 throw ErrorClass("<matrices> and <cones> not processed correctly");
976// delete osilreader;
977// osilreader = NULL;
978 delete osilreader2;
979 osilreader2 = NULL;
980 delete osilwriter;
981 osilwriter = NULL;
982 delete fileUtil;
983 fileUtil = NULL;
984
985 unitTestResult << "TEST " << nOfTest << ": Successful test of OSiL parser on problem testMatricesAndCones.osil" << std::endl;
986 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
987
988 // now test the matrix manipulation routines
989 // (expansion, separation into blocks, transformations, etc.)
990 cout << endl << "TEST " << ++nOfTest << ": Test matrix manipulation routines (using testMatricesAndCones.osil)" << endl << endl;
991
992// some matrices we cannot handle yet...
993// bool* omit = new bool[instance1->instanceData->matrices->numberOfMatrices];
994// omit[ 0] = true; //false;
995// omit[ 1] = true; //false;
996// omit[ 2] = true;
997// omit[ 3] = true;
998// omit[ 4] = true; //false;
999// omit[ 5] = true; //false;
1000// omit[ 6] = true;
1001// omit[ 7] = true; //false;
1002// omit[ 8] = true; //false;
1003// omit[ 9] = true; //false;
1004// omit[10] = true;
1005// omit[11] = true; //false;
1006// omit[12] = true; //false;
1007// omit[13] = true;
1008// omit[14] = true;
1009// omit[15] = true;
1010// omit[16] = true;
1011// omit[17] = true;
1012// omit[18] = true;
1013// omit[19] = true;
1014// omit[20] = true;
1015// omit[21] = true;
1016// omit[22] = true; //false;
1017// omit[23] = true;
1018// omit[24] = true; //false;
1019// omit[25] = true;
1020// omit[26] = true;
1021// omit[27] = true; //false;
1022// omit[28] = true; //false;
1023// omit[29] = true; //false;
1024// omit[30] = true; //false;
1025// omit[31] = true; //false;
1026// omit[32] = true; //false; //--- expansion test 1
1027// omit[33] = true; //false;
1028// omit[34] = true; //false;
1029// omit[35] = false; //--- expansion test 2
1030// omit[36] = false;
1031// omit[37] = true; //--- expansion test 3
1032// omit[38] = true; //--- expansion test 4
1033// omit[39] = true; //--- expansion test 5
1034
1035// for (int i=0; i < instance1->instanceData->matrices->numberOfMatrices; i++)
1036// {
1037// if (!omit[i])
1038// {
1039
1040 cout << endl << "Test matrix expansion in column major form" << endl;
1041
1042 GeneralSparseMatrix* test1_a
1044 if (test1_a->valueSize != 17)
1045 throw ErrorClass("Failed column expansion of matrix 32 (by columns)");
1046 if (test1_a->isDiagonal())
1047 throw ErrorClass("Failed diagonality assessment of matrix 32");
1048
1049 int rowPartition1[3];
1050 rowPartition1[0]= 0;
1051 rowPartition1[1]= 3;
1052 rowPartition1[2]= 7;
1053
1054 int colPartition1[3];
1055 colPartition1[0]= 0;
1056 colPartition1[1]= 2;
1057 colPartition1[2]= 6;
1058
1059 cout << endl << "Test matrix expansion in blocks form" << endl;
1060 ExpandedMatrixBlocks* test1_b
1061 = instance1->instanceData->matrices->matrix[32]
1062 ->getBlocks(rowPartition1,3,colPartition1,3,false,false);
1063 if (test1_b->blockNumber != 4)
1064 throw ErrorClass("Failed block expansion of matrix 32");
1065 if (test1_b->isBlockDiagonal())
1066 throw ErrorClass("Failed block expansion of matrix 32");
1067 if (test1_b->blocks[0]->valueSize != 3)
1068 throw ErrorClass("Failed block expansion of matrix 32");
1069 if (test1_b->blocks[0]->isDiagonal())
1070 throw ErrorClass("Failed block expansion of matrix 32");
1071
1072 cout << endl << "Test matrix expansion in row major form" << endl;
1073 GeneralSparseMatrix* test1_c
1075 if (test1_c->valueSize != 17)
1076 throw ErrorClass("Failed row expansion of matrix 32");
1077 if (test1_c->isDiagonal())
1078 throw ErrorClass("Failed diagonality assessment of matrix 32 (by rows)");
1079
1080//#if 0
1081 cout << endl << "Another matrix expansion in column major form" << endl;
1082
1083 GeneralSparseMatrix* test2_a =
1085 if (test2_a->valueSize != 68)
1086 throw ErrorClass("Failed column expansion of matrix 35 (by columns)");
1087
1088 int rowPartition2[6];
1089 rowPartition2[0]= 0;
1090 rowPartition2[1]= 5;
1091 rowPartition2[2]= 10;
1092 rowPartition2[3]= 15;
1093 rowPartition2[4]= 20;
1094 rowPartition2[5]= 25;
1095
1096 int colPartition2[5];
1097 colPartition2[0]= 0;
1098 colPartition2[1]= 6;
1099 colPartition2[2]= 12;
1100 colPartition2[3]= 18;
1101 colPartition2[4]= 24;
1102
1103 cout << endl << "Another matrix expansion in blocks format" << endl;
1104 ExpandedMatrixBlocks* test2_b
1105 = instance1->instanceData->matrices->matrix[35]
1106 ->getBlocks(rowPartition2,6,colPartition2,5,false,false);
1107 if (test2_b->blockNumber != 20)
1108 throw ErrorClass("Failed block expansion of matrix 35");
1109 if (test2_b->isBlockDiagonal())
1110 throw ErrorClass("Failed block expansion of matrix 35");
1111 if (test2_b->blocks[0]->valueSize != 5)
1112 throw ErrorClass("Failed block expansion of matrix 35");
1113 if (test2_b->blocks[10]->valueSize != 4)
1114 throw ErrorClass("Failed block expansion of matrix 35");
1115 if (test2_b->blocks[15]->valueSize != 1)
1116 throw ErrorClass("Failed block expansion of matrix 35");
1117 if (test2_b->blocks[16]->valueSize != 2)
1118 throw ErrorClass("Failed block expansion of matrix 35");
1119
1120
1121 cout << endl << "Another matrix expansion in row major form" << endl;
1122 GeneralSparseMatrix* test2_c =
1124 if (test2_c->valueSize != 68)
1125 throw ErrorClass("Failed column expansion of matrix 35 (by rows)");
1126
1127
1128#if 0
1129 int partition3[4];
1130 partition3[0]= 0;
1131 partition3[1]= 2;
1132 partition3[2]= 5;
1133 partition3[3]= 7;
1134
1135 cout << endl << "Test matrix expansion 3_a" << endl;
1136
1137 ExpandedMatrixBlocks* test3_a
1138 = instance1->instanceData->matrices->matrix[36]
1139 ->getBlocks(partition3,4,partition3,4,false,true);
1140
1141 if (test3_a == NULL)
1142 throw ErrorClass("Failed block expansion of matrix 36");
1143 if (test3_a->blockNumber != 2)
1144 throw ErrorClass("Failed block expansion of matrix 36");
1145 if (!test3_a->isBlockDiagonal())
1146 throw ErrorClass("Failed block expansion of matrix 36");
1147
1148 cout << endl << "Test matrix expansion 3_b" << endl;
1149 GeneralSparseMatrix* test3_b = test3_a->getBlock(0,0);
1150 if (test3_b->valueSize != 3)
1151 throw ErrorClass("Failed block expansion of matrix 36");
1152 if (test3_b->isDiagonal())
1153 throw ErrorClass("Failed block expansion of matrix 36");
1154
1155 cout << endl << "Test matrix expansion 3_c" << endl;
1156 GeneralSparseMatrix* test3_c = test3_a->getBlock(1,1);
1157 if (test3_c->valueSize != 3)
1158 throw ErrorClass("Failed block expansion of matrix 36");
1159 if (!test3_c->isDiagonal())
1160 throw ErrorClass("Failed block expansion of matrix 36");
1161
1162 cout << endl << "Test matrix expansion 3_d" << endl;
1163 GeneralSparseMatrix* test3_d = test3_a->getBlock(2,2);
1164 if (test3_d != NULL)
1165 throw ErrorClass("Failed block expansion of matrix 36");
1166
1167
1168 cout << endl << "Test matrix expansion 6_a" << endl;
1169 GeneralSparseMatrix* test6_a =
1171 if (!test6_a->isDiagonal())
1172 throw ErrorClass("Failed diagonality assessment of matrix 11 (by columns)");
1173
1174 cout << endl << "Test matrix expansion 6_b" << endl;
1175 GeneralSparseMatrix* test6_b =
1177 if (!test6_b->isDiagonal())
1178 throw ErrorClass("Failed diagonality assessment of matrix 11 (by rows)");
1179
1180
1181#endif
1182
1183// }
1184// }
1185
1186 delete osilreader;
1187 osilreader = NULL;
1188
1189 unitTestResult << "TEST " << nOfTest << ": Successful test of matrix manipulation routines" << std::endl;
1190 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1191
1192 }
1193 catch(const ErrorClass& eclass){
1194 cout << endl << endl << endl;
1195 cout << eclass.errormsg << endl;
1196 unitTestResultFailure << "Sorry Unit Test Failed Testing OSiL <matrix> Parser (Test "
1197 << nOfTest << ")" << endl;
1198
1199 if (osilreader != NULL)
1200 delete osilreader;
1201 osilreader = NULL;
1202 if (osilreader2 != NULL)
1203 delete osilreader2;
1204 osilreader2 = NULL;
1205 if (osilwriter != NULL)
1206 delete osilwriter;
1207 osilwriter = NULL;
1208 if (fileUtil != NULL)
1209 delete fileUtil;
1210 fileUtil = NULL;
1211 }
1212 }
1213
1214#if 0
1215 // Now test <timeDomain> and stochastic programming
1216
1217 // some pointer declarations
1218 std::string *sncheck = new std::string[6];
1219 int *nvcheck = new int[6];
1220 int *nccheck = new int[6];
1221 int *nocheck = new int[6];
1222 int **lvcheck = new int*[6];
1223 int **lccheck = new int*[6];
1224 int **locheck = new int*[6];
1225 std::string *sn1 = new std::string[6];
1226 int *nv1= new int[6];
1227 int *nc1 = new int[6];
1228 int *no1 = new int[6];
1229 int **lv1 = new int*[6];
1230 int **lc1 = new int*[6];
1231 int **lo1 = new int*[6];
1232 int *nelem = new int[4];
1233 int *startIdx = new int[4];
1234 int **VI = new int*[4];
1235
1236 try{
1237 cout << endl << "TEST " << ++nOfTest << ": Stochastic extensions to OSiL" << endl << endl;
1238
1239 osilreader = new OSiLReader();
1240 fileUtil = new FileUtil();
1241
1242 clock_t start, finish;
1243 double duration;
1244 cout << "\nTest parsing a stochastic model" << endl;
1245 cout << "First read the file into a string" << endl;
1246 start = clock();
1247 osilFileName = dataDir + "osilFiles" + dirsep + "finplan1.osil";
1248 osil = fileUtil->getFileAsString( &osilFileName[0]);
1249 finish = clock();
1250 duration = (double) (finish - start) / CLOCKS_PER_SEC;
1251 cout << "Reading the file into a string took (seconds): "<< duration << endl;
1252 start = clock();
1253 cout << "PARSE THE OSIL STRING INTO AN OSINSTANCE OBJECT" << endl;
1254 osilreader->readOSiL( osil);
1255 finish = clock();
1256 duration = (double) (finish - start) / CLOCKS_PER_SEC;
1257 cout << "Parsing took (seconds): "<< duration << endl;
1258 unitTestResult << "TEST " << nOfTest << ": Successful test of OSiL parser on problem finplan1.osil" << std::endl;
1259 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1260 delete osilreader;
1261 osilreader = NULL;
1262 delete fileUtil;
1263 fileUtil = NULL;
1264 }
1265 catch(const ErrorClass& eclass){
1266 cout << endl << endl << endl;
1267 cout << eclass.errormsg << endl;
1268 unitTestResultFailure << "Error parsing an osil file with time domain information (Test " << nOfTest << ")" << endl;
1269
1270 if (osilreader != NULL)
1271 delete osilreader;
1272 osilreader = NULL;
1273 if (fileUtil != NULL)
1274 delete fileUtil;
1275 fileUtil = NULL;
1276 }
1280 try{
1281 cout << endl << "TEST " << ++nOfTest << ": GET() AND SET() METHODS FOR TimeDomain OBJECT" << endl << endl;
1282
1283 osilreader = new OSiLReader();
1284
1285 //create an osinstance
1286 osinstance = osilreader->readOSiL( osil);
1287 std::string f = osinstance->getTimeDomainFormat();
1288 ok = (f == "stages");
1289 int n = osinstance->getTimeDomainStageNumber();
1290 ok &= (n == 6);
1291
1292 sncheck[0] = "";
1293 sncheck[1] = "";
1294 sncheck[2] = "";
1295 sncheck[3] = "test";
1296 sncheck[4] = "Wha'zzup?";
1297 sncheck[5] = "";
1298
1299 std::string* sn = osinstance->getTimeDomainStageNames();
1300
1301 for (int i = 0; i < 6; i++)
1302 ok &= (sn[i] == sncheck[i]);
1303
1304 int* nv = osinstance->getTimeDomainStageNumberOfVariables();
1305
1306 nvcheck[0] = 2;
1307 nvcheck[1] = 2;
1308 nvcheck[2] = 0;
1309 nvcheck[3] = 0;
1310 nvcheck[4] = 2;
1311 nvcheck[5] = 2;
1312
1313 for (int i = 0; i < 6; i++)
1314 ok &= (nv[i] == nvcheck[i]);
1315
1316 int* nc = osinstance->getTimeDomainStageNumberOfConstraints();
1317
1318 nccheck[0] = 1;
1319 nccheck[1] = 1;
1320 nccheck[2] = 0;
1321 nccheck[3] = 0;
1322 nccheck[4] = 1;
1323 nccheck[5] = 1;
1324
1325 for (int i = 0; i < 6; i++)
1326 ok &= (nc[i] == nccheck[i]);
1327
1328 int* no = osinstance->getTimeDomainStageNumberOfObjectives();
1329
1330 nocheck[0] = 1;
1331 nocheck[1] = 1;
1332 nocheck[2] = 1;
1333 nocheck[3] = 0;
1334 nocheck[4] = 1;
1335 nocheck[5] = 1;
1336
1337 for (int i = 0; i < 6; i++)
1338 ok &= (no[i] == nocheck[i]);
1339
1340 int** lv = osinstance->getTimeDomainStageVarList();
1341 int** lc = osinstance->getTimeDomainStageConList();
1342 int** lo = osinstance->getTimeDomainStageObjList();
1343
1344 for (int i = 0; i < 6; i++)
1345 {
1346 lvcheck[i] = new int[2];
1347 lccheck[i] = new int[2];
1348 locheck[i] = new int[2];
1349 };
1350 lvcheck[0][0] = 0;
1351 lvcheck[0][1] = 1;
1352 lvcheck[1][0] = 2;
1353 lvcheck[1][1] = 3;
1354 lvcheck[4][0] = 4;
1355 lvcheck[4][1] = 5;
1356 lvcheck[5][0] = 6;
1357 lvcheck[5][1] = 7;
1358 lccheck[0][0] = 0;
1359 lccheck[1][0] = 1;
1360 lccheck[4][0] = 2;
1361 lccheck[5][0] = 3;
1362 locheck[0][0] = -1;
1363 locheck[1][0] = -1;
1364 locheck[2][0] = -1;
1365 locheck[4][0] = -1;
1366 locheck[5][0] = -1;
1367
1368 for (int i = 0; i < 6; i++) {
1369 for (int j = 0; j < nv[i]; j++)
1370 ok &= (lvcheck[i][j] == lv[i][j]);
1371 for (int j = 0; j < nc[i]; j++)
1372 ok &= (lccheck[i][j] == lc[i][j]);
1373 for (int j = 0; j < no[i]; j++)
1374 ok &= (locheck[i][j] == lo[i][j]);
1375 };
1376
1377
1378 for (int i = 0; i < 6; i++) {
1379 sn1[i] = sn[i];
1380 nv1[i] = nv[i];
1381 nc1[i] = nc[i];
1382 no1[i] = no[i];
1383 lv1[i] = new int[2];
1384 lc1[i] = new int[2];
1385 lo1[i] = new int[2];
1386 for (int j = 0; j < nv[i]; j++) {
1387 lv1[i][j] = lv[i][j];
1388 };
1389 for (int j = 0; j < nc[i]; j++) {
1390 lc1[i][j] = lc[i][j];
1391 };
1392 for (int j = 0; j < no[i]; j++) {
1393 lo1[i][j] = lo[i][j];
1394 };
1395 };
1396
1397 ok &= osinstance->setTimeDomain("none");
1398 n = 0;
1399 ok &= osinstance->setTimeDomainStages(n,NULL);
1400 ok &= osinstance->setTimeDomainStages(4,NULL);
1401
1402 n = osinstance->getTimeDomainStageNumber();
1403 ok &= (n == 4);
1404
1405 for (int i = 0; i < 4; i++)
1406 { nelem[i] = 2;
1407 startIdx[i] = 2*i;
1408 VI[i] = new int[2];
1409 VI[i][0] = 2*i;
1410 VI[i][1] = 2*i + 1;
1411 };
1412 ok &= osinstance->setTimeDomainStageVariablesUnordered(4,nelem,VI);
1413
1414 for (int i = 0; i < 4; i++)
1415 { nelem[i] = 1;
1416 startIdx[i] = i;
1417 };
1418 ok &= osinstance->setTimeDomainStageConstraintsOrdered(4,nelem,startIdx);
1419
1420 for (int i = 0; i < 4; i++)
1421 { nelem[i] = 1;
1422 startIdx[i] = -1;
1423 };
1424 ok &= osinstance->setTimeDomainStageObjectivesOrdered(4,nelem,startIdx);
1425
1426 ok &= osinstance->setTimeDomain("none");
1427
1428 ok &= osinstance->setTimeDomain("interval");
1429
1430 ok &= osinstance->setTimeDomainInterval(0.0, 1.0);
1431 double lower = osinstance->getTimeDomainIntervalStart();
1432 ok &= (lower == 0.0);
1433 double upper = osinstance->getTimeDomainIntervalHorizon();
1434 ok &= (upper == 1.0);
1435
1436 ok &= osinstance->setTimeDomain("none");
1437
1438 ok &= osinstance->setTimeDomainStages(6,sncheck);
1439 ok &= osinstance->setTimeDomainStageVariablesUnordered(6,nvcheck,lvcheck);
1440 ok &= osinstance->setTimeDomainStageObjectivesUnordered(6,nocheck,locheck);
1441 ok &= osinstance->setTimeDomainStageConstraintsUnordered(6,nccheck,lccheck);
1442 int n2 = osinstance->getTimeDomainStageNumber();
1443 ok &= (n2 == 6);
1444 std::string* sn2 = osinstance->getTimeDomainStageNames();
1445 int* nv2 = osinstance->getTimeDomainStageNumberOfVariables();
1446 int* nc2 = osinstance->getTimeDomainStageNumberOfConstraints();
1447 int* no2 = osinstance->getTimeDomainStageNumberOfObjectives();
1448 int** lv2 = osinstance->getTimeDomainStageVarList();
1449 int** lc2 = osinstance->getTimeDomainStageConList();
1450 int** lo2 = osinstance->getTimeDomainStageObjList();
1451 for (int i = 0; i < n2; i++)
1452 { ok &= (sn2[i] == sncheck[i]);
1453 ok &= (nv2[i] == nvcheck[i]);
1454 ok &= (nc2[i] == nccheck[i]);
1455 ok &= (no2[i] == nocheck[i]);
1456 for (int j = 0; j < nv2[i]; j++)
1457 ok &= (lv2[i][j] == lvcheck[i][j]);
1458 for (int j = 0; j < nc2[i]; j++)
1459 ok &= (lc2[i][j] == lccheck[i][j]);
1460 for (int j = 0; j < no2[i]; j++)
1461 ok &= (lo2[i][j] == locheck[i][j]);
1462 };
1463 // Garbage Collection
1464 if (sncheck != NULL)
1465 delete [] sncheck;
1466 sncheck = NULL;
1467 if (nvcheck != NULL)
1468 delete [] nvcheck;
1469 nvcheck = NULL;
1470 if (nccheck != NULL)
1471 delete [] nccheck;
1472 nccheck = NULL;
1473 if (nocheck != NULL)
1474 delete [] nocheck;
1475 nocheck = NULL;
1476
1477 for (int i = 0; i < 6; i++) {
1478 if (lvcheck[i] != NULL)
1479 delete [] lvcheck[i];
1480 if (lccheck[i] != NULL)
1481 delete [] lccheck[i];
1482 if (locheck[i] != NULL)
1483 delete [] locheck[i];
1484 if (lv1[i] != NULL)
1485 delete [] lv1[i];
1486 if (lc1[i] != NULL)
1487 delete [] lc1[i];
1488 if (lo1[i] != NULL)
1489 delete [] lo1[i];
1490 };
1491 if (lvcheck != NULL)
1492 delete [] lvcheck;
1493 lvcheck = NULL;
1494 if (lccheck != NULL)
1495 delete [] lccheck;
1496 lccheck = NULL;
1497 if (locheck != NULL)
1498 delete [] locheck;
1499 locheck = NULL;
1500 if (lv1 != NULL)
1501 delete [] lv1;
1502 lv1 = NULL;
1503 if (lc1 != NULL)
1504 delete [] lc1;
1505 lc1 = NULL;
1506 if (lo1 != NULL)
1507 delete [] lo1;
1508 lo1 = NULL;
1509 if (sn1 != NULL)
1510 delete [] sn1;
1511 sn1 = NULL;
1512 if (nv1 != NULL)
1513 delete[] nv1;
1514 nv1 = NULL;
1515 if (nc1 != NULL)
1516 delete[] nc1;
1517 nc1 = NULL;
1518 if (no1 != NULL)
1519 delete[] no1;
1520 no1 = NULL;
1521 if (nelem != NULL)
1522 delete [] nelem;
1523 nelem = NULL;
1524 if (startIdx != NULL)
1525 delete [] startIdx;
1526 startIdx = NULL;
1527 if (VI != NULL)
1528 {
1529 for (int i = 0; i < 4; i++) {
1530 if (VI[i] != NULL)
1531 delete [] VI[i];
1532 };
1533 delete [] VI;
1534 VI = NULL;
1535 }
1536
1537 if (osilreader != NULL)
1538 delete osilreader;
1539 osilreader = NULL;
1540 unitTestResult << "TEST " << nOfTest << ": Successful test of osinstance get() and set() methods" << std::endl;
1541 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
1542 }
1543 catch(const ErrorClass& eclass)
1544 {
1545 cout << endl << endl << endl;
1546 cout << eclass.errormsg << endl;
1547 unitTestResultFailure << "Sorry Unit Test Failed osinstance get() and set() Methods (Test "<< nOfTest << ")" << endl;
1548 // Garbage Collection
1549 if (sncheck != NULL)
1550 delete [] sncheck;
1551 sncheck = NULL;
1552 if (nvcheck != NULL)
1553 delete [] nvcheck;
1554 nvcheck = NULL;
1555 if (nccheck != NULL)
1556 delete [] nccheck;
1557 nccheck = NULL;
1558 if (nocheck != NULL)
1559 delete [] nocheck;
1560 nocheck = NULL;
1561
1562 for (int i = 0; i < 6; i++) {
1563 if (lvcheck[i] != NULL)
1564 delete [] lvcheck[i];
1565 if (lccheck[i] != NULL)
1566 delete [] lccheck[i];
1567 if (locheck[i] != NULL)
1568 delete [] locheck[i];
1569 if (lv1[i] != NULL)
1570 delete [] lv1[i];
1571 if (lc1[i] != NULL)
1572 delete [] lc1[i];
1573 if (lo1[i] != NULL)
1574 delete [] lo1[i];
1575 };
1576 if (lvcheck != NULL)
1577 delete [] lvcheck;
1578 lvcheck = NULL;
1579 if (lccheck != NULL)
1580 delete [] lccheck;
1581 lccheck = NULL;
1582 if (locheck != NULL)
1583 delete [] locheck;
1584 locheck = NULL;
1585 if (lv1 != NULL)
1586 delete [] lv1;
1587 lv1 = NULL;
1588 if (lc1 != NULL)
1589 delete [] lc1;
1590 lc1 = NULL;
1591 if (lo1 != NULL)
1592 delete [] lo1;
1593 lo1 = NULL;
1594 if (sn1 != NULL)
1595 delete [] sn1;
1596 sn1 = NULL;
1597 if (nv1 != NULL)
1598 delete[] nv1;
1599 nv1 = NULL;
1600 if (nc1 != NULL)
1601 delete[] nc1;
1602 nc1 = NULL;
1603 if (no1 != NULL)
1604 delete[] no1;
1605 no1 = NULL;
1606 if (nelem != NULL)
1607 delete [] nelem;
1608 nelem = NULL;
1609 if (startIdx != NULL)
1610 delete [] startIdx;
1611 startIdx = NULL;
1612 if (VI != NULL)
1613 {
1614 for (int i = 0; i < 4; i++) {
1615 if (VI[i] != NULL)
1616 delete [] VI[i];
1617 };
1618 delete [] VI;
1619 VI = NULL;
1620 }
1621
1622 if (osilreader != NULL)
1623 delete osilreader;
1624 osilreader = NULL;
1625 }
1626#endif // test of <timeDomain> and various set() and get) methods
1627
1628 //
1629 // Now test the OSoL parser
1630
1631 try{
1646 cout << endl << "TEST " << ++nOfTest << ": OSoL parser" << endl << endl;
1647
1648 fileUtil = new FileUtil();
1649 osolwriter = new OSoLWriter();
1650 osolreader = new OSoLReader();
1651
1652 std::string tmpOSoL;
1653 clock_t start, finish;
1654 double duration;
1655 cout << "Test parsing an OSoL file" << endl;
1656 cout << "First read the OSoL file into a string" << endl;
1657 osolFileName = dataDir + "osolFiles" + dirsep + "parsertest.osol";
1658 cout << osolFileName << endl;
1659 start = clock();
1660 std::string osol = fileUtil->getFileAsString( osolFileName.c_str() );
1661 finish = clock();
1662 duration = (double) (finish - start) / CLOCKS_PER_SEC;
1663 cout << "Reading the file into a string took (seconds): "<< duration << endl;
1664 start = clock();
1665 cout << "PARSE THE OSOL STRING INTO AN OSOPTION OBJECT" << endl;
1666 osoption = osolreader->readOSoL( osol);
1667
1668 //Pad all the arrays
1669 cout << endl << "Test the add() methods" << endl;
1670
1671 ok = osoption->setAnOtherGeneralOption("testing","one","two three");
1672 ok = osoption->setOtherSystemOptions(0,NULL) && ok;
1673 ok = osoption->setAnOtherSystemOption("Ho Ho Ho","","") && ok;
1674 ok = osoption->setAnOtherServiceOption("OneMore","Option","To Go") && ok;
1675 ok = osoption->setAnotherJobDependency("DoReMi") && ok;
1676 ok = osoption->setAnotherRequiredDirectory("C:\\MSYS") && ok;
1677 ok = osoption->setAnotherRequiredFile("C:\\MSYS\\junk.tmp") && ok;
1678 ok = osoption->setAnotherDirectoryToMake("C:\\tempdir") && ok;
1679 ok = osoption->setAnotherFileToMake("C:\\tempdir\\temp.tmp") && ok;
1680 ok = osoption->setAnotherInputDirectoryToMove("C:\\tempdir","C:\\OS\\calc",true) && ok;
1681 ok = osoption->setAnotherInputFileToMove("C:\\OS\\parinc.osil","C:\\OS\\calc\\input.osil",true) && ok;
1682 ok = osoption->setAnotherOutputFileToMove("C:\\OS\\calc\\putput.osrl","C:\\OS\\parinc.osol",false) && ok;
1683 ok = osoption->setAnotherOutputDirectoryToMove("C:\\OS\\calc","C:\\OS\\save",false) && ok;
1684 ok = osoption->setAnotherFileToDelete("C:\\OS\\calc\\input.osil") && ok;
1685 ok = osoption->setAnotherDirectoryToDelete("C:\\tempdir") && ok;
1686 ok = osoption->setAnotherProcessToKill("ABC123") && ok;
1687 ok = osoption->setAnOtherJobOption("DoReMi","ABC","One Two Three") && ok;
1688 ok = osoption->setAnotherInitVarValue(5,12.3) && ok;
1689 ok = osoption->setAnotherInitVarValueString(6,"BLUE") && ok;
1694
1695 int SOS3idx[2];
1696 double SOS3val[2];
1697 std::string SOS3nam[2];
1698 SOS3idx[0] = 3;
1699 SOS3idx[1] = 6;
1700 SOS3val[0] = 1.0;
1701 SOS3val[1] = 2.0;
1702 SOS3nam[0] = "a name";
1703 SOS3nam[1] = "another";
1704 int tnvar;
1705 tnvar = osoption->getNumberOfSOS();
1706 ok = osoption->setAnotherSOSVariableBranchingWeight(3,2,1.0,SOS3idx,SOS3val,SOS3nam) && ok;
1707 assert (osoption->getNumberOfSOS() == (tnvar + 1));
1710 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[0]->value == 1.0);
1711 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[1]->value == 2.0);
1712 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[0]->name == "a name");
1713 assert (osoption->optimization->variables->sosVariableBranchingWeights->sos[tnvar]->var[1]->name == "another");
1714#ifdef DEBUG
1715 cout << endl << "another SOS has been added" << endl << endl;
1716#endif
1717
1718 OtherVariableOption *varopt;
1719 varopt = new OtherVariableOption();
1720 varopt->name = "testVarOpt";
1721 varopt->numberOfVar = 2;
1722 varopt->numberOfEnumerations = 0;
1723 varopt->var = new OtherVarOption*[2];
1724 varopt->var[0] = new OtherVarOption();
1725 varopt->var[0]->idx = 0;
1726 varopt->var[0]->value = "3.0";
1727 varopt->var[1] = new OtherVarOption();
1728 varopt->var[1]->idx = 1;
1729 varopt->var[1]->lbValue = "0.0";
1730 varopt->var[1]->ubValue = "10.0";
1731 ok = osoption->setAnOtherVariableOption(varopt) && ok;
1732 delete varopt;
1733 varopt = NULL;
1734#ifdef DEBUG
1735 cout << endl << "another variable option has been added" << endl << endl;
1736#endif
1737
1738 OtherObjectiveOption *objopt;
1739 objopt = new OtherObjectiveOption();
1740 objopt->name = "testObjOpt";
1741 objopt->numberOfObj = 0;
1742 objopt->numberOfEnumerations = 0;
1743 ok = osoption->setAnOtherObjectiveOption(objopt) && ok;
1744 delete objopt;
1745 objopt = NULL;
1746#ifdef DEBUG
1747 cout << endl << "another objective option has been added" << endl << endl;
1748#endif
1749
1750 ok = osoption->setAnotherInitConValue(2,17.0) && ok;
1751 ok = osoption->setAnotherInitDualVarValue(2,0.0,DBL_MAX) && ok;
1752
1753 OtherConstraintOption *conopt;
1754 conopt = new OtherConstraintOption();
1755 conopt->name = "testConOpt";
1756
1757 conopt->numberOfCon = 0;
1758 conopt->numberOfEnumerations = 1;
1759
1762 conopt->enumeration[0]->numberOfEl = 3;
1763 conopt->enumeration[0]->value = "test";
1764 conopt->enumeration[0]->description = "this is not a test";
1765 conopt->enumeration[0]->numberOfEl = 3;
1766 conopt->enumeration[0]->el = new int[3];
1767 conopt->enumeration[0]->el[0] = 1;
1768 conopt->enumeration[0]->el[1] = 3;
1769 conopt->enumeration[0]->el[2] = 5;
1770
1771 ok = osoption->setAnOtherConstraintOption(conopt) && ok;
1772 delete conopt;
1773 conopt = NULL;
1774#ifdef DEBUG
1775 cout << endl << "another constraint option has been added" << endl << endl;
1776#endif
1777
1778 ok = osoption->setAnotherSolverOption("HoHum","gus","PhoNY","","test","") && ok;
1779
1780 if (!ok)
1781 throw ErrorClass(" Could not add to osoption data structure");
1782
1783 //Now transfer to another osoption using get() and set() methods
1784 std::string optionstring, fileName, fileSource, fileDescription, fileCreator, fileLicence;
1785 int option_i;
1786 double option_d;
1787// OSOption* osoption2;
1788 osoption2= new OSOption();
1789
1790 cout << endl << "transfer osoption to another OSOption object" << endl;
1791
1792 fileName = osoption->getFileName();
1793 fileSource = osoption->getFileSource();
1794 fileDescription = osoption->getFileDescription();
1795 fileCreator = osoption->getFileCreator();
1796 fileLicence = osoption->getFileLicence();
1797 ok = osoption2->setHeader(fileName, fileSource, fileDescription, fileCreator, fileLicence);
1798#ifdef DEBUG
1799 if (!ok)
1800 throw ErrorClass(" error in get/set option header");
1801#endif
1802
1803
1804 optionstring = osoption->getServiceURI();
1805 ok = osoption2->setServiceURI(optionstring);
1806#ifdef DEBUG
1807 if (!ok)
1808 throw ErrorClass(" error in get/set ServiceURI");
1809#endif
1810
1811 optionstring = osoption->getServiceName();
1812 ok = osoption2->setServiceName(optionstring) && ok;
1813#ifdef DEBUG
1814 if (!ok)
1815 throw ErrorClass(" error in get/set ServiceName");
1816#endif
1817
1818 optionstring = osoption->getInstanceName();
1819 ok = osoption2->setInstanceName(optionstring) && ok;
1820#ifdef DEBUG
1821 if (!ok)
1822 throw ErrorClass(" error in get/set InstanceName");
1823#endif
1824
1825 optionstring = osoption->getInstanceLocation();
1826 ok = osoption2->setInstanceLocation(optionstring) && ok;
1827#ifdef DEBUG
1828 if (!ok)
1829 throw ErrorClass(" error in get/set InstanceLocation");
1830#endif
1831
1832 optionstring = osoption->getInstanceLocationType();
1833 ok = osoption2->setInstanceLocationType(optionstring) && ok;
1834#ifdef DEBUG
1835 if (!ok)
1836 throw ErrorClass(" error in get/set InstanceLocationtype");
1837#endif
1838
1839 optionstring = osoption->getJobID();
1840 ok = osoption2->setJobID(optionstring) && ok;
1841#ifdef DEBUG
1842 if (!ok)
1843 throw ErrorClass(" error in get/set JobID");
1844#endif
1845
1846 optionstring = osoption->getSolverToInvoke();
1847 ok = osoption2->setSolverToInvoke(optionstring) && ok;
1848#ifdef DEBUG
1849 if (!ok)
1850 throw ErrorClass(" error in get/set SolverToInvoke");
1851#endif
1852
1853 optionstring = osoption->getInstanceLocationType();
1854 ok = osoption2->setInstanceLocationType(optionstring) && ok;
1855#ifdef DEBUG
1856 if (!ok)
1857 throw ErrorClass(" error in get/set InstanceLocationType");
1858#endif
1859
1860 optionstring = osoption->getUserName();
1861 ok = osoption2->setUserName(optionstring) && ok;
1862#ifdef DEBUG
1863 if (!ok)
1864 throw ErrorClass(" error in get/set UserName");
1865#endif
1866
1867 optionstring = osoption->getPassword();
1868#ifdef DEBUG
1869 if (!ok)
1870 throw ErrorClass(" error in get/set Password");
1871#endif
1872 ok = osoption2->setPassword(optionstring) && ok;
1873
1874 optionstring = osoption->getContact();
1875 ok = osoption2->setContact(optionstring) && ok;
1876#ifdef DEBUG
1877 if (!ok)
1878 throw ErrorClass(" error in get/set Contact");
1879#endif
1880
1881 optionstring = osoption->getContactTransportType();
1882 ok = osoption2->setContactTransportType(optionstring) && ok;
1883#ifdef DEBUG
1884 if (!ok)
1885 throw ErrorClass(" error in get/set TransportType");
1886#endif
1887
1888 int nopt;
1889 OtherOption** otherOpt;
1891 otherOpt = osoption->getOtherGeneralOptions();
1892 ok = osoption2->setOtherGeneralOptions(nopt, otherOpt) && ok;
1893#ifdef DEBUG
1894 if (!ok)
1895 throw ErrorClass(" error in get/set OtherGeneralOption");
1896#endif
1897
1898 std::string tempDescription;
1899
1900 optionstring = osoption->getMinDiskSpaceUnit();
1901 tempDescription = osoption->getMinDiskSpaceDescription();
1902 option_d = osoption->getMinDiskSpace();
1903 ok = osoption2->setMinDiskSpace(optionstring,tempDescription,option_d) && ok;
1904#ifdef DEBUG
1905 if (!ok)
1906 throw ErrorClass(" error in get/set MinDiskSpace");
1907#endif
1908
1909 optionstring = osoption->getMinMemoryUnit();
1910 tempDescription = osoption->getMinMemoryDescription();
1911 option_d = osoption->getMinMemorySize();
1912 ok = osoption2->setMinMemorySize(optionstring,tempDescription,option_d) && ok;
1913#ifdef DEBUG
1914 if (!ok)
1915 throw ErrorClass(" error in get/set MinMemorySize");
1916#endif
1917
1918 optionstring = osoption->getMinCPUSpeedUnit();
1919 tempDescription = osoption->getMinCPUSpeedDescription();
1920 option_d = osoption->getMinCPUSpeed();
1921 ok = osoption2->setMinCPUSpeed(optionstring,tempDescription,option_d) && ok;
1922#ifdef DEBUG
1923 if (!ok)
1924 throw ErrorClass(" error in get/set MinCPUSpeed");
1925#endif
1926
1927 option_i = osoption->getMinCPUNumber();
1928 optionstring = osoption->getMinCPUNumberDescription();
1929 ok = osoption2->setMinCPUNumber(option_i, optionstring) && ok;
1930#ifdef DEBUG
1931 if (!ok)
1932 throw ErrorClass(" error in get/set MinCPUNumber");
1933#endif
1934
1935 OtherOption** otherOpt2;
1937 otherOpt2 = osoption->getOtherSystemOptions();
1938 ok = osoption2->setOtherSystemOptions(nopt, otherOpt2) && ok;
1939#ifdef DEBUG
1940 if (!ok)
1941 throw ErrorClass(" error in get/set OtherSystemOptions");
1942#endif
1943
1944
1945 optionstring = osoption->getServiceType();
1946 ok = osoption2->setServiceType(optionstring) && ok;
1947#ifdef DEBUG
1948 if (!ok)
1949 throw ErrorClass(" error in get/set ServiceType");
1950#endif
1951
1952 OtherOption** otherOpt3;
1954 otherOpt3 = osoption->getOtherServiceOptions();
1955 ok = osoption2->setOtherServiceOptions(nopt, otherOpt3) && ok;
1956#ifdef DEBUG
1957 if (!ok)
1958 throw ErrorClass(" error in get/set OtherServiceOptions");
1959#endif
1960
1961
1962 option_d = osoption->getMaxTime();
1963 ok = osoption2->setMaxTime(option_d) && ok;
1964#ifdef DEBUG
1965 if (!ok)
1966 throw ErrorClass(" error in get/set MaxTime");
1967#endif
1968
1969 optionstring = osoption->getMaxTimeUnit();
1970 ok = osoption2->setMaxTimeUnit(optionstring) && ok;
1971#ifdef DEBUG
1972 if (!ok)
1973 throw ErrorClass(" error in get/set MaxTimeUnit");
1974#endif
1975
1976 optionstring = osoption->getRequestedStartTime();
1977 ok = osoption2->setRequestedStartTime(optionstring) && ok;
1978#ifdef DEBUG
1979 if (!ok)
1980 throw ErrorClass(" error in get/set RequestedStartTime");
1981#endif
1982
1984 std::string* tJobID = osoption->getJobDependencies();
1985 ok = osoption2->setJobDependencies(nopt, tJobID) && ok;
1986#ifdef DEBUG
1987 if (!ok)
1988 throw ErrorClass(" error in get/set JobDependencies");
1989#endif
1990
1992 std::string* reqDir = osoption->getRequiredDirectories();
1993 ok = osoption2->setRequiredDirectories(nopt, reqDir) && ok;
1994#ifdef DEBUG
1995 if (!ok)
1996 throw ErrorClass(" error in get/set RequiredDirectories");
1997#endif
1998
2000 std::string* reqFil = osoption->getRequiredFiles();
2001 ok = osoption2->setRequiredFiles(nopt, reqFil) && ok;
2002#ifdef DEBUG
2003 if (!ok)
2004 throw ErrorClass(" error in get/set RequiredFiles");
2005#endif
2006
2008 std::string* mkDir = osoption->getDirectoriesToMake();
2009 ok = osoption2->setDirectoriesToMake(nopt, mkDir) && ok;
2010#ifdef DEBUG
2011 if (!ok)
2012 throw ErrorClass(" error in get/set DirectoriesToMake");
2013#endif
2014
2016 std::string* mkFil = osoption->getFilesToMake();
2017 ok = osoption2->setFilesToMake(nopt, mkFil) && ok;
2018#ifdef DEBUG
2019 if (!ok)
2020 throw ErrorClass(" error in get/set FilesToMake");
2021#endif
2022
2025 ok = osoption2->setInputDirectoriesToMove(nopt, inDMv) && ok;
2026#ifdef DEBUG
2027 if (!ok)
2028 throw ErrorClass(" error in get/set InputDirectoriesToMove");
2029#endif
2030
2033 ok = osoption2->setInputFilesToMove(nopt, inFMv) && ok;
2034#ifdef DEBUG
2035 if (!ok)
2036 throw ErrorClass(" error in get/set InputFilesToMove");
2037#endif
2038
2041 ok = osoption2->setOutputFilesToMove(nopt, outFMv) && ok;
2042#ifdef DEBUG
2043 if (!ok)
2044 throw ErrorClass(" error in get/set OutputFilesToMove");
2045#endif
2046
2049 ok = osoption2->setOutputDirectoriesToMove(nopt, outDMv) && ok;
2050#ifdef DEBUG
2051 if (!ok)
2052 throw ErrorClass(" error in get/set OutputDirectoriesToMove");
2053#endif
2054
2056 std::string* rmFil = osoption->getFilesToDelete();
2057 ok = osoption2->setFilesToDelete(nopt, rmFil) && ok;
2058#ifdef DEBUG
2059 if (!ok)
2060 throw ErrorClass(" error in get/set FilesToDelete");
2061#endif
2062
2064 std::string* rmDir = osoption->getDirectoriesToDelete();
2065 ok = osoption2->setDirectoriesToDelete(nopt, rmDir) && ok;
2066#ifdef DEBUG
2067 if (!ok)
2068 throw ErrorClass(" error in get/set DirectoriesToDelete");
2069#endif
2070
2072 std::string* rmProc = osoption->getProcessesToKill();
2073 ok = osoption2->setProcessesToKill(nopt, rmProc) && ok;
2074#ifdef DEBUG
2075 if (!ok)
2076 throw ErrorClass(" error in get/set ProcessesToKill");
2077#endif
2078
2079 OtherOption** otherOpt4;
2081 otherOpt4 = osoption->getOtherJobOptions();
2082 ok = osoption2->setOtherJobOptions(nopt, otherOpt4) && ok;
2083#ifdef DEBUG
2084 if (!ok)
2085 throw ErrorClass(" error in get/set OtherJobOptions");
2086#endif
2087
2088 int nvar, nobj, ncon;
2089 nvar = osoption->getOptionInt("numberOfVariables");
2090 ok = osoption2->setNumberOfVariables(nvar) && ok;
2091 nobj = osoption->getOptionInt("numberOfObjectives");
2092 ok = osoption2->setNumberOfObjectives(nobj) && ok;
2093 ncon = osoption->getOptionInt("numberOfConstraints");
2094 ok = osoption2->setNumberOfConstraints(ncon) && ok;
2095 // eliminate references to numberOfVariables
2096 nvar = 10;
2097 nobj = 2;
2098 ncon = 8;
2099#ifdef DEBUG
2100 if (!ok)
2101 throw ErrorClass(" error in get/set problem dimensions");
2102#endif
2103
2104// use sparse methods only because some schema elements allow NaN
2106 InitVarValue** IVV;
2108 ok = osoption2->setInitVarValuesSparse(nopt, IVV) && ok;
2109#ifdef DEBUG
2110 if (!ok)
2111 throw ErrorClass(" error in get/set InitVarValues");
2112#endif
2113
2115
2116 InitVarValueString** IVV2;
2118 ok = osoption2->setInitVarValuesStringSparse(nopt, IVV2) && ok;
2119#ifdef DEBUG
2120 if (!ok)
2121 throw ErrorClass(" error in get/set InitVarValuesString");
2122#endif
2123
2124 int* IBS;
2125
2127 if (nvar > 0)
2128 {
2129 IBS = new int[nvar];
2132 delete[] IBS;
2133#ifdef DEBUG
2134 if (!ok)
2135 throw ErrorClass(" error in get/set InitBasisStatus");
2136#endif
2137 }
2138
2140 if (nvar > 0)
2141 {
2142 IBS = new int[nvar];
2143
2146 delete[] IBS;
2147#ifdef DEBUG
2148 if (!ok)
2149 throw ErrorClass(" error in get/set InitBasisStatus");
2150#endif
2151 }
2152
2154 if (nvar > 0)
2155 {
2156 IBS = new int[nvar];
2159 delete[] IBS;
2160#ifdef DEBUG
2161 if (!ok)
2162 throw ErrorClass(" error in get/set InitBasisStatus");
2163#endif
2164 }
2165
2167 if (nvar > 0)
2168 {
2169 IBS = new int[nvar];
2172 delete[] IBS;
2173#ifdef DEBUG
2174 if (!ok)
2175 throw ErrorClass(" error in get/set InitBasisStatus");
2176#endif
2177 }
2178
2180 if (nvar > 0)
2181 {
2182 IBS = new int[nvar];
2185 delete[] IBS;
2186#ifdef DEBUG
2187 if (!ok)
2188 throw ErrorClass(" error in get/set InitBasisStatus");
2189#endif
2190 }
2191
2193 if (nvar > 0)
2194 {
2195 IBS = new int[nvar];
2198 delete[] IBS;
2199#ifdef DEBUG
2200 if (!ok)
2201 throw ErrorClass(" error in get/set InitBasisStatus");
2202#endif
2203 }
2204
2206 if (nvar > 0)
2207 {
2208 IBS = new int[nvar];
2211 delete[] IBS;
2212#ifdef DEBUG
2213 if (!ok)
2214 throw ErrorClass(" error in get/set InitBasisStatus");
2215#endif
2216 }
2217
2218
2219 BranchingWeight** BW;
2222 ok = osoption2->setIntegerVariableBranchingWeightsSparse(nopt, BW) && ok;
2223#ifdef DEBUG
2224 if (!ok)
2225 throw ErrorClass(" error in get/set IntegerVariableBranchingWeights");
2226#endif
2227
2228 SOSWeights** sos;
2230 nopt = osoption->getNumberOfSOS();
2231 ok = osoption2->setSOSVariableBranchingWeights(nopt, sos) && ok;
2232#ifdef DEBUG
2233 if (!ok)
2234 throw ErrorClass(" error in get/set SOSVariableBranchingWeights");
2235#endif
2236
2237 OtherVariableOption** otherV;
2240 ok = osoption2->setOtherVariableOptions(nopt, otherV) && ok;
2241#ifdef DEBUG
2242 if (!ok)
2243 throw ErrorClass(" error in get/set OtherVariableOptions");
2244#endif
2245
2247 InitObjValue** IOV;
2249 for (int lmn=0; lmn < nobj; lmn++)
2250
2251 ok = osoption2->setInitObjValuesSparse(nopt, IOV) && ok;
2252#ifdef DEBUG
2253 if (!ok)
2254 throw ErrorClass(" error in get/set InitObjValues");
2255#endif
2256
2258 InitObjBound** IOB;
2260 ok = osoption2->setInitObjBoundsSparse(nopt, IOB) && ok;
2261#ifdef DEBUG
2262 if (!ok)
2263 throw ErrorClass(" error in get/set InitObjBounds");
2264#endif
2265
2267 if (nvar > 0)
2268 {
2269 IBS = new int[nvar];
2272 delete[] IBS;
2273#ifdef DEBUG
2274 if (!ok)
2275 throw ErrorClass(" error in get/set InitBasisStatus");
2276#endif
2277 }
2278
2280 if (nvar > 0)
2281 {
2282 IBS = new int[nvar];
2285 delete[] IBS;
2286#ifdef DEBUG
2287 if (!ok)
2288 throw ErrorClass(" error in get/set InitBasisStatus");
2289#endif
2290 }
2291
2293 if (nvar > 0)
2294 {
2295 IBS = new int[nvar];
2298 delete[] IBS;
2299#ifdef DEBUG
2300 if (!ok)
2301 throw ErrorClass(" error in get/set InitBasisStatus");
2302#endif
2303 }
2304
2306 if (nvar > 0)
2307 {
2308 IBS = new int[nvar];
2311 delete[] IBS;
2312#ifdef DEBUG
2313 if (!ok)
2314 throw ErrorClass(" error in get/set InitBasisStatus");
2315#endif
2316 }
2317
2319 if (nvar > 0)
2320 {
2321 IBS = new int[nvar];
2324 delete[] IBS;
2325#ifdef DEBUG
2326 if (!ok)
2327 throw ErrorClass(" error in get/set InitBasisStatus");
2328#endif
2329 }
2330
2332 if (nvar > 0)
2333 {
2334 IBS = new int[nvar];
2337 delete[] IBS;
2338#ifdef DEBUG
2339 if (!ok)
2340 throw ErrorClass(" error in get/set InitBasisStatus");
2341#endif
2342 }
2343
2345 if (nvar > 0)
2346 {
2347 IBS = new int[nvar];
2350 delete[] IBS;
2351#ifdef DEBUG
2352 if (!ok)
2353 throw ErrorClass(" error in get/set InitBasisStatus");
2354#endif
2355 }
2356
2357 OtherObjectiveOption** otherO;
2360 ok = osoption2->setOtherObjectiveOptions(nopt, otherO) && ok;
2361#ifdef DEBUG
2362 if (!ok)
2363 throw ErrorClass(" error in get/set OtherObjectiveOptions");
2364#endif
2365
2366
2368 InitConValue** ICV;
2370 ok = osoption2->setInitConValuesSparse(nopt, ICV) && ok;
2371#ifdef DEBUG
2372 if (!ok)
2373 throw ErrorClass(" error in get/set InitConValues");
2374#endif
2375
2377 InitDualVarValue** IDV;
2379 ok = osoption2->setInitDualVarValuesSparse(nopt, IDV) && ok;
2380#ifdef DEBUG
2381 if (!ok)
2382 throw ErrorClass(" error in get/set InitDualVarValues");
2383#endif
2384
2386 if (nvar > 0)
2387 {
2388 IBS = new int[nvar];
2391 delete[] IBS;
2392#ifdef DEBUG
2393 if (!ok)
2394 throw ErrorClass(" error in get/set InitBasisStatus");
2395#endif
2396 }
2397
2399 if (nvar > 0)
2400 {
2401 IBS = new int[nvar];
2404 delete[] IBS;
2405#ifdef DEBUG
2406 if (!ok)
2407 throw ErrorClass(" error in get/set InitBasisStatus");
2408#endif
2409 }
2410
2412 if (nvar > 0)
2413 {
2414 IBS = new int[nvar];
2417 delete[] IBS;
2418#ifdef DEBUG
2419 if (!ok)
2420 throw ErrorClass(" error in get/set InitBasisStatus");
2421#endif
2422 }
2423
2425 if (nvar > 0)
2426 {
2427 IBS = new int[nvar];
2430 delete[] IBS;
2431#ifdef DEBUG
2432 if (!ok)
2433 throw ErrorClass(" error in get/set InitBasisStatus");
2434#endif
2435 }
2436
2438 if (nvar > 0)
2439 {
2440 IBS = new int[nvar];
2443 delete[] IBS;
2444#ifdef DEBUG
2445 if (!ok)
2446 throw ErrorClass(" error in get/set InitBasisStatus");
2447#endif
2448 }
2449
2451 if (nvar > 0)
2452 {
2453 IBS = new int[nvar];
2456 delete[] IBS;
2457#ifdef DEBUG
2458 if (!ok)
2459 throw ErrorClass(" error in get/set InitBasisStatus");
2460#endif
2461 }
2462
2464 if (nvar > 0)
2465 {
2466 IBS = new int[nvar];
2469 delete[] IBS;
2470#ifdef DEBUG
2471 if (!ok)
2472 throw ErrorClass(" error in get/set InitBasisStatus");
2473#endif
2474 }
2475
2476 OtherConstraintOption** otherC;
2479 ok = osoption2->setOtherConstraintOptions(nopt, otherC) && ok;
2480#ifdef DEBUG
2481 if (!ok)
2482 throw ErrorClass(" error in get/set OtherConstraintOptions");
2483#endif
2484
2485 SolverOption** SO;
2486
2489 ok = osoption2->setSolverOptions(nopt, SO) && ok;
2490
2491
2492#ifdef DEBUG
2493 if (!ok)
2494 throw ErrorClass(" error in get/set SolverOptions");
2495#endif
2496
2497 ok = osoption->IsEqual(osoption2) && ok;
2498 if (ok)
2499 cout << "get/set methods successfully duplicate OSOption object" << std::endl << std::endl;
2500 else
2501 throw ErrorClass("OSOption get() and set() methods do not work correctly");
2502
2503 cout << "Write the content to a new file" << endl;
2504 tmpOSoL = osolwriter->writeOSoL( osoption);
2505 cout << endl << "Here is tmpOSoL:" <<endl;
2506 cout << endl << endl << tmpOSoL << endl;
2507 cout << "-----------------------------------------" << endl << endl;
2508
2509 // make sure we can parse without error
2510 osolreader2 = new OSoLReader();
2511 cout << "Read the string back" << endl;
2512
2513 osoption3 = osolreader2->readOSoL( tmpOSoL);
2514
2515 cout << "Compare the two OSOption objects" << endl;
2516
2517//extern const OSSmartPtr<OSOutput> osoutput;
2518// osoutput->SetPrintLevel("stdout", (ENUM_OUTPUT_LEVEL)907);
2519
2520 ok = osoption->IsEqual(osoption3);
2521 if (!ok)
2522 throw ErrorClass(" Loss of information in OSoL write/read");
2523
2524 delete osoption2;
2525 osoption2 = NULL;
2526 delete osolreader2;
2527 osolreader2 = NULL;
2528 delete osolwriter;
2529 osolwriter = NULL;
2530 delete osolreader;
2531 osolreader = NULL;
2532 delete fileUtil;
2533 fileUtil = NULL;
2534
2535 unitTestResult <<
2536 "TEST " << nOfTest << ": Successful test of OSoL set() and get() methods"
2537 << std::endl;
2538 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2539 }
2540 catch(const ErrorClass& eclass)
2541 {
2542 cout << endl << endl << endl;
2543 cout << eclass.errormsg << endl;
2544 unitTestResultFailure << "Sorry Unit Test Failed OSoL set() and get() methods (Test " << nOfTest << ")" << endl;
2545
2546 if (osoption2 != NULL)
2547 delete osoption2;
2548 osoption2 = NULL;
2549
2550 if (osolreader2 != NULL)
2551 delete osolreader2;
2552 osolreader2 = NULL;
2553
2554 if (osolwriter != NULL)
2555 delete osolwriter;
2556 osolwriter = NULL;
2557
2558 if (osolreader != NULL)
2559 delete osolreader;
2560 osolreader = NULL;
2561
2562 if (fileUtil != NULL)
2563 delete fileUtil;
2564 fileUtil = NULL;
2565 }
2566
2567 // a few more smaller examples
2568 try{
2569 cout << endl << "TEST " << ++nOfTest << ": Parse another .osol file" << endl << endl;
2570
2571 fileUtil = new FileUtil();
2572 osolwriter = new OSoLWriter();
2573 osolreader = new OSoLReader();
2574
2575 std::string tmpOSoL;
2576 clock_t start, finish;
2577 double duration;
2578
2579 start = clock();
2580
2581 cout << "First read the OSoL file into a string" << endl;
2582 osolFileName = dataDir + "osolFiles" + dirsep + "parsertest2.osol";
2583 osol = fileUtil->getFileAsString( osolFileName.c_str() );
2584 finish = clock();
2585 duration = (double) (finish - start) / CLOCKS_PER_SEC;
2586 cout << "Reading the file into a string took (seconds): "<< duration << endl;
2587 cout << endl << osol << endl;
2588 cout << "Parse the OSoL string into an OSOption object" << endl;
2589 osoption = osolreader->readOSoL( osol);
2590
2591 std::cout << "string read; now write again" << std::endl;
2592 tmpOSoL = osolwriter->writeOSoL( osoption) ;
2593
2594 std::cout << "object written; delete osolreader" << std::endl;
2595
2596 delete osolreader;
2597 osolreader = NULL;
2598 osolreader = new OSoLReader();
2599 osolreader->readOSoL( tmpOSoL);
2600 delete osolwriter;
2601 osolwriter = NULL;
2602 delete osolreader;
2603 osolreader = NULL;
2604 delete fileUtil;
2605 fileUtil = NULL;
2606
2607 // a third example
2608 cout << "Test parsing another OSoL file" << endl;
2609
2610 osolwriter = new OSoLWriter();
2611 osolreader = new OSoLReader();
2612 fileUtil = new FileUtil();
2613
2614 cout << "First read the OSoL file into a string" << endl;
2615 osolFileName = dataDir + "osolFiles" + dirsep + "parsertest3.osol";
2616 osol = fileUtil->getFileAsString( osolFileName.c_str() );
2617 finish = clock();
2618 duration = (double) (finish - start) / CLOCKS_PER_SEC;
2619 cout << "Reading the file into a string took (seconds): "<< duration << endl;
2620 cout << "Parse the OSoL string into an OSOption object" << endl;
2621 osoption = osolreader->readOSoL( osol);
2622 tmpOSoL = osolwriter->writeOSoL( osoption) ;
2623 delete osolreader;
2624 osolreader = NULL;
2625 osolreader = new OSoLReader();
2626 osolreader->readOSoL( tmpOSoL);
2627 delete osolwriter;
2628 osolwriter = NULL;
2629 delete osolreader;
2630 osolreader = NULL;
2631 delete fileUtil;
2632 fileUtil = NULL;
2633
2634
2635 // a trivial string
2636 cout << "Test parsing a trivial string" << endl;
2637
2638 osolreader = new OSoLReader();
2639
2640 osol = "<osol></osol>";
2641 cout << "Parse the OSoL string into an OSOption object" << endl;
2642 osoption = osolreader->readOSoL( osol);
2643 delete osolreader;
2644 osolreader = NULL;
2645
2646 unitTestResult << "TEST " << nOfTest << ": Successful test of OSoL parser" << std::endl;
2647 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2648 }
2649
2650 catch(const ErrorClass& eclass){
2651
2652 std::cout << "Content of error msg:" << std::endl << "-------------------------------" << std::endl;
2653 std::cout << eclass.errormsg << endl;
2654 std::cout << "-------------------------------" << std::endl;
2655
2656 unitTestResultFailure << eclass.errormsg << endl;
2657 unitTestResultFailure << "There was a failure in the test for reading OSoL (Test " << nOfTest << ")" << endl;
2658
2659 if(osolwriter != NULL)
2660 delete osolwriter;
2661 osolwriter = NULL;
2662 if(osolreader != NULL)
2663 delete osolreader;
2664 osolreader = NULL;
2665 if (fileUtil != NULL)
2666 delete fileUtil;
2667 fileUtil = NULL;
2668 }
2669
2670
2671 // Finally a .osol file that has a number of semantic errors (not catchable by the schema)
2672 try{
2673 cout << endl << "TEST " << ++nOfTest << ": Parse faulty .osol file" << endl << endl;
2674
2675 fileUtil = new FileUtil();
2676 osolwriter = new OSoLWriter();
2677 osolreader = new OSoLReader();
2678
2679 std::string tmpOSoL;
2680
2681 cout << "First read the OSoL file into a string" << endl;
2682 osolFileName = dataDir + "osolFiles" + dirsep + "parsertestWithErrors.osol";
2683 osol = fileUtil->getFileAsString( osolFileName.c_str() );
2684
2685 cout << "Parse the OSoL string into an OSOption object" << endl;
2686 osoption = osolreader->readOSoL( osol);
2687
2688
2689 delete osolreader;
2690 osolreader = NULL;
2691 osolreader = new OSoLReader();
2692 osolreader->readOSoL( tmpOSoL);
2693 delete osolwriter;
2694 osolwriter = NULL;
2695 delete osolreader;
2696 osolreader = NULL;
2697 delete fileUtil;
2698 fileUtil = NULL;
2699
2700 unitTestResultFailure << "OSoL parser: error detection failed in faulty OSoL file (Test " << nOfTest << ")" << endl;
2701 }
2702
2703 catch(const ErrorClass& eclass)
2704 {
2705 std::string resultFileName, resultFileContent;
2706 resultFileName = dataDir + "osolFiles" + dirsep + "parsertestWithErrors.result";
2707 resultFileContent = fileUtil->getFileAsString( resultFileName.c_str() );
2708
2709 std::cout << std::endl << std::endl << "error message should be:" << resultFileContent << std::endl;
2710 std::cout << std::endl << std::endl << "error message now reads:" << eclass.errormsg << std::endl;
2711
2712 if (resultFileContent == eclass.errormsg)
2713 {
2714 unitTestResult << "TEST " << nOfTest << ": Successful error handling of faulty OSoL input" << std::endl;
2715 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2716 }
2717 else
2718 {
2719 int i,j,ni,nj;
2720 i = 0;
2721 j = 0;
2722 ni = resultFileContent.size() - 1;
2723 nj = eclass.errormsg.size() - 1;
2724 ok = true;
2725 for (;;)
2726 {
2727 if (i >= ni || j >= nj) break;
2728 for (;;)
2729 {
2730 if (resultFileContent[i] != '\n' && resultFileContent[i] != '\r' &&
2731 resultFileContent[i] != '\t' && resultFileContent[i] != ' ' ) break;
2732 if (i >= ni) break;
2733 i++;
2734 }
2735 for (;;)
2736 {
2737 if (eclass.errormsg[j] != '\n' && eclass.errormsg[j] != '\r' &&
2738 eclass.errormsg[j] != '\t' && eclass.errormsg[j] != ' ' ) break;
2739 if (j >= nj) break;
2740 j++;
2741 }
2742
2743 ok &= (resultFileContent[i] == eclass.errormsg[j]);
2744 if (!ok) break;
2745 i++;
2746 j++;
2747 }
2748
2749 if (ok)
2750 {
2751 unitTestResult << "TEST " << nOfTest << ": Successful error handling of faulty OSoL input" << std::endl;
2752 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2753 }
2754 else
2755 unitTestResultFailure << "Test " << nOfTest << ": There was a failure in the error handling of the OSoL parser" << endl;
2756 }
2757
2758 if(osolwriter != NULL)
2759 delete osolwriter;
2760 osolwriter = NULL;
2761 if(osolreader != NULL)
2762 delete osolreader;
2763 osolreader = NULL;
2764 if (fileUtil != NULL)
2765 delete fileUtil;
2766 fileUtil = NULL;
2767 }
2768
2769 // Now test the deep copy of an OSOption object
2770
2771 /*OSOption * */ osoption2 = NULL;
2772
2773 try{
2774 cout << endl << "TEST " << ++nOfTest << ": Test deep copy of OSOption object" << endl << endl;
2775
2776 fileUtil = new FileUtil();
2777 osolreader = new OSoLReader();
2778
2779 osolFileName = dataDir + "osolFiles" + dirsep + "parsertest.osol";
2780 std::string osol = fileUtil->getFileAsString( osolFileName.c_str() );
2781 cout << "Read osol file" << endl;
2782 osoption = osolreader->readOSoL( osol);
2783 osoption2 = new OSOption();
2784 cout << "Duplicate OSOption object" << endl;
2785 osoption2->deepCopyFrom(osoption);
2786 cout << "Compare the two objects" << endl;
2787 ok = (osoption->IsEqual(osoption2));
2788
2789 delete osolreader;
2790 osolreader = NULL;
2791 delete osoption2;
2792 osoption2 = NULL;
2793 delete fileUtil;
2794 fileUtil = NULL;
2795
2796 if (ok)
2797 {
2798 unitTestResult << "TEST " << nOfTest << ": Successful test of OSOption deep copy methods" << std::endl;
2799 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
2800 }
2801 else
2802 unitTestResultFailure << "Test " << nOfTest << ": OSOption deep copy method is not working" << endl;
2803 }
2804
2805 catch(const ErrorClass& eclass)
2806 {
2807 unitTestResultFailure << "Sorry Unit Test Failed Test " << nOfTest << ": Deep copy of OSOoption object " + eclass.errormsg << endl;
2808 if(osolreader != NULL)
2809 delete osolreader;
2810 osolreader = NULL;
2811 if (fileUtil != NULL)
2812 delete fileUtil;
2813 fileUtil = NULL;
2814 if(osoption2 != NULL)
2815 delete osoption2;
2816 osoption2 = NULL;
2817 }
2818
2819
2820
2821//#endif //!!! end of #if 0: OSrL parser development
2822
2832 int* intArray;
2833 intArray = new int[3];
2834 int* tempArray = new int[3];
2835
2836 try{
2837 cout << endl << "TEST " << ++nOfTest << ": OSrL set() tools" << endl << endl;
2838
2839 osresult1 = new OSResult();
2840 osresult2 = new OSResult();
2841
2842 ok = true;
2843 ok &= (osresult1->IsEqual(osresult2));
2844 if (!ok)
2845 throw ErrorClass("Empty osresult objects do not compare equal!");
2846
2847// <general> element
2848 cout << "Set <general> element" << endl;
2849 ok &= osresult1->setGeneralStatusType("warning");
2850 if (!ok)
2851 throw ErrorClass("Error during setGeneralStatusType!");
2852 ok &= (!osresult1->IsEqual(osresult2));
2853 if (!ok)
2854 throw ErrorClass("setGeneralStatusType: osresult objects falsely compare equal!");
2855 ok &= osresult2->setGeneralStatusType("warning");
2856 if (!ok)
2857 throw ErrorClass("Error during setGeneralStatusType!");
2858 ok &= (osresult1->IsEqual(osresult2));
2859 if (!ok)
2860 throw ErrorClass("setGeneralStatusType: osresult objects falsely compare unequal!");
2861
2862 ok &= osresult1->setGeneralStatusDescription("some nonempty string");
2863 if (!ok)
2864 throw ErrorClass("Error during setGeneralStatusDescription!");
2865 ok &= (!osresult1->IsEqual(osresult2));
2866 if (!ok)
2867 throw ErrorClass("setGeneralStatusDescription: osresult objects falsely compare equal!");
2868 ok &= osresult2->setGeneralStatusDescription("some nonempty string");
2869 if (!ok)
2870 throw ErrorClass("Error during setGeneralStatusDescription!");
2871 ok &= (osresult1->IsEqual(osresult2));
2872 if (!ok)
2873 throw ErrorClass("setGeneralStatusDescription: osresult objects falsely compare unequal!");
2874
2875 ok &= osresult1->setNumberOfGeneralSubstatuses(3);
2876 if (!ok)
2877 throw ErrorClass("Error during setNumberOfGeneralSubstatuses!");
2878 ok &= (!osresult1->IsEqual(osresult2));
2879 if (!ok)
2880 throw ErrorClass("setNumberOfGeneralSubstatuses: osresult objects falsely compare equal!");
2881 ok &= osresult2->setNumberOfGeneralSubstatuses(3);
2882 if (!ok)
2883 throw ErrorClass("Error during setNumberOfGeneralSubstatuses!");
2884 ok &= (osresult1->IsEqual(osresult2));
2885 if (!ok)
2886 throw ErrorClass("setNumberOfGeneralSubstatuses: osresult objects falsely compare unequal!");
2887
2888 for (int i=0; i < 3; ++i)
2889 {
2890 ok &= osresult1->setGeneralSubstatusName(i,"some name");
2891 if (!ok)
2892 throw ErrorClass("Error during setGeneralSubstatusName!");
2893 ok &= (!osresult1->IsEqual(osresult2));
2894 if (!ok)
2895 throw ErrorClass("setGeneralSubstatusName: osresult objects falsely compare equal!");
2896 ok &= osresult2->setGeneralSubstatusName(i,"some name");
2897 if (!ok)
2898 throw ErrorClass("Error during setGeneralSubstatusName!");
2899 ok &= (osresult1->IsEqual(osresult2));
2900 if (!ok)
2901 throw ErrorClass("setGeneralSubstatusName: osresult objects falsely compare unequal!");
2902
2903 ok &= osresult1->setGeneralSubstatusDescription(i,"ABC 123");
2904 if (!ok)
2905 throw ErrorClass("Error during setGeneralSubstatusDescription!");
2906 ok &= (!osresult1->IsEqual(osresult2));
2907 if (!ok)
2908 throw ErrorClass("setGeneralSubstatusDescription: osresult objects falsely compare equal!");
2909 ok &= osresult2->setGeneralSubstatusDescription(i,"ABC 123");
2910 if (!ok)
2911 throw ErrorClass("Error during setGeneralSubstatusDescription!");
2912 ok &= (osresult1->IsEqual(osresult2));
2913 if (!ok)
2914 throw ErrorClass("setGeneralSubstatusDescription: osresult objects falsely compare unequal!");
2915 }
2916
2917 ok &= osresult1->setGeneralMessage("testing 123");
2918 if (!ok)
2919 throw ErrorClass("Error during setGeneralMessage!");
2920 ok &= (!osresult1->IsEqual(osresult2));
2921 if (!ok)
2922 throw ErrorClass("setGeneralMessage: osresult objects falsely compare equal!");
2923 ok &= osresult2->setGeneralMessage("testing 123");
2924 if (!ok)
2925 throw ErrorClass("Error during setGeneralMessage!");
2926 ok &= (osresult1->IsEqual(osresult2));
2927 if (!ok)
2928 throw ErrorClass("setGeneralMessage: osresult objects falsely compare unequal!");
2929
2930 ok &= osresult1->setServiceName("testing 123");
2931 if (!ok)
2932 throw ErrorClass("Error during setServiceName!");
2933 ok &= (!osresult1->IsEqual(osresult2));
2934 if (!ok)
2935 throw ErrorClass("setServiceName: osresult objects falsely compare equal!");
2936 ok &= osresult2->setServiceName("testing 123");
2937 if (!ok)
2938 throw ErrorClass("Error during setServiceName!");
2939 ok &= (osresult1->IsEqual(osresult2));
2940 if (!ok)
2941 throw ErrorClass("setServiceName: osresult objects falsely compare unequal!");
2942
2943 ok &= osresult1->setServiceURI("testing 123");
2944 if (!ok)
2945 throw ErrorClass("Error during setServiceURI!");
2946 ok &= (!osresult1->IsEqual(osresult2));
2947 if (!ok)
2948 throw ErrorClass("setServiceURI: osresult objects falsely compare equal!");
2949 ok &= osresult2->setServiceURI("testing 123");
2950 if (!ok)
2951 throw ErrorClass("Error during setServiceURI!");
2952 ok &= (osresult1->IsEqual(osresult2));
2953 if (!ok)
2954 throw ErrorClass("setServiceURI: osresult objects falsely compare unequal!");
2955
2956 ok &= osresult1->setInstanceName("testing 123");
2957 if (!ok)
2958 throw ErrorClass("Error during setInstanceName!");
2959 ok &= (!osresult1->IsEqual(osresult2));
2960 if (!ok)
2961 throw ErrorClass("setInstanceName: osresult objects falsely compare equal!");
2962 ok &= osresult2->setInstanceName("testing 123");
2963 if (!ok)
2964 throw ErrorClass("Error during setInstanceName!");
2965 ok &= (osresult1->IsEqual(osresult2));
2966 if (!ok)
2967 throw ErrorClass("setInstanceName: osresult objects falsely compare unequal!");
2968
2969 ok &= osresult1->setJobID("testing 123");
2970 if (!ok)
2971 throw ErrorClass("Error during setJobID!");
2972 ok &= (!osresult1->IsEqual(osresult2));
2973 if (!ok)
2974 throw ErrorClass("setJobID: osresult objects falsely compare equal!");
2975 ok &= osresult2->setJobID("testing 123");
2976 if (!ok)
2977 throw ErrorClass("Error during setJobID!");
2978 ok &= (osresult1->IsEqual(osresult2));
2979 if (!ok)
2980 throw ErrorClass("setJobID: osresult objects falsely compare unequal!");
2981
2982 ok &= osresult1->setSolverInvoked("testing 123");
2983 if (!ok)
2984 throw ErrorClass("Error during setSolverInvoked!");
2985 ok &= (!osresult1->IsEqual(osresult2));
2986 if (!ok)
2987 throw ErrorClass("setSolverInvoked: osresult objects falsely compare equal!");
2988 ok &= osresult2->setSolverInvoked("testing 123");
2989 if (!ok)
2990 throw ErrorClass("Error during setSolverInvoked!");
2991 ok &= (osresult1->IsEqual(osresult2));
2992 if (!ok)
2993 throw ErrorClass("setSolverInvoked: osresult objects falsely compare unequal!");
2994
2995 ok &= osresult1->setTimeStamp("2001-12-17T09:30:47.0Z");
2996 if (!ok)
2997 throw ErrorClass("Error during setTimeStamp!");
2998 ok &= (!osresult1->IsEqual(osresult2));
2999 if (!ok)
3000 throw ErrorClass("setTimeStamp: osresult objects falsely compare equal!");
3001 ok &= osresult2->setTimeStamp("2001-12-17T09:30:47.0Z");
3002 if (!ok)
3003 throw ErrorClass("Error during setTimeStamp!");
3004 ok &= (osresult1->IsEqual(osresult2));
3005 if (!ok)
3006 throw ErrorClass("setTimeStamp: osresult objects falsely compare unequal!");
3007
3008 ok &= osresult1->setNumberOfOtherGeneralResults(3);
3009 if (!ok)
3010 throw ErrorClass("Error during setNumberOfOtherGeneralResults!");
3011 ok &= (!osresult1->IsEqual(osresult2));
3012 if (!ok)
3013 throw ErrorClass("setNumberOfOtherGeneralResults: osresult objects falsely compare equal!");
3014 ok &= osresult2->setNumberOfOtherGeneralResults(3);
3015 if (!ok)
3016 throw ErrorClass("Error during setNumberOfOtherGeneralResults!");
3017 ok &= (osresult1->IsEqual(osresult2));
3018 if (!ok)
3019 throw ErrorClass("setNumberOfOtherGeneralResults: osresult objects falsely compare unequal!");
3020
3021 for (int i=0; i < 3; ++i)
3022 {
3023 ok &= osresult1->setOtherGeneralResultName(i,"some name");
3024 if (!ok)
3025 throw ErrorClass("Error during setOtherGeneralResultName!");
3026 ok &= (!osresult1->IsEqual(osresult2));
3027 if (!ok)
3028 throw ErrorClass("setOtherGeneralResultName: osresult objects falsely compare equal!");
3029 ok &= osresult2->setOtherGeneralResultName(i,"some name");
3030 if (!ok)
3031 throw ErrorClass("Error during setOtherGeneralResultName!");
3032 ok &= (osresult1->IsEqual(osresult2));
3033 if (!ok)
3034 throw ErrorClass("setOtherGeneralResultName: osresult objects falsely compare unequal!");
3035
3036 ok &= osresult1->setOtherGeneralResultValue(i,"some value");
3037 if (!ok)
3038 throw ErrorClass("Error during setOtherGeneralResultValue!");
3039 ok &= (!osresult1->IsEqual(osresult2));
3040 if (!ok)
3041 throw ErrorClass("setOtherGeneralResultValue: osresult objects falsely compare equal!");
3042 ok &= osresult2->setOtherGeneralResultValue(i,"some value");
3043 if (!ok)
3044 throw ErrorClass("Error during setOtherGeneralResultValue!");
3045 ok &= (osresult1->IsEqual(osresult2));
3046 if (!ok)
3047 throw ErrorClass("setOtherGeneralResultValue: osresult objects falsely compare unequal!");
3048
3049 ok &= osresult1->setOtherGeneralResultDescription(i,"ABC 123");
3050 if (!ok)
3051 throw ErrorClass("Error during setOtherGeneralResultDescription!");
3052 ok &= (!osresult1->IsEqual(osresult2));
3053 if (!ok)
3054 throw ErrorClass("setOtherGeneralResultDescription: osresult objects falsely compare equal!");
3055 ok &= osresult2->setOtherGeneralResultDescription(i,"ABC 123");
3056 if (!ok)
3057 throw ErrorClass("Error during setOtherGeneralResultDescription!");
3058 ok &= (osresult1->IsEqual(osresult2));
3059 if (!ok)
3060 throw ErrorClass("setOtherGeneralResultDescription: osresult objects falsely compare unequal!");
3061 }
3062
3063// <system> element
3064 cout << "Set <system> element" << endl;
3065 ok &= osresult1->setSystemInformation("testing 123");
3066 if (!ok)
3067 throw ErrorClass("Error during setSystemInformation!");
3068 ok &= (!osresult1->IsEqual(osresult2));
3069 if (!ok)
3070 throw ErrorClass("setSystemInformation: osresult objects falsely compare equal!");
3071 ok &= osresult2->setSystemInformation("testing 123");
3072 if (!ok)
3073 throw ErrorClass("Error during setSystemInformation!");
3074 ok &= (osresult1->IsEqual(osresult2));
3075 if (!ok)
3076 throw ErrorClass("setSystemInformation: osresult objects falsely compare unequal!");
3077
3078 ok &= osresult1->setAvailableDiskSpaceUnit("megabyte");
3079 if (!ok)
3080 throw ErrorClass("Error during setAvailableDiskSpaceUnit!");
3081 ok &= (!osresult1->IsEqual(osresult2));
3082 if (!ok)
3083 throw ErrorClass("setAvailableDiskSpaceUnit: osresult objects falsely compare equal!");
3084 ok &= osresult2->setAvailableDiskSpaceUnit("megabyte");
3085 if (!ok)
3086 throw ErrorClass("Error during setAvailableDiskSpaceUnit!");
3087 ok &= (osresult1->IsEqual(osresult2));
3088 if (!ok)
3089 throw ErrorClass("setAvailableDiskSpaceUnit: osresult objects falsely compare unequal!");
3090
3091 ok &= osresult1->setAvailableDiskSpaceDescription("testing 123");
3092 if (!ok)
3093 throw ErrorClass("Error during setAvailableDiskSpaceDescription!");
3094 ok &= (!osresult1->IsEqual(osresult2));
3095 if (!ok)
3096 throw ErrorClass("setAvailableDiskSpaceDescription: osresult objects falsely compare equal!");
3097 ok &= osresult2->setAvailableDiskSpaceDescription("testing 123");
3098 if (!ok)
3099 throw ErrorClass("Error during setAvailableDiskSpaceDescription!");
3100 ok &= (osresult1->IsEqual(osresult2));
3101 if (!ok)
3102 throw ErrorClass("setAvailableDiskSpaceDescription: osresult objects falsely compare unequal!");
3103
3104 ok &= osresult1->setAvailableDiskSpaceValue(100.0);
3105 if (!ok)
3106 throw ErrorClass("Error during setAvailableDiskSpaceValue!");
3107 ok &= (!osresult1->IsEqual(osresult2));
3108 if (!ok)
3109 throw ErrorClass("setAvailableDiskSpaceValue: osresult objects falsely compare equal!");
3110 ok &= osresult2->setAvailableDiskSpaceValue(100.0);
3111 if (!ok)
3112 throw ErrorClass("Error during setAvailableDiskSpaceValue!");
3113 ok &= (osresult1->IsEqual(osresult2));
3114 if (!ok)
3115 throw ErrorClass("setAvailableDiskSpaceValue: osresult objects falsely compare unequal!");
3116
3117 ok &= osresult1->setAvailableMemoryUnit("megabyte");
3118 if (!ok)
3119 throw ErrorClass("Error during setAvailableMemoryUnit!");
3120 ok &= (!osresult1->IsEqual(osresult2));
3121 if (!ok)
3122 throw ErrorClass("setAvailableMemoryUnit: osresult objects falsely compare equal!");
3123 ok &= osresult2->setAvailableMemoryUnit("megabyte");
3124 if (!ok)
3125 throw ErrorClass("Error during setAvailableMemoryUnit!");
3126 ok &= (osresult1->IsEqual(osresult2));
3127
3128 if (!ok)
3129 throw ErrorClass("setAvailableMemoryUnit: osresult objects falsely compare unequal!");
3130
3131 ok &= osresult1->setAvailableMemoryDescription("testing 123");
3132 if (!ok)
3133 throw ErrorClass("Error during setAvailableMemoryDescription!");
3134 ok &= (!osresult1->IsEqual(osresult2));
3135 if (!ok)
3136 throw ErrorClass("setAvailableMemoryDescription: osresult objects falsely compare equal!");
3137 ok &= osresult2->setAvailableMemoryDescription("testing 123");
3138 if (!ok)
3139 throw ErrorClass("Error during setAvailableMemoryDescription!");
3140 ok &= (osresult1->IsEqual(osresult2));
3141 if (!ok)
3142 throw ErrorClass("setAvailableMemoryDescription: osresult objects falsely compare unequal!");
3143
3144 ok &= osresult1->setAvailableMemoryValue(100.0);
3145 if (!ok)
3146 throw ErrorClass("Error during setAvailableMemoryValue!");
3147 ok &= (!osresult1->IsEqual(osresult2));
3148 if (!ok)
3149 throw ErrorClass("setAvailableMemoryValue: osresult objects falsely compare equal!");
3150 ok &= osresult2->setAvailableMemoryValue(100.0);
3151 if (!ok)
3152 throw ErrorClass("Error during setAvailableMemoryValue!");
3153 ok &= (osresult1->IsEqual(osresult2));
3154 if (!ok)
3155 throw ErrorClass("setAvailableMemoryValue: osresult objects falsely compare unequal!");
3156
3157 ok &= osresult1->setAvailableCPUSpeedUnit("megahertz");
3158 if (!ok)
3159 throw ErrorClass("Error during setAvailableCPUSpeedUnit!");
3160 ok &= (!osresult1->IsEqual(osresult2));
3161 if (!ok)
3162 throw ErrorClass("setAvailableCPUSpeedUnit: osresult objects falsely compare equal!");
3163 ok &= osresult2->setAvailableCPUSpeedUnit("megahertz");
3164 if (!ok)
3165 throw ErrorClass("Error during setAvailableCPUSpeedUnit!");
3166 ok &= (osresult1->IsEqual(osresult2));
3167 if (!ok)
3168 throw ErrorClass("setAvailableCPUSpeedUnit: osresult objects falsely compare unequal!");
3169
3170 ok &= osresult1->setAvailableCPUSpeedDescription("testing 123");
3171 if (!ok)
3172 throw ErrorClass("Error during setAvailableCPUSpeedDescription!");
3173 ok &= (!osresult1->IsEqual(osresult2));
3174 if (!ok)
3175 throw ErrorClass("setAvailableCPUSpeedDescription: osresult objects falsely compare equal!");
3176 ok &= osresult2->setAvailableCPUSpeedDescription("testing 123");
3177 if (!ok)
3178 throw ErrorClass("Error during setAvailableCPUSpeedDescription!");
3179 ok &= (osresult1->IsEqual(osresult2));
3180 if (!ok)
3181 throw ErrorClass("setAvailableCPUSpeedDescription: osresult objects falsely compare unequal!");
3182
3183 ok &= osresult1->setAvailableCPUSpeedValue(100.0);
3184 if (!ok)
3185 throw ErrorClass("Error during setAvailableCPUSpeedValue!");
3186 ok &= (!osresult1->IsEqual(osresult2));
3187 if (!ok)
3188 throw ErrorClass("setAvailableCPUSpeedValue: osresult objects falsely compare equal!");
3189 ok &= osresult2->setAvailableCPUSpeedValue(100.0);
3190 if (!ok)
3191 throw ErrorClass("Error during setAvailableCPUSpeedValue!");
3192 ok &= (osresult1->IsEqual(osresult2));
3193 if (!ok)
3194 throw ErrorClass("setAvailableCPUSpeedValue: osresult objects falsely compare unequal!");
3195
3196 ok &= osresult1->setAvailableCPUNumberDescription("testing 123");
3197 if (!ok)
3198 throw ErrorClass("Error during setAvailableCPUNumberDescription!");
3199 ok &= (!osresult1->IsEqual(osresult2));
3200 if (!ok)
3201 throw ErrorClass("setAvailableCPUNumberDescription: osresult objects falsely compare equal!");
3202 ok &= osresult2->setAvailableCPUNumberDescription("testing 123");
3203 if (!ok)
3204 throw ErrorClass("Error during setAvailableCPUNumberDescription!");
3205 ok &= (osresult1->IsEqual(osresult2));
3206 if (!ok)
3207 throw ErrorClass("setAvailableCPUNumberDescription: osresult objects falsely compare unequal!");
3208
3209 ok &= osresult1->setAvailableCPUNumberValue(100);
3210 if (!ok)
3211 throw ErrorClass("Error during setAvailableCPUNumberValue!");
3212 ok &= (!osresult1->IsEqual(osresult2));
3213 if (!ok)
3214 throw ErrorClass("setAvailableCPUNumberValue: osresult objects falsely compare equal!");
3215 ok &= osresult2->setAvailableCPUNumberValue(100);
3216 if (!ok)
3217 throw ErrorClass("Error during setAvailableCPUNumberValue!");
3218 ok &= (osresult1->IsEqual(osresult2));
3219 if (!ok)
3220 throw ErrorClass("setAvailableCPUNumberValue: osresult objects falsely compare unequal!");
3221
3222 ok &= osresult1->setNumberOfOtherSystemResults(3);
3223 if (!ok)
3224 throw ErrorClass("Error during setNumberOfOtherSystemResults!");
3225 ok &= (!osresult1->IsEqual(osresult2));
3226 if (!ok)
3227 throw ErrorClass("setNumberOfOtherSystemResults: osresult objects falsely compare equal!");
3228 ok &= osresult2->setNumberOfOtherSystemResults(3);
3229 if (!ok)
3230 throw ErrorClass("Error during setNumberOfOtherSystemResults!");
3231 ok &= (osresult1->IsEqual(osresult2));
3232 if (!ok)
3233 throw ErrorClass("setNumberOfOtherSystemResults: osresult objects falsely compare unequal!");
3234
3235 for (int i=0; i < 3; ++i)
3236 {
3237 ok &= osresult1->setOtherSystemResultName(i,"some name");
3238 if (!ok)
3239 throw ErrorClass("Error during setOtherSystemResultName!");
3240 ok &= (!osresult1->IsEqual(osresult2));
3241 if (!ok)
3242 throw ErrorClass("setOtherSystemResultName: osresult objects falsely compare equal!");
3243 ok &= osresult2->setOtherSystemResultName(i,"some name");
3244 if (!ok)
3245 throw ErrorClass("Error during setOtherSystemResultName!");
3246 ok &= (osresult1->IsEqual(osresult2));
3247 if (!ok)
3248 throw ErrorClass("setOtherSystemResultName: osresult objects falsely compare unequal!");
3249
3250 ok &= osresult1->setOtherSystemResultValue(i,"some value");
3251 if (!ok)
3252 throw ErrorClass("Error during setOtherSystemResultValue!");
3253 ok &= (!osresult1->IsEqual(osresult2));
3254 if (!ok)
3255 throw ErrorClass("setOtherSystemResultValue: osresult objects falsely compare equal!");
3256 ok &= osresult2->setOtherSystemResultValue(i,"some value");
3257 if (!ok)
3258 throw ErrorClass("Error during setOtherSystemResultValue!");
3259 ok &= (osresult1->IsEqual(osresult2));
3260 if (!ok)
3261 throw ErrorClass("setOtherSystemResultValue: osresult objects falsely compare unequal!");
3262
3263 ok &= osresult1->setOtherSystemResultDescription(i,"ABC 123");
3264 if (!ok)
3265 throw ErrorClass("Error during setSOtherSystemResultDescription!");
3266 ok &= (!osresult1->IsEqual(osresult2));
3267 if (!ok)
3268 throw ErrorClass("setOtherSystemResultDescription: osresult objects falsely compare equal!");
3269 ok &= osresult2->setOtherSystemResultDescription(i,"ABC 123");
3270 if (!ok)
3271 throw ErrorClass("Error during setOtherSystemResultDescription!");
3272 ok &= (osresult1->IsEqual(osresult2));
3273 if (!ok)
3274 throw ErrorClass("setOtherSystemResultDescription: osresult objects falsely compare unequal!");
3275 }
3276
3277// <service> element
3278 cout << "Set <service> element" << endl;
3279 ok &= osresult1->setCurrentState("busy");
3280 if (!ok)
3281 throw ErrorClass("Error during setCurrentState!");
3282 ok &= (!osresult1->IsEqual(osresult2));
3283 if (!ok)
3284 throw ErrorClass("setCurrentState: osresult objects falsely compare equal!");
3285 ok &= osresult2->setCurrentState("busy");
3286 if (!ok)
3287 throw ErrorClass("Error during setCurrentState!");
3288 ok &= (osresult1->IsEqual(osresult2));
3289 if (!ok)
3290 throw ErrorClass("setCurrentState: osresult objects falsely compare unequal!");
3291
3292 ok &= osresult1->setCurrentJobCount(123);
3293 if (!ok)
3294 throw ErrorClass("Error during setCurrentJobCount!");
3295 ok &= (!osresult1->IsEqual(osresult2));
3296 if (!ok)
3297 throw ErrorClass("setCurrentJobCount: osresult objects falsely compare equal!");
3298 ok &= osresult2->setCurrentJobCount(123);
3299 if (!ok)
3300 throw ErrorClass("Error during setCurrentJobCount!");
3301 ok &= (osresult1->IsEqual(osresult2));
3302 if (!ok)
3303 throw ErrorClass("setCurrentJobCount: osresult objects falsely compare unequal!");
3304
3305 ok &= osresult1->setTotalJobsSoFar(123);
3306 if (!ok)
3307 throw ErrorClass("Error during setTotalJobsSoFar!");
3308 ok &= (!osresult1->IsEqual(osresult2));
3309 if (!ok)
3310 throw ErrorClass("setTotalJobsSoFar: osresult objects falsely compare equal!");
3311 ok &= osresult2->setTotalJobsSoFar(123);
3312 if (!ok)
3313 throw ErrorClass("Error during setTotalJobsSoFar!");
3314 ok &= (osresult1->IsEqual(osresult2));
3315 if (!ok)
3316 throw ErrorClass("setTotalJobsSoFar: osresult objects falsely compare unequal!");
3317
3318 ok &= osresult1->setTimeServiceStarted("2001-12-17T09:30:47.0Z");
3319 if (!ok)
3320 throw ErrorClass("Error during setTimeServiceStarted!");
3321 ok &= (!osresult1->IsEqual(osresult2));
3322 if (!ok)
3323 throw ErrorClass("setTimeServiceStarted: osresult objects falsely compare equal!");
3324 ok &= osresult2->setTimeServiceStarted("2001-12-17T09:30:47.0Z");
3325 if (!ok)
3326 throw ErrorClass("Error during setTimeServiceStarted!");
3327 ok &= (osresult1->IsEqual(osresult2));
3328 if (!ok)
3329 throw ErrorClass("setTimeServiceStarted: osresult objects falsely compare unequal!");
3330
3331 ok &= osresult1->setServiceUtilization(0.8);
3332 if (!ok)
3333 throw ErrorClass("Error during setServiceUtilization!");
3334 ok &= (!osresult1->IsEqual(osresult2));
3335 if (!ok)
3336 throw ErrorClass("setServiceUtilization: osresult objects falsely compare equal!");
3337 ok &= osresult2->setServiceUtilization(0.8);
3338 if (!ok)
3339 throw ErrorClass("Error during setServiceUtilization!");
3340 ok &= (osresult1->IsEqual(osresult2));
3341 if (!ok)
3342 throw ErrorClass("setServiceUtilization: osresult objects falsely compare unequal!");
3343
3344 ok &= osresult1->setNumberOfOtherServiceResults(3);
3345 if (!ok)
3346 throw ErrorClass("Error during setNumberOfOtherServiceResults!");
3347 ok &= (!osresult1->IsEqual(osresult2));
3348 if (!ok)
3349 throw ErrorClass("setNumberOfOtherServiceResults: osresult objects falsely compare equal!");
3350 ok &= osresult2->setNumberOfOtherServiceResults(3);
3351 if (!ok)
3352 throw ErrorClass("Error during setNumberOfOtherServiceResults!");
3353 ok &= (osresult1->IsEqual(osresult2));
3354 if (!ok)
3355 throw ErrorClass("setNumberOfOtherServiceResults: osresult objects falsely compare unequal!");
3356
3357 for (int i=0; i < 3; ++i)
3358 {
3359 ok &= osresult1->setOtherServiceResultName(i,"some name");
3360 if (!ok)
3361 throw ErrorClass("Error during setOtherServiceResultName!");
3362 ok &= (!osresult1->IsEqual(osresult2));
3363 if (!ok)
3364 throw ErrorClass("setOtherServiceResultName: osresult objects falsely compare equal!");
3365 ok &= osresult2->setOtherServiceResultName(i,"some name");
3366 if (!ok)
3367 throw ErrorClass("Error during setOtherServiceResultName!");
3368 ok &= (osresult1->IsEqual(osresult2));
3369 if (!ok)
3370 throw ErrorClass("setOtherServiceResultName: osresult objects falsely compare unequal!");
3371
3372 ok &= osresult1->setOtherServiceResultValue(i,"some value");
3373 if (!ok)
3374 throw ErrorClass("Error during setOtherServiceResultValue!");
3375 ok &= (!osresult1->IsEqual(osresult2));
3376 if (!ok)
3377 throw ErrorClass("setOtherServiceResultValue: osresult objects falsely compare equal!");
3378 ok &= osresult2->setOtherServiceResultValue(i,"some value");
3379 if (!ok)
3380 throw ErrorClass("Error during setOtherServiceResultValue!");
3381 ok &= (osresult1->IsEqual(osresult2));
3382 if (!ok)
3383 throw ErrorClass("setOtherServiceResultValue: osresult objects falsely compare unequal!");
3384
3385
3386 ok &= osresult1->setOtherServiceResultDescription(i,"ABC 123");
3387 if (!ok)
3388 throw ErrorClass("Error during setOtherServiceResultDescription!");
3389 ok &= (!osresult1->IsEqual(osresult2));
3390 if (!ok)
3391 throw ErrorClass("setOtherServiceResultDescription: osresult objects falsely compare equal!");
3392 ok &= osresult2->setOtherServiceResultDescription(i,"ABC 123");
3393 if (!ok)
3394 throw ErrorClass("Error during setOtherServiceResultDescription!");
3395 ok &= (osresult1->IsEqual(osresult2));
3396 if (!ok)
3397 throw ErrorClass("setOtherServiceResultDescription: osresult objects falsely compare unequal!");
3398 }
3399//======================
3400// <job> element
3401 cout << "Set <job> element" << endl;
3402 ok &= osresult1->setJobStatus("waiting");
3403 if (!ok)
3404 throw ErrorClass("Error during setJobStatus!");
3405 ok &= (!osresult1->IsEqual(osresult2));
3406 if (!ok)
3407 throw ErrorClass("setJobStatus: osresult objects falsely compare equal!");
3408 ok &= osresult2->setJobStatus("waiting");
3409 if (!ok)
3410 throw ErrorClass("Error during setJobStatus!");
3411 ok &= (osresult1->IsEqual(osresult2));
3412 if (!ok)
3413 throw ErrorClass("setJobStatus: osresult objects falsely compare unequal!");
3414
3415 ok &= osresult1->setJobSubmitTime("2001-12-17T09:30:47.0Z");
3416 if (!ok)
3417 throw ErrorClass("Error during setJobSubmitTime!");
3418 ok &= (!osresult1->IsEqual(osresult2));
3419 if (!ok)
3420 throw ErrorClass("setJobSubmitTime: osresult objects falsely compare equal!");
3421 ok &= osresult2->setJobSubmitTime("2001-12-17T09:30:47.0Z");
3422 if (!ok)
3423 throw ErrorClass("Error during setJobSubmitTime!");
3424 ok &= (osresult1->IsEqual(osresult2));
3425 if (!ok)
3426 throw ErrorClass("setJobSubmitTime: osresult objects falsely compare unequal!");
3427
3428 ok &= osresult1->setScheduledStartTime("2001-12-17T09:30:47.0Z");
3429 if (!ok)
3430 throw ErrorClass("Error during setScheduledStartTime!");
3431 ok &= (!osresult1->IsEqual(osresult2));
3432 if (!ok)
3433 throw ErrorClass("setScheduledStartTime: osresult objects falsely compare equal!");
3434 ok &= osresult2->setScheduledStartTime("2001-12-17T09:30:47.0Z");
3435 if (!ok)
3436 throw ErrorClass("Error during setScheduledStartTime!");
3437 ok &= (osresult1->IsEqual(osresult2));
3438 if (!ok)
3439 throw ErrorClass("setScheduledStartTime: osresult objects falsely compare unequal!");
3440
3441 ok &= osresult1->setActualStartTime("2001-12-17T09:30:47.0Z");
3442 if (!ok)
3443 throw ErrorClass("Error during setActualStartTime!");
3444 ok &= (!osresult1->IsEqual(osresult2));
3445 if (!ok)
3446 throw ErrorClass("setActualStartTime: osresult objects falsely compare equal!");
3447 ok &= osresult2->setActualStartTime("2001-12-17T09:30:47.0Z");
3448 if (!ok)
3449 throw ErrorClass("Error during setActualStartTime!");
3450 ok &= (osresult1->IsEqual(osresult2));
3451 if (!ok)
3452 throw ErrorClass("setActualStartTime: osresult objects falsely compare unequal!");
3453
3454 ok &= osresult1->setJobEndTime("2001-12-17T09:30:47.0Z");
3455 if (!ok)
3456 throw ErrorClass("Error during setJobEndTime!");
3457 ok &= (!osresult1->IsEqual(osresult2));
3458 if (!ok)
3459 throw ErrorClass("setJobEndTime: osresult objects falsely compare equal!");
3460 ok &= osresult2->setJobEndTime("2001-12-17T09:30:47.0Z");
3461 if (!ok)
3462 throw ErrorClass("Error during setJobEndTime!");
3463 ok &= (osresult1->IsEqual(osresult2));
3464 if (!ok)
3465 throw ErrorClass("setJobEndTime: osresult objects falsely compare unequal!");
3466
3467 ok &= osresult1->setNumberOfTimes(3);
3468 if (!ok)
3469 throw ErrorClass("Error during setNumberOfTimes!");
3470 ok &= (!osresult1->IsEqual(osresult2));
3471 if (!ok)
3472 throw ErrorClass("setNumberOfTimes: osresult objects falsely compare equal!");
3473 ok &= osresult2->setNumberOfTimes(3);
3474 if (!ok)
3475 throw ErrorClass("Error during setNumberOfTimes!");
3476 ok &= (osresult1->IsEqual(osresult2));
3477 if (!ok)
3478 throw ErrorClass("setNumberOfTimes: osresult objects falsely compare unequal!");
3479
3480 for (int i=0; i < 3; ++i)
3481 {
3482 ok &= osresult1->setTimingInformation(i,"cpuTime","other",/*"tick",*/"second","blabla",3.14);
3483 if (!ok)
3484 throw ErrorClass("Error during setTimingInformation!");
3485 ok &= (!osresult1->IsEqual(osresult2));
3486 if (!ok)
3487 throw ErrorClass("setTimingInformation: osresult objects falsely compare equal!");
3488 ok &= osresult2->setTimingInformation(i,"cpuTime","other",/*"tick",*/"second","blabla",3.14);
3489 if (!ok)
3490 throw ErrorClass("Error during setTimingInformation!");
3491 ok &= (osresult1->IsEqual(osresult2));
3492 if (!ok)
3493 throw ErrorClass("setTimingInformation: osresult objects falsely compare unequal!");
3494
3495 }
3496
3497 ok &= osresult1->setUsedDiskSpaceUnit("megabyte");
3498 if (!ok)
3499 throw ErrorClass("Error during setUsedDiskSpaceUnit!");
3500 ok &= (!osresult1->IsEqual(osresult2));
3501 if (!ok)
3502 throw ErrorClass("setUsedDiskSpaceUnit: osresult objects falsely compare equal!");
3503 ok &= osresult2->setUsedDiskSpaceUnit("megabyte");
3504 if (!ok)
3505 throw ErrorClass("Error during setUsedDiskSpaceUnit!");
3506 ok &= (osresult1->IsEqual(osresult2));
3507 if (!ok)
3508 throw ErrorClass("setUsedDiskSpaceUnit: osresult objects falsely compare unequal!");
3509
3510 ok &= osresult1->setUsedDiskSpaceDescription("testing 123");
3511 if (!ok)
3512 throw ErrorClass("Error during setUsedDiskSpaceDescription!");
3513 ok &= (!osresult1->IsEqual(osresult2));
3514 if (!ok)
3515 throw ErrorClass("setUsedDiskSpaceDescription: osresult objects falsely compare equal!");
3516 ok &= osresult2->setUsedDiskSpaceDescription("testing 123");
3517 if (!ok)
3518 throw ErrorClass("Error during setUsedDiskSpaceDescription!");
3519 ok &= (osresult1->IsEqual(osresult2));
3520 if (!ok)
3521 throw ErrorClass("setUsedDiskSpaceDescription: osresult objects falsely compare unequal!");
3522
3523 ok &= osresult1->setUsedDiskSpaceValue(100.0);
3524 if (!ok)
3525 throw ErrorClass("Error during setUsedDiskSpaceValue!");
3526 ok &= (!osresult1->IsEqual(osresult2));
3527 if (!ok)
3528 throw ErrorClass("setUsedDiskSpaceValue: osresult objects falsely compare equal!");
3529 ok &= osresult2->setUsedDiskSpaceValue(100.0);
3530 if (!ok)
3531 throw ErrorClass("Error during setUsedDiskSpaceValue!");
3532 ok &= (osresult1->IsEqual(osresult2));
3533 if (!ok)
3534 throw ErrorClass("setUsedDiskSpaceValue: osresult objects falsely compare unequal!");
3535
3536 ok &= osresult1->setUsedMemoryUnit("megabyte");
3537 if (!ok)
3538 throw ErrorClass("Error during setUsedMemoryUnit!");
3539 ok &= (!osresult1->IsEqual(osresult2));
3540 if (!ok)
3541 throw ErrorClass("setUsedMemoryUnit: osresult objects falsely compare equal!");
3542 ok &= osresult2->setUsedMemoryUnit("megabyte");
3543 if (!ok)
3544 throw ErrorClass("Error during setUsedMemoryUnit!");
3545 ok &= (osresult1->IsEqual(osresult2));
3546 if (!ok)
3547 throw ErrorClass("setUsedMemoryUnit: osresult objects falsely compare unequal!");
3548
3549 ok &= osresult1->setUsedMemoryDescription("testing 123");
3550 if (!ok)
3551 throw ErrorClass("Error during setUsedMemoryDescription!");
3552 ok &= (!osresult1->IsEqual(osresult2));
3553 if (!ok)
3554 throw ErrorClass("setUsedMemoryDescription: osresult objects falsely compare equal!");
3555 ok &= osresult2->setUsedMemoryDescription("testing 123");
3556 if (!ok)
3557 throw ErrorClass("Error during setUsedMemoryDescription!");
3558 ok &= (osresult1->IsEqual(osresult2));
3559 if (!ok)
3560 throw ErrorClass("setUsedMemoryDescription: osresult objects falsely compare unequal!");
3561
3562 ok &= osresult1->setUsedMemoryValue(100.0);
3563 if (!ok)
3564 throw ErrorClass("Error during setUsedMemoryValue!");
3565 ok &= (!osresult1->IsEqual(osresult2));
3566 if (!ok)
3567 throw ErrorClass("setUsedMemoryValue: osresult objects falsely compare equal!");
3568 ok &= osresult2->setUsedMemoryValue(100.0);
3569 if (!ok)
3570 throw ErrorClass("Error during setUsedMemoryValue!");
3571 ok &= (osresult1->IsEqual(osresult2));
3572 if (!ok)
3573 throw ErrorClass("setUsedMemoryValue: osresult objects falsely compare unequal!");
3574
3575 ok &= osresult1->setUsedCPUSpeedUnit("megahertz");
3576 if (!ok)
3577 throw ErrorClass("Error during setUsedCPUSpeedUnit!");
3578 ok &= (!osresult1->IsEqual(osresult2));
3579 if (!ok)
3580 throw ErrorClass("setUsedCPUSpeedUnit: osresult objects falsely compare equal!");
3581 ok &= osresult2->setUsedCPUSpeedUnit("megahertz");
3582 if (!ok)
3583 throw ErrorClass("Error during setUsedCPUSpeedUnit!");
3584 ok &= (osresult1->IsEqual(osresult2));
3585 if (!ok)
3586 throw ErrorClass("setUsedCPUSpeedUnit: osresult objects falsely compare unequal!");
3587
3588 ok &= osresult1->setUsedCPUSpeedDescription("testing 123");
3589 if (!ok)
3590 throw ErrorClass("Error during setUsedCPUSpeedDescription!");
3591 ok &= (!osresult1->IsEqual(osresult2));
3592 if (!ok)
3593 throw ErrorClass("setUsedCPUSpeedDescription: osresult objects falsely compare equal!");
3594 ok &= osresult2->setUsedCPUSpeedDescription("testing 123");
3595 if (!ok)
3596 throw ErrorClass("Error during setUsedCPUSpeedDescription!");
3597 ok &= (osresult1->IsEqual(osresult2));
3598 if (!ok)
3599 throw ErrorClass("setUsedCPUSpeedDescription: osresult objects falsely compare unequal!");
3600
3601 ok &= osresult1->setUsedCPUSpeedValue(100.0);
3602 if (!ok)
3603 throw ErrorClass("Error during setUsedCPUSpeedValue!");
3604 ok &= (!osresult1->IsEqual(osresult2));
3605 if (!ok)
3606 throw ErrorClass("setUsedCPUSpeedValue: osresult objects falsely compare equal!");
3607 ok &= osresult2->setUsedCPUSpeedValue(100.0);
3608 if (!ok)
3609 throw ErrorClass("Error during setUsedCPUSpeedValue!");
3610 ok &= (osresult1->IsEqual(osresult2));
3611 if (!ok)
3612 throw ErrorClass("setUsedCPUSpeedValue: osresult objects falsely compare unequal!");
3613
3614 ok &= osresult1->setUsedCPUNumberDescription("testing 123");
3615 if (!ok)
3616 throw ErrorClass("Error during setUsedCPUNumberDescription!");
3617 ok &= (!osresult1->IsEqual(osresult2));
3618 if (!ok)
3619 throw ErrorClass("setUsedCPUNumberDescription: osresult objects falsely compare equal!");
3620 ok &= osresult2->setUsedCPUNumberDescription("testing 123");
3621 if (!ok)
3622 throw ErrorClass("Error during setUsedCPUNumberDescription!");
3623 ok &= (osresult1->IsEqual(osresult2));
3624 if (!ok)
3625 throw ErrorClass("setUsedCPUNumberDescription: osresult objects falsely compare unequal!");
3626
3627 ok &= osresult1->setUsedCPUNumberValue(100);
3628 if (!ok)
3629 throw ErrorClass("Error during setUsedCPUNumberValue!");
3630 ok &= (!osresult1->IsEqual(osresult2));
3631 if (!ok)
3632 throw ErrorClass("setUsedCPUNumberValue: osresult objects falsely compare equal!");
3633 ok &= osresult2->setUsedCPUNumberValue(100);
3634 if (!ok)
3635 throw ErrorClass("Error during setUsedCPUNumberValue!");
3636 ok &= (osresult1->IsEqual(osresult2));
3637 if (!ok)
3638 throw ErrorClass("setUsedCPUNumberValue: osresult objects falsely compare unequal!");
3639
3640 ok &= osresult1->setNumberOfOtherJobResults(3);
3641 if (!ok)
3642 throw ErrorClass("Error during setNumberOfOtherJobResults!");
3643 ok &= (!osresult1->IsEqual(osresult2));
3644 if (!ok)
3645 throw ErrorClass("setNumberOfOtherJobResults: osresult objects falsely compare equal!");
3646 ok &= osresult2->setNumberOfOtherJobResults(3);
3647 if (!ok)
3648 throw ErrorClass("Error during setNumberOfOtherJobResults!");
3649 ok &= (osresult1->IsEqual(osresult2));
3650 if (!ok)
3651 throw ErrorClass("setNumberOfOtherJobResults: osresult objects falsely compare unequal!");
3652
3653 for (int i=0; i < 3; ++i)
3654 {
3655 ok &= osresult1->setOtherJobResultName(i,"some name");
3656 if (!ok)
3657 throw ErrorClass("Error during setOtherJobResultName!");
3658 ok &= (!osresult1->IsEqual(osresult2));
3659 if (!ok)
3660 throw ErrorClass("setOtherJobResultName: osresult objects falsely compare equal!");
3661 ok &= osresult2->setOtherJobResultName(i,"some name");
3662 if (!ok)
3663 throw ErrorClass("Error during setOtherJobResultName!");
3664 ok &= (osresult1->IsEqual(osresult2));
3665 if (!ok)
3666 throw ErrorClass("setOtherJobResultName: osresult objects falsely compare unequal!");
3667
3668 ok &= osresult1->setOtherJobResultValue(i,"some value");
3669 if (!ok)
3670 throw ErrorClass("Error during setOtherJobResultValue!");
3671 ok &= (!osresult1->IsEqual(osresult2));
3672 if (!ok)
3673 throw ErrorClass("setOtherJobResultValue: osresult objects falsely compare equal!");
3674 ok &= osresult2->setOtherJobResultValue(i,"some value");
3675 if (!ok)
3676 throw ErrorClass("Error during setOtherJobResultValue!");
3677 ok &= (osresult1->IsEqual(osresult2));
3678 if (!ok)
3679 throw ErrorClass("setOtherJobResultValue: osresult objects falsely compare unequal!");
3680
3681 ok &= osresult1->setOtherJobResultDescription(i,"ABC 123");
3682 if (!ok)
3683 throw ErrorClass("Error during setOtherJobResultDescription!");
3684 ok &= (!osresult1->IsEqual(osresult2));
3685 if (!ok)
3686 throw ErrorClass("setOtherJobResultDescription: osresult objects falsely compare equal!");
3687 ok &= osresult2->setOtherJobResultDescription(i,"ABC 123");
3688 if (!ok)
3689 throw ErrorClass("Error during setOtherJobResultDescription!");
3690 ok &= (osresult1->IsEqual(osresult2));
3691 if (!ok)
3692 throw ErrorClass("setOtherJobResultDescription: osresult objects falsely compare unequal!");
3693 }
3694
3695 cout << "Set <optimization> element" << endl;
3696 ok &= osresult1->setSolutionNumber(2);
3697 if (!ok)
3698 throw ErrorClass("Error during setSolutionNumber!");
3699 ok &= (!osresult1->IsEqual(osresult2));
3700 if (!ok)
3701 throw ErrorClass("setSolutionNumber: osresult objects falsely compare equal!");
3702 ok &= osresult2->setSolutionNumber(2);
3703 if (!ok)
3704 throw ErrorClass("Error during setSolutionNumber!");
3705 ok &= (osresult1->IsEqual(osresult2));
3706 if (!ok)
3707 throw ErrorClass("setSolutionNumber: osresult objects falsely compare unequal!");
3708
3709 ok &= osresult1->setVariableNumber(4);
3710 if (!ok)
3711 throw ErrorClass("Error during setVariableNumber!");
3712 ok &= (!osresult1->IsEqual(osresult2));
3713 if (!ok)
3714 throw ErrorClass("setVariableNumber: osresult objects falsely compare equal!");
3715 ok &= osresult2->setVariableNumber(4);
3716 if (!ok)
3717 throw ErrorClass("Error during setVariableNumber!");
3718 ok &= (osresult1->IsEqual(osresult2));
3719 if (!ok)
3720 throw ErrorClass("setVariableNumber: osresult objects falsely compare unequal!");
3721
3722 ok &= osresult1->setObjectiveNumber(2);
3723 if (!ok)
3724 throw ErrorClass("Error during setObjectiveNumber!");
3725 ok &= (!osresult1->IsEqual(osresult2));
3726 if (!ok)
3727 throw ErrorClass("setObjectiveNumber: osresult objects falsely compare equal!");
3728 ok &= osresult2->setObjectiveNumber(2);
3729 if (!ok)
3730 throw ErrorClass("Error during setObjectiveNumber!");
3731 ok &= (osresult1->IsEqual(osresult2));
3732 if (!ok)
3733 throw ErrorClass("setObjectiveNumber: osresult objects falsely compare unequal!");
3734
3735 ok &= osresult1->setConstraintNumber(3);
3736 if (!ok)
3737 throw ErrorClass("Error during setConstraintNumber!");
3738 ok &= (!osresult1->IsEqual(osresult2));
3739 if (!ok)
3740 throw ErrorClass("setConstraintNumber: osresult objects falsely compare equal!");
3741 ok &= osresult2->setConstraintNumber(3);
3742 if (!ok)
3743 throw ErrorClass("Error during setConstraintNumber!");
3744 ok &= (osresult1->IsEqual(osresult2));
3745 if (!ok)
3746 throw ErrorClass("setConstraintNumber: osresult objects falsely compare unequal!");
3747
3748 for (int i=0; i < 2; ++i)
3749 {
3750 ok &= osresult1->setSolutionTargetObjectiveIdx(i,-2);
3751 if (!ok)
3752 throw ErrorClass("Error during setSolutionTargetObjectiveIdx!");
3753 ok &= (!osresult1->IsEqual(osresult2));
3754 if (!ok)
3755 throw ErrorClass("setSolutionTargetObjectiveIdx: osresult objects falsely compare equal!");
3756 ok &= osresult2->setSolutionTargetObjectiveIdx(i,-2);
3757 if (!ok)
3758 throw ErrorClass("Error during setSolutionTargetObjectiveIdx!");
3759 ok &= (osresult1->IsEqual(osresult2));
3760 if (!ok)
3761 throw ErrorClass("setSolutionTargetObjectiveIdx: osresult objects falsely compare unequal!");
3762
3763 ok &= osresult1->setSolutionTargetObjectiveName(i,"a.n.other");
3764 if (!ok)
3765 throw ErrorClass("Error during setSolutionTargetObjectiveName!");
3766 ok &= (!osresult1->IsEqual(osresult2));
3767 if (!ok)
3768 throw ErrorClass("setSolutionTargetObjectiveName: osresult objects falsely compare equal!");
3769 ok &= osresult2->setSolutionTargetObjectiveName(i,"a.n.other");
3770 if (!ok)
3771 throw ErrorClass("Error during setSolutionTargetObjectiveName!");
3772 ok &= (osresult1->IsEqual(osresult2));
3773 if (!ok)
3774 throw ErrorClass("setSolutionTargetObjectiveName: osresult objects falsely compare unequal!");
3775
3776 ok &= osresult1->setSolutionWeightedObjectives(i,"true");
3777 if (!ok)
3778 throw ErrorClass("Error during setSolutionWeightedObjectives!");
3779 ok &= (!osresult1->IsEqual(osresult2));
3780 if (!ok)
3781 throw ErrorClass("setSolutionWeightedObjectives: osresult objects falsely compare equal!");
3782 ok &= osresult2->setSolutionWeightedObjectives(i,"true");
3783 if (!ok)
3784 throw ErrorClass("Error during setSolutionWeightedObjectives!");
3785 ok &= (osresult1->IsEqual(osresult2));
3786 if (!ok)
3787 throw ErrorClass("setSolutionWeightedObjectives: osresult objects falsely compare unequal!");
3788
3789 ok &= osresult1->setSolutionStatusType(i,"locallyOptimal");
3790 if (!ok)
3791 throw ErrorClass("Error during setSolutionStatusType!");
3792 ok &= (!osresult1->IsEqual(osresult2));
3793 if (!ok)
3794 throw ErrorClass("setSolutionStatusType: osresult objects falsely compare equal!");
3795 ok &= osresult2->setSolutionStatusType(i,"locallyOptimal");
3796 if (!ok)
3797 throw ErrorClass("Error during setSolutionStatusType!");
3798 ok &= (osresult1->IsEqual(osresult2));
3799 if (!ok)
3800 throw ErrorClass("setSolutionStatusType: osresult objects falsely compare unequal!");
3801
3802 ok &= osresult1->setSolutionStatusDescription(i,"ABC 123");
3803 if (!ok)
3804 throw ErrorClass("Error during setSolutionStatusDescription!");
3805 ok &= (!osresult1->IsEqual(osresult2));
3806 if (!ok)
3807 throw ErrorClass("setSolutionStatusDescription: osresult objects falsely compare equal!");
3808 ok &= osresult2->setSolutionStatusDescription(i,"ABC 123");
3809 if (!ok)
3810 throw ErrorClass("Error during setSolutionStatusDescription!");
3811 ok &= (osresult1->IsEqual(osresult2));
3812 if (!ok)
3813 throw ErrorClass("setSolutionStatusDescription: osresult objects falsely compare unequal!");
3814
3815 ok &= osresult1->setNumberOfSolutionSubstatuses(i,3);
3816 if (!ok)
3817 throw ErrorClass("Error during setNumberOfSolutionSubstatuses!");
3818 ok &= (!osresult1->IsEqual(osresult2));
3819 if (!ok)
3820 throw ErrorClass("setNumberOfSolutionSubstatuses: osresult objects falsely compare equal!");
3821 ok &= osresult2->setNumberOfSolutionSubstatuses(i,3);
3822 if (!ok)
3823 throw ErrorClass("Error during setNumberOfSolutionSubstatuses!");
3824 ok &= (osresult1->IsEqual(osresult2));
3825 if (!ok)
3826 throw ErrorClass("setNumberOfSolutionSubstatuses: osresult objects falsely compare unequal!");
3827
3828 for (int j=0; j < 3; ++j)
3829 {
3830 ok &= osresult1->setSolutionSubstatusType(i,j,"other");
3831 if (!ok)
3832 throw ErrorClass("Error during setSolutionSubstatusType!");
3833 ok &= (!osresult1->IsEqual(osresult2));
3834 if (!ok)
3835 throw ErrorClass("setSolutionSubstatusType: osresult objects falsely compare equal!");
3836 ok &= osresult2->setSolutionSubstatusType(i,j,"other");
3837 if (!ok)
3838 throw ErrorClass("Error during setSolutionSubstatusType!");
3839 ok &= (osresult1->IsEqual(osresult2));
3840 if (!ok)
3841 throw ErrorClass("setSolutionSubstatusType: osresult objects falsely compare unequal!");
3842
3843 ok &= osresult1->setSolutionSubstatusDescription(i,j,"whatever");
3844 if (!ok)
3845 throw ErrorClass("Error during setSolutionSubstatusDescription!");
3846 ok &= (!osresult1->IsEqual(osresult2));
3847 if (!ok)
3848 throw ErrorClass("setSolutionSubstatusDescription: osresult objects falsely compare equal!");
3849 ok &= osresult2->setSolutionSubstatusDescription(i,j,"whatever");
3850 if (!ok)
3851 throw ErrorClass("Error during setSolutionSubstatusDescription!");
3852 ok &= (osresult1->IsEqual(osresult2));
3853 if (!ok)
3854 throw ErrorClass("setSolutionSubstatusDescription: osresult objects falsely compare unequal!");
3855 }
3856
3857 ok &= osresult1->setSolutionMessage(i,"ABC 123");
3858 if (!ok)
3859 throw ErrorClass("Error during setSolutionMessage!");
3860 ok &= (!osresult1->IsEqual(osresult2));
3861 if (!ok)
3862 throw ErrorClass("setSolutionMessage: osresult objects falsely compare equal!");
3863 ok &= osresult2->setSolutionMessage(i,"ABC 123");
3864 if (!ok)
3865 throw ErrorClass("Error during setSolutionMessage!");
3866 ok &= (osresult1->IsEqual(osresult2));
3867 if (!ok)
3868 throw ErrorClass("setSolutionMessage: osresult objects falsely compare unequal!");
3869
3870 ok &= osresult1->setNumberOfVarValues(i,3);
3871 if (!ok)
3872 throw ErrorClass("Error during setNumberOfVarValues!");
3873 ok &= (!osresult1->IsEqual(osresult2));
3874 if (!ok)
3875 throw ErrorClass("setNumberOfVarValues: osresult objects falsely compare equal!");
3876 ok &= osresult2->setNumberOfVarValues(i,3);
3877 if (!ok)
3878 throw ErrorClass("Error during setNumberOfVarValues!");
3879 ok &= (osresult1->IsEqual(osresult2));
3880 if (!ok)
3881 throw ErrorClass("setNumberOfVarValues: osresult objects falsely compare unequal!");
3882
3883 for (int j=0; j < 3; ++j)
3884 {
3885 ok &= osresult1->setVarValue(i,j,j,"varname",3.14);
3886 if (!ok)
3887 throw ErrorClass("Error during setVarValue!");
3888 ok &= (!osresult1->IsEqual(osresult2));
3889 if (!ok)
3890 throw ErrorClass("setVarValue: osresult objects falsely compare equal!");
3891 ok &= osresult2->setVarValue(i,j,j,"varname",3.14);
3892 if (!ok)
3893 throw ErrorClass("Error during setVarValue!");
3894 ok &= (osresult1->IsEqual(osresult2));
3895 if (!ok)
3896 throw ErrorClass("setVarValue: osresult objects falsely compare unequal!");
3897 }
3898
3899 ok &= osresult1->setNumberOfVarValuesString(i,3);
3900 if (!ok)
3901 throw ErrorClass("Error during setNumberOfVarValuesString!");
3902 ok &= (!osresult1->IsEqual(osresult2));
3903 if (!ok)
3904 throw ErrorClass("setNumberOfVarValuesString: osresult objects falsely compare equal!");
3905
3906
3907 ok &= osresult2->setNumberOfVarValuesString(i,3);
3908 if (!ok)
3909 throw ErrorClass("Error during setNumberOfVarValuesString!");
3910 ok &= (osresult1->IsEqual(osresult2));
3911 if (!ok)
3912 throw ErrorClass("setNumberOfVarValuesString: osresult objects falsely compare unequal!");
3913
3914 for (int j=0; j < 3; ++j)
3915 {
3916 ok &= osresult1->setVarValueString(i,j,j,"varname","one");
3917 if (!ok)
3918 throw ErrorClass("Error during setVarValueString!");
3919 ok &= (!osresult1->IsEqual(osresult2));
3920 if (!ok)
3921 throw ErrorClass("setVarValueString: osresult objects falsely compare equal!");
3922 ok &= osresult2->setVarValueString(i,j,j,"varname","one");
3923 if (!ok)
3924 throw ErrorClass("Error during setVarValueString!");
3925 ok &= (osresult1->IsEqual(osresult2));
3926 if (!ok)
3927 throw ErrorClass("setVarValueString: osresult objects falsely compare unequal!");
3928 }
3929
3930 intArray[0]=1000*i + 1100 + 10 + 1;
3931 intArray[1]=1000*i + 1100 + 10 + 2;
3932 intArray[2]=1000*i + 1100 + 10 + 3;
3933
3935 if (!ok)
3936 throw ErrorClass("Error during setBasisStatus (variables basic)!");
3937 ok &= (!osresult1->IsEqual(osresult2));
3938 if (!ok)
3939 throw ErrorClass("setBasisStatus (variables basic): osresult objects falsely compare equal!");
3941 if (!ok)
3942 throw ErrorClass("Error during setBasisStatus (variables basic)!");
3943 ok &= (osresult1->IsEqual(osresult2));
3944 if (!ok)
3945 throw ErrorClass("setBasisStatus (variables basic): osresult objects falsely compare unequal!");
3946
3947 intArray[0] = intArray[0] + 10;
3948 intArray[1] = intArray[1] + 10;
3949 intArray[2] = intArray[2] + 10;
3950
3951
3953 if (!ok)
3954 throw ErrorClass("Error during setBasisStatus (variables atLower)!");
3955 ok &= (!osresult1->IsEqual(osresult2));
3956 if (!ok)
3957 throw ErrorClass("setBasisStatus (variables atLower): osresult objects falsely compare equal!");
3959 if (!ok)
3960 throw ErrorClass("Error during setBasisStatus (variables atLower)!");
3961 ok &= (osresult1->IsEqual(osresult2));
3962 if (!ok)
3963 throw ErrorClass("setBasisStatus (variables atLower): osresult objects falsely compare unequal!");
3964 intArray[0] = intArray[0] + 10;
3965 intArray[1] = intArray[1] + 10;
3966
3967 intArray[2] = intArray[2] + 10;
3968
3969
3971 if (!ok)
3972 throw ErrorClass("Error during setBasisStatus (variables atUpper)!");
3973 ok &= (!osresult1->IsEqual(osresult2));
3974 if (!ok)
3975 throw ErrorClass("setBasisStatus (variables atUpper): osresult objects falsely compare equal!");
3977 if (!ok)
3978 throw ErrorClass("Error during setBasisStatus (variables atUpper)!");
3979 ok &= (osresult1->IsEqual(osresult2));
3980 if (!ok)
3981 throw ErrorClass("setBasisStatus (variables atUpper): osresult objects falsely compare unequal!");
3982 intArray[0] = intArray[0] + 10;
3983 intArray[1] = intArray[1] + 10;
3984
3985 intArray[2] = intArray[2] + 10;
3986
3987
3989 if (!ok)
3990 throw ErrorClass("Error during setBasisStatus (variables atEquality)!");
3991 ok &= (!osresult1->IsEqual(osresult2));
3992 if (!ok)
3993 throw ErrorClass("setBasisStatus (variables atEquality): osresult objects falsely compare equal!");
3995 if (!ok)
3996 throw ErrorClass("Error during setBasisStatus (variables atEquality)!");
3997 ok &= (osresult1->IsEqual(osresult2));
3998 if (!ok)
3999 throw ErrorClass("setBasisStatus (variables atEquality): osresult objects falsely compare unequal!");
4000
4001 intArray[0] = intArray[0] + 10;
4002 intArray[1] = intArray[1] + 10;
4003 intArray[2] = intArray[2] + 10;
4004
4006 if (!ok)
4007 throw ErrorClass("Error during setBasisStatus (variables isFree)!");
4008 ok &= (!osresult1->IsEqual(osresult2));
4009 if (!ok)
4010 throw ErrorClass("setBasisStatus (variables isFree): osresult objects falsely compare equal!");
4012 if (!ok)
4013 throw ErrorClass("Error during setBasisStatus (variables isFree)!");
4014 ok &= (osresult1->IsEqual(osresult2));
4015 if (!ok)
4016 throw ErrorClass("setBasisStatus (variables isFree): osresult objects falsely compare unequal!");
4017
4018 intArray[0] = intArray[0] + 10;
4019 intArray[1] = intArray[1] + 10;
4020 intArray[2] = intArray[2] + 10;
4021
4023 if (!ok)
4024 throw ErrorClass("Error during setBasisStatus (variables superbasic)!");
4025 ok &= (!osresult1->IsEqual(osresult2));
4026 if (!ok)
4027 throw ErrorClass("setBasisStatus (variables superbasic): osresult objects falsely compare equal!");
4029 if (!ok)
4030 throw ErrorClass("Error during setBasisStatus (variables superbasic)!");
4031 ok &= (osresult1->IsEqual(osresult2));
4032 if (!ok)
4033 throw ErrorClass("setBasisStatus (variables superbasic): osresult objects falsely compare unequal!");
4034
4035 intArray[0] = intArray[0] + 10;
4036 intArray[1] = intArray[1] + 10;
4037 intArray[2] = intArray[2] + 10;
4038
4040 if (!ok)
4041 throw ErrorClass("Error during setBasisStatus (variables unknown)!");
4042 ok &= (!osresult1->IsEqual(osresult2));
4043 if (!ok)
4044 throw ErrorClass("setBasisStatus (variables unknown): osresult objects falsely compare equal!");
4046 if (!ok)
4047 throw ErrorClass("Error during setBasisStatus (variables unknown)!");
4048 ok &= (osresult1->IsEqual(osresult2));
4049 if (!ok)
4050 throw ErrorClass("setBasisStatus (variables unknown): osresult objects falsely compare unequal!");
4051
4052 ok &= osresult1->setNumberOfOtherVariableResults(i,3);
4053 if (!ok)
4054 throw ErrorClass("Error during setNumberOfOtherVariableResults!");
4055 ok &= (!osresult1->IsEqual(osresult2));
4056 if (!ok)
4057 throw ErrorClass("setNumberOfOtherVariableResults: osresult objects falsely compare equal!");
4058 ok &= osresult2->setNumberOfOtherVariableResults(i,3);
4059 if (!ok)
4060 throw ErrorClass("Error during setNumberOfOtherVariableResults!");
4061 ok &= (osresult1->IsEqual(osresult2));
4062 if (!ok)
4063 throw ErrorClass("setNumberOfOtherVariableResults: osresult objects falsely compare unequal!");
4064
4065 for (int j=0; j < 2; ++j)
4066 {
4067 ok &= osresult1->setOtherVariableResultName(i,j,"other");
4068 if (!ok)
4069 throw ErrorClass("Error during setOtherVariableResultName!");
4070 ok &= (!osresult1->IsEqual(osresult2));
4071 if (!ok)
4072 throw ErrorClass("setOtherVariableResultName: osresult objects falsely compare equal!");
4073 ok &= osresult2->setOtherVariableResultName(i,j,"other");
4074 if (!ok)
4075 throw ErrorClass("Error during setOtherVariableResultName!");
4076 ok &= (osresult1->IsEqual(osresult2));
4077 if (!ok)
4078 throw ErrorClass("setOtherVariableResultName: osresult objects falsely compare unequal!");
4079
4080 ok &= osresult1->setOtherVariableResultDescription(i,j,"other");
4081 if (!ok)
4082 throw ErrorClass("Error during setOtherVariableResultDescription!");
4083 ok &= (!osresult1->IsEqual(osresult2));
4084 if (!ok)
4085 throw ErrorClass("setOtherVariableResultDescription: osresult objects falsely compare equal!");
4086 ok &= osresult2->setOtherVariableResultDescription(i,j,"other");
4087 if (!ok)
4088 throw ErrorClass("Error during setOtherVariableResultDescription!");
4089 ok &= (osresult1->IsEqual(osresult2));
4090 if (!ok)
4091 throw ErrorClass("setOtherVariableResultDescription: osresult objects falsely compare unequal!");
4092
4093 ok &= osresult1->setOtherVariableResultValue(i,j,"other");
4094 if (!ok)
4095 throw ErrorClass("Error during setOtherVariableResultValue!");
4096 ok &= (!osresult1->IsEqual(osresult2));
4097 if (!ok)
4098 throw ErrorClass("setOtherVariableResultValue: osresult objects falsely compare equal!");
4099 ok &= osresult2->setOtherVariableResultValue(i,j,"other");
4100 if (!ok)
4101 throw ErrorClass("Error during setOtherVariableResultValue!");
4102 ok &= (osresult1->IsEqual(osresult2));
4103 if (!ok)
4104 throw ErrorClass("setOtherVariableResultValue: osresult objects falsely compare unequal!");
4105
4106 ok &= osresult1->setOtherVariableResultNumberOfVar(i,j,3);
4107 if (!ok)
4108 throw ErrorClass("Error during setOtherVariableResultNumberOfVar!");
4109 ok &= (!osresult1->IsEqual(osresult2));
4110 if (!ok)
4111 throw ErrorClass("setOtherVariableResultNumberOfVar: osresult objects falsely compare equal!");
4112 ok &= osresult2->setOtherVariableResultNumberOfVar(i,j,3);
4113 if (!ok)
4114 throw ErrorClass("Error during setOtherVariableResultNumberOfVar!");
4115 ok &= (osresult1->IsEqual(osresult2));
4116 if (!ok)
4117 throw ErrorClass("setOtherVariableResultNumberOfVar: osresult objects falsely compare unequal!");
4118
4119 for (int k=0; k < 3; ++k)
4120 {
4121 ok &= osresult1->setOtherVariableResultVarIdx(i,j,k,k);
4122 if (!ok)
4123 throw ErrorClass("Error during setOtherVariableResultVarIdx!");
4124 ok &= (!osresult1->IsEqual(osresult2));
4125 if (!ok)
4126 throw ErrorClass("setOtherVariableResultVarIdx: osresult objects falsely compare equal!");
4127 ok &= osresult2->setOtherVariableResultVarIdx(i,j,k,k);
4128 if (!ok)
4129 throw ErrorClass("Error during setOtherVariableResultVarIdx!");
4130 ok &= (osresult1->IsEqual(osresult2));
4131 if (!ok)
4132 throw ErrorClass("setOtherVariableResultVarIdx: osresult objects falsely compare unequal!");
4133
4134 ok &= osresult1->setOtherVariableResultVar(i,j,k,"value");
4135 if (!ok)
4136 throw ErrorClass("Error during setOtherVariableResultVar!");
4137 ok &= (!osresult1->IsEqual(osresult2));
4138 if (!ok)
4139 throw ErrorClass("setOtherVariableResultVar: osresult objects falsely compare equal!");
4140 ok &= osresult2->setOtherVariableResultVar(i,j,k,"value");
4141 if (!ok)
4142 throw ErrorClass("Error during setOtherVariableResultVar!");
4143 ok &= (osresult1->IsEqual(osresult2));
4144 if (!ok)
4145 throw ErrorClass("setOtherVariableResultVar: osresult objects falsely compare unequal!");
4146 }
4147 }
4148
4149// The third <other> result uses enumerations
4150
4151 ok &= osresult1->setOtherVariableResultName(i,2,"other");
4152 if (!ok)
4153 throw ErrorClass("Error during setOtherVariableResultName!");
4154 ok &= (!osresult1->IsEqual(osresult2));
4155 if (!ok)
4156 throw ErrorClass("setOtherVariableResultName: osresult objects falsely compare equal!");
4157 ok &= osresult2->setOtherVariableResultName(i,2,"other");
4158 if (!ok)
4159 throw ErrorClass("Error during setOtherVariableResultName!");
4160
4161 ok &= (osresult1->IsEqual(osresult2));
4162 if (!ok)
4163 throw ErrorClass("setOtherVariableResultName: osresult objects falsely compare unequal!");
4164
4165 ok &= osresult1->setOtherVariableResultDescription(i,2,"other");
4166 if (!ok)
4167 throw ErrorClass("Error during setOtherVariableResultDescription!");
4168 ok &= (!osresult1->IsEqual(osresult2));
4169 if (!ok)
4170 throw ErrorClass("setOtherVariableResultDescription: osresult objects falsely compare equal!");
4171 ok &= osresult2->setOtherVariableResultDescription(i,2,"other");
4172 if (!ok)
4173 throw ErrorClass("Error during setOtherVariableResultDescription!");
4174 ok &= (osresult1->IsEqual(osresult2));
4175 if (!ok)
4176 throw ErrorClass("setOtherVariableResultDescription: osresult objects falsely compare unequal!");
4177
4178 ok &= osresult1->setOtherVariableResultValue(i,2,"other");
4179 if (!ok)
4180 throw ErrorClass("Error during setOtherVariableResultValue!");
4181 ok &= (!osresult1->IsEqual(osresult2));
4182 if (!ok)
4183 throw ErrorClass("setOtherVariableResultValue: osresult objects falsely compare equal!");
4184 ok &= osresult2->setOtherVariableResultValue(i,2,"other");
4185 if (!ok)
4186 throw ErrorClass("Error during setOtherVariableResultValue!");
4187 ok &= (osresult1->IsEqual(osresult2));
4188 if (!ok)
4189 throw ErrorClass("setOtherVariableResultValue: osresult objects falsely compare unequal!");
4190
4191
4192 ok &= osresult1->setOtherVariableResultNumberOfEnumerations(i,2,2);
4193 if (!ok)
4194 throw ErrorClass("Error during setOtherVariableResultNumberOfEnumerations!");
4195 ok &= (!osresult1->IsEqual(osresult2));
4196 if (!ok)
4197 throw ErrorClass("setOtherVariableResultNumberOfEnumerations: osresult objects falsely compare equal!");
4198 ok &= osresult2->setOtherVariableResultNumberOfEnumerations(i,2,2);
4199 if (!ok)
4200 throw ErrorClass("Error during setOtherVariableResultNumberOfEnumerations!");
4201 ok &= (osresult1->IsEqual(osresult2));
4202 if (!ok)
4203 throw ErrorClass("setOtherVariableResultNumberOfEnumerations: osresult objects falsely compare unequal!");
4204
4205 for (int k=0; k < 2; ++k)
4206 {
4207 intArray[0] = 1000*i + 1130 + 10*k + 1;
4208 intArray[1] = 1000*i + 1130 + 10*k + 2;
4209 intArray[2] = 1000*i + 1130 + 10*k + 3;
4210
4211
4212 ok &= osresult1->setOtherOptionOrResultEnumeration(i,2,
4213 ENUM_PROBLEM_COMPONENT_variables,k,"value","description",intArray,3);
4214 if (!ok)
4215 throw ErrorClass("Error during setOtherOptionOrResultEnumeration!");
4216 ok &= (!osresult1->IsEqual(osresult2));
4217 if (!ok)
4218 throw ErrorClass("setOtherOptionOrResultEnumeration: osresult objects falsely compare equal!");
4219 ok &= osresult2->setOtherOptionOrResultEnumeration(i,2,
4220 ENUM_PROBLEM_COMPONENT_variables,k,"value","description",intArray,3);
4221 if (!ok)
4222 throw ErrorClass("Error during setOtherOptionOrResultEnumeration!");
4223 ok &= (osresult1->IsEqual(osresult2));
4224 if (!ok)
4225 throw ErrorClass("setOtherOptionOrResultEnumeration: osresult objects falsely compare unequal!");
4226 }
4227
4228
4229 ok &= osresult1->setNumberOfObjValues(i,2);
4230 if (!ok)
4231 throw ErrorClass("Error during setNumberOfObjValues!");
4232 ok &= (!osresult1->IsEqual(osresult2));
4233 if (!ok)
4234 throw ErrorClass("setNumberOfObjValues: osresult objects falsely compare equal!");
4235 ok &= osresult2->setNumberOfObjValues(i,2);
4236 if (!ok)
4237 throw ErrorClass("Error during setNumberOfObjValues!");
4238 ok &= (osresult1->IsEqual(osresult2));
4239 if (!ok)
4240 throw ErrorClass("setNumberOfObjValues: osresult objects falsely compare unequal!");
4241
4242 for (int j=0; j < 2; ++j)
4243 {
4244 ok &= osresult1->setObjValue(i,j,-2,"objname",3.14);
4245 if (!ok)
4246 throw ErrorClass("Error during setObjValue!");
4247 ok &= (!osresult1->IsEqual(osresult2));
4248 if (!ok)
4249 throw ErrorClass("setObjValue: osresult objects falsely compare equal!");
4250 ok &= osresult2->setObjValue(i,j,-2,"objname",3.14);
4251 if (!ok)
4252 throw ErrorClass("Error during setObjValue!");
4253 ok &= (osresult1->IsEqual(osresult2));
4254 if (!ok)
4255 throw ErrorClass("setObjValue: osresult objects falsely compare unequal!");
4256 }
4257 intArray[0] = -1000*i - 1200 - 10 - 1;
4258 intArray[1] = -1000*i - 1200 - 10 - 2;
4259 intArray[2] = -1000*i - 1200 - 10 - 3;
4260
4262 if (!ok)
4263 throw ErrorClass("Error during setBasisStatus (objectives basic)!");
4264 ok &= (!osresult1->IsEqual(osresult2));
4265 if (!ok)
4266 throw ErrorClass("setBasisStatus (objectives basic): osresult objects falsely compare equal!");
4268 if (!ok)
4269 throw ErrorClass("Error during setBasisStatus (objectives basic)!");
4270 ok &= (osresult1->IsEqual(osresult2));
4271 if (!ok)
4272 throw ErrorClass("setBasisStatus (objectives basic): osresult objects falsely compare unequal!");
4273
4274 intArray[0] = intArray[0] - 10;
4275 intArray[1] = intArray[1] - 10;
4276 intArray[2] = intArray[2] - 10;
4277
4279 if (!ok)
4280 throw ErrorClass("Error during setBasisStatus (objectives atLower)!");
4281 ok &= (!osresult1->IsEqual(osresult2));
4282 if (!ok)
4283 throw ErrorClass("setBasisStatus (objectives atLower): osresult objects falsely compare equal!");
4285 if (!ok)
4286 throw ErrorClass("Error during setBasisStatus (objectives atLower)!");
4287 ok &= (osresult1->IsEqual(osresult2));
4288 if (!ok)
4289 throw ErrorClass("setBasisStatus (objectives atLower): osresult objects falsely compare unequal!");
4290
4291 intArray[0] = intArray[0] - 10;
4292 intArray[1] = intArray[1] - 10;
4293 intArray[2] = intArray[2] - 10;
4294
4296
4297 if (!ok)
4298 throw ErrorClass("Error during setBasisStatus (objectives atUpper)!");
4299 ok &= (!osresult1->IsEqual(osresult2));
4300 if (!ok)
4301 throw ErrorClass("setBasisStatus (objectives atUpper): osresult objects falsely compare equal!");
4303 if (!ok)
4304 throw ErrorClass("Error during setBasisStatus (objectives atUpper)!");
4305 ok &= (osresult1->IsEqual(osresult2));
4306 if (!ok)
4307 throw ErrorClass("setBasisStatus (objectives atUpper): osresult objects falsely compare unequal!");
4308
4309 intArray[0] = intArray[0] - 10;
4310 intArray[1] = intArray[1] - 10;
4311 intArray[2] = intArray[2] - 10;
4312
4314
4315 if (!ok)
4316 throw ErrorClass("Error during setBasisStatus (objectives atEquality)!");
4317 ok &= (!osresult1->IsEqual(osresult2));
4318 if (!ok)
4319 throw ErrorClass("setBasisStatus (objectives atEquality): osresult objects falsely compare equal!");
4321 if (!ok)
4322 throw ErrorClass("Error during setBasisStatus (objectives atEquality)!");
4323 ok &= (osresult1->IsEqual(osresult2));
4324 if (!ok)
4325 throw ErrorClass("setBasisStatus (objectives atEquality): osresult objects falsely compare unequal!");
4326
4327
4328 intArray[0] = intArray[0] - 10;
4329 intArray[1] = intArray[1] - 10;
4330 intArray[2] = intArray[2] - 10;
4331
4333 if (!ok)
4334 throw ErrorClass("Error during setBasisStatus (objectives isFree)!");
4335 ok &= (!osresult1->IsEqual(osresult2));
4336 if (!ok)
4337 throw ErrorClass("setBasisStatus (objectives isFree): osresult objects falsely compare equal!");
4339 if (!ok)
4340 throw ErrorClass("Error during setBasisStatus (objectives isFree)!");
4341 ok &= (osresult1->IsEqual(osresult2));
4342 if (!ok)
4343 throw ErrorClass("setBasisStatus (objectives isFree): osresult objects falsely compare unequal!");
4344
4345
4346 intArray[0] = intArray[0] - 10;
4347 intArray[1] = intArray[1] - 10;
4348 intArray[2] = intArray[2] - 10;
4349
4351 if (!ok)
4352 throw ErrorClass("Error during setBasisStatus (objectives superbasic)!");
4353 ok &= (!osresult1->IsEqual(osresult2));
4354 if (!ok)
4355 throw ErrorClass("setBasisStatus (objectives superbasic): osresult objects falsely compare equal!");
4357 if (!ok)
4358 throw ErrorClass("Error during setBasisStatus (objectives superbasic)!");
4359
4360 ok &= (osresult1->IsEqual(osresult2));
4361 if (!ok)
4362 throw ErrorClass("setBasisStatus (objectives superbasic): osresult objects falsely compare unequal!");
4363
4364
4365 intArray[0] = intArray[0] - 10;
4366 intArray[1] = intArray[1] - 10;
4367 intArray[2] = intArray[2] - 10;
4368
4370 if (!ok)
4371 throw ErrorClass("Error during setBasisStatus (objectives unknown)!");
4372 ok &= (!osresult1->IsEqual(osresult2));
4373 if (!ok)
4374 throw ErrorClass("setBasisStatus (objectives unknown): osresult objects falsely compare equal!");
4376 if (!ok)
4377 throw ErrorClass("Error during setBasisStatus (objectives unknown)!");
4378 ok &= (osresult1->IsEqual(osresult2));
4379 if (!ok)
4380 throw ErrorClass("setBasisStatus (objectives unknown): osresult objects falsely compare unequal!");
4381
4382 ok &= osresult1->setNumberOfOtherObjectiveResults(i,3);
4383 if (!ok)
4384 throw ErrorClass("Error during setNumberOfOtherObjectiveResults!");
4385 ok &= (!osresult1->IsEqual(osresult2));
4386 if (!ok)
4387 throw ErrorClass("setNumberOfOtherObjectiveResults: osresult objects falsely compare equal!");
4388 ok &= osresult2->setNumberOfOtherObjectiveResults(i,3);
4389 if (!ok)
4390 throw ErrorClass("Error during setNumberOfOtherObjectiveResults!");
4391 ok &= (osresult1->IsEqual(osresult2));
4392 if (!ok)
4393 throw ErrorClass("setNumberOfOtherObjectiveResults: osresult objects falsely compare unequal!");
4394
4395 for (int j=0; j < 2; ++j)
4396 {
4397 ok &= osresult1->setOtherObjectiveResultName(i,j,"other");
4398 if (!ok)
4399 throw ErrorClass("Error during setOtherObjectiveResultName!");
4400 ok &= (!osresult1->IsEqual(osresult2));
4401 if (!ok)
4402 throw ErrorClass("setOtherObjectiveResultName: osresult objects falsely compare equal!");
4403 ok &= osresult2->setOtherObjectiveResultName(i,j,"other");
4404 if (!ok)
4405 throw ErrorClass("Error during setOtherObjectiveResultName!");
4406 ok &= (osresult1->IsEqual(osresult2));
4407 if (!ok)
4408 throw ErrorClass("setOtherObjectiveResultName: osresult objects falsely compare unequal!");
4409
4410 ok &= osresult1->setOtherObjectiveResultDescription(i,j,"other");
4411 if (!ok)
4412 throw ErrorClass("Error during setOtherObjectiveResultDescription!");
4413 ok &= (!osresult1->IsEqual(osresult2));
4414 if (!ok)
4415 throw ErrorClass("setOtherObjectiveResultDescription: osresult objects falsely compare equal!");
4416 ok &= osresult2->setOtherObjectiveResultDescription(i,j,"other");
4417 if (!ok)
4418 throw ErrorClass("Error during setOtherObjectiveResultDescription!");
4419 ok &= (osresult1->IsEqual(osresult2));
4420 if (!ok)
4421 throw ErrorClass("setOtherObjectiveResultDescription: osresult objects falsely compare unequal!");
4422
4423 ok &= osresult1->setOtherObjectiveResultValue(i,j,"other");
4424 if (!ok)
4425 throw ErrorClass("Error during setOtherObjectiveResultValue!");
4426 ok &= (!osresult1->IsEqual(osresult2));
4427 if (!ok)
4428 throw ErrorClass("setOtherObjectiveResultValue: osresult objects falsely compare equal!");
4429 ok &= osresult2->setOtherObjectiveResultValue(i,j,"other");
4430 if (!ok)
4431 throw ErrorClass("Error during setOtherObjectiveResultValue!");
4432 ok &= (osresult1->IsEqual(osresult2));
4433 if (!ok)
4434 throw ErrorClass("setOtherObjectiveResultValue: osresult objects falsely compare unequal!");
4435
4436 ok &= osresult1->setOtherObjectiveResultNumberOfObj(i,j,2);
4437 if (!ok)
4438 throw ErrorClass("Error during setOtherObjectiveResultNumberOfObj!");
4439 ok &= (!osresult1->IsEqual(osresult2));
4440 if (!ok)
4441 throw ErrorClass("setOtherObjectiveResultNumberOfObj: osresult objects falsely compare equal!");
4442
4443 ok &= osresult2->setOtherObjectiveResultNumberOfObj(i,j,2);
4444 if (!ok)
4445 throw ErrorClass("Error during setOtherObjectiveResultNumberOfObj!");
4446 ok &= (osresult1->IsEqual(osresult2));
4447 if (!ok)
4448 throw ErrorClass("setOtherObjectiveResultNumberOfObj: osresult objects falsely compare unequal!");
4449
4450 for (int k=0; k < 2; ++k)
4451 {
4452 ok &= osresult1->setOtherObjectiveResultObjIdx(i,j,k,-2);
4453 if (!ok)
4454 throw ErrorClass("Error during setOtherObjectiveResultObjIdx!");
4455 ok &= (!osresult1->IsEqual(osresult2));
4456 if (!ok)
4457 throw ErrorClass("setOtherObjectiveResultObjIdx: osresult objects falsely compare equal!");
4458 ok &= osresult2->setOtherObjectiveResultObjIdx(i,j,k,-2);
4459 if (!ok)
4460 throw ErrorClass("Error during setOtherObjectiveResultObjIdx!");
4461 ok &= (osresult1->IsEqual(osresult2));
4462 if (!ok)
4463 throw ErrorClass("setOtherObjectiveResultObjIdx: osresult objects falsely compare unequal!");
4464
4465 ok &= osresult1->setOtherObjectiveResultObj(i,j,k,"value");
4466 if (!ok)
4467 throw ErrorClass("Error during setOtherObjectiveResultObj!");
4468 ok &= (!osresult1->IsEqual(osresult2));
4469 if (!ok)
4470 throw ErrorClass("setOtherObjectiveResultObj: osresult objects falsely compare equal!");
4471 ok &= osresult2->setOtherObjectiveResultObj(i,j,k,"value");
4472 if (!ok)
4473 throw ErrorClass("Error during setOtherObjectiveResultObj!");
4474 ok &= (osresult1->IsEqual(osresult2));
4475 if (!ok)
4476 throw ErrorClass("setOtherObjectiveResultObj: osresult objects falsely compare unequal!");
4477 }
4478 }
4479// The third <other> result uses enumerations
4480
4481 ok &= osresult1->setOtherObjectiveResultName(i,2,"other");
4482 if (!ok)
4483 throw ErrorClass("Error during setOtherObjectiveResultName!");
4484 ok &= (!osresult1->IsEqual(osresult2));
4485 if (!ok)
4486 throw ErrorClass("setOtherObjectiveResultName: osresult objects falsely compare equal!");
4487 ok &= osresult2->setOtherObjectiveResultName(i,2,"other");
4488 if (!ok)
4489 throw ErrorClass("Error during setOtherObjectiveResultName!");
4490 ok &= (osresult1->IsEqual(osresult2));
4491 if (!ok)
4492 throw ErrorClass("setOtherObjectiveResultName: osresult objects falsely compare unequal!");
4493
4494 ok &= osresult1->setOtherObjectiveResultDescription(i,2,"other");
4495 if (!ok)
4496 throw ErrorClass("Error during setOtherObjectiveResultDescription!");
4497 ok &= (!osresult1->IsEqual(osresult2));
4498 if (!ok)
4499 throw ErrorClass("setOtherObjectiveResultDescription: osresult objects falsely compare equal!");
4500 ok &= osresult2->setOtherObjectiveResultDescription(i,2,"other");
4501 if (!ok)
4502 throw ErrorClass("Error during setOtherObjectiveResultDescription!");
4503 ok &= (osresult1->IsEqual(osresult2));
4504 if (!ok)
4505 throw ErrorClass("setOtherObjectiveResultDescription: osresult objects falsely compare unequal!");
4506
4507 ok &= osresult1->setOtherObjectiveResultValue(i,2,"other");
4508 if (!ok)
4509 throw ErrorClass("Error during setOtherObjectiveResultValue!");
4510 ok &= (!osresult1->IsEqual(osresult2));
4511 if (!ok)
4512 throw ErrorClass("setOtherObjectiveResultValue: osresult objects falsely compare equal!");
4513 ok &= osresult2->setOtherObjectiveResultValue(i,2,"other");
4514 if (!ok)
4515 throw ErrorClass("Error during setOtherObjectiveResultValue!");
4516 ok &= (osresult1->IsEqual(osresult2));
4517 if (!ok)
4518 throw ErrorClass("setOtherObjectiveResultValue: osresult objects falsely compare unequal!");
4519
4520 ok &= osresult1->setOtherObjectiveResultNumberOfEnumerations(i,2,2);
4521 if (!ok)
4522 throw ErrorClass("Error during setOtherObjectiveResultNumberOfEnumerations!");
4523 ok &= (!osresult1->IsEqual(osresult2));
4524 if (!ok)
4525 throw ErrorClass("setOtherObjectiveResultNumberOfEnumerations: osresult objects falsely compare equal!");
4526 ok &= osresult2->setOtherObjectiveResultNumberOfEnumerations(i,2,2);
4527 if (!ok)
4528 throw ErrorClass("Error during setOtherObjectiveResultNumberOfEnumerations!");
4529 ok &= (osresult1->IsEqual(osresult2));
4530 if (!ok)
4531 throw ErrorClass("setOtherObjectiveResultNumberOfEnumerations: osresult objects falsely compare unequal!");
4532
4533 for (int k=0; k < 2; ++k)
4534 {
4535
4536 intArray[0] = -(1000*i + 1230 + 10*k + 1);
4537 intArray[1] = -(1000*i + 1230 + 10*k + 2);
4538 intArray[2] = -(1000*i + 1230 + 10*k + 3);
4539
4540 ok &= osresult1->setOtherOptionOrResultEnumeration(i,2,
4541 ENUM_PROBLEM_COMPONENT_objectives,k,"value","description",intArray,3);
4542 if (!ok)
4543 throw ErrorClass("Error during setOtherOptionOrResultEnumeration (objective)!");
4544 ok &= (!osresult1->IsEqual(osresult2));
4545 if (!ok)
4546 throw ErrorClass("setOtherOptionOrResultEnumeration: osresult objects falsely compare equal!");
4547 ok &= osresult2->setOtherOptionOrResultEnumeration(i,2,
4548 ENUM_PROBLEM_COMPONENT_objectives,k,"value","description",intArray,3);
4549 if (!ok)
4550 throw ErrorClass("Error during setOtherOptionOrResultEnumeration (objective)!");
4551 ok &= (osresult1->IsEqual(osresult2));
4552 if (!ok)
4553 throw ErrorClass("setOtherOptionOrResultEnumeration: osresult objects falsely compare unequal!");
4554 }
4555
4556
4557 ok &= osresult1->setNumberOfDualValues(i,3);
4558 if (!ok)
4559 throw ErrorClass("Error during setNumberOfDualValues!");
4560 ok &= (!osresult1->IsEqual(osresult2));
4561 if (!ok)
4562 throw ErrorClass("setNumberOfDualValues: osresult objects falsely compare equal!");
4563 ok &= osresult2->setNumberOfDualValues(i,3);
4564 if (!ok)
4565 throw ErrorClass("Error during setNumberOfDualValues!");
4566 ok &= (osresult1->IsEqual(osresult2));
4567 if (!ok)
4568 throw ErrorClass("setNumberOfDualValues: osresult objects falsely compare unequal!");
4569
4570 for (int j=0; j < 3; ++j)
4571 {
4572 ok &= osresult1->setDualValue(i,j,j,"conname",3.14);
4573 if (!ok)
4574 throw ErrorClass("Error during setDualValue!");
4575 ok &= (!osresult1->IsEqual(osresult2));
4576 if (!ok)
4577 throw ErrorClass("setDualValue: osresult objects falsely compare equal!");
4578 ok &= osresult2->setDualValue(i,j,j,"conname",3.14);
4579 if (!ok)
4580 throw ErrorClass("Error during setDualValue!");
4581 ok &= (osresult1->IsEqual(osresult2));
4582 if (!ok)
4583 throw ErrorClass("setDualValue: osresult objects falsely compare unequal!");
4584 }
4585
4586 intArray[0] = 1000*i + 1300 + 10 + 1;
4587 intArray[1] = 1000*i + 1300 + 10 + 2;
4588 intArray[2] = 1000*i + 1300 + 10 + 3;
4589
4591 if (!ok)
4592 throw ErrorClass("Error during setBasisStatus (constraints basic)!");
4593 ok &= (!osresult1->IsEqual(osresult2));
4594 if (!ok)
4595 throw ErrorClass("setBasisStatus (constraints basic): osresult objects falsely compare equal!");
4597 if (!ok)
4598 throw ErrorClass("Error during setBasisStatus (constraints basic)!");
4599 ok &= (osresult1->IsEqual(osresult2));
4600 if (!ok)
4601 throw ErrorClass("setBasisStatus (constraints basic): osresult objects falsely compare unequal!");
4602
4603 intArray[0] = intArray[0] + 10;
4604 intArray[1] = intArray[1] + 10;
4605 intArray[2] = intArray[2] + 10;
4606
4608 if (!ok)
4609 throw ErrorClass("Error during setBasisStatus (constraints atLower)!");
4610 ok &= (!osresult1->IsEqual(osresult2));
4611 if (!ok)
4612 throw ErrorClass("setBasisStatus (constraints atLower): osresult objects falsely compare equal!");
4614 if (!ok)
4615 throw ErrorClass("Error during setBasisStatus (constraints atLower)!");
4616 ok &= (osresult1->IsEqual(osresult2));
4617 if (!ok)
4618 throw ErrorClass("setBasisStatus (constraints atLower): osresult objects falsely compare unequal!");
4619
4620 intArray[0] = intArray[0] + 10;
4621 intArray[1] = intArray[1] + 10;
4622 intArray[2] = intArray[2] + 10;
4623
4624
4626 if (!ok)
4627 throw ErrorClass("Error during setBasisStatus (constraints atUpper)!");
4628 ok &= (!osresult1->IsEqual(osresult2));
4629 if (!ok)
4630 throw ErrorClass("setBasisStatus (constraints atUpper): osresult objects falsely compare equal!");
4632 if (!ok)
4633 throw ErrorClass("Error during setBasisStatus (constraints atUpper)!");
4634 ok &= (osresult1->IsEqual(osresult2));
4635 if (!ok)
4636 throw ErrorClass("setBasisStatus (constraints atUpper): osresult objects falsely compare unequal!");
4637
4638 intArray[0] = intArray[0] + 10;
4639 intArray[1] = intArray[1] + 10;
4640 intArray[2] = intArray[2] + 10;
4641
4642
4644 if (!ok)
4645 throw ErrorClass("Error during setBasisStatus (constraints atEquality)!");
4646 ok &= (!osresult1->IsEqual(osresult2));
4647 if (!ok)
4648 throw ErrorClass("setBasisStatus (constraints atEquality): osresult objects falsely compare equal!");
4650 if (!ok)
4651 throw ErrorClass("Error during setBasisStatus (constraints atEquality)!");
4652 ok &= (osresult1->IsEqual(osresult2));
4653 if (!ok)
4654 throw ErrorClass("setBasisStatus (constraints atEquality): osresult objects falsely compare unequal!");
4655
4656
4657 intArray[0] = intArray[0] + 10;
4658 intArray[1] = intArray[1] + 10;
4659 intArray[2] = intArray[2] + 10;
4660
4662 if (!ok)
4663 throw ErrorClass("Error during setBasisStatus (constraints isFree)!");
4664 ok &= (!osresult1->IsEqual(osresult2));
4665 if (!ok)
4666 throw ErrorClass("setBasisStatus (constraints isFree): osresult objects falsely compare equal!");
4668 if (!ok)
4669 throw ErrorClass("Error during setBasisStatus (constraints isFree)!");
4670 ok &= (osresult1->IsEqual(osresult2));
4671 if (!ok)
4672 throw ErrorClass("setBasisStatus (constraints isFree): osresult objects falsely compare unequal!");
4673
4674
4675 intArray[0] = intArray[0] + 10;
4676 intArray[1] = intArray[1] + 10;
4677 intArray[2] = intArray[2] + 10;
4678
4680 if (!ok)
4681 throw ErrorClass("Error during setBasisStatus (constraints superbasic)!");
4682 ok &= (!osresult1->IsEqual(osresult2));
4683 if (!ok)
4684 throw ErrorClass("setBasisStatus (constraints superbasic): osresult objects falsely compare equal!");
4686 if (!ok)
4687 throw ErrorClass("Error during setBasisStatus (constraints superbasic)!");
4688 ok &= (osresult1->IsEqual(osresult2));
4689 if (!ok)
4690 throw ErrorClass("setBasisStatus (constraints superbasic): osresult objects falsely compare unequal!");
4691
4692 intArray[0] = intArray[0] + 10;
4693 intArray[1] = intArray[1] + 10;
4694 intArray[2] = intArray[2] + 10;
4695
4696
4698 if (!ok)
4699 throw ErrorClass("Error during setBasisStatus (constraints unknown)!");
4700 ok &= (!osresult1->IsEqual(osresult2));
4701 if (!ok)
4702 throw ErrorClass("setBasisStatus (constraints unknown): osresult objects falsely compare equal!");
4704 if (!ok)
4705 throw ErrorClass("Error during setBasisStatus (constraints unknown)!");
4706 ok &= (osresult1->IsEqual(osresult2));
4707 if (!ok)
4708 throw ErrorClass("setBasisStatus (constraints unknown): osresult objects falsely compare unequal!");
4709
4710 ok &= osresult1->setNumberOfOtherConstraintResults(i,3);
4711 if (!ok)
4712 throw ErrorClass("Error during setNumberOfOtherConstraintResults!");
4713 ok &= (!osresult1->IsEqual(osresult2));
4714 if (!ok)
4715 throw ErrorClass("setNumberOfOtherConstraintResults: osresult objects falsely compare equal!");
4716 ok &= osresult2->setNumberOfOtherConstraintResults(i,3);
4717 if (!ok)
4718 throw ErrorClass("Error during setNumberOfOtherConstraintResults!");
4719 ok &= (osresult1->IsEqual(osresult2));
4720 if (!ok)
4721 throw ErrorClass("setNumberOfOtherConstraintResults: osresult objects falsely compare unequal!");
4722
4723 for (int j=0; j < 2; ++j)
4724 {
4725 ok &= osresult1->setOtherConstraintResultName(i,j,"other");
4726 if (!ok)
4727 throw ErrorClass("Error during setOtherConstraintResultName!");
4728 ok &= (!osresult1->IsEqual(osresult2));
4729 if (!ok)
4730 throw ErrorClass("setOtherConstraintResultName: osresult objects falsely compare equal!");
4731 ok &= osresult2->setOtherConstraintResultName(i,j,"other");
4732 if (!ok)
4733 throw ErrorClass("Error during setOtherConstraintResultName!");
4734 ok &= (osresult1->IsEqual(osresult2));
4735 if (!ok)
4736 throw ErrorClass("setOtherConstraintResultName: osresult objects falsely compare unequal!");
4737
4738 ok &= osresult1->setOtherConstraintResultDescription(i,j,"other");
4739 if (!ok)
4740 throw ErrorClass("Error during setOtherConstraintResultDescription!");
4741 ok &= (!osresult1->IsEqual(osresult2));
4742 if (!ok)
4743 throw ErrorClass("setOtherConstraintResultDescription: osresult objects falsely compare equal!");
4744 ok &= osresult2->setOtherConstraintResultDescription(i,j,"other");
4745 if (!ok)
4746 throw ErrorClass("Error during setOtherConstraintResultDescription!");
4747 ok &= (osresult1->IsEqual(osresult2));
4748 if (!ok)
4749 throw ErrorClass("setOtherConstraintResultDescription: osresult objects falsely compare unequal!");
4750
4751 ok &= osresult1->setOtherConstraintResultValue(i,j,"other");
4752 if (!ok)
4753 throw ErrorClass("Error during setOtherConstraintResultValue!");
4754 ok &= (!osresult1->IsEqual(osresult2));
4755 if (!ok)
4756 throw ErrorClass("setOtherConstraintResultValue: osresult objects falsely compare equal!");
4757 ok &= osresult2->setOtherConstraintResultValue(i,j,"other");
4758 if (!ok)
4759 throw ErrorClass("Error during setOtherConstraintResultValue!");
4760 ok &= (osresult1->IsEqual(osresult2));
4761 if (!ok)
4762 throw ErrorClass("setOtherConstraintResultValue: osresult objects falsely compare unequal!");
4763
4764 ok &= osresult1->setOtherConstraintResultNumberOfCon(i,j,3);
4765 if (!ok)
4766 throw ErrorClass("Error during setOtherConstraintResultNumberOfCon!");
4767 ok &= (!osresult1->IsEqual(osresult2));
4768 if (!ok)
4769 throw ErrorClass("setOtherConstraintResultNumberOfCon: osresult objects falsely compare equal!");
4770 ok &= osresult2->setOtherConstraintResultNumberOfCon(i,j,3);
4771 if (!ok)
4772 throw ErrorClass("Error during setOtherConstraintResultNumberOfCon!");
4773 ok &= (osresult1->IsEqual(osresult2));
4774 if (!ok)
4775 throw ErrorClass("setOtherConstraintResultNumberOfCon: osresult objects falsely compare unequal!");
4776
4777 for (int k=0; k < 3; ++k)
4778 {
4779 ok &= osresult1->setOtherConstraintResultConIdx(i,j,k,k);
4780 if (!ok)
4781 throw ErrorClass("Error during setOtherConstraintResultConIdx!");
4782 ok &= (!osresult1->IsEqual(osresult2));
4783 if (!ok)
4784 throw ErrorClass("setOtherConstraintResultConIdx: osresult objects falsely compare equal!");
4785 ok &= osresult2->setOtherConstraintResultConIdx(i,j,k,k);
4786 if (!ok)
4787 throw ErrorClass("Error during setOtherConstraintResultConIdx!");
4788 ok &= (osresult1->IsEqual(osresult2));
4789 if (!ok)
4790 throw ErrorClass("setOtherConstraintResultConIdx: osresult objects falsely compare unequal!");
4791
4792 ok &= osresult1->setOtherConstraintResultCon(i,j,k,"value");
4793 if (!ok)
4794 throw ErrorClass("Error during setOtherConstraintResultCon!");
4795 ok &= (!osresult1->IsEqual(osresult2));
4796 if (!ok)
4797 throw ErrorClass("setOtherConstraintResultCon: osresult objects falsely compare equal!");
4798 ok &= osresult2->setOtherConstraintResultCon(i,j,k,"value");
4799 if (!ok)
4800 throw ErrorClass("Error during setOtherConstraintResultCon!");
4801 ok &= (osresult1->IsEqual(osresult2));
4802 if (!ok)
4803 throw ErrorClass("setOtherConstraintResultCon: osresult objects falsely compare unequal!");
4804 }
4805 }
4806
4807
4808// The third <other> result uses enumerations
4809
4810 ok &= osresult1->setOtherConstraintResultName(i,2,"other");
4811 if (!ok)
4812 throw ErrorClass("Error during setOtherConstraintResultName!");
4813 ok &= (!osresult1->IsEqual(osresult2));
4814 if (!ok)
4815 throw ErrorClass("setOtherConstraintResultName: osresult objects falsely compare equal!");
4816 ok &= osresult2->setOtherConstraintResultName(i,2,"other");
4817 if (!ok)
4818 throw ErrorClass("Error during setOtherConstraintResultName!");
4819 ok &= (osresult1->IsEqual(osresult2));
4820 if (!ok)
4821 throw ErrorClass("setOtherConstraintResultName: osresult objects falsely compare unequal!");
4822
4823 ok &= osresult1->setOtherConstraintResultDescription(i,2,"other");
4824 if (!ok)
4825 throw ErrorClass("Error during setOtherConstraintResultDescription!");
4826 ok &= (!osresult1->IsEqual(osresult2));
4827 if (!ok)
4828 throw ErrorClass("setOtherConstraintResultDescription: osresult objects falsely compare equal!");
4829 ok &= osresult2->setOtherConstraintResultDescription(i,2,"other");
4830 if (!ok)
4831 throw ErrorClass("Error during setOtherConstraintResultDescription!");
4832 ok &= (osresult1->IsEqual(osresult2));
4833 if (!ok)
4834 throw ErrorClass("setOtherConstraintResultDescription: osresult objects falsely compare unequal!");
4835
4836 ok &= osresult1->setOtherConstraintResultValue(i,2,"other");
4837 if (!ok)
4838 throw ErrorClass("Error during setOtherConstraintResultValue!");
4839 ok &= (!osresult1->IsEqual(osresult2));
4840 if (!ok)
4841 throw ErrorClass("setOtherConstraintResultValue: osresult objects falsely compare equal!");
4842 ok &= osresult2->setOtherConstraintResultValue(i,2,"other");
4843 if (!ok)
4844 throw ErrorClass("Error during setOtherConstraintResultValue!");
4845 ok &= (osresult1->IsEqual(osresult2));
4846 if (!ok)
4847 throw ErrorClass("setOtherConstraintResultValue: osresult objects falsely compare unequal!");
4848
4849 ok &= osresult1->setOtherConstraintResultNumberOfEnumerations(i,2,2);
4850 if (!ok)
4851 throw ErrorClass("Error during setOtherConstraintResultNumberOfEnumerations!");
4852 ok &= (!osresult1->IsEqual(osresult2));
4853 if (!ok)
4854 throw ErrorClass("setOtherConstraintResultNumberOfEnumerations: osresult objects falsely compare equal!");
4855 ok &= osresult2->setOtherConstraintResultNumberOfEnumerations(i,2,2);
4856 if (!ok)
4857 throw ErrorClass("Error during setOtherConstraintResultNumberOfEnumerations!");
4858 ok &= (osresult1->IsEqual(osresult2));
4859 if (!ok)
4860 throw ErrorClass("setOtherConstraintResultNumberOfEnumerations: osresult objects falsely compare unequal!");
4861
4862 for (int k=0; k < 2; ++k)
4863 {
4864 intArray[0] = 1000*i + 1330 + 10*k + 1;
4865 intArray[1] = 1000*i + 1330 + 10*k + 2;
4866 intArray[2] = 1000*i + 1330 + 10*k + 3;
4867
4868 ok &= osresult1->setOtherOptionOrResultEnumeration(i,2,
4869 ENUM_PROBLEM_COMPONENT_constraints,k,"value","description",intArray,3);
4870 if (!ok)
4871 throw ErrorClass("Error during setOtherOptionOrResultEnumeration (constraint)!");
4872 ok &= (!osresult1->IsEqual(osresult2));
4873 if (!ok)
4874 throw ErrorClass("setOtherOptionOrResultEnumeration: osresult objects falsely compare equal!");
4875 ok &= osresult2->setOtherOptionOrResultEnumeration(i,2,
4876 ENUM_PROBLEM_COMPONENT_constraints,k,"value","description",intArray,3);
4877 if (!ok)
4878 throw ErrorClass("Error during setOtherOptionOrResultEnumeration (constraint)!");
4879 ok &= (osresult1->IsEqual(osresult2));
4880 if (!ok)
4881 throw ErrorClass("setOtherOptionOrResultEnumeration: osresult objects falsely compare unequal!");
4882 }
4883
4884
4885 ok &= osresult1->setNumberOfOtherSolutionResults(i,3);
4886 if (!ok)
4887 throw ErrorClass("Error during setNumberOfOtherSolutionResults!");
4888 ok &= (!osresult1->IsEqual(osresult2));
4889 if (!ok)
4890 throw ErrorClass("setNumberOfOtherSolutionResults: osresult objects falsely compare equal!");
4891 ok &= osresult2->setNumberOfOtherSolutionResults(i,3);
4892 if (!ok)
4893 throw ErrorClass("Error during setNumberOfOtherSolutionResults!");
4894 ok &= (osresult1->IsEqual(osresult2));
4895 if (!ok)
4896 throw ErrorClass("setNumberOfOtherSolutionResults: osresult objects falsely compare unequal!");
4897
4898 for (int j=0; j < 3; ++j)
4899 {
4900 ok &= osresult1->setOtherSolutionResultName(i,j,"other");
4901 if (!ok)
4902 throw ErrorClass("Error during setOtherSolutionResultName!");
4903 ok &= (!osresult1->IsEqual(osresult2));
4904 if (!ok)
4905 throw ErrorClass("setOtherSolutionResultName: osresult objects falsely compare equal!");
4906 ok &= osresult2->setOtherSolutionResultName(i,j,"other");
4907 if (!ok)
4908 throw ErrorClass("Error during setOtherSolutionResultName!");
4909 ok &= (osresult1->IsEqual(osresult2));
4910 if (!ok)
4911 throw ErrorClass("setOtherSolutionResultName: osresult objects falsely compare unequal!");
4912
4913 ok &= osresult1->setOtherSolutionResultCategory(i,j,"other");
4914 if (!ok)
4915 throw ErrorClass("Error during setOtherSolutionResultCategory!");
4916 ok &= (!osresult1->IsEqual(osresult2));
4917 if (!ok)
4918 throw ErrorClass("setOtherSolutionResultCategory: osresult objects falsely compare equal!");
4919 ok &= osresult2->setOtherSolutionResultCategory(i,j,"other");
4920 if (!ok)
4921 throw ErrorClass("Error during setOtherSolutionResultCategory!");
4922 ok &= (osresult1->IsEqual(osresult2));
4923 if (!ok)
4924 throw ErrorClass("setOtherSolutionResultCategory: osresult objects falsely compare unequal!");
4925
4926 ok &= osresult1->setOtherSolutionResultDescription(i,j,"other");
4927 if (!ok)
4928 throw ErrorClass("Error during setOtherSolutionResultDescription!");
4929 ok &= (!osresult1->IsEqual(osresult2));
4930 if (!ok)
4931 throw ErrorClass("setOtherSolutionResultDescription: osresult objects falsely compare equal!");
4932 ok &= osresult2->setOtherSolutionResultDescription(i,j,"other");
4933 if (!ok)
4934 throw ErrorClass("Error during setOtherSolutionResultDescription!");
4935 ok &= (osresult1->IsEqual(osresult2));
4936 if (!ok)
4937 throw ErrorClass("setOtherSolutionResultDescription: osresult objects falsely compare unequal!");
4938
4939 ok &= osresult1->setOtherSolutionResultNumberOfItems(i,j,3);
4940 if (!ok)
4941 throw ErrorClass("Error during setOtherSolutionResultNumberOfItems!");
4942 ok &= (!osresult1->IsEqual(osresult2));
4943 if (!ok)
4944 throw ErrorClass("setOtherSolutionResultNumberOfItems: osresult objects falsely compare equal!");
4945 ok &= osresult2->setOtherSolutionResultNumberOfItems(i,j,3);
4946 if (!ok)
4947 throw ErrorClass("Error during setOtherSolutionResultNumberOfItems!");
4948 ok &= (osresult1->IsEqual(osresult2));
4949 if (!ok)
4950 throw ErrorClass("setOtherSolutionResultNumberOfItems: osresult objects falsely compare unequal!");
4951
4952 for (int k=0; k < 3; ++k)
4953 {
4954 ok &= osresult1->setOtherSolutionResultItem(i,j,k,"blabla");
4955 if (!ok)
4956 throw ErrorClass("Error during setOtherSolutionResultItem!");
4957 ok &= (!osresult1->IsEqual(osresult2));
4958 if (!ok)
4959 throw ErrorClass("setOtherSolutionResultItem: osresult objects falsely compare equal!");
4960 ok &= osresult2->setOtherSolutionResultItem(i,j,k,"blabla");
4961 if (!ok)
4962 throw ErrorClass("Error during setOtherSolutionResultItem!");
4963 ok &= (osresult1->IsEqual(osresult2));
4964 if (!ok)
4965 throw ErrorClass("setOtherSolutionResultItem: osresult objects falsely compare unequal!");
4966 }
4967 }
4968 }
4969
4970 ok &= osresult1->setNumberOfSolverOutputs(3);
4971 if (!ok)
4972 throw ErrorClass("Error during setNumberOfSolverOutputs!");
4973 ok &= (!osresult1->IsEqual(osresult2));
4974 if (!ok)
4975 throw ErrorClass("setNumberOfSolverOutputs: osresult objects falsely compare equal!");
4976 ok &= osresult2->setNumberOfSolverOutputs(3);
4977 if (!ok)
4978 throw ErrorClass("Error during setNumberOfSolverOutputs!");
4979 ok &= (osresult1->IsEqual(osresult2));
4980 if (!ok)
4981 throw ErrorClass("setNumberOfSolverOutputs: osresult objects falsely compare unequal!");
4982
4983 for (int i=0; i < 3; ++i)
4984 {
4985 ok &= osresult1->setSolverOutputName(i,"some name");
4986 if (!ok)
4987 throw ErrorClass("Error during setSolverOutputName!");
4988 ok &= (!osresult1->IsEqual(osresult2));
4989 if (!ok)
4990 throw ErrorClass("setSolverOutputName: osresult objects falsely compare equal!");
4991 ok &= osresult2->setSolverOutputName(i,"some name");
4992 if (!ok)
4993 throw ErrorClass("Error during setSolverOutputName!");
4994 ok &= (osresult1->IsEqual(osresult2));
4995 if (!ok)
4996 throw ErrorClass("setSolverOutputName: osresult objects falsely compare unequal!");
4997
4998 ok &= osresult1->setSolverOutputCategory(i,"some name");
4999 if (!ok)
5000 throw ErrorClass("Error during setSolverOutputCategory!");
5001 ok &= (!osresult1->IsEqual(osresult2));
5002 if (!ok)
5003 throw ErrorClass("setSolverOutputCategory: osresult objects falsely compare equal!");
5004 ok &= osresult2->setSolverOutputCategory(i,"some name");
5005 if (!ok)
5006 throw ErrorClass("Error during setSolverOutputCategory!");
5007 ok &= (osresult1->IsEqual(osresult2));
5008 if (!ok)
5009 throw ErrorClass("setSolverOutputCategory: osresult objects falsely compare unequal!");
5010
5011 ok &= osresult1->setSolverOutputDescription(i,"some name");
5012 if (!ok)
5013 throw ErrorClass("Error during setSolverOutputDescription!");
5014 ok &= (!osresult1->IsEqual(osresult2));
5015 if (!ok)
5016 throw ErrorClass("setSolverOutputDescription: osresult objects falsely compare equal!");
5017 ok &= osresult2->setSolverOutputDescription(i,"some name");
5018 if (!ok)
5019 throw ErrorClass("Error during setSolverOutputDescription!");
5020 ok &= (osresult1->IsEqual(osresult2));
5021 if (!ok)
5022 throw ErrorClass("setSolverOutputDescription: osresult objects falsely compare unequal!");
5023
5024 ok &= osresult1->setSolverOutputNumberOfItems(i,3);
5025 if (!ok)
5026 throw ErrorClass("Error during setSolverOutputNumberOfItems!");
5027 ok &= (!osresult1->IsEqual(osresult2));
5028 if (!ok)
5029 throw ErrorClass("setSolverOutputNumberOfItems: osresult objects falsely compare equal!");
5030 ok &= osresult2->setSolverOutputNumberOfItems(i,3);
5031 if (!ok)
5032 throw ErrorClass("Error during setSolverOutputNumberOfItems!");
5033 ok &= (osresult1->IsEqual(osresult2));
5034 if (!ok)
5035 throw ErrorClass("setSolverOutputNumberOfItems: osresult objects falsely compare unequal!");
5036
5037 for (int j=0; j < 3; ++j)
5038 {
5039 ok &= osresult1->setSolverOutputItem(i,j,"other");
5040 if (!ok)
5041 throw ErrorClass("Error during setSolverOutputItem!");
5042 ok &= (!osresult1->IsEqual(osresult2));
5043 if (!ok)
5044 throw ErrorClass("setSolverOutputItem: osresult objects falsely compare equal!");
5045 ok &= osresult2->setSolverOutputItem(i,j,"other");
5046 if (!ok)
5047 throw ErrorClass("Error during setSolverOutputItem!");
5048 ok &= (osresult1->IsEqual(osresult2));
5049 if (!ok)
5050 throw ErrorClass("setSolverOutputItem: osresult objects falsely compare unequal!");
5051 }
5052 }
5053
5054 if (!ok)
5055 throw ErrorClass("Unspecified error while testing set() methods");
5056
5057 unitTestResult << "TEST " << nOfTest << ": Successful test of OSrL set() tools" << std::endl;
5058 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
5059
5060 cout << endl << "TEST " << ++nOfTest << ": OSrLWriter and OSrLReader " << endl << endl;
5061
5062
5063 osrlwriter = new OSrLWriter();
5064 osrlreader = new OSrLReader();
5065 std::string tempOSrL;
5066
5067 cout << "write out the OSResult object from previous test" << endl;
5068
5069 tempOSrL = osrlwriter->writeOSrL( osresult1);
5070
5071 cout << tempOSrL << endl;
5072
5073 cout << "Read the string back into memory" << endl;
5074
5075 osresult3 = osrlreader->readOSrL( tempOSrL);
5076
5077 cout << "write out the new object created" << endl;
5078
5079 tempOSrL = osrlwriter->writeOSrL( osresult3);
5080
5081 std::cout << "Here is the temporary OSrL string produced from OSrLReader" << std::endl << tempOSrL << std::endl;
5082
5083 cout << "verify that the old and new objects are equal" << endl;
5084
5085 ok &= (osresult1->IsEqual(osresult3));
5086 if (!ok)
5087 throw ErrorClass("Writing an osresult then reading leads to loss of data");
5088
5089 unitTestResult << "TEST " << nOfTest << ": Successful test of OSrLWriter and OSrLReader" << std::endl;
5090 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
5091
5097 cout << endl << "TEST " << ++nOfTest << ": OSrL get() methods" << endl << endl;
5098//#ifdef TEMP //---------------------------for the time being----------------------------------
5099
5100 if (osresult2 != NULL) delete osresult2;
5101 osresult2 = new OSResult();
5102
5103 std::string tempStr;
5104 double tempDbl;
5105 int tempInt;
5106
5107 tempStr = osresult1->getGeneralStatusType();
5108 ok &= osresult2->setGeneralStatusType(tempStr);
5109 if (!ok)
5110 throw ErrorClass("Error during setGeneralStatusType!");
5111 tempStr = osresult1->getGeneralStatusDescription();
5112 ok &= osresult2->setGeneralStatusDescription(tempStr);
5113 if (!ok)
5114 throw ErrorClass("Error during setGeneralStatusDescription!");
5115
5116 tempInt = osresult1->getNumberOfGeneralSubstatuses();
5117 ok &= osresult2->setNumberOfGeneralSubstatuses(tempInt);
5118 if (!ok)
5119 throw ErrorClass("Error during setNumberOfGeneralSubstatuses!");
5120 for (int i=0; i < tempInt; i++)
5121 {
5122 tempStr = osresult1->getGeneralSubstatusName(i);
5123 ok &= osresult2->setGeneralSubstatusName(i,tempStr);
5124 if (!ok)
5125 throw ErrorClass("Error during setGeneralSubstatusName!");
5126 tempStr = osresult1->getGeneralSubstatusDescription(i);
5127 ok &= osresult2->setGeneralSubstatusDescription(i,tempStr);
5128 if (!ok)
5129 throw ErrorClass("Error during setGeneralSubstatusDescription!");
5130 }
5131
5132 tempStr = osresult1->getGeneralMessage();
5133 ok &= osresult2->setGeneralMessage(tempStr);
5134 if (!ok)
5135 throw ErrorClass("Error during setGeneralMessage!");
5136 tempStr = osresult1->getServiceURI();
5137 ok &= osresult2->setServiceURI(tempStr);
5138 if (!ok)
5139 throw ErrorClass("Error during setServiceURI!");
5140 tempStr = osresult1->getServiceName();
5141 ok &= osresult2->setServiceName(tempStr);
5142 if (!ok)
5143 throw ErrorClass("Error during setServiceName!");
5144 tempStr = osresult1->getInstanceName();
5145 ok &= osresult2->setInstanceName(tempStr);
5146 if (!ok)
5147 throw ErrorClass("Error during setInstanceName!");
5148 tempStr = osresult1->getJobID();
5149 ok &= osresult2->setJobID(tempStr);
5150 if (!ok)
5151 throw ErrorClass("Error during setJobID!");
5152 tempStr = osresult1->getSolverInvoked();
5153 ok &= osresult2->setSolverInvoked(tempStr);
5154 if (!ok)
5155 throw ErrorClass("Error during setSolverInvoked!");
5156 tempStr = osresult1->getTimeStamp();
5157 ok &= osresult2->setTimeStamp(tempStr);
5158 if (!ok)
5159 throw ErrorClass("Error during setTimeStamp!");
5160
5161 tempInt = osresult1->getNumberOfOtherGeneralResults();
5162 ok &= osresult2->setNumberOfOtherGeneralResults(tempInt);
5163 if (!ok)
5164 throw ErrorClass("Error during setNumberOfOtherGeneralResults!");
5165 for (int i=0; i < tempInt; i++)
5166 {
5167 tempStr = osresult1->getOtherGeneralResultName(i);
5168 ok &= osresult2->setOtherGeneralResultName(i,tempStr);
5169 if (!ok)
5170 throw ErrorClass("Error during setOtherGeneralResultName!");
5171 tempStr = osresult1->getOtherGeneralResultValue(i);
5172 ok &= osresult2->setOtherGeneralResultValue(i,tempStr);
5173 if (!ok)
5174 throw ErrorClass("Error during setOtherGeneralResultValue!");
5175 tempStr = osresult1->getOtherGeneralResultDescription(i);
5176 ok &= osresult2->setOtherGeneralResultDescription(i,tempStr);
5177 if (!ok)
5178 throw ErrorClass("Error during setOtherGeneralResultDescription!");
5179 }
5180
5181 tempStr = osresult1->getSystemInformation();
5182 ok &= osresult2->setSystemInformation(tempStr);
5183 if (!ok)
5184 throw ErrorClass("Error during setSystemInformation!");
5185 tempStr = osresult1->getAvailableDiskSpaceUnit();
5186 ok &= osresult2->setAvailableDiskSpaceUnit(tempStr);
5187 if (!ok)
5188 throw ErrorClass("Error during setAvailableDiskSpaceUnit!");
5189 tempStr = osresult1->getAvailableDiskSpaceDescription();
5190 ok &= osresult2->setAvailableDiskSpaceDescription(tempStr);
5191 if (!ok)
5192 throw ErrorClass("Error during setAvailableDiskSpaceDescription!");
5193 tempDbl = osresult1->getAvailableDiskSpaceValue();
5194 ok &= osresult2->setAvailableDiskSpaceValue(tempDbl);
5195 if (!ok)
5196 throw ErrorClass("Error during setAvailableDiskSpaceValue!");
5197 tempStr = osresult1->getAvailableMemoryUnit();
5198 ok &= osresult2->setAvailableMemoryUnit(tempStr);
5199 if (!ok)
5200 throw ErrorClass("Error during setAvailableMemoryUnit!");
5201 tempStr = osresult1->getAvailableMemoryDescription();
5202 ok &= osresult2->setAvailableMemoryDescription(tempStr);
5203 if (!ok)
5204 throw ErrorClass("Error during setAvailableMemoryDescription!");
5205 tempDbl = osresult1->getAvailableMemoryValue();
5206 ok &= osresult2->setAvailableMemoryValue(tempDbl);
5207 if (!ok)
5208 throw ErrorClass("Error during setAvailableMemoryValue!");
5209 tempStr = osresult1->getAvailableCPUSpeedUnit();
5210 ok &= osresult2->setAvailableCPUSpeedUnit(tempStr);
5211 if (!ok)
5212 throw ErrorClass("Error during setAvailableCPUSpeedUnit!");
5213 tempStr = osresult1->getAvailableCPUSpeedDescription();
5214 ok &= osresult2->setAvailableCPUSpeedDescription(tempStr);
5215 if (!ok)
5216 throw ErrorClass("Error during setAvailableCPUSpeedDescription!");
5217 tempDbl = osresult1->getAvailableCPUSpeedValue();
5218 ok &= osresult2->setAvailableCPUSpeedValue(tempDbl);
5219 if (!ok)
5220 throw ErrorClass("Error during setAvailableCPUSpeedValue!");
5221 tempStr = osresult1->getAvailableCPUNumberDescription();
5222 ok &= osresult2->setAvailableCPUNumberDescription(tempStr);
5223 if (!ok)
5224 throw ErrorClass("Error during setAvailableCPUNumberDescription!");
5225 tempInt = osresult1->getAvailableCPUNumberValue();
5226 ok &= osresult2->setAvailableCPUNumberValue(tempInt);
5227 if (!ok)
5228 throw ErrorClass("Error during setAvailableCPUNumberValue!");
5229
5230 tempInt = osresult1->getNumberOfOtherSystemResults();
5231 ok &= osresult2->setNumberOfOtherSystemResults(tempInt);
5232 if (!ok)
5233 throw ErrorClass("Error during setNumberOfOtherSystemResults!");
5234 for (int i=0; i < tempInt; i++)
5235 {
5236 tempStr = osresult1->getOtherSystemResultName(i);
5237 ok &= osresult2->setOtherSystemResultName(i,tempStr);
5238 if (!ok)
5239 throw ErrorClass("Error during setOtherSystemResultName!");
5240 tempStr = osresult1->getOtherSystemResultValue(i);
5241 ok &= osresult2->setOtherSystemResultValue(i,tempStr);
5242 if (!ok)
5243 throw ErrorClass("Error during setOtherSystemResultValue!");
5244 tempStr = osresult1->getOtherSystemResultDescription(i);
5245 ok &= osresult2->setOtherSystemResultDescription(i,tempStr);
5246 if (!ok)
5247 throw ErrorClass("Error during setOtherSystemResultDescription!");
5248 }
5249
5250 tempStr = osresult1->getCurrentState();
5251 ok &= osresult2->setCurrentState(tempStr);
5252 if (!ok)
5253 throw ErrorClass("Error during setCurrentState!");
5254 tempInt = osresult1->getCurrentJobCount();
5255 ok &= osresult2->setCurrentJobCount(tempInt);
5256 if (!ok)
5257 throw ErrorClass("Error during setCurrentJobCount!");
5258 tempInt = osresult1->getTotalJobsSoFar();
5259 ok &= osresult2->setTotalJobsSoFar(tempInt);
5260 if (!ok)
5261 throw ErrorClass("Error during setTotalJobsSoFar!");
5262 tempStr = osresult1->getTimeServiceStarted();
5263 ok &= osresult2->setTimeServiceStarted(tempStr);
5264 if (!ok)
5265 throw ErrorClass("Error during setTimeServiceStarted!");
5266 tempDbl = osresult1->getServiceUtilization();
5267 ok &= osresult2->setServiceUtilization(tempDbl);
5268 if (!ok)
5269 throw ErrorClass("Error during setServiceUtilization!");
5270
5271 tempInt = osresult1->getNumberOfOtherServiceResults();
5272 ok &= osresult2->setNumberOfOtherServiceResults(tempInt);
5273 if (!ok)
5274 throw ErrorClass("Error during setNumberOfOtherServiceResults!");
5275 for (int i=0; i < tempInt; i++)
5276 {
5277 tempStr = osresult1->getOtherServiceResultName(i);
5278 ok &= osresult2->setOtherServiceResultName(i,tempStr);
5279 if (!ok)
5280 throw ErrorClass("Error during setOtherServiceResultName!");
5281 tempStr = osresult1->getOtherServiceResultValue(i);
5282 ok &= osresult2->setOtherServiceResultValue(i,tempStr);
5283 if (!ok)
5284 throw ErrorClass("Error during setOtherServiceResultValue!");
5285 tempStr = osresult1->getOtherServiceResultDescription(i);
5286 ok &= osresult2->setOtherServiceResultDescription(i,tempStr);
5287 if (!ok)
5288 throw ErrorClass("Error during setOtherServiceResultDescription!");
5289 }
5290
5291 tempStr = osresult1->getJobStatus();
5292 ok &= osresult2->setJobStatus(tempStr);
5293 if (!ok)
5294 throw ErrorClass("Error during setJobStatus!");
5295 tempStr = osresult1->getJobSubmitTime();
5296 ok &= osresult2->setJobSubmitTime(tempStr);
5297 if (!ok)
5298 throw ErrorClass("Error during setJobSubmitTime!");
5299 tempStr = osresult1->getScheduledStartTime();
5300 ok &= osresult2->setScheduledStartTime(tempStr);
5301 if (!ok)
5302 throw ErrorClass("Error during setScheduledStartTime!");
5303 tempStr = osresult1->getActualStartTime();
5304 ok &= osresult2->setActualStartTime(tempStr);
5305 if (!ok)
5306 throw ErrorClass("Error during setActualStartTime!");
5307 tempStr = osresult1->getJobEndTime();
5308 ok &= osresult2->setJobEndTime(tempStr);
5309 if (!ok)
5310 throw ErrorClass("Error during setJobEndTime!");
5311
5312 tempInt = osresult1->getNumberOfTimes();
5313 ok &= osresult2->setNumberOfTimes(tempInt);
5314 if (!ok)
5315 throw ErrorClass("Error during setNumberOfTimes!");
5316 for (int i=0; i < tempInt; i++)
5317 {
5318 string tempStr1,tempStr2,tempStr3,tempStr4;
5319 tempStr1 = osresult1->getTimingInfoType(i);
5320 tempStr2 = osresult1->getTimingInfoCategory(i);
5321 tempStr3 = osresult1->getTimingInfoUnit(i);
5322 tempStr4 = osresult1->getTimingInfoDescription(i);
5323 tempDbl = osresult1->getTimingInfoValue(i);
5324 ok &= osresult2->setTimingInformation(i,tempStr1,tempStr2,tempStr3,tempStr4,tempDbl);
5325 if (!ok)
5326 throw ErrorClass("Error during setTimingInformation!");
5327 }
5328
5329 tempStr = osresult1->getUsedDiskSpaceUnit();
5330 ok &= osresult2->setUsedDiskSpaceUnit(tempStr);
5331 if (!ok)
5332 throw ErrorClass("Error during setUsedDiskSpaceUnit!");
5333 tempStr = osresult1->getUsedDiskSpaceDescription();
5334 ok &= osresult2->setUsedDiskSpaceDescription(tempStr);
5335 if (!ok)
5336 throw ErrorClass("Error during setUsedDiskSpaceDescription!");
5337 tempDbl = osresult1->getUsedDiskSpaceValue();
5338 ok &= osresult2->setUsedDiskSpaceValue(tempDbl);
5339 if (!ok)
5340 throw ErrorClass("Error during setUsedDiskSpaceValue!");
5341 tempStr = osresult1->getUsedMemoryUnit();
5342 ok &= osresult2->setUsedMemoryUnit(tempStr);
5343 if (!ok)
5344 throw ErrorClass("Error during setUsedMemoryUnit!");
5345 tempStr = osresult1->getUsedMemoryDescription();
5346 ok &= osresult2->setUsedMemoryDescription(tempStr);
5347 if (!ok)
5348 throw ErrorClass("Error during setUsedMemoryDescription!");
5349 tempDbl = osresult1->getUsedMemoryValue();
5350 ok &= osresult2->setUsedMemoryValue(tempDbl);
5351 if (!ok)
5352 throw ErrorClass("Error during setUsedMemoryValue!");
5353 tempStr = osresult1->getUsedCPUSpeedUnit();
5354 ok &= osresult2->setUsedCPUSpeedUnit(tempStr);
5355 if (!ok)
5356 throw ErrorClass("Error during setUsedCPUSpeedUnit!");
5357 tempStr = osresult1->getUsedCPUSpeedDescription();
5358 ok &= osresult2->setUsedCPUSpeedDescription(tempStr);
5359 if (!ok)
5360 throw ErrorClass("Error during setUsedCPUSpeedDescription!");
5361 tempDbl = osresult1->getUsedCPUSpeedValue();
5362 ok &= osresult2->setUsedCPUSpeedValue(tempDbl);
5363 if (!ok)
5364 throw ErrorClass("Error during setUsedCPUSpeedValue!");
5365 tempStr = osresult1->getUsedCPUNumberDescription();
5366 ok &= osresult2->setUsedCPUNumberDescription(tempStr);
5367 if (!ok)
5368 throw ErrorClass("Error during setUsedCPUNumberDescription!");
5369 tempInt = osresult1->getUsedCPUNumberValue();
5370 ok &= osresult2->setUsedCPUNumberValue(tempInt);
5371 if (!ok)
5372 throw ErrorClass("Error during setUsedCPUNumberValue!");
5373
5374 tempInt = osresult1->getNumberOfOtherJobResults();
5375 ok &= osresult2->setNumberOfOtherJobResults(tempInt);
5376 if (!ok)
5377 throw ErrorClass("Error during setNumberOfOtherJobResults!");
5378 for (int i=0; i < tempInt; i++)
5379 {
5380 tempStr = osresult1->getOtherJobResultName(i);
5381 ok &= osresult2->setOtherJobResultName(i,tempStr);
5382 if (!ok)
5383 throw ErrorClass("Error during setOtherJobResultName!");
5384 tempStr = osresult1->getOtherJobResultValue(i);
5385 ok &= osresult2->setOtherJobResultValue(i,tempStr);
5386 if (!ok)
5387 throw ErrorClass("Error during setOtherJobResultValue!");
5388 tempStr = osresult1->getOtherJobResultDescription(i);
5389 ok &= osresult2->setOtherJobResultDescription(i,tempStr);
5390 if (!ok)
5391 throw ErrorClass("Error during setOtherJobResultDescription!");
5392 }
5393
5394 tempInt = osresult1->getSolutionNumber();
5395 ok &= osresult2->setSolutionNumber(tempInt);
5396 if (!ok)
5397 throw ErrorClass("Error during setSolutionNumber!");
5398 int nSoln = tempInt;
5399 int nVar, nObj, nCon, nOther, nItem;
5400
5401 tempInt = osresult1->getVariableNumber();
5402 ok &= osresult2->setVariableNumber(tempInt);
5403 if (!ok)
5404 throw ErrorClass("Error during setVariableNumber!");
5405 tempInt = osresult1->getObjectiveNumber();
5406 ok &= osresult2->setObjectiveNumber(tempInt);
5407 if (!ok)
5408 throw ErrorClass("Error during setObjectiveNumber!");
5409 tempInt = osresult1->getConstraintNumber();
5410 ok &= osresult2->setConstraintNumber(tempInt);
5411 if (!ok)
5412 throw ErrorClass("Error during setConstraintNumber!");
5413
5414 for (int i=0; i < nSoln; ++i)
5415 {
5416 tempInt = osresult1->getSolutionTargetObjectiveIdx(i);
5417 ok &= osresult2->setSolutionTargetObjectiveIdx(i,tempInt);
5418 if (!ok)
5419 throw ErrorClass("Error during setSolutionTargetObjectiveIdx!");
5420 tempStr = osresult1->getSolutionTargetObjectiveName(i);
5421 ok &= osresult2->setSolutionTargetObjectiveName(i,tempStr);
5422 if (!ok)
5423 throw ErrorClass("Error during getSolutionTargetObjectiveName!");
5424 bool tempLog = osresult1->getSolutionWeightedObjectives(i);
5425 ok &= osresult2->setSolutionWeightedObjectives(i,tempLog);
5426 if (!ok)
5427 throw ErrorClass("Error during setSolutionWeightedObjectives!");
5428 tempStr = osresult1->getSolutionStatusType(i);
5429 ok &= osresult2->setSolutionStatusType(i,tempStr);
5430 if (!ok)
5431 throw ErrorClass("Error during setSolutionStatusType!");
5432 tempStr = osresult1->getSolutionStatusDescription(i);
5433 ok &= osresult2->setSolutionStatusDescription(i,tempStr);
5434 if (!ok)
5435 throw ErrorClass("Error during setSolutionStatusDescription!");
5436
5437 tempInt = osresult1->getNumberOfSolutionSubstatuses(i);
5438 ok &= osresult2->setNumberOfSolutionSubstatuses(i,tempInt);
5439 if (!ok)
5440 throw ErrorClass("Error during setNumberOfSolutionSubstatuses!");
5441
5442 for (int j=0; j < tempInt; ++j)
5443 {
5444 tempStr = osresult1->getSolutionSubstatusType(i,j);
5445 ok &= osresult2->setSolutionSubstatusType(i,j,tempStr);
5446 if (!ok)
5447 throw ErrorClass("Error during setSolutionSubstatusType!");
5448 tempStr = osresult1->getSolutionSubstatusDescription(i,j);
5449 ok &= osresult2->setSolutionSubstatusDescription(i,j,tempStr);
5450 if (!ok)
5451 throw ErrorClass("Error during setSolutionSubstatusDescription!");
5452 }
5453
5454 tempStr = osresult1->getSolutionMessage(i);
5455 ok &= osresult2->setSolutionMessage(i,tempStr);
5456 if (!ok)
5457 throw ErrorClass("Error during setSolutionMessage!");
5458
5459 tempInt = osresult1->getNumberOfVarValues(i);
5460 ok &= osresult2->setNumberOfVarValues(i,tempInt);
5461 if (!ok)
5462 throw ErrorClass("Error during setNumberOfVarValues!");
5463 nVar = tempInt;
5464
5465 for (int j=0; j < nVar; ++j)
5466 {
5467 tempInt = osresult1->getVarValueIdx(i,j);
5468 tempStr = osresult1->getVarValueName(i,j);
5469 tempDbl = osresult1->getVarValue(i,j);
5470 ok &= osresult2->setVarValue(i,j,tempInt,tempStr,tempDbl);
5471 if (!ok)
5472 throw ErrorClass("Error during setVarValue!");
5473 }
5474
5475 tempInt = osresult1->getNumberOfVarValuesString(i);
5476 ok &= osresult2->setNumberOfVarValuesString(i,tempInt);
5477 if (!ok)
5478 throw ErrorClass("Error during setNumberOfVarValuesString!");
5479 nVar = tempInt;
5480
5481 std::string tempStr1, tempStr2;
5482
5483 for (int j=0; j < nVar; ++j)
5484 {
5485 tempInt = osresult1->getVarValueStringIdx(i,j);
5486 tempStr1 = osresult1->getVarValueStringName(i,j);
5487 tempStr2 = osresult1->getVarValueString(i,j);
5488 ok &= osresult2->setVarValueString(i,j,tempInt,tempStr1,tempStr2);
5489 if (!ok)
5490 throw ErrorClass("Error during setVarValueString!");
5491 }
5492
5493// int* tempArray = new int[3];
5495 for (int j=0; j<tempInt; ++j)
5497 ok &= osresult2->setBasisStatus(i,ENUM_PROBLEM_COMPONENT_variables,ENUM_BASIS_STATUS_basic,tempArray,tempInt);
5498 if (!ok)
5499 throw ErrorClass("Error during setBasisStatus (variables basic)!");
5500
5502 for (int j=0; j<tempInt; ++j)
5505 if (!ok)
5506 throw ErrorClass("Error during setBasisStatus (variables atLower)!");
5507
5509 for (int j=0; j<tempInt; ++j)
5512 if (!ok)
5513 throw ErrorClass("Error during setBasisStatus (variables atUpper)!");
5514
5516 for (int j=0; j<tempInt; ++j)
5519 if (!ok)
5520 throw ErrorClass("Error during setBasisStatus (variables atEquality)!");
5521
5523 for (int j=0; j<tempInt; ++j)
5525 ok &= osresult2->setBasisStatus(i,ENUM_PROBLEM_COMPONENT_variables,ENUM_BASIS_STATUS_isFree,tempArray,tempInt);
5526 if (!ok)
5527 throw ErrorClass("Error during setBasisStatus (variables isFree)!");
5528
5530 for (int j=0; j<tempInt; ++j)
5533 if (!ok)
5534 throw ErrorClass("Error during setBasisStatus (variables superbasic)!");
5535
5537 for (int j=0; j<tempInt; ++j)
5540 if (!ok)
5541 throw ErrorClass("Error during setBasisStatus (variables unknown)!");
5542
5543
5544 tempInt = osresult1->getNumberOfOtherVariableResults(i);
5545 ok &= osresult2->setNumberOfOtherVariableResults(i,tempInt);
5546 if (!ok)
5547 throw ErrorClass("Error during setNumberOfOtherVariableResults!");
5548 nOther = tempInt;
5549 for (int j=0; j < nOther; ++j)
5550 {
5551 tempStr = osresult1->getOtherVariableResultName(i,j);
5552 ok &= osresult2->setOtherVariableResultName(i,j,tempStr);
5553 if (!ok)
5554 throw ErrorClass("Error during setOtherVariableResultName!");
5555 tempStr = osresult1->getOtherVariableResultDescription(i,j);
5556 ok &= osresult2->setOtherVariableResultDescription(i,j,tempStr);
5557 if (!ok)
5558 throw ErrorClass("Error during setOtherVariableResultDescription!");
5559 tempStr = osresult1->getOtherVariableResultValue(i,j);
5560 ok &= osresult2->setOtherVariableResultValue(i,j,tempStr);
5561 if (!ok)
5562 throw ErrorClass("Error during setOtherVariableResultValue!");
5563
5564 tempInt = osresult1->getOtherVariableResultNumberOfVar(i,j);
5565 ok &= osresult2->setOtherVariableResultNumberOfVar(i,j,tempInt);
5566 if (!ok)
5567 throw ErrorClass("Error during setOtherVariableResultNumberOfVar!");
5568
5569 int nVar = tempInt;
5570 for (int k=0; k < nVar; ++k)
5571 {
5572 tempInt = osresult1->getOtherVariableResultVarIdx(i,j,k);
5573 ok &= osresult2->setOtherVariableResultVarIdx(i,j,k,tempInt);
5574 if (!ok)
5575 throw ErrorClass("Error during setOtherVariableResultVarIdx!");
5576 tempStr = osresult1->getOtherVariableResultVar(i,j,k);
5577 ok &= osresult2->setOtherVariableResultVar(i,j,k,tempStr);
5578 if (!ok)
5579 throw ErrorClass("Error during setOtherVariableResultVar!");
5580 }
5581
5582 int nEnum = osresult1->getOtherVariableResultNumberOfEnumerations(i,j);
5583 ok &= osresult2->setOtherVariableResultNumberOfEnumerations(i,j,nEnum);
5584 if (!ok)
5585 throw ErrorClass("Error during setOtherVariableResultNumberOfEnumerations!");
5586
5587 for (int k=0; k < nEnum; ++k)
5588 {
5589// if (tempArray != NULL) delete[] tempArray;
5590 tempStr1 = osresult1->getOtherVariableResultEnumerationValue(i,j,k);
5591 tempStr2 = osresult1->getOtherVariableResultEnumerationDescription(i,j,k);
5592 tempInt = osresult1->getOtherVariableResultEnumerationNumberOfEl(i,j,k);
5593 for (int l=0; l<tempInt; ++l)
5594 tempArray[l] = osresult1->getOtherVariableResultEnumerationEl(i,j,k,l);
5595 ok &= osresult2->setOtherOptionOrResultEnumeration(i,j,
5596 ENUM_PROBLEM_COMPONENT_variables,k,tempStr1,tempStr2,tempArray,tempInt);
5597 if (!ok)
5598 throw ErrorClass("Error during setOtherVariableResultEnumeration!");
5599 }
5600 }
5601
5602 tempInt = osresult1->getNumberOfObjValues(i);
5603 ok &= osresult2->setNumberOfObjValues(i,tempInt);
5604 if (!ok)
5605 throw ErrorClass("Error during setNumberOfObjValues!");
5606 nObj = tempInt;
5607 for (int j=0; j < nObj; ++j)
5608 {
5609 tempInt = osresult1->getObjValueIdx(i,j);
5610 tempStr = osresult1->getObjValueName(i,j);
5611 tempDbl = osresult1->getObjValue(i,j);
5612 ok &= osresult2->setObjValue(i,j,tempInt,tempStr,tempDbl);
5613 if (!ok)
5614 throw ErrorClass("Error during setObjValue!");
5615 }
5616
5617
5619 for (int j=0; j<tempInt; ++j)
5621 ok &= osresult2->setBasisStatus(i,ENUM_PROBLEM_COMPONENT_objectives,ENUM_BASIS_STATUS_basic,tempArray,tempInt);
5622 if (!ok)
5623 throw ErrorClass("Error during setBasisStatus (objectives basic)!");
5624
5626 for (int j=0; j<tempInt; ++j)
5629 if (!ok)
5630 throw ErrorClass("Error during setBasisStatus (objectives atLower)!");
5631
5633 for (int j=0; j<tempInt; ++j)
5636 if (!ok)
5637 throw ErrorClass("Error during setBasisStatus (objectives atUpper)!");
5638
5640 for (int j=0; j<tempInt; ++j)
5643 if (!ok)
5644 throw ErrorClass("Error during setBasisStatus (objectives atEquality)!");
5645
5647 for (int j=0; j<tempInt; ++j)
5650 if (!ok)
5651 throw ErrorClass("Error during setBasisStatus (objectives isFree)!");
5652
5654 for (int j=0; j<tempInt; ++j)
5657 if (!ok)
5658 throw ErrorClass("Error during setBasisStatus (objectives superbasic)!");
5659
5661 for (int j=0; j<tempInt; ++j)
5664 if (!ok)
5665 throw ErrorClass("Error during setBasisStatus (objectives unknown)!");
5666
5667
5668
5669 tempInt = osresult1->getNumberOfOtherObjectiveResults(i);
5670 ok &= osresult2->setNumberOfOtherObjectiveResults(i,tempInt);
5671 if (!ok)
5672 throw ErrorClass("Error during setNumberOfOtherObjectiveResults!");
5673 nOther = tempInt;
5674 for (int j=0; j < nOther; ++j)
5675 {
5676 tempStr = osresult1->getOtherObjectiveResultName(i,j);
5677 ok &= osresult2->setOtherObjectiveResultName(i,j,tempStr);
5678 if (!ok)
5679 throw ErrorClass("Error during setOtherObjectiveResultName!");
5680 tempStr = osresult1->getOtherObjectiveResultDescription(i,j);
5681 ok &= osresult2->setOtherObjectiveResultDescription(i,j,tempStr);
5682 if (!ok)
5683 throw ErrorClass("Error during setOtherObjectiveResultDescription!");
5684 tempStr = osresult1->getOtherObjectiveResultValue(i,j);
5685 ok &= osresult2->setOtherObjectiveResultValue(i,j,tempStr);
5686 if (!ok)
5687 throw ErrorClass("Error during setOtherObjectiveResultValue!");
5688
5689 tempInt = osresult1->getOtherObjectiveResultNumberOfObj(i,j);
5690 ok &= osresult2->setOtherObjectiveResultNumberOfObj(i,j,tempInt);
5691 if (!ok)
5692 throw ErrorClass("Error during setOtherObjectiveResultNumberOfObj!");
5693
5694 nObj = tempInt;
5695 for (int k=0; k < nObj; ++k)
5696 {
5697 tempInt = osresult1->getOtherObjectiveResultObjIdx(i,j,k);
5698 ok &= osresult2->setOtherObjectiveResultObjIdx(i,j,k,tempInt);
5699 if (!ok)
5700 throw ErrorClass("Error during setOtherObjectiveResultObjIdx!");
5701 tempStr = osresult1->getOtherObjectiveResultObj(i,j,k);
5702 ok &= osresult2->setOtherObjectiveResultObj(i,j,k,tempStr);
5703 if (!ok)
5704 throw ErrorClass("Error during setOtherObjectiveResultObj!");
5705 }
5706
5707 int nEnum = osresult1->getOtherObjectiveResultNumberOfEnumerations(i,j);
5708 ok &= osresult2->setOtherObjectiveResultNumberOfEnumerations(i,j,nEnum);
5709 if (!ok)
5710 throw ErrorClass("Error during setOtherObjectiveResultNumberOfEnumerations!");
5711 std::string tempStr1, tempStr2;
5712
5713 for (int k=0; k < nEnum; ++k)
5714 {
5715// if (tempArray != NULL) delete[] tempArray;
5716 tempStr1 = osresult1->getOtherObjectiveResultEnumerationValue(i,j,k);
5717 tempStr2 = osresult1->getOtherObjectiveResultEnumerationDescription(i,j,k);
5718 tempInt = osresult1->getOtherObjectiveResultEnumerationNumberOfEl(i,j,k);
5719 for (int l=0; l<tempInt; ++l)
5720 tempArray[l] = osresult1->getOtherObjectiveResultEnumerationEl(i,j,k,l);
5721 ok &= osresult2->setOtherOptionOrResultEnumeration(i,j,
5722 ENUM_PROBLEM_COMPONENT_objectives,k,tempStr1,tempStr2,tempArray,tempInt);
5723 if (!ok)
5724 throw ErrorClass("Error during setOtherObjectiveResultEnumeration!");
5725 }
5726 }
5727
5728
5729 tempInt = osresult1->getNumberOfDualValues(i);
5730 ok &= osresult2->setNumberOfDualValues(i,tempInt);
5731 if (!ok)
5732 throw ErrorClass("Error during setNumberOfDualValues!");
5733 nCon = tempInt;
5734 for (int j=0; j < nCon; ++j)
5735 {
5736 tempInt = osresult1->getDualValueIdx(i,j);
5737 tempStr = osresult1->getDualValueName(i,j);
5738 tempDbl = osresult1->getDualValue(i,j);
5739 ok &= osresult2->setDualValue(i,j,tempInt,tempStr,tempDbl);
5740 if (!ok)
5741 throw ErrorClass("Error during setDualValue!");
5742 }
5743
5744
5746 for (int j=0; j<tempInt; ++j)
5749 if (!ok)
5750 throw ErrorClass("Error during setBasisStatus (constraints basic)!");
5751
5753 for (int j=0; j<tempInt; ++j)
5756 if (!ok)
5757 throw ErrorClass("Error during setBasisStatus (constraints atLower)!");
5758
5760 for (int j=0; j<tempInt; ++j)
5763 if (!ok)
5764 throw ErrorClass("Error during setBasisStatus (constraints atUpper)!");
5765
5767 for (int j=0; j<tempInt; ++j)
5770 if (!ok)
5771 throw ErrorClass("Error during setBasisStatus (constraints atEquality)!");
5772
5774 for (int j=0; j<tempInt; ++j)
5777 if (!ok)
5778 throw ErrorClass("Error during setBasisStatus (constraints isFree)!");
5779
5781 for (int j=0; j<tempInt; ++j)
5784 if (!ok)
5785 throw ErrorClass("Error during setBasisStatus (constraints superbasic)!");
5786
5788 for (int j=0; j<tempInt; ++j)
5791 if (!ok)
5792 throw ErrorClass("Error during setBasisStatus (constraints unknown)!");
5793
5794
5795
5796
5797 tempInt = osresult1->getNumberOfOtherConstraintResults(i);
5798 ok &= osresult2->setNumberOfOtherConstraintResults(i,tempInt);
5799 if (!ok)
5800 throw ErrorClass("Error during setNumberOfOtherConstraintResults!");
5801 nOther = tempInt;
5802 for (int j=0; j < nOther; ++j)
5803 {
5804 tempStr = osresult1->getOtherConstraintResultName(i,j);
5805 ok &= osresult2->setOtherConstraintResultName(i,j,tempStr);
5806 if (!ok)
5807 throw ErrorClass("Error during setOtherConstraintResultName!");
5808 tempStr = osresult1->getOtherConstraintResultDescription(i,j);
5809 ok &= osresult2->setOtherConstraintResultDescription(i,j,tempStr);
5810 if (!ok)
5811 throw ErrorClass("Error during setOtherConstraintResultDescription!");
5812 tempStr = osresult1->getOtherConstraintResultValue(i,j);
5813 ok &= osresult2->setOtherConstraintResultValue(i,j,tempStr);
5814 if (!ok)
5815 throw ErrorClass("Error during setOtherConstraintResultValue!");
5816 tempInt = osresult1->getOtherConstraintResultNumberOfCon(i,j);
5817 ok &= osresult2->setOtherConstraintResultNumberOfCon(i,j,tempInt);
5818 if (!ok)
5819 throw ErrorClass("Error during setOtherConstraintResultNumberOfCon!");
5820
5821 nCon = tempInt;
5822 for (int k=0; k < nCon; ++k)
5823 {
5824 tempInt = osresult1->getOtherConstraintResultConIdx(i,j,k);
5825 ok &= osresult2->setOtherConstraintResultConIdx(i,j,k,tempInt);
5826 if (!ok)
5827 throw ErrorClass("Error during setOtherConstraintResultConIdx!");
5828 tempStr = osresult1->getOtherConstraintResultCon(i,j,k);
5829 ok &= osresult2->setOtherConstraintResultCon(i,j,k,tempStr);
5830 if (!ok)
5831 throw ErrorClass("Error during setOtherConstraintResultCon!");
5832 }
5833
5834
5835
5836 int nEnum = osresult1->getOtherConstraintResultNumberOfEnumerations(i,j);
5837 ok &= osresult2->setOtherConstraintResultNumberOfEnumerations(i,j,nEnum);
5838 if (!ok)
5839 throw ErrorClass("Error during setOtherConstraintResultNumberOfEnumerations!");
5840 std::string tempStr1, tempStr2;
5841
5842 for (int k=0; k < nEnum; ++k)
5843 {
5844 tempStr1 = osresult1->getOtherConstraintResultEnumerationValue(i,j,k);
5845 tempStr2 = osresult1->getOtherConstraintResultEnumerationDescription(i,j,k);
5846 tempInt = osresult1->getOtherConstraintResultEnumerationNumberOfEl(i,j,k);
5847 for (int l=0; l<tempInt; ++l)
5848 tempArray[l] = osresult1->getOtherConstraintResultEnumerationEl(i,j,k,l);
5849 ok &= osresult2->setOtherOptionOrResultEnumeration(i,j,
5850 ENUM_PROBLEM_COMPONENT_constraints,k,tempStr1,tempStr2,tempArray,tempInt);
5851
5852 if (!ok)
5853 throw ErrorClass("Error during setOtherConstraintResultEnumeration!");
5854 }
5855 }
5856
5857
5858 tempInt = osresult1->getNumberOfOtherSolutionResults(i);
5859 ok &= osresult2->setNumberOfOtherSolutionResults(i,tempInt);
5860 if (!ok)
5861 throw ErrorClass("Error during setNumberOfOtherSolutionResults!");
5862 nOther = tempInt;
5863 for (int j=0; j < nOther; ++j)
5864 {
5865 tempStr = osresult1->getOtherSolutionResultName(i,j);
5866 ok &= osresult2->setOtherSolutionResultName(i,j,tempStr);
5867 if (!ok)
5868 throw ErrorClass("Error during setOtherSolutionResultName!");
5869 tempStr = osresult1->getOtherSolutionResultCategory(i,j);
5870 ok &= osresult2->setOtherSolutionResultCategory(i,j,tempStr);
5871 if (!ok)
5872 throw ErrorClass("Error during setOtherSolutionResultCategory!");
5873 tempStr = osresult1->getOtherSolutionResultDescription(i,j);
5874 ok &= osresult2->setOtherSolutionResultDescription(i,j,tempStr);
5875 if (!ok)
5876 throw ErrorClass("Error during setOtherSolutionResultDescription!");
5877 tempInt = osresult1->getOtherSolutionResultNumberOfItems(i,j);
5878 ok &= osresult2->setOtherSolutionResultNumberOfItems(i,j,tempInt);
5879 if (!ok)
5880 throw ErrorClass("Error during setOtherSolutionResultNumberOfItems!");
5881
5882 nItem = tempInt;
5883 for (int k=0; k < nItem; ++k)
5884 {
5885 tempStr = osresult1->getOtherSolutionResultItem(i,j,k);
5886 ok &= osresult2->setOtherSolutionResultItem(i,j,k,tempStr);
5887 if (!ok)
5888 throw ErrorClass("Error during setSolutionResultItem!");
5889 }
5890 }
5891 }
5892
5893 tempInt = osresult1->getNumberOfSolverOutputs();
5894 ok &= osresult2->setNumberOfSolverOutputs(tempInt);
5895 if (!ok)
5896 throw ErrorClass("Error during setNumberOfSolverOutputs!");
5897 nOther = tempInt;
5898 for (int i=0; i < nOther; ++i)
5899 {
5900 tempStr = osresult1->getSolverOutputName(i);
5901 ok &= osresult2->setSolverOutputName(i,tempStr);
5902 if (!ok)
5903 throw ErrorClass("Error during setSolverOutputName!");
5904 tempStr = osresult1->getSolverOutputCategory(i);
5905 ok &= osresult2->setSolverOutputCategory(i,tempStr);
5906 if (!ok)
5907 throw ErrorClass("Error during setSolverOutputCategory!");
5908 tempStr = osresult1->getSolverOutputDescription(i);
5909 ok &= osresult2->setSolverOutputDescription(i,tempStr);
5910 if (!ok)
5911 throw ErrorClass("Error during setSolverOutputDescription!");
5912 tempInt = osresult1->getSolverOutputNumberOfItems(i);
5913 ok &= osresult2->setSolverOutputNumberOfItems(i,tempInt);
5914 if (!ok)
5915 throw ErrorClass("Error during setSolverOutputNumberOfItems!");
5916 for (int j=0; j < tempInt; ++j)
5917 {
5918 tempStr = osresult1->getSolverOutputItem(i,j);
5919 ok &= osresult2->setSolverOutputItem(i,j,tempStr);
5920 if (!ok)
5921 throw ErrorClass("Error during setSolverOutputItem!");
5922 }
5923 }
5924
5925
5926 ok &= osresult1->IsEqual(osresult2);
5927 if (!ok)
5928 throw ErrorClass("Error duplicating OSResult object using get() and set() methods");
5929
5930 if (osrlwriter != NULL) delete osrlwriter;
5931 osrlwriter = NULL;
5932 if (osrlreader != NULL) delete osrlreader;
5933 osrlreader = NULL;
5934 if (osresult1 != NULL) delete osresult1;
5935 osresult1 = NULL;
5936 if (osresult2 != NULL) delete osresult2;
5937 osresult2 = NULL;
5938// if (osresult != NULL) delete osresult;
5939// osresult = NULL;
5940 if (tempArray != NULL) delete[] tempArray;
5941 tempArray = NULL;
5942
5943 unitTestResult << "TEST " << nOfTest << ": Successful test of OSrL tools" << std::endl;
5944 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
5945 }
5946
5947 catch(const ErrorClass& eclass)
5948 {
5949 cout << endl << endl << endl;
5950 if (osrlwriter != NULL) delete osrlwriter;
5951 osrlwriter = NULL;
5952 if (osrlreader != NULL) delete osrlreader;
5953 osrlreader = NULL;
5954 if (osresult1 != NULL) delete osresult1;
5955 osresult1 = NULL;
5956 if (osresult2 != NULL) delete osresult2;
5957
5958 osresult2 = NULL;
5959// if (osresult != NULL) delete osresult;
5960// osresult = NULL;
5961 if (tempArray != NULL) delete[] tempArray;
5962 tempArray = NULL;
5963 // " Problem with the test reading OSoL data";
5964 unitTestResultFailure << eclass.errormsg << endl;
5965 unitTestResultFailure << "Test " << nOfTest << ": There was a failure in the test of OSrL get() methods" << endl;
5966 }
5967
5968 // Now test the OSrL parser
5969 try{
5980 cout << endl << "TEST " << ++nOfTest << ": OSrL parser" << endl << endl;
5981
5982 osrlwriter = new OSrLWriter();
5983 osrlreader = new OSrLReader();
5984 fileUtil = new FileUtil();
5985
5986 std::string tmpOSrL;
5987 clock_t start, finish;
5988 double duration;
5989 std::string osrl;
5990 cout << "Test parsing an OSrL file" << endl;
5991 cout << "First read the OSrL file into a string" << endl;
5992 osrlFileName = dataDir + "osrlFiles" + dirsep + "parserTest.osrl";
5993 start = clock();
5994 osrl = fileUtil->getFileAsString( osrlFileName.c_str() );
5995 finish = clock();
5996 duration = (double) (finish - start) / CLOCKS_PER_SEC;
5997 cout << "Reading the file into a string took (seconds): "<< duration << endl;
5998 cout << osrl << endl;
5999 start = clock();
6000 cout << "PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
6001 osresult = osrlreader->readOSrL( osrl);
6002 cout << "Finished read; write OSResult object to temporary string" << endl;
6003
6004 tmpOSrL = osrlwriter->writeOSrL( osresult);
6005
6006 cout << tmpOSrL << endl;
6007
6008
6009 // make sure we can parse without error
6010 delete osrlreader;
6011 osrlreader = new OSrLReader();
6012 osrlreader->readOSrL( tmpOSrL);
6013
6014 delete osrlwriter;
6015 osrlwriter = NULL;
6016 delete osrlreader;
6017 osrlreader = NULL;
6018 delete fileUtil;
6019 fileUtil = NULL;
6020
6021if (THOROUGH)
6022{
6023 // now a second example -- this one has errors. Make sure they are reported correctly
6024 cout << endl << "Test parsing another OSrL file" << endl;
6025 osrlwriter = new OSrLWriter();
6026 osrlreader = new OSrLReader();
6027 cout << "FIRST READ THE OSrL FILE INTO A STRING" << endl;
6028 //errorExample.osrl -- check to see if we read an error message correctly;
6029 osrlFileName = dataDir + "osrlFiles" + dirsep + "errorExample.osrl";
6030 osrl = fileUtil->getFileAsString( osrlFileName.c_str() );
6031 finish = clock();
6032 duration = (double) (finish - start) / CLOCKS_PER_SEC;
6033 cout << "Reading the file into a string took (seconds): "<< duration << endl;
6034 cout << "PARSE THE OSRL STRING INTO AN OSRESULT OBJECT" << endl;
6035 osresult = osrlreader->readOSrL( osrl);
6036 tmpOSrL = osrlwriter->writeOSrL( osresult) ;
6037 delete osrlreader;
6038 osrlreader = new OSrLReader();
6039 osrlreader->readOSrL( tmpOSrL);
6040 delete osrlwriter;
6041 osrlwriter = NULL;
6042 delete osrlreader;
6043 osrlreader = NULL;
6044}
6045 unitTestResult <<
6046 "TEST " << nOfTest << ": Successful test of OSrL parser on file parserTest.osrl"
6047 << std::endl;
6048 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6049 }
6050 catch(const ErrorClass& eclass)
6051 {
6052 unitTestResultFailure << eclass.errormsg << endl;
6053 unitTestResultFailure << "Test " << nOfTest << ": There was a failure in the test for reading OSrL" << endl;
6054
6055 if(osrlwriter != NULL) delete osrlwriter;
6056 osrlwriter = NULL;
6057 if(osrlreader != NULL) delete osrlreader;
6058 osrlreader = NULL;
6059 if (fileUtil != NULL)
6060 delete fileUtil;
6061 fileUtil = NULL;
6062 }
6063
6064 if (intArray !=NULL)
6065 {
6066 delete[] intArray;
6067 intArray = NULL;
6068 }
6069
6070} // end #if PARSER_TESTS
6071
6072
6073if (SOLVER_TESTS){
6074 try{
6075 cout << endl << "TEST " << ++nOfTest << ": Clp solver on parincLinearByRow.osil" << endl << endl;
6076
6077 osilreader = new OSiLReader();
6078 osolreader = new OSoLReader();
6079 solver = new CoinSolver();
6080 osilwriter = new OSiLWriter();
6081 osrlreader = new OSrLReader();
6082 fileUtil = new FileUtil();
6083
6084 ok = true;
6085 std::cout << "create a new COIN Clp for OSiL string solution" << std::endl;
6086 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinearByRow.osil";
6087 osolFileName = dataDir + "osolFiles" + dirsep + "parincLinearByRow_clp.osol";
6088 osil = fileUtil->getFileAsString( osilFileName.c_str());
6089 osol = fileUtil->getFileAsString( osolFileName.c_str());
6090
6091 solver->sSolverName = "clp";
6092 solver->osinstance = osilreader->readOSiL( osil);
6093 std::cout << " Done reading the OSiL" << std::endl;
6094 // now write it again as a string
6095 osilwriter->m_bWhiteSpace = true;
6096 std::cout << " Write the OSiL" << std::endl;
6097 osil = osilwriter->writeOSiL( solver->osinstance) ;
6098 //std::cout << osil << std::endl;
6099 std::cout << " Done writing the OSiL" << std::endl;
6100 solver->osoption = osolreader->readOSoL( osol);
6101 cout << "call the COIN - clp Solver for parincLinearbyRow" << endl;
6102 //solver->buildSolverInstance();
6103 std::cout << "call solver" << std::endl;
6104 solver->solve();
6105 std::cout << "returned from solver" << std::endl;
6106 check = 7668;
6107 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6108 if (ok)
6109 {
6110#ifdef DEBUG
6111 cout << solver->osrl << endl;
6112#endif
6113 cout << "COIN clp solver solution for parincLinearByRow checks." << endl;
6114 }
6115 else
6116 { cout << "COIN clp solver solution for parincLinearByRow in error:" << endl;
6117 cout << solver->osrl << endl;
6118 }
6119 if(ok == false) throw ErrorClass(" Fail unit test with clp on parincLinearByRow.osil");
6120 // parse the osrl file
6121#ifdef DEBUG
6122 cout << "\nThe osrl file:\n" << solver->osrl << endl;
6123 cout << "Start parsing the file" << endl;
6124#endif
6125 osrlreader->readOSrL( solver->osrl);
6126#ifdef DEBUG
6127 cout << "read successfully" << endl;
6128#endif
6129 delete osilreader;
6130 osilreader = NULL;
6131#ifdef DEBUG
6132 cout << "osilreader successfully deleted" << endl;
6133#endif
6134 delete osolreader;
6135 osolreader = NULL;
6136#ifdef DEBUG
6137 cout << "osolreader successfully deleted" << endl;
6138#endif
6139 delete solver;
6140 solver = NULL;
6141#ifdef DEBUG
6142 cout << "solver successfully deleted" << endl;
6143#endif
6144 delete osilwriter;
6145 osilwriter = NULL;
6146#ifdef DEBUG
6147 cout << "osilwriter successfully deleted" << endl;
6148#endif
6149 delete osrlreader;
6150 osrlreader = NULL;
6151#ifdef DEBUG
6152 cout << "osrlreader successfully deleted" << endl;
6153#endif
6154 delete fileUtil;
6155 fileUtil = NULL;
6156
6157 unitTestResult << "TEST " << nOfTest << ": Solved problem parincLinearByRow.osil with Clp" << std::endl;
6158 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6159 }
6160 catch(const ErrorClass& eclass)
6161 {
6162 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Clp Solver:"
6163 << endl << eclass.errormsg<< endl;
6164
6165 if (osilreader != NULL)
6166 delete osilreader;
6167 osilreader = NULL;
6168 if (osolreader != NULL)
6169 delete osolreader;
6170 osolreader = NULL;
6171 if (solver != NULL)
6172 delete solver;
6173 solver = NULL;
6174 if (osilwriter != NULL)
6175 delete osilwriter;
6176 osilwriter = NULL;
6177 if (osrlreader != NULL)
6178 delete osrlreader;
6179 osrlreader = NULL;
6180 if (fileUtil != NULL)
6181 delete fileUtil;
6182 fileUtil = NULL;
6183 }
6184
6185 CoinSolver *cSolver = new CoinSolver();
6186 try
6187 {
6188 cout << endl << "TEST " << ++nOfTest << ": Clp warmstart tests with parincLinear.osil" << endl << endl;
6189
6190/* we test
6191 * 1. simply sizing the warmstart
6192 * 2. putting a complete advanced basis
6193 * 3. putting a partial basis
6194 * 4. giving unusual statuses
6195 * 5. over-saturating the basis
6196 * 6. retrieving the optimal basis and using it as a start
6197 */
6198 fileUtil = new FileUtil();
6199 int* bv;
6200 int* bc;
6201
6202 ok = true;
6203
6204 std::cout << "simply size the warmstart" << std::endl;
6205 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
6206
6207 cSolver->sSolverName = "clp";
6208 cSolver->osil = fileUtil->getFileAsString( osilFileName.c_str());
6209 cSolver->osoption = new OSOption();
6210 cSolver->osoption->optimization = new OptimizationOption();
6211 cSolver->osoption->optimization->variables = new VariableOption();
6215 ok &= cSolver->osoption->setAnotherSolverOption("primalSimplex", "true", "osi", "", "bool", "");
6216
6217 std::cout << "call the COIN - clp Solver for parincLinear" << std::endl;
6218 cSolver->solve();
6219 std::cout << "returned from solver" << std::endl;
6220 check = 7668;
6221 ok &= ( fabs(check - getObjVal( cSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL);
6222 std::cout << "initial solution took " << getItCount(cSolver->osrl) << " iterations" << std::endl;
6223// ok &= ( getItCount(cSolver->osrl) == 2);
6224 if (ok)
6225 {
6226 cout << "COIN clp solver interface passes initial warmstart test." << endl;
6227 }
6228 else
6229 {
6230 cout << "COIN clp solver interface warmstart error:" << endl;
6231 cout << cSolver->osrl << endl;
6232 }
6233
6234 if(ok == false) throw ErrorClass(" Fail unit test with clp warmstarts on parincLinear.osil");
6235 delete cSolver;
6236
6237 std::cout << std::endl << "put a complete advanced basis" << std::endl;
6238 cSolver = new CoinSolver();
6239 cSolver->sSolverName = "clp";
6240 cSolver->osil = fileUtil->getFileAsString( osilFileName.c_str());
6241 cSolver->osoption = new OSOption();
6242 cSolver->osoption->optimization = new OptimizationOption();
6243 cSolver->osoption->optimization->variables = new VariableOption();
6247
6248 bv = new int[2];
6249 bv[0] = 0;
6250 bv[1] = 1;
6253 delete [] bv;
6254
6255 bc = new int[1];
6256 bc[0] = 2;
6258 bc[0] = 3;
6260 delete [] bc;
6261
6262 if(ok == false) throw ErrorClass(" Fail setting warmstart advanced basis for clp");
6263
6264 std::cout << "call the COIN - clp Solver" << std::endl;
6265 cSolver->solve();
6266 std::cout << "returned from solver" << std::endl;
6267 check = 7668;
6268 ok &= ( fabs(check - getObjVal( cSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL);
6269 std::cout << "warmstart solution took " << getItCount(cSolver->osrl) << " iterations" << std::endl;
6270// ok &= ( getItCount(cSolver->osrl) == 3);
6271
6272 if (ok)
6273 {
6274 cout << "COIN clp solver interface passes complete basis warmstart test." << endl;
6275 }
6276 else
6277 {
6278 cout << "COIN clp solver interface warmstart error:" << endl;
6279 cout << cSolver->osrl << endl;
6280 }
6281
6282 if(ok == false) throw ErrorClass(" Fail unit test with clp warmstarts on parincLinear.osil");
6283 delete cSolver;
6284
6285
6286 std::cout << std::endl << "put a partial basis" << std::endl;
6287 cSolver = new CoinSolver();
6288 cSolver->sSolverName = "clp";
6289 cSolver->osil = fileUtil->getFileAsString( osilFileName.c_str());
6290 cSolver->osoption = new OSOption();
6291 cSolver->osoption->optimization = new OptimizationOption();
6292 cSolver->osoption->optimization->variables = new VariableOption();
6296
6297 bv = new int[1];
6298 bv[0] = 1;
6300 bv[0] = 2;
6302 delete [] bv;
6303
6304 if(ok == false) throw ErrorClass(" Fail setting warmstart partial basis for clp");
6305 std::cout << "call the COIN - clp Solver" << std::endl;
6306 cSolver->solve();
6307 std::cout << "returned from solver" << std::endl;
6308 check = 7668;
6309 ok &= ( fabs(check - getObjVal( cSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL);
6310 std::cout << "warmstart solution took " << getItCount(cSolver->osrl) << " iterations" << std::endl;
6311// ok &= ( getItCount(cSolver->osrl) == 4);
6312 if (ok)
6313 {
6314 cout << "COIN clp solver interface passes partial basis warmstart test." << endl;
6315 }
6316 else
6317 {
6318 cout << "COIN clp solver interface warmstart error:" << endl;
6319 cout << cSolver->osrl << endl;
6320 }
6321
6322 if(ok == false) throw ErrorClass(" Fail unit test with clp warmstarts on parincLinear.osil");
6323 delete cSolver;
6324
6325
6326 std::cout << std::endl << "test unusual basis statuses" << std::endl;
6327 cSolver = new CoinSolver();
6328 cSolver->sSolverName = "clp";
6329 cSolver->osil = fileUtil->getFileAsString( osilFileName.c_str());
6330 cSolver->osoption = new OSOption();
6331 cSolver->osoption->optimization = new OptimizationOption();
6332 cSolver->osoption->optimization->variables = new VariableOption();
6336
6337 bv = new int[2];
6338 bv[0] = 0;
6339 bv[1] = 1;
6342 delete [] bv;
6343
6344 bc = new int[1];
6345 bc[0] = 2;
6347 bc[0] = 3;
6349 delete [] bc;
6350
6351 if(ok == false) throw ErrorClass(" Fail setting unusual basis statuses for clp");
6352 std::cout << "call the COIN - clp Solver" << std::endl;
6353 cSolver->solve();
6354 std::cout << "returned from solver" << std::endl;
6355 check = 7668;
6356 ok &= ( fabs(check - getObjVal( cSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL);
6357 std::cout << "warmstart solution took " << getItCount(cSolver->osrl) << " iterations" << std::endl;
6358// ok &= ( getItCount(cSolver->osrl) == 2);
6359 if (ok)
6360 {
6361 cout << "COIN clp solver interface passes unusual basis warmstart test." << endl;
6362 }
6363 else
6364 {
6365 cout << "COIN clp solver interface warmstart error:" << endl;
6366 cout << cSolver->osrl << endl;
6367 }
6368
6369 if(ok == false) throw ErrorClass(" Fail unit test with clp warmstarts on parincLinear.osil");
6370 delete cSolver;
6371
6372 std::cout << std::endl << "test over-saturated basis" << std::endl;
6373 cSolver = new CoinSolver();
6374 cSolver->sSolverName = "clp";
6375 cSolver->osil = fileUtil->getFileAsString( osilFileName.c_str());
6376 cSolver->osoption = new OSOption();
6377 cSolver->osoption->optimization = new OptimizationOption();
6378 cSolver->osoption->optimization->variables = new VariableOption();
6382
6383 bv = new int[2];
6384 bv[0] = 0;
6385 bv[1] = 1;
6386 bc = new int[4];
6387 bc[0] = 3;
6388 bc[1] = 1;
6389 bc[2] = 0;
6390 bc[3] = 2;
6393 delete [] bv;
6394 delete [] bc;
6395
6396 if(ok == false) throw ErrorClass(" Fail setting over-saturated basis for clp");
6397 std::cout << "call the COIN - clp Solver" << std::endl;
6398 cSolver->solve();
6399 std::cout << "returned from solver" << std::endl;
6400 check = 7668;
6401 ok &= ( fabs(check - getObjVal( cSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL);
6402 std::cout << "warmstart solution took " << getItCount(cSolver->osrl) << " iterations" << std::endl;
6403// ok &= ( getItCount(cSolver->osrl) == 3);
6404 if (ok)
6405 {
6406 cout << "COIN clp solver interface passes over-saturated basis warmstart test." << endl;
6407 }
6408 else
6409 {
6410 cout << "COIN clp solver interface warmstart error:" << endl;
6411 cout << cSolver->osrl << endl;
6412 }
6413 if(ok == false) throw ErrorClass(" Fail unit test with clp warmstarts on parincLinear.osil");
6414 delete cSolver;
6415
6416 std::cout << std::endl << "test using optimal basis" << std::endl;
6417 cSolver = new CoinSolver();
6418 cSolver->sSolverName = "clp";
6419 cSolver->osil = fileUtil->getFileAsString( osilFileName.c_str());
6420 cSolver->osoption = new OSOption();
6421 cSolver->osoption->optimization = new OptimizationOption();
6422 cSolver->osoption->optimization->variables = new VariableOption();
6426
6427 bv = new int[2];
6428 bv[0] = 0;
6429 bv[1] = 1;
6431 bv[0] = 1;
6432 bv[1] = 3;
6434 bv[0] = 0;
6435 bv[1] = 2;
6437 delete [] bv;
6438
6439 double* iv = new double[2];
6440 iv[0] = 539.9999999999999;
6441 iv[1] = 252.0000000000001;
6442 ok &= cSolver->osoption->setInitVarValuesDense(2,iv);
6443 if (!ok) throw ErrorClass(" Fail setting starting values during warmstart tests");
6444 delete [] iv;
6445
6446 std::cout << "call the COIN - clp Solver" << std::endl;
6447 cSolver->solve();
6448 std::cout << "returned from solver" << std::endl;
6449 check = 7668;
6450 ok &= ( fabs(check - getObjVal( cSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL);
6451 std::cout << "solve from optimal solution took " << getItCount(cSolver->osrl) << " iterations" << std::endl;
6452 ok &= ( getItCount(cSolver->osrl) == 0);
6453
6454 if (ok)
6455 {
6456 cout << "COIN clp solver interface passes warmstart from optimal basis." << endl;
6457 }
6458 else
6459 {
6460 cout << "COIN clp solver interface warmstart error:" << endl;
6461 cout << cSolver->osrl << endl;
6462 }
6463
6464 cout << cSolver->osrl << endl;
6465 if(ok == false) throw ErrorClass(" Fail unit test with clp warmstarts on parincLinear.osil");
6466
6467 delete cSolver;
6468 cSolver = NULL;
6469#ifdef DEBUG
6470 cout << "solver successfully deleted" << endl;
6471#endif
6472 delete fileUtil;
6473 fileUtil = NULL;
6474
6475 unitTestResult << "TEST " << nOfTest << ": Warmstarts for problem parincLinear.osil with Clp" << std::endl;
6476 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6477 }
6478 catch(const ErrorClass& eclass)
6479 {
6480 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Clp Solver Warmstarts:"
6481 << endl << eclass.errormsg<< endl;
6482
6483 if (cSolver != NULL)
6484 delete cSolver;
6485 cSolver = NULL;
6486 if (fileUtil != NULL)
6487 delete fileUtil;
6488 fileUtil = NULL;
6489 }
6490
6491#if 0
6492 try{
6493 // solve another problem
6494 // a problem that is a pure quadratic
6495 cout << endl << "TEST " << ++nOfTest << ": Clp solver on parincQuadratic.osil" << endl << endl;
6496 cout << "create a new Clp Solver for OSiL string solution" << endl;
6497
6498 fileUtil = new FileUtil();
6499 osilreader = new OSiLReader();
6500 solver = new CoinSolver();
6501
6502 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
6503 osil = fileUtil->getFileAsString( osilFileName.c_str());
6504 osol = "";
6505 solver->osinstance = osilreader->readOSiL( osil);
6506 solver->osil = osil;
6507 cout << "call the clp Solver" << endl;
6508 solver->buildSolverInstance();
6509 solver->solve();
6510 check = 49920.5;
6511 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6512 if (ok)
6513 {
6514#ifdef DEBUG
6515 cout << solver->osrl << endl;
6516#endif
6517 cout << "Clp solver solution for parincQuadratic checks." << endl;
6518 }
6519 else
6520 { cout << "Clp solver solution for parincQuadratic in error:" << endl;
6521 cout << solver->osrl << endl;
6522 }
6523 if(ok == false) throw ErrorClass(" Fail unit test with Clp on parincQuadradic.osil");
6524 delete osilreader;
6525 osilreader = NULL;
6526 delete solver;
6527 solver = NULL;
6528 delete fileUtil;
6529 fileUtil = NULL;
6530 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with Clp" << std::endl;
6531 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6532 }
6533 catch(const ErrorClass& eclass)
6534 {
6535 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Clp Solver:"
6536 << endl << eclass.errormsg<< endl;
6537 if (osilreader != NULL)
6538 delete osilreader;
6539 osilreader = NULL;
6540 if (solver != NULL)
6541 delete solver;
6542 solver = NULL;
6543 if (fileUtil != NULL)
6544 delete fileUtil;
6545 fileUtil = NULL;
6546 }
6547#endif
6548
6549 // now solve another problem -- try an integer program
6550 try{
6551 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0033.osil" << endl << endl;
6552
6553 fileUtil = new FileUtil();
6554 osilreader = new OSiLReader();
6555 osolreader = new OSoLReader();
6556 solver = new CoinSolver();
6557
6558 std::cout << "create a new COIN Cbc for OSiL string solution" << std::endl;
6559 ok = true;
6560 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
6561 //osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cbc.osol";
6562 osil = fileUtil->getFileAsString( osilFileName.c_str());
6563 //osol = fileUtil->getFileAsString( osolFileName.c_str());
6564 osol = "";
6565 solver->sSolverName ="cbc";
6566 solver->osil = osil;
6567 solver->osol = osol;
6568 solver->osinstance = NULL;
6569 solver->osoption = NULL;
6570 cout << "call the COIN - Cbc Solver for p0033" << endl;
6571 solver->buildSolverInstance();
6572 solver->solve();
6573 check = 3089;
6574 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6575 if (ok)
6576 {
6577#ifdef DEBUG
6578 cout << solver->osrl << endl;
6579#endif
6580 cout << "Coin cbc solution for p0033 checks" << endl;
6581 }
6582 else
6583 { cout << "Coin cbc solution for p0033 in error:" << endl;
6584 cout << solver->osrl << endl;
6585 }
6586 if (ok == false) throw ErrorClass(" Fail unit test with Cbc on p0033.osil");
6587 delete solver;
6588 solver = NULL;
6589
6590 delete osilreader;
6591 osilreader = NULL;
6592 delete osolreader;
6593 osolreader = NULL;
6594 delete fileUtil;
6595 fileUtil = NULL;
6596 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with Cbc" << std::endl;
6597 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6598 }
6599 catch(const ErrorClass& eclass)
6600 {
6601 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Cbc Solver:"
6602 << endl << eclass.errormsg<< endl;
6603 if (solver != NULL)
6604 delete solver;
6605 solver = NULL;
6606 if (osilreader != NULL)
6607 delete osilreader;
6608 osilreader = NULL;
6609 if (osolreader != NULL)
6610 delete osolreader;
6611 osolreader = NULL;
6612 if (fileUtil != NULL)
6613 delete fileUtil;
6614 fileUtil = NULL;
6615 }
6616
6617if( THOROUGH == true){
6618
6619 // now solve the same problem with a different instance representation --- using mult and incr
6620 try{
6621 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0033MULT.osil" << endl << endl;
6622
6623 osilreader = new OSiLReader();
6624 osolreader = new OSoLReader();
6625 solver = new CoinSolver();
6626 fileUtil = new FileUtil();
6627
6628 std::cout << "create a new COIN Cbc for OSiL string solution" << std::endl;
6629 ok = true;
6630 osilFileName = dataDir + "osilFiles" + dirsep + "p0033MULT.osil";
6631 //osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cbc.osol";
6632 osil = fileUtil->getFileAsString( osilFileName.c_str());
6633 //osol = fileUtil->getFileAsString( osolFileName.c_str());
6634 osol = "";
6635 solver->sSolverName ="cbc";
6636 solver->osil = osil;
6637 solver->osol = osol;
6638 solver->osinstance = NULL;
6639 solver->osoption = NULL;
6640 cout << "call the COIN - Cbc Solver for p0033MULT" << endl;
6641 solver->buildSolverInstance();
6642 solver->solve();
6643 check = 3089;
6644 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6645 if (ok)
6646 {
6647#ifdef DEBUG
6648 cout << solver->osrl << endl;
6649#endif
6650 cout << "Coin cbc solution for p0033MULT checks" << endl;
6651 }
6652 else
6653 { cout << "Coin cbc solution for p0033MULT in error:" << endl;
6654 cout << solver->osrl << endl;
6655 }
6656 if (ok == false) throw ErrorClass(" Fail unit test with Cbc on p0033MULT.osil");
6657 delete solver;
6658 solver = NULL;
6659 delete osilreader;
6660 osilreader = NULL;
6661 delete osolreader;
6662 osolreader = NULL;
6663 delete fileUtil;
6664 fileUtil = NULL;
6665 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033MULT.osil with Cbc" << std::endl;
6666 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6667 }
6668 catch(const ErrorClass& eclass)
6669 {
6670 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Cbc Solver:"
6671 << endl << eclass.errormsg<< endl;
6672 if (solver != NULL)
6673 delete solver;
6674 solver = NULL;
6675 if (osilreader != NULL)
6676 delete osilreader;
6677 osilreader = NULL;
6678 if (osolreader != NULL)
6679 delete osolreader;
6680 osolreader = NULL;
6681 if (fileUtil != NULL)
6682 delete fileUtil;
6683 fileUtil = NULL;
6684 }
6685
6686
6687 // now test p0201.osil
6688 try{
6689 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0033.osil - node limit set" << endl << endl;
6690
6691 fileUtil = new FileUtil();
6692 osilreader = new OSiLReader();
6693 osolreader = new OSoLReader();
6694 solver = new CoinSolver();
6695
6696 ok = true;
6697 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
6698 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cbc.osol";
6699 osil = fileUtil->getFileAsString( osilFileName.c_str());
6700 osol = fileUtil->getFileAsString( osolFileName.c_str());
6701 solver->sSolverName ="cbc";
6702 solver->osil = osil;
6703 solver->osol = osol;
6704 solver->osinstance = NULL;
6705 solver->osoption = NULL;
6706 cout << "call the COIN - Cbc Solver for p0033" << endl;
6707 solver->buildSolverInstance();
6708 solver->solve();
6709 //cout << "Here is the COIN Cbc solver solution for p0033" << endl;
6710 //cout << solver->osrl << endl;
6711 if( solver->osrl.find("node limit reached") != std::string::npos)
6712 ok = true;
6713 else
6714 ok = false;
6715 if (ok == false) throw ErrorClass(" node limit option on p0033.osil not processed properly");
6716 delete solver;
6717 solver = NULL;
6718 delete osilreader;
6719 osilreader = NULL;
6720 delete osolreader;
6721 osolreader = NULL;
6722 delete fileUtil;
6723 fileUtil = NULL;
6724 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with Cbc node limit" << std::endl;
6725 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6726 }
6727 catch(const ErrorClass& eclass)
6728 {
6729 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Cbc Solver:"
6730 << endl << eclass.errormsg<< endl;
6731 if (solver != NULL)
6732 delete solver;
6733 solver = NULL;
6734 if (osilreader != NULL)
6735 delete osilreader;
6736 osilreader = NULL;
6737 if (osolreader != NULL)
6738 delete osolreader;
6739 osolreader = NULL;
6740 if (fileUtil != NULL)
6741 delete fileUtil;
6742 fileUtil = NULL;
6743 }
6744
6745
6746 try{
6747 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on p0201.osil" << endl << endl;
6748
6749 fileUtil = new FileUtil();
6750 osilreader = new OSiLReader();
6751 osolreader = new OSoLReader();
6752 solver = new CoinSolver();
6753
6754 ok = true;
6755 osilFileName = dataDir + "osilFiles" + dirsep + "p0201.osil";
6756 osolFileName = dataDir + "osolFiles" + dirsep + "p0201_cbc.osol";
6757 osil = fileUtil->getFileAsString( osilFileName.c_str());
6758 osol = fileUtil->getFileAsString( osolFileName.c_str());
6759 solver->sSolverName ="cbc";
6760 solver->osil = osil;
6761 solver->osol = osol;
6762 solver->osinstance = NULL;
6763 solver->osoption = NULL;
6764 cout << "call the COIN - Cbc Solver for p0201" << endl;
6765 solver->solve();
6766 cout << "Here is the COIN Cbc solver solution for p0201" << endl;
6767 std::cout << solver->osrl << std::endl;
6768 check = 7615;
6769 // we put a node limit in, so we should not find 7615
6770 // check that the node limit was found
6771 string::size_type pos;
6772 pos = solver->osrl.find( "node limit");
6773 if(pos == std::string::npos) throw ErrorClass(" Error with p0201 on Cbc");
6774 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
6775 //ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6776 //if(ok == false) throw ErrorClass(" Fail unit test with Cbc on p0201.osil");
6777 delete solver;
6778 solver = NULL;
6779 delete osilreader;
6780 osilreader = NULL;
6781 delete osolreader;
6782 osolreader = NULL;
6783 delete fileUtil;
6784 fileUtil = NULL;
6785 unitTestResult << "TEST " << nOfTest << ": Solved problem p0201.osil with Cbc" << std::endl;
6786 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6787 }
6788 catch(const ErrorClass& eclass)
6789 {
6790 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Cbc Solver:"
6791 << endl << eclass.errormsg<< endl;
6792 if (solver != NULL)
6793 delete solver;
6794 solver = NULL;
6795 if (osilreader != NULL)
6796 delete osilreader;
6797 osilreader = NULL;
6798 if (osolreader != NULL)
6799 delete osolreader;
6800 osolreader = NULL;
6801 if (fileUtil != NULL)
6802 delete fileUtil;
6803 fileUtil = NULL;
6804 }
6805
6806 try{
6807 cout << endl << "TEST " << ++nOfTest << ": Cbc solver on parincInteger.osil" << endl << endl;
6808
6809 fileUtil = new FileUtil();
6810 osilreader = new OSiLReader();
6811 osolreader = new OSoLReader();
6812 solver = new CoinSolver();
6813
6814 ok = true;
6815 osilFileName = dataDir + "osilFiles" + dirsep + "parincInteger.osil";
6816 osolFileName = dataDir + "osolFiles" + dirsep + "parincInteger_cbc.osol";
6817 osil = fileUtil->getFileAsString( osilFileName.c_str());
6818 osol = fileUtil->getFileAsString( osolFileName.c_str());
6819 solver->sSolverName ="cbc";
6820 cout << "parse OSiL file" << endl;
6821 solver->osinstance = osilreader->readOSiL( osil);
6822 solver->osol = osol;
6823 cout << "call the COIN - Cbc Solver for parincInteger" << endl;
6824// solver->buildSolverInstance();
6825 solver->solve();
6826 check = 7668;
6827 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6828 if (ok)
6829 {
6830#ifdef DEBUG
6831 cout << solver->osrl << endl;
6832#endif
6833 cout << "COIN cbc solver solution for parincInteger checks." << endl;
6834
6835
6836 }
6837 else
6838 { cout << "COIN cbc solver solution for parincInteger in error:" << endl;
6839 cout << solver->osrl << endl;
6840 }
6841 if(ok == false) throw ErrorClass(" Fail unit test with Cbc on parincInteger.osil");
6842 delete osilreader;
6843 osilreader = NULL;
6844 delete osolreader;
6845 osolreader = NULL;
6846 delete solver;
6847 solver = NULL;
6848 delete fileUtil;
6849 fileUtil = NULL;
6850 unitTestResult << "TEST " << nOfTest << ": Solved problem parincInteger.osil with Cbc" << std::endl;
6851 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6852 }
6853 catch(const ErrorClass& eclass)
6854 {
6855 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Cbc Solver:"
6856 << endl << eclass.errormsg<< endl;
6857 if (solver != NULL)
6858 delete solver;
6859 solver = NULL;
6860 if (osilreader != NULL)
6861 delete osilreader;
6862 osilreader = NULL;
6863 if (osolreader != NULL)
6864 delete osolreader;
6865 osolreader = NULL;
6866 if (fileUtil != NULL)
6867 delete fileUtil;
6868 fileUtil = NULL;
6869 }
6870} // end of if(THOROUGH)
6871
6872#ifdef COIN_HAS_SYMPHONY
6873 try{
6874 cout << endl << "TEST " << ++nOfTest << ": SYMPHONY solver on p0033.osil" << endl << endl;
6875
6876 fileUtil = new FileUtil();
6877 osolreader = new OSoLReader();
6878 solver = new CoinSolver();
6879
6880 ok = true;
6881 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
6882 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_sym.osol";
6883 osil = fileUtil->getFileAsString( osilFileName.c_str());
6884 osol = fileUtil->getFileAsString( osolFileName.c_str());
6885 solver->sSolverName = "symphony";
6886 solver->osil = osil;
6887 solver->osinstance = NULL;
6888 solver->osoption = osolreader->readOSoL( osol);
6889 cout << "build the solver instance for COIN - SYMPHONY" << endl;
6890 solver->buildSolverInstance();
6891// cout << "call the COIN - SYMPHONY Solver for p0033" << endl;
6892 solver->solve();
6893 check = 3089;
6894 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
6895 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6896 if (ok)
6897 {
6898#ifdef DEBUG
6899 cout << solver->osrl << endl;
6900#endif
6901 cout << "COIN SYMPHONY solver solution for p0033 checks." << endl;
6902 }
6903 else
6904 { cout << "COIN SYMPHONY solver solution for p0033 in error:" << endl;
6905 cout << solver->osrl << endl;
6906 }
6907 if(ok == false) throw ErrorClass(" Fail unit test with SYMPHONY on p0033.osil");
6908 delete solver;
6909 solver = NULL;
6910 delete osolreader;
6911 osolreader = NULL;
6912 delete fileUtil;
6913 fileUtil = NULL;
6914 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with SYMPHONY" << std::endl;
6915 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6916 }
6917 catch(const ErrorClass& eclass)
6918 {
6919 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the SYMPHONY Solver:"
6920 << endl << eclass.errormsg << endl;
6921 if (solver != NULL)
6922 delete solver;
6923 solver = NULL;
6924 if (osolreader != NULL)
6925 delete osolreader;
6926 osolreader = NULL;
6927 if (fileUtil != NULL)
6928 delete fileUtil;
6929 fileUtil = NULL;
6930 }
6931#endif
6932
6933
6934
6935#ifdef COIN_HAS_DYLP
6936 try{
6937 cout << endl << "TEST " << ++nOfTest << ": DyLP solver on parincLinear.osil" << endl << endl;
6938
6939 fileUtil = new FileUtil();
6940 osilreader = new OSiLReader();
6941 solver = new CoinSolver();
6942
6943 ok = true;
6944 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
6945 osolFileName = dataDir + "osolFiles" + dirsep + "parincLinear_dylp.osol";
6946 osil = fileUtil->getFileAsString( osilFileName.c_str());
6947 osol = fileUtil->getFileAsString( osolFileName.c_str());
6948 solver->sSolverName = "dylp";
6949 solver->osol = osol;
6950 solver->osinstance = osilreader->readOSiL( osil);
6951 cout << "call the COIN - DyLP solver for parincLinear" << endl;
6952 solver->buildSolverInstance();
6953 solver->solve();
6954 check = 7668;
6955 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
6956 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
6957 if (ok)
6958 {
6959#ifdef DEBUG
6960 cout << solver->osrl << endl;
6961#endif
6962 cout << "COIN DyLP solver solution for parincLinear checks." << endl;
6963 }
6964 else
6965 { cout << "COIN DyLP solver solution for parincLinear in error:" << endl;
6966 cout << solver->osrl << endl;
6967 }
6968 if(ok == false) throw ErrorClass(" Fail unit test with DyLP on parincLinear.osil");
6969 delete solver;
6970 solver = NULL;
6971 delete osilreader;
6972 osilreader = NULL;
6973 delete fileUtil;
6974 fileUtil = NULL;
6975 unitTestResult << "TEST " << nOfTest << ": Solved problem parincLinear.osil with DyLP" << std::endl;
6976 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
6977 }
6978 catch(const ErrorClass& eclass)
6979 {
6980 cout << "OSrL = " << solver->osrl << endl;
6981 cout << endl << endl << endl;
6982 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the DyLP Solver:"
6983 << endl << eclass.errormsg << endl;
6984 if (solver != NULL)
6985 delete solver;
6986 solver = NULL;
6987 if (osilreader != NULL)
6988 delete osilreader;
6989 osilreader = NULL;
6990 if (fileUtil != NULL)
6991 delete fileUtil;
6992 fileUtil = NULL;
6993 }
6994#endif
6995
6996
6997#ifdef COIN_HAS_VOL
6998 try{
6999 cout << endl << "TEST " << ++nOfTest << ": Vol solver on volumeTest.osil" << endl << endl;
7000
7001 fileUtil = new FileUtil();
7002 osolreader = new OSoLReader();
7003 solver = new CoinSolver();
7004
7005 ok = true;
7006 osilFileName = dataDir + "osilFiles" + dirsep + "volumeTest.osil";
7007 osolFileName = dataDir + "osolFiles" + dirsep + "volumeTest_vol.osol";
7008 osil = fileUtil->getFileAsString( osilFileName.c_str());
7009 osol = fileUtil->getFileAsString( osolFileName.c_str());
7010 solver->sSolverName = "vol";
7011 solver->osil = osil;
7012 solver->osinstance = NULL;
7013 solver->osoption = osolreader->readOSoL( osol);
7014 cout << "call the COIN - Vol solver for volumeTest" << endl;
7015 solver->buildSolverInstance();
7016 solver->solve();
7017 check = 7;
7018 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
7019 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7020 if (ok)
7021 {
7022#ifdef DEBUG
7023 cout << solver->osrl << endl;
7024#endif
7025 cout << "COIN Vol solver solution for volumeTest checks." << endl;
7026 }
7027 else
7028 { cout << "COIN Vol solver solution for volumeTest in error:" << endl;
7029 cout << solver->osrl << endl;
7030 }
7031 if(ok == false) throw ErrorClass(" Fail unit test with Vol on volumeTest.osil");
7032 delete solver;
7033 solver = NULL;
7034 delete osolreader;
7035 osolreader = NULL;
7036 delete fileUtil;
7037 fileUtil = NULL;
7038 unitTestResult << "TEST " << nOfTest << ": Solved problem volumeTest.osil with Vol" << std::endl;
7039 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7040 }
7041 catch(const ErrorClass& eclass)
7042 {
7043 cout << "OSrL = " << solver->osrl << endl;
7044 cout << endl << endl << endl;
7045 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Vol Solver:"
7046 << endl << eclass.errormsg << endl;
7047 if (solver != NULL)
7048 delete solver;
7049 solver = NULL;
7050 if (osolreader != NULL)
7051 delete osolreader;
7052 osolreader = NULL;
7053 if (fileUtil != NULL)
7054 delete fileUtil;
7055 fileUtil = NULL;
7056 }
7057#endif
7058
7059#ifdef COIN_HAS_GLPK
7060 try{
7061 cout << endl << "TEST " << ++nOfTest << ": GLPK solver on p0033.osil" << endl << endl;
7062
7063 fileUtil = new FileUtil();
7064 osilreader = new OSiLReader();
7065 osolreader = new OSoLReader();
7066 solver = new CoinSolver();
7067
7068 ok = true;
7069 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
7070 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_glpk.osol";
7071 osil = fileUtil->getFileAsString( osilFileName.c_str());
7072 osol = fileUtil->getFileAsString( osolFileName.c_str());
7073 solver->sSolverName = "glpk";
7074 solver->osinstance = osilreader->readOSiL( osil);
7075 solver->osoption = osolreader->readOSoL( osol);
7076 cout << "call the GLPK Solver for p0033" << endl;
7077 solver->buildSolverInstance();
7078 solver->solve();
7079 check = 3089;
7080 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
7081 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7082 if (ok)
7083 {
7084#ifdef DEBUG
7085 cout << solver->osrl << endl;
7086#endif
7087 cout << "GLPK solver solution for p0033 checks." << endl;
7088 }
7089 else
7090 { cout << "GLPK solver solution for p0033 in error:" << endl;
7091 cout << solver->osrl << endl;
7092 }
7093 if(ok == false) throw ErrorClass(" Fail unit test with GLPK on p0033.osil");
7094 delete solver;
7095 solver = NULL;
7096 delete osilreader;
7097 osilreader = NULL;
7098 delete osolreader;
7099 osolreader = NULL;
7100 delete fileUtil;
7101 fileUtil = NULL;
7102 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with GLPK" << std::endl;
7103 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7104 }
7105 catch(const ErrorClass& eclass)
7106 {
7107 cout << "OSrL = " << solver->osrl << endl;
7108 cout << endl << endl << endl;
7109 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Glpk Solver:"
7110 << endl << eclass.errormsg << endl;
7111 if (solver != NULL)
7112 delete solver;
7113 solver = NULL;
7114 if (osilreader != NULL)
7115 delete osilreader;
7116 osilreader = NULL;
7117 if (osolreader != NULL)
7118 delete osolreader;
7119 osolreader = NULL;
7120 if (fileUtil != NULL)
7121 delete fileUtil;
7122 fileUtil = NULL;
7123 }
7124#endif
7125
7126#ifdef COIN_HAS_CPX
7127 try{
7128 cout << endl << "TEST " << ++nOfTest << ": Cplex solver on p0033.osil" << endl << endl;
7129
7130 fileUtil = new FileUtil();
7131 solver = new CoinSolver();
7132
7133 ok = true;
7134 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
7135 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cpx.osol";
7136 osil = fileUtil->getFileAsString( osilFileName.c_str());
7137 osol = fileUtil->getFileAsString( osolFileName.c_str());
7138 solver->sSolverName = "cplex";
7139 solver->osil = osil;
7140 solver->osol = osol;
7141 solver->osinstance = NULL;
7142 cout << "call the CPLEX Solver for p0033" << endl;
7143 solver->buildSolverInstance();
7144 solver->solve();
7145 check = 3089;
7146 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
7147 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7148 if (ok)
7149 {
7150#ifdef DEBUG
7151 cout << solver->osrl << endl;
7152#endif
7153 cout << "CPLEX solver solution for p0033 checks." << endl;
7154 }
7155 else
7156 { cout << "CPLEX solver solution for p0033 in error:" << endl;
7157 cout << solver->osrl << endl;
7158 }
7159 if(ok == false) throw ErrorClass(" Fail unit test with CPLEX on p0033.osil");
7160 delete solver;
7161 solver = NULL;
7162 delete fileUtil;
7163 fileUtil = NULL;
7164 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with CPLEX" << std::endl;
7165 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7166 }
7167 catch(const ErrorClass& eclass)
7168 {
7169 cout << "OSrL = " << solver->osrl << endl;
7170 cout << endl << endl << endl;
7171 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Cplex Solver:"
7172 << endl << eclass.errormsg << endl;
7173 if (solver != NULL)
7174 delete solver;
7175 solver = NULL;
7176 if (fileUtil != NULL)
7177 delete fileUtil;
7178 fileUtil = NULL;
7179 }
7180
7181#if 0
7182 try{
7183 // solve another problem
7184 // a problem that is a pure quadratic
7185 cout << endl << "TEST " << ++nOfTest << ": Cplex solver on parincQuadratic.osil" << endl << endl;
7186 cout << "create a new Cplex Solver for OSiL string solution" << endl;
7187
7188 fileUtil = new FileUtil();
7189 osilreader = new OSiLReader();
7190 solver = new CoinSolver();
7191
7192 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
7193 osil = fileUtil->getFileAsString( osilFileName.c_str());
7194 osol = "";
7195 solver->osinstance = osilreader->readOSiL( osil);
7196 solver->osil = osil;
7197 cout << "call the Cplex Solver" << endl;
7198 solver->buildSolverInstance();
7199 solver->solve();
7200 check = 49920.5;
7201 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7202 if (ok)
7203 {
7204#ifdef DEBUG
7205 cout << solver->osrl << endl;
7206#endif
7207 cout << "Cplex solver solution for parincQuadratic checks." << endl;
7208 }
7209 else
7210 { cout << "Cplex solver solution for parincQuadratic in error:" << endl;
7211 cout << solver->osrl << endl;
7212 }
7213 if(ok == false) throw ErrorClass(" Fail unit test with Cplex on parincQuadradic.osil");
7214 delete osilreader;
7215 osilreader = NULL;
7216 delete solver;
7217 solver = NULL;
7218 delete fileUtil;
7219 fileUtil = NULL;
7220 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with Cplex" << std::endl;
7221 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7222 }
7223 catch(const ErrorClass& eclass)
7224 {
7225 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Cplex Solver:"
7226 << endl << eclass.errormsg<< endl;
7227 if (osilreader != NULL)
7228 delete osilreader;
7229 osilreader = NULL;
7230 if (solver != NULL)
7231 delete solver;
7232 solver = NULL;
7233 if (fileUtil != NULL)
7234 delete fileUtil;
7235 fileUtil = NULL;
7236 }
7237#endif //if 0
7238#endif //ifdef COIN_HAS_CPX
7239
7240
7241#ifdef COIN_HAS_GRB
7242 try{
7243 cout << endl << "TEST " << ++nOfTest << ": Gurobi solver on p0033.osil" << endl << endl;
7244
7245 fileUtil = new FileUtil();
7246 solver = new CoinSolver();
7247
7248 ok = true;
7249 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
7250 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cpx.osol";
7251 osil = fileUtil->getFileAsString( osilFileName.c_str());
7252 osol = fileUtil->getFileAsString( osolFileName.c_str());
7253 solver->sSolverName = "gurobi";
7254 solver->osil = osil;
7255 solver->osol = osol;
7256 solver->osinstance = NULL;
7257 cout << "call the Gurobi Solver for p0033" << endl;
7258 solver->buildSolverInstance();
7259 solver->solve();
7260 check = 3089;
7261 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
7262 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7263 if (ok)
7264 {
7265#ifdef DEBUG
7266 cout << solver->osrl << endl;
7267#endif
7268 cout << "Gurobi solver solution for p0033 checks." << endl;
7269 }
7270 else
7271 { cout << "Gurobi solver solution for p0033 in error:" << endl;
7272 cout << solver->osrl << endl;
7273 }
7274 if(ok == false) throw ErrorClass(" Fail unit test with Gurobi on p0033.osil");
7275 delete solver;
7276 solver = NULL;
7277 delete fileUtil;
7278 fileUtil = NULL;
7279 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with Gurobi" << std::endl;
7280 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7281 }
7282 catch(const ErrorClass& eclass)
7283 {
7284 cout << "OSrL = " << solver->osrl << endl;
7285 cout << endl << endl << endl;
7286 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Gurobi Solver:"
7287 << endl << eclass.errormsg << endl;
7288 if (solver != NULL)
7289 delete solver;
7290 solver = NULL;
7291 if (fileUtil != NULL)
7292 delete fileUtil;
7293 fileUtil = NULL;
7294 }
7295
7296#if 0
7297 try{
7298 // solve another problem
7299 // a problem that is a pure quadratic
7300 cout << endl << "TEST " << ++nOfTest << ": Gurobi solver on parincQuadratic.osil" << endl << endl;
7301 cout << "create a new Gurobi Solver for OSiL string solution" << endl;
7302
7303 fileUtil = new FileUtil();
7304 osilreader = new OSiLReader();
7305 solver = new CoinSolver();
7306
7307 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
7308 osil = fileUtil->getFileAsString( osilFileName.c_str());
7309 osol = "";
7310 solver->osinstance = osilreader->readOSiL( osil);
7311 solver->osil = osil;
7312 cout << "call the Gurobi Solver" << endl;
7313 solver->buildSolverInstance();
7314 solver->solve();
7315 check = 49920.5;
7316 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7317 if (ok)
7318 {
7319#ifdef DEBUG
7320 cout << solver->osrl << endl;
7321#endif
7322 cout << "Gurobi solver solution for parincQuadratic checks." << endl;
7323 }
7324 else
7325 { cout << "Gurobi solver solution for parincQuadratic in error:" << endl;
7326 cout << solver->osrl << endl;
7327 }
7328 if(ok == false) throw ErrorClass(" Fail unit test with Gurobi on parincQuadradic.osil");
7329 delete osilreader;
7330 osilreader = NULL;
7331 delete solver;
7332 solver = NULL;
7333 delete fileUtil;
7334 fileUtil = NULL;
7335 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with Gurobi" << std::endl;
7336 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7337 }
7338 catch(const ErrorClass& eclass)
7339 {
7340 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Gurobi Solver:"
7341 << endl << eclass.errormsg<< endl;
7342 if (osilreader != NULL)
7343 delete osilreader;
7344 osilreader = NULL;
7345 if (solver != NULL)
7346 delete solver;
7347 solver = NULL;
7348 if (fileUtil != NULL)
7349 delete fileUtil;
7350 fileUtil = NULL;
7351 }
7352#endif //if 0
7353#endif //ifdef COIN_HAS_GRB
7354
7355#ifdef COIN_HAS_MSK
7356 try{
7357 cout << endl << "TEST " << ++nOfTest << ": MOSEK solver on p0033.osil" << endl << endl;
7358
7359 fileUtil = new FileUtil();
7360 solver = new CoinSolver();
7361
7362 ok = true;
7363 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
7364 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cpx.osol";
7365 osil = fileUtil->getFileAsString( osilFileName.c_str());
7366 osol = fileUtil->getFileAsString( osolFileName.c_str());
7367 solver->sSolverName = "mosek";
7368 solver->osil = osil;
7369 solver->osol = osol;
7370 solver->osinstance = NULL;
7371 cout << "call the MOSEK Solver for p0033" << endl;
7372 solver->buildSolverInstance();
7373 solver->solve();
7374 check = 3089;
7375 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
7376 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7377 if (ok)
7378 {
7379#ifdef DEBUG
7380 cout << solver->osrl << endl;
7381#endif
7382 cout << "MOSEK solver solution for p0033 checks." << endl;
7383 }
7384 else
7385 { cout << "MOSEK solver solution for p0033 in error:" << endl;
7386 cout << solver->osrl << endl;
7387 }
7388 if(ok == false) throw ErrorClass(" Fail unit test with MOSEK on p0033.osil");
7389 delete solver;
7390 solver = NULL;
7391 delete fileUtil;
7392 fileUtil = NULL;
7393 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with MOSEK" << std::endl;
7394 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7395 }
7396 catch(const ErrorClass& eclass)
7397 {
7398 cout << "OSrL = " << solver->osrl << endl;
7399 cout << endl << endl << endl;
7400 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the MOSEK Solver:"
7401 << endl << eclass.errormsg << endl;
7402 if (solver != NULL)
7403 delete solver;
7404 solver = NULL;
7405 if (fileUtil != NULL)
7406 delete fileUtil;
7407 fileUtil = NULL;
7408 }
7409
7410#if 0
7411 try{
7412 // solve another problem
7413 // a problem that is a pure quadratic
7414 cout << endl << "TEST " << ++nOfTest << ": MOSEK solver on parincQuadratic.osil" << endl << endl;
7415 cout << "create a new MOSEK Solver for OSiL string solution" << endl;
7416
7417 fileUtil = new FileUtil();
7418 osilreader = new OSiLReader();
7419 solver = new CoinSolver();
7420
7421 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
7422 osil = fileUtil->getFileAsString( osilFileName.c_str());
7423 osol = "";
7424 solver->osinstance = osilreader->readOSiL( osil);
7425 solver->osil = osil;
7426 cout << "call the MOSEK Solver" << endl;
7427 solver->buildSolverInstance();
7428 solver->solve();
7429 check = 49920.5;
7430 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7431 if (ok)
7432 {
7433#ifdef DEBUG
7434 cout << solver->osrl << endl;
7435#endif
7436 cout << "MOSEK solver solution for parincQuadratic checks." << endl;
7437 }
7438 else
7439 { cout << "MOSEK solver solution for parincQuadratic in error:" << endl;
7440 cout << solver->osrl << endl;
7441 }
7442 if(ok == false) throw ErrorClass(" Fail unit test with MOSEK on parincQuadradic.osil");
7443 delete osilreader;
7444 osilreader = NULL;
7445 delete solver;
7446 solver = NULL;
7447 delete fileUtil;
7448 fileUtil = NULL;
7449 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with MOSEK" << std::endl;
7450 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7451 }
7452 catch(const ErrorClass& eclass)
7453 {
7454 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the MOSEK Solver:"
7455 << endl << eclass.errormsg<< endl;
7456 if (osilreader != NULL)
7457 delete osilreader;
7458 osilreader = NULL;
7459 if (solver != NULL)
7460 delete solver;
7461 solver = NULL;
7462 if (fileUtil != NULL)
7463 delete fileUtil;
7464 fileUtil = NULL;
7465 }
7466#endif //if 0
7467#endif //ifdef COIN_HAS_MSK
7468
7469#ifdef COIN_HAS_SOPLEX
7470 try{
7471 cout << endl << "TEST " << ++nOfTest << ": SoPlex solver on parincLinear.osil" << endl << endl;
7472
7473 fileUtil = new FileUtil();
7474 solver = new CoinSolver();
7475
7476 ok = true;
7477 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
7478 osil = fileUtil->getFileAsString( osilFileName.c_str());
7479 solver->sSolverName = "soplex";
7480 solver->osil = osil;
7481 solver->osinstance = NULL;
7482 cout << "call the SoPlex Solver for parincLinear" << endl;
7483 solver->buildSolverInstance();
7484 solver->solve();
7485 check = 7668;
7486 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
7487 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7488 if (ok)
7489 {
7490#ifdef DEBUG
7491 cout << solver->osrl << endl;
7492#endif
7493 cout << "SoPlex solver solution for parincLinear checks." << endl;
7494 }
7495 else
7496 {
7497 cout << "SoPlex solver solution for parincLinear in error:" << endl;
7498 cout << solver->osrl << endl;
7499 }
7500 if(ok == false) throw ErrorClass(" Fail unit test with Soplex on parincLinear.osil");
7501 delete solver;
7502 solver = NULL;
7503 delete fileUtil;
7504 fileUtil = NULL;
7505 unitTestResult << "TEST " << nOfTest << ": Solved problem parincLinear.osil with SoPlex" << std::endl;
7506 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7507 }
7508 catch(const ErrorClass& eclass)
7509 {
7510 cout << "OSrL = " << solver->osrl << endl;
7511 cout << endl << endl << endl;
7512 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the SoPlex Solver:"
7513 << endl << eclass.errormsg << endl;
7514 if (solver != NULL)
7515 delete solver;
7516 solver = NULL;
7517 if (fileUtil != NULL)
7518 delete fileUtil;
7519 fileUtil = NULL;
7520 }
7521#endif
7522
7523#ifdef COIN_HAS_XPR
7524 try{
7525 cout << endl << "TEST " << ++nOfTest << ": XPRESS solver on p0033.osil" << endl << endl;
7526
7527 fileUtil = new FileUtil();
7528 solver = new CoinSolver();
7529
7530 ok = true;
7531 osilFileName = dataDir + "osilFiles" + dirsep + "p0033.osil";
7532 osolFileName = dataDir + "osolFiles" + dirsep + "p0033_cpx.osol";
7533 osil = fileUtil->getFileAsString( osilFileName.c_str());
7534 osol = fileUtil->getFileAsString( osolFileName.c_str());
7535 solver->sSolverName = "xpress";
7536 solver->osil = osil;
7537 solver->osol = osol;
7538 solver->osinstance = NULL;
7539 cout << "call the XPRESS Solver for p0033" << endl;
7540 solver->buildSolverInstance();
7541 solver->solve();
7542 check = 3089;
7543 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
7544 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7545 if (ok)
7546 {
7547#ifdef DEBUG
7548 cout << solver->osrl << endl;
7549#endif
7550 cout << "XPRESS solver solution for p0033 checks." << endl;
7551 }
7552 else
7553 { cout << "XPRESS solver solution for p0033 in error:" << endl;
7554 cout << solver->osrl << endl;
7555 }
7556 if(ok == false) throw ErrorClass(" Fail unit test with XPRESS on p0033.osil");
7557 delete solver;
7558 solver = NULL;
7559 delete fileUtil;
7560 fileUtil = NULL;
7561 unitTestResult << "TEST " << nOfTest << ": Solved problem p0033.osil with XPRESS" << std::endl;
7562 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7563 }
7564 catch(const ErrorClass& eclass)
7565 {
7566 cout << "OSrL = " << solver->osrl << endl;
7567 cout << endl << endl << endl;
7568 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the XPRESS Solver:"
7569 << endl << eclass.errormsg << endl;
7570 if (solver != NULL)
7571 delete solver;
7572 solver = NULL;
7573 if (fileUtil != NULL)
7574 delete fileUtil;
7575 fileUtil = NULL;
7576 }
7577
7578#if 0
7579 try{
7580 // solve another problem
7581 // a problem that is a pure quadratic
7582 cout << endl << "TEST " << ++nOfTest << ": XPRESS solver on parincQuadratic.osil" << endl << endl;
7583 cout << "create a new XPRESS Solver for OSiL string solution" << endl;
7584
7585 fileUtil = new FileUtil();
7586 osilreader = new OSiLReader();
7587 solver = new CoinSolver();
7588
7589 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
7590 osil = fileUtil->getFileAsString( osilFileName.c_str());
7591 osol = "";
7592 solver->osinstance = osilreader->readOSiL( osil);
7593 solver->osil = osil;
7594 cout << "call the XPRESS Solver" << endl;
7595 solver->buildSolverInstance();
7596 solver->solve();
7597 check = 49920.5;
7598 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7599 if (ok)
7600 {
7601#ifdef DEBUG
7602 cout << solver->osrl << endl;
7603#endif
7604 cout << "XPRESS solver solution for parincQuadratic checks." << endl;
7605 }
7606 else
7607 { cout << "XPRESS solver solution for parincQuadratic in error:" << endl;
7608 cout << solver->osrl << endl;
7609 }
7610 if(ok == false) throw ErrorClass(" Fail unit test with XPRESS on parincQuadradic.osil");
7611 delete osilreader;
7612 osilreader = NULL;
7613 delete solver;
7614 solver = NULL;
7615 delete fileUtil;
7616 fileUtil = NULL;
7617 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with XPRESS" << std::endl;
7618 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7619 }
7620 catch(const ErrorClass& eclass)
7621 {
7622 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the XPRESS Solver:"
7623 << endl << eclass.errormsg<< endl;
7624 if (osilreader != NULL)
7625 delete osilreader;
7626 osilreader = NULL;
7627 if (solver != NULL)
7628 delete solver;
7629 solver = NULL;
7630 if (fileUtil != NULL)
7631 delete fileUtil;
7632 fileUtil = NULL;
7633 }
7634#endif //if 0
7635#endif //ifdef COIN_HAS_XPR
7636
7637
7638#ifdef COIN_HAS_IPOPT
7639 IpoptSolver *ipoptSolver = NULL;
7640 try{
7641 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver with avion2.osil" << endl << endl;
7642
7643 fileUtil = new FileUtil();
7644 osilreader = new OSiLReader();
7645 osolreader = new OSoLReader();
7646 ipoptSolver = new IpoptSolver();
7647
7648 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
7649 ok = true;
7650 // avion does not work with Mumps on AIX xlC compiler
7651#ifndef XLC_
7652 osilFileName = dataDir + "osilFiles" + dirsep + "avion2.osil";
7653 osolFileName = dataDir + "osolFiles" + dirsep + "avion2_ipopt.osol";
7654 osil = fileUtil->getFileAsString( osilFileName.c_str());
7655 osol = fileUtil->getFileAsString( osolFileName.c_str());
7656 cout << "IPOPT Solver created for OSiL string solution" << endl;
7657 ipoptSolver->osol = osol;
7658 ipoptSolver->osinstance = osilreader->readOSiL( osil);
7659 ipoptSolver->osol = osol;
7660 cout << "call the IPOPT Solver" << endl;
7661 ipoptSolver->buildSolverInstance();
7662 ipoptSolver->solve();
7663 check = 9.46801e+07;
7664 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
7665 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7666 if (ok)
7667 {
7668#ifdef DEBUG
7669 cout << ipoptSolver->osrl << endl;
7670#endif
7671 cout << "IPOPT solver solution for avion2 checks." << endl;
7672 }
7673 else
7674 { cout << "IPOPT solver solution for avion2 in error:" << endl;
7675 cout << ipoptSolver->osrl << endl;
7676 }
7677 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on avion2.osil");
7678 delete osilreader;
7679 osilreader = NULL;
7680 delete osolreader;
7681 osolreader = NULL;
7682 delete ipoptSolver;
7683 ipoptSolver = NULL;
7684 delete fileUtil;
7685 fileUtil = NULL;
7686 unitTestResult << "TEST " << nOfTest << ": Solved problem avion2.osil with Ipopt" << std::endl;
7687 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7688#endif
7689 }
7690 catch(const ErrorClass& eclass)
7691 {
7692 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
7693 << endl << eclass.errormsg<< endl;
7694 if (osilreader != NULL)
7695 delete osilreader;
7696 osilreader = NULL;
7697 if (osolreader != NULL)
7698 delete osolreader;
7699 osolreader = NULL;
7700 if (ipoptSolver != NULL)
7701 delete ipoptSolver;
7702 ipoptSolver = NULL;
7703 if (fileUtil != NULL)
7704 delete fileUtil;
7705 fileUtil = NULL;
7706 }
7707
7708if(THOROUGH == true){
7709 // solve another problem
7710 try{
7711 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver with HS071_NLPMod.osil" << endl << endl;
7712 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
7713
7714 fileUtil = new FileUtil();
7715 osilreader = new OSiLReader();
7716 osolreader = new OSoLReader();
7717 ipoptSolver = new IpoptSolver();
7718
7719 // a problem with all nonlinear terms, no linear terms
7720 osilFileName = dataDir + "osilFiles" + dirsep + "HS071_NLPMod.osil";
7721 osolFileName = dataDir + "osolFiles" + dirsep + "HS071_NLPMod_ipopt.osol";
7722 osil = fileUtil->getFileAsString( osilFileName.c_str());
7723 osol = fileUtil->getFileAsString( osolFileName.c_str());
7724 cout << "IPOPT Solver created for OSiL string solution" << endl;
7725// osol = "<osol></osol>";
7726 ipoptSolver->osinstance = osilreader->readOSiL( osil);
7727 ipoptSolver->osoption = osolreader->readOSoL( osol);
7728 ipoptSolver->osol = osol;
7729 ipoptSolver->buildSolverInstance();
7730 ipoptSolver->solve();
7731 cout << "Here is the IPOPT solver solution for HS071_NLP" << endl;
7732 check = 17.014;
7733 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
7734 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7735 if (ok)
7736 {
7737#ifdef DEBUG
7738 cout << ipoptSolver->osrl << endl;
7739#endif
7740 cout << "IPOPT solver solution for HS071_NLP checks." << endl;
7741 }
7742 else
7743 { cout << "IPOPT solver solution for HS071_NLP in error:" << endl;
7744 cout << ipoptSolver->osrl << endl;
7745 }
7746 delete osilreader;
7747 osilreader = NULL;
7748 delete osolreader;
7749 osolreader = NULL;
7750 delete ipoptSolver;
7751 ipoptSolver = NULL;
7752 delete fileUtil;
7753 fileUtil = NULL;
7754 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on HS071_NLP.osil");
7755 unitTestResult << "TEST " << nOfTest << ": Solved problem HS071.osil with Ipopt" << std::endl;
7756 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7757 }
7758 catch(const ErrorClass& eclass)
7759 {
7760 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
7761 << endl << eclass.errormsg<< endl;
7762 if (osilreader != NULL)
7763 delete osilreader;
7764 osilreader = NULL;
7765 if (osolreader != NULL)
7766 delete osolreader;
7767 osolreader = NULL;
7768 if (ipoptSolver != NULL)
7769 delete ipoptSolver;
7770 ipoptSolver = NULL;
7771 if (fileUtil != NULL)
7772 delete fileUtil;
7773 fileUtil = NULL;
7774 }
7775
7776 try{
7777 // solve another problem
7778 // a problem with both quadratic terms and general nonlinear terms
7779 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on rosenbrockmod.osil" << endl << endl;
7780 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
7781
7782 fileUtil = new FileUtil();
7783 osilreader = new OSiLReader();
7784 osolreader = new OSoLReader();
7785 ipoptSolver = new IpoptSolver();
7786
7787 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
7788 osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockmod_ipopt.osol";
7789 osil = fileUtil->getFileAsString( osilFileName.c_str());
7790 osol = fileUtil->getFileAsString( osolFileName.c_str());
7791 cout << "IPOPT Solver created for OSiL string solution" << endl;
7792 ipoptSolver->osil = osil;
7793 ipoptSolver->osoption = osolreader->readOSoL( osol);
7794 cout << "call the IPOPT Solver" << endl;
7795 ipoptSolver->buildSolverInstance();
7796 ipoptSolver->solve();
7797 check = 6.7279;
7798 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
7799 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7800 if (ok)
7801 {
7802#ifdef DEBUG
7803 cout << ipoptSolver->osrl << endl;
7804#endif
7805 cout << "Ipopt solver solution for rosenbrockmod checks." << endl;
7806 }
7807 else
7808 { cout << "Ipopt solver solution for rosenbrockmod in error:" << endl;
7809 cout << ipoptSolver->osrl << endl;
7810 }
7811 if(ok == false)
7812 throw ErrorClass(" Fail unit test with Ipopt on rosenbrockmod.osil");
7813 delete osilreader;
7814 osilreader = NULL;
7815 delete osolreader;
7816 osolreader = NULL;
7817 delete ipoptSolver;
7818 ipoptSolver = NULL;
7819 delete fileUtil;
7820 fileUtil = NULL;
7821 unitTestResult << "TEST " << nOfTest << ": Solved problem rosenbrockmod.osil with Ipopt" << std::endl;
7822 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7823 //return 0;
7824 }
7825 catch(const ErrorClass& eclass)
7826 {
7827 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
7828 << endl << eclass.errormsg<< endl;
7829 if (osilreader != NULL)
7830 delete osilreader;
7831 osilreader = NULL;
7832 if (osolreader != NULL)
7833 delete osolreader;
7834 osolreader = NULL;
7835 if (ipoptSolver != NULL)
7836 delete ipoptSolver;
7837 ipoptSolver = NULL;
7838 if (fileUtil != NULL)
7839 delete fileUtil;
7840 fileUtil = NULL;
7841 }
7842
7843 try{
7844 // solve another problem
7845 // a problem that is a pure quadratic
7846 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincQuadratic.osil" << endl << endl;
7847 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
7848
7849 fileUtil = new FileUtil();
7850 osilreader = new OSiLReader();
7851 osolreader = new OSoLReader();
7852 ipoptSolver = new IpoptSolver();
7853
7854 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
7855 osolFileName = dataDir + "osolFiles" + dirsep + "parincQuadratic_ipopt.osol";
7856 osil = fileUtil->getFileAsString( osilFileName.c_str());
7857 osol = fileUtil->getFileAsString( osolFileName.c_str());
7858 cout << "IPOPT Solver created for OSiL string solution" << endl;
7859 ipoptSolver->osinstance = osilreader->readOSiL( osil);
7860 ipoptSolver->osil = osil;
7861 ipoptSolver->osol = osol;
7862 cout << "call the IPOPT Solver" << endl;
7863 ipoptSolver->buildSolverInstance();
7864 ipoptSolver->solve();
7865 check = 49920.5;
7866 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
7867 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7868 if (ok)
7869 {
7870#ifdef DEBUG
7871 cout << ipoptSolver->osrl << endl;
7872#endif
7873 cout << "IPOPT solver solution for parincQuadratic checks." << endl;
7874 }
7875 else
7876 { cout << "IPOPT solver solution for parincQuadratic in error:" << endl;
7877 cout << ipoptSolver->osrl << endl;
7878 }
7879 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincQuadradic.osil");
7880 delete osilreader;
7881 osilreader = NULL;
7882 delete osolreader;
7883 osolreader = NULL;
7884 delete ipoptSolver;
7885 ipoptSolver = NULL;
7886 delete fileUtil;
7887 fileUtil = NULL;
7888 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with Ipopt" << std::endl;
7889 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7890 }
7891 catch(const ErrorClass& eclass)
7892 {
7893 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
7894 << endl << eclass.errormsg<< endl;
7895 if (osilreader != NULL)
7896 delete osilreader;
7897 osilreader = NULL;
7898 if (osolreader != NULL)
7899 delete osolreader;
7900 osolreader = NULL;
7901 if (ipoptSolver != NULL)
7902 delete ipoptSolver;
7903 ipoptSolver = NULL;
7904 if (fileUtil != NULL)
7905 delete fileUtil;
7906 fileUtil = NULL;
7907 }
7908
7909 // solve another problem
7910 // try a pure linear program
7911 try{
7912 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincLinear.osil" << endl << endl;
7913 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
7914
7915 fileUtil = new FileUtil();
7916 osilreader = new OSiLReader();
7917 osolreader = new OSoLReader();
7918 ipoptSolver = new IpoptSolver();
7919
7920 osilFileName = dataDir + "osilFiles" + dirsep + "parincLinear.osil";
7921 osolFileName = dataDir + "osolFiles" + dirsep + "parincLinear_ipopt.osol";
7922 osil = fileUtil->getFileAsString( osilFileName.c_str());
7923 osol = fileUtil->getFileAsString( osolFileName.c_str());
7924 cout << "IPOPT Solver created for OSiL string solution" << endl;
7925 ipoptSolver->osinstance = osilreader->readOSiL( osil);
7926 ipoptSolver->osoption = NULL;
7927 ipoptSolver->osol = "";
7928 cout << "call the IPOPT Solver" << endl;
7929 ipoptSolver->buildSolverInstance();
7930 ipoptSolver->solve();
7931 check = 7668;
7932 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-1 , 1e-1);
7933 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
7934 if (ok)
7935 {
7936#ifdef DEBUG
7937 cout << ipoptSolver->osrl << endl;
7938#endif
7939 cout << "IPOPT solver solution for parincLinear checks." << endl;
7940 }
7941 else
7942 { cout << "IPOPT solver solution for parincLinear in error:" << endl;
7943 cout << ipoptSolver->osrl << endl;
7944 }
7945 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincLinear.osil");
7946 delete osilreader;
7947 osilreader = NULL;
7948 delete osolreader;
7949 osolreader = NULL;
7950 delete ipoptSolver;
7951 ipoptSolver = NULL;
7952 delete fileUtil;
7953 fileUtil = NULL;
7954 unitTestResult << "TEST " << nOfTest << ": Solved problem parincLinear.osil with Ipopt" << std::endl;
7955 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
7956 }
7957 catch(const ErrorClass& eclass)
7958 {
7959 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
7960 << endl << eclass.errormsg<< endl;
7961 if (osilreader != NULL)
7962 delete osilreader;
7963 osilreader = NULL;
7964 if (osolreader != NULL)
7965 delete osolreader;
7966 osolreader = NULL;
7967 if (ipoptSolver != NULL)
7968 delete ipoptSolver;
7969 ipoptSolver = NULL;
7970 if (fileUtil != NULL)
7971 delete fileUtil;
7972 fileUtil = NULL;
7973 }
7974
7975 // solve another problem
7976 // callBackTest.osil
7977 try{
7978 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on callBackTest.osil" << endl << endl;
7979 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
7980
7981 fileUtil = new FileUtil();
7982 osilreader = new OSiLReader();
7983 osolreader = new OSoLReader();
7984 ipoptSolver = new IpoptSolver();
7985
7986 osilFileName = dataDir + "osilFiles" + dirsep + "callBackTest.osil";
7987 osolFileName = dataDir + "osolFiles" + dirsep + "callBackTest_ipopt.osol";
7988 osil = fileUtil->getFileAsString( osilFileName.c_str());
7989 osol = fileUtil->getFileAsString( osolFileName.c_str());
7990 cout << "IPOPT Solver created for OSiL string solution" << endl;
7991 ipoptSolver->osinstance = osilreader->readOSiL( osil);
7992 ipoptSolver->osoption = osolreader->readOSoL( osol);
7993 ipoptSolver->osol = osol;
7994 cout << "call the IPOPT Solver" << endl;
7995 ipoptSolver->buildSolverInstance();
7996 ipoptSolver->solve();
7997 check = 1.00045e+06;
7998 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
7999 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8000 if (ok)
8001 {
8002#ifdef DEBUG
8003 cout << ipoptSolver->osrl << endl;
8004#endif
8005 cout << "IPOPT solver solution for callBackTest checks." << endl;
8006 }
8007 else
8008 { cout << "IPOPT solver solution for callBackTest in error:" << endl;
8009 cout << ipoptSolver->osrl << endl;
8010 }
8011 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on callBackTest.osil");
8012 delete osilreader;
8013 osilreader = NULL;
8014 delete osolreader;
8015 osolreader = NULL;
8016 delete ipoptSolver;
8017 ipoptSolver = NULL;
8018 delete fileUtil;
8019 fileUtil = NULL;
8020 unitTestResult << "TEST " << nOfTest << ": Solved problem callBackTest.osil with Ipopt" << std::endl;
8021 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8022 }
8023 catch(const ErrorClass& eclass)
8024 {
8025 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
8026 << endl << eclass.errormsg<< endl;
8027 if (osilreader != NULL)
8028 delete osilreader;
8029 osilreader = NULL;
8030 if (osolreader != NULL)
8031 delete osolreader;
8032 osolreader = NULL;
8033 if (ipoptSolver != NULL)
8034 delete ipoptSolver;
8035 ipoptSolver = NULL;
8036 if (fileUtil != NULL)
8037 delete fileUtil;
8038 fileUtil = NULL;
8039 }
8040
8041 // solve another problem
8042 // callBackTest.osil
8043 try{
8044 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on callBackTestRowMajor.osil" << endl << endl;
8045 cout << "create a new IPOPT Solver for OSiL string solution" << endl;
8046
8047 fileUtil = new FileUtil();
8048 osilreader = new OSiLReader();
8049 osolreader = new OSoLReader();
8050 ipoptSolver = new IpoptSolver();
8051
8052 osilFileName = dataDir + "osilFiles" + dirsep + "callBackTestRowMajor.osil";
8053 osolFileName = dataDir + "osolFiles" + dirsep + "callBackTestRowMajor_ipopt.osol";
8054 osil = fileUtil->getFileAsString( osilFileName.c_str());
8055 osol = fileUtil->getFileAsString( osolFileName.c_str());
8056 cout << "IPOPT Solver created for OSiL string solution" << endl;
8057 ipoptSolver->osinstance = NULL;
8058 ipoptSolver->osoption = NULL;
8059 ipoptSolver->osil = osil;
8060 ipoptSolver->osol = osol;
8061 cout << "call the IPOPT Solver" << endl;
8062// ipoptSolver->buildSolverInstance();
8063 ipoptSolver->solve();
8064 check = 1.00045e+06;
8065 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
8066 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8067 if (ok)
8068 {
8069#ifdef DEBUG
8070 cout << ipoptSolver->osrl << endl;
8071#endif
8072 cout << "IPOPT solver solution for callBackTestRowMajor checks." << endl;
8073 }
8074 else
8075 { cout << "IPOPT solver solution for callBackTestRowMajor in error:" << endl;
8076 cout << ipoptSolver->osrl << endl;
8077 }
8078 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on callBackTestRowMajor.osil");
8079 delete osilreader;
8080 osilreader = NULL;
8081 delete osolreader;
8082 osolreader = NULL;
8083 delete ipoptSolver;
8084 ipoptSolver = NULL;
8085 delete fileUtil;
8086 fileUtil = NULL;
8087 unitTestResult << "TEST " << nOfTest << ": Solved problem callBackRowMajor.osil with Ipopt" << std::endl;
8088 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8089 }
8090 catch(const ErrorClass& eclass)
8091 {
8092 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
8093 << endl << eclass.errormsg<< endl;
8094 if (osilreader != NULL)
8095 delete osilreader;
8096 osilreader = NULL;
8097
8098 if (osolreader != NULL)
8099 delete osolreader;
8100 osolreader = NULL;
8101 if (ipoptSolver != NULL)
8102 delete ipoptSolver;
8103 ipoptSolver = NULL;
8104 if (fileUtil != NULL)
8105 delete fileUtil;
8106 fileUtil = NULL;
8107 }
8108
8109 try{
8110 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on rosenbrockorig.osil" << endl << endl;
8111
8112 fileUtil = new FileUtil();
8113 osilreader = new OSiLReader();
8114 osolreader = new OSoLReader();
8115 ipoptSolver = new IpoptSolver();
8116
8117 ok = true;
8118 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorig.osil";
8119// osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockorig_Ipopt.osol";
8120 osil = fileUtil->getFileAsString( osilFileName.c_str());
8121// osol = fileUtil->getFileAsString( osolFileName.c_str());
8122 osol = "";
8123 ipoptSolver->sSolverName = "ipopt";
8124 ipoptSolver->osil = osil;
8125 ipoptSolver->osol = osol;
8126// ipoptSolver->osinstance = osilreader->readOSiL( osil);
8127// ipoptSolver->osoption = osolreader->readOSoL( osol);
8128 cout << "call the COIN - Ipopt Solver for rosenbrockorig" << endl;
8129 cout << endl << endl << osil << endl << endl;
8130 ipoptSolver->buildSolverInstance();
8131
8132 cout << ipoptSolver->osinstance->printModel() << endl << endl;
8133 //cout << osilreader->m_osinstance->printModel() << endl << endl;
8134
8135 std::cout << " CALL SOLVE " << std::endl;
8136 ipoptSolver->solve();
8137 check = 0;
8138 ok = ( fabs(check - getObjVal( ipoptSolver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8139 if (ok)
8140 {
8141#ifdef DEBUG
8142 cout << ipoptSolver->osrl << endl;
8143#endif
8144 cout << "Ipopt solver solution for rosenbrockorig checks." << endl;
8145 }
8146 else
8147 { cout << "Ipopt solver solution for rosenbrockorig in error:" << endl;
8148 cout << ipoptSolver->osrl << endl;
8149 }
8150 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on rosenbrockorig.osil");
8151
8152 delete ipoptSolver;
8153 ipoptSolver = NULL;
8154 delete osilreader;
8155 osilreader = NULL;
8156 delete osolreader;
8157 osolreader = NULL;
8158 delete fileUtil;
8159 fileUtil = NULL;
8160 unitTestResult << "TEST " << nOfTest << ": Solved problem rosenbrockorig.osil with Ipopt" << std::endl;
8161 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8162 }
8163 catch(const ErrorClass& eclass)
8164 {
8165 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
8166 << endl << eclass.errormsg<< endl;
8167 if (osilreader != NULL)
8168 delete osilreader;
8169 osilreader = NULL;
8170 if (osolreader != NULL)
8171 delete osolreader;
8172 osolreader = NULL;
8173 if (ipoptSolver != NULL)
8174 delete ipoptSolver;
8175 ipoptSolver = NULL;
8176 if (fileUtil != NULL)
8177 delete fileUtil;
8178 fileUtil = NULL;
8179 }
8180
8181 try{
8182 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on HS071_feas.osil" << endl << endl;
8183
8184 fileUtil = new FileUtil();
8185 ipoptSolver = new IpoptSolver();
8186
8187 ok = true;
8188 osilFileName = dataDir + "osilFiles" + dirsep + "HS071_feas.osil";
8189// osolFileName = dataDir + "osolFiles" + dirsep + "HS071_feas_Ipopt.osol";
8190 osil = fileUtil->getFileAsString( osilFileName.c_str());
8191// osol = fileUtil->getFileAsString( osolFileName.c_str());
8192 osol = "";
8193 ipoptSolver->sSolverName = "ipopt";
8194 ipoptSolver->osil = osil;
8195 ipoptSolver->osol = osol;
8196// ipoptSolver->osinstance = osilreader->readOSiL( osil);
8197// ipoptSolver->osoption = osolreader->readOSoL( osol);
8198 ipoptSolver->buildSolverInstance();
8199
8200 cout << "call the COIN - Ipopt Solver for HS071_feas.osil" << endl;
8201 ipoptSolver->solve();
8202
8203// osresult = new OSResult();
8204 osrlreader = new OSrLReader();
8205 osresult = osrlreader->readOSrL(ipoptSolver->osrl);
8206
8207 check = 3.162277659974328;
8208 ok = ( fabs(check - osresult->getVarValue(0,0) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8209 check = 3.1622776613181367;
8210 ok &= ( fabs(check - osresult->getVarValue(0,0) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8211 check = 3.1622776594067235;
8212 ok &= ( fabs(check - osresult->getVarValue(0,0) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8213 check = 3.162277659974329;
8214 ok &= ( fabs(check - osresult->getVarValue(0,0) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8215
8216 if (ok)
8217 {
8218#ifdef DEBUG
8219 cout << ipoptSolver->osrl << endl;
8220#endif
8221 cout << "Ipopt feasible point for HS071_feas checks." << endl;
8222 }
8223 else
8224 { cout << "Ipopt feasible point for HS071_feas in error:" << endl;
8225 cout << ipoptSolver->osrl << endl;
8226 }
8227 if(ok == false) throw ErrorClass(" Fail unit test with Ipopt on HS071_feas.osil");
8228
8229 delete ipoptSolver;
8230 ipoptSolver = NULL;
8231 delete fileUtil;
8232 fileUtil = NULL;
8233 delete osrlreader;
8234 osrlreader = NULL;
8235
8236 unitTestResult << "TEST " << nOfTest << ": Correctly solved problem HS071_feas with Ipopt" << std::endl;
8237 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8238 }
8239 catch(const ErrorClass& eclass)
8240 {
8241 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
8242 << endl << eclass.errormsg<< endl;
8243 if (osilreader != NULL)
8244 delete osilreader;
8245 osilreader = NULL;
8246 if (osolreader != NULL)
8247 delete osolreader;
8248 osolreader = NULL;
8249 if (osrlreader != NULL)
8250 delete osrlreader;
8251 osrlreader = NULL;
8252 if (ipoptSolver != NULL)
8253 delete ipoptSolver;
8254 ipoptSolver = NULL;
8255 if (fileUtil != NULL)
8256 delete fileUtil;
8257 fileUtil = NULL;
8258 }
8259
8260 try{
8261 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on HS071_no-obj.osil" << endl << endl;
8262 try {
8263
8264 fileUtil = new FileUtil();
8265 ipoptSolver = new IpoptSolver();
8266
8267 ok = true;
8268 osilFileName = dataDir + "osilFiles" + dirsep + "HS071_no-obj.osil";
8269 osil = fileUtil->getFileAsString( osilFileName.c_str());
8270 osol = "";
8271 ipoptSolver->sSolverName = "ipopt";
8272 ipoptSolver->osil = osil;
8273 ipoptSolver->osol = osol;
8274// ipoptSolver->osinstance = osilreader->readOSiL( osil);
8275// ipoptSolver->osoption = osolreader->readOSoL( osol);
8276 ipoptSolver->buildSolverInstance();
8277
8278 cout << "call the COIN - Ipopt Solver for HS071_no-obj.osil" << endl;
8279 ipoptSolver->solve();
8280 }
8281 catch(const ErrorClass& eclass)
8282 {
8283 ok = (ipoptSolver->osresult->getGeneralMessage() ==
8284 "Ipopt NEEDS AN OBJECTIVE FUNCTION\n(For pure feasibility problems, use zero function.)");
8285 if(ok == false)
8286 { cout << "Ipopt solver returns:" << endl;
8287 cout << ipoptSolver->osrl << endl;
8288 throw ErrorClass(" Fail unit test with Ipopt on HS071_no-obj.osil");
8289 }
8290 }
8291
8292 cout << "Received error message from Ipopt: \"Ipopt NEEDS AN OBJECTIVE FUNCTION\"" << endl;
8293
8294 delete ipoptSolver;
8295 ipoptSolver = NULL;
8296 delete fileUtil;
8297 fileUtil = NULL;
8298
8299 unitTestResult << "TEST " << nOfTest << ": Correctly diagnosed problem HS071_no-obj with Ipopt" << std::endl;
8300 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8301 }
8302 catch(const ErrorClass& eclass)
8303 {
8304 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Ipopt Solver:"
8305 << endl << eclass.errormsg<< endl;
8306 if (osilreader != NULL)
8307 delete osilreader;
8308 osilreader = NULL;
8309 if (osolreader != NULL)
8310 delete osolreader;
8311 osolreader = NULL;
8312 if (ipoptSolver != NULL)
8313 delete ipoptSolver;
8314 ipoptSolver = NULL;
8315 if (fileUtil != NULL)
8316 delete fileUtil;
8317 fileUtil = NULL;
8318 }
8319
8320
8321} // end if (THOROUGH)
8322#endif // end #ifdef COIN_HAS_IPOPT
8323
8324
8325#ifdef COIN_HAS_BONMIN
8326 try{
8327 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on bonminEx1.osil" << endl << endl;
8328
8329 fileUtil = new FileUtil();
8330 osilreader = new OSiLReader();
8331 osolreader = new OSoLReader();
8332 solver = new BonminSolver();
8333
8334 ok = true;
8335 osilFileName = dataDir + "osilFiles" + dirsep + "bonminEx1.osil";
8336 osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Bonmin.osol";
8337 osil = fileUtil->getFileAsString( osilFileName.c_str());
8338 osol = fileUtil->getFileAsString( osolFileName.c_str());
8339 //solver->sSolverName = "bonmin";
8340// solver->osinstance = osilreader->readOSiL( osil);
8341 solver->osil = osil;
8342 solver->osoption = osolreader->readOSoL( osol);
8343 cout << "call the COIN - Bonmin Solver for bonminEx1" << endl;
8344// solver->buildSolverInstance();
8345 solver->solve();
8346 check = -17.07106795327683;
8347 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8348 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8349 if (ok)
8350 {
8351#ifdef DEBUG
8352 cout << solver->osrl << endl;
8353#endif
8354 cout << "Bonmin solver solution for bonminEx1 checks." << endl;
8355 }
8356 else
8357 { cout << "Bonmin solver solution for bonminEx1 in error:" << endl;
8358 cout << solver->osrl << endl;
8359 }
8360 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on bonminEx1.osil");
8361 delete solver;
8362 solver = NULL;
8363 delete osilreader;
8364 osilreader = NULL;
8365 delete osolreader;
8366 osolreader = NULL;
8367 delete fileUtil;
8368 fileUtil = NULL;
8369 unitTestResult << "TEST " << nOfTest << ": Solved problem bonminEx1.osil with Bonmin" << std::endl;
8370 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8371 }
8372 catch(const ErrorClass& eclass)
8373 {
8374 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Bonmin Solver:"
8375 << endl << eclass.errormsg << endl;
8376 if (solver != NULL)
8377 delete solver;
8378 solver = NULL;
8379 if (osilreader != NULL)
8380 delete osilreader;
8381 osilreader = NULL;
8382 if (osolreader != NULL)
8383 delete osolreader;
8384 osolreader = NULL;
8385 if (fileUtil != NULL)
8386 delete fileUtil;
8387 fileUtil = NULL;
8388 }
8389
8390if (THOROUGH == true){
8391 try{
8392 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on wayneQuadratic.osil" << endl << endl;
8393
8394 fileUtil = new FileUtil();
8395 osilreader = new OSiLReader();
8396 solver = new BonminSolver();
8397
8398 ok = true;
8399 osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
8400 osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Bonmin1.osol";
8401 osil = fileUtil->getFileAsString( osilFileName.c_str());
8402 osol = fileUtil->getFileAsString( osolFileName.c_str());
8403 solver->osol = osol;
8404 solver->osinstance = osilreader->readOSiL( osil);
8405 cout << "call the Bonmin Solver for wayneQuadratic" << endl;
8406 solver->buildSolverInstance();
8407 // Do this one with two different osol files!!!
8408 solver->solve();
8409 check = 2.925;
8410 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8411 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8412 if (ok)
8413 {
8414#ifdef DEBUG
8415 cout << solver->osrl << endl;
8416#endif
8417 cout << "Bonmin solver solution for wayneQuadratic checks." << endl;
8418 }
8419 else
8420 { cout << "Bonmin solver solution for wayneQuadratic in error:" << endl;
8421 cout << solver->osrl << endl;
8422 }
8423 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on wayneQuadratic.osil");
8424 delete solver;
8425 solver = NULL;
8426 delete osilreader;
8427 osilreader = NULL;
8428 delete fileUtil;
8429 fileUtil = NULL;
8430 unitTestResult << "TEST " << nOfTest << ": Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
8431 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8432 }
8433 catch(const ErrorClass& eclass)
8434 {
8435 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Bonmin Solver:"
8436 << endl << eclass.errormsg << endl;
8437 if (solver != NULL)
8438 delete solver;
8439 solver = NULL;
8440 if (osilreader != NULL)
8441 delete osilreader;
8442 osilreader = NULL;
8443 if (fileUtil != NULL)
8444 delete fileUtil;
8445 fileUtil = NULL;
8446 }
8447
8448 try{
8449 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on wayneQuadratic.osil" << endl << endl;
8450
8451 fileUtil = new FileUtil();
8452 osilreader = new OSiLReader();
8453 osolreader = new OSoLReader();
8454 solver = new BonminSolver();
8455
8456 ok = true;
8457 osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
8458 osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Bonmin2.osol";
8459 osil = fileUtil->getFileAsString( osilFileName.c_str());
8460 osol = fileUtil->getFileAsString( osolFileName.c_str());
8461 solver->osol = osol;
8462 solver->osinstance = osilreader->readOSiL( osil);
8463 solver->osoption = osolreader->readOSoL( osol);
8464 cout << "call the Bonmin Solver for wayneQuadratic" << endl;
8465 solver->buildSolverInstance();
8466 // Do this one with two different osol files!!!
8467 solver->solve();
8468 check = 2.925;
8469 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8470 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8471 if (ok)
8472 {
8473#ifdef DEBUG
8474 cout << solver->osrl << endl;
8475#endif
8476 cout << "Bonmin solver solution for wayneQuadratic checks." << endl;
8477 }
8478 else
8479 { cout << "Bonmin solver solution for wayneQuadratic in error:" << endl;
8480 cout << solver->osrl << endl;
8481 }
8482 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on wayneQuadratic.osil");
8483 delete solver;
8484 solver = NULL;
8485 delete osilreader;
8486 osilreader = NULL;
8487 delete osolreader;
8488 osolreader = NULL;
8489 delete fileUtil;
8490 fileUtil = NULL;
8491 unitTestResult << "TEST " << nOfTest << ": Solved problem wayneQuadratic.osil with Bonmin" << std::endl;
8492 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8493 }
8494 catch(const ErrorClass& eclass)
8495 {
8496 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Bonmin Solver:"
8497 << endl << eclass.errormsg << endl;
8498 if (solver != NULL)
8499 delete solver;
8500 solver = NULL;
8501 if (osilreader != NULL)
8502 delete osilreader;
8503 osilreader = NULL;
8504 if (osolreader != NULL)
8505 delete osolreader;
8506 osolreader = NULL;
8507 if (fileUtil != NULL)
8508 delete fileUtil;
8509 fileUtil = NULL;
8510 }
8511
8512 try{
8513 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on rosenbrockorig.osil" << endl << endl;
8514
8515 fileUtil = new FileUtil();
8516 osilreader = new OSiLReader();
8517 solver = new BonminSolver();
8518
8519 ok = true;
8520 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorig.osil";
8521 osil = fileUtil->getFileAsString( osilFileName.c_str());
8522 solver->osol = "";
8523 solver->osinstance = osilreader->readOSiL( osil);
8524 cout << "build solver instance" << endl;
8525 solver->buildSolverInstance();
8526 cout << "call the Bonmin Solver for rosenbrockorig" << endl;
8527 solver->solve();
8528 check = 0;
8529 cout << "Verify solution" <<endl;
8530 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8531 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8532 if (ok)
8533 {
8534#ifdef DEBUG
8535 cout << solver->osrl << endl;
8536#endif
8537 cout << "Bonmin solver solution for rosenbrockorig checks." << endl;
8538 }
8539 else
8540 { cout << "Bonmin solver solution for rosenbrockorig in error:" << endl;
8541 cout << solver->osrl << endl;
8542 }
8543 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on rosenbrockorig.osil");
8544 delete solver;
8545 solver = NULL;
8546 delete osilreader;
8547 osilreader = NULL;
8548 delete fileUtil;
8549 fileUtil = NULL;
8550 unitTestResult << "TEST " << nOfTest << ": Solved problem rosenbrockorig.osil with Bonmin" << std::endl;
8551 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8552 }
8553 catch(const ErrorClass& eclass)
8554 {
8555 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Bonmin Solver:"
8556 << endl << eclass.errormsg << endl;
8557 if (solver != NULL)
8558 delete solver;
8559 solver = NULL;
8560 if (osilreader != NULL)
8561 delete osilreader;
8562 osilreader = NULL;
8563 if (fileUtil != NULL)
8564 delete fileUtil;
8565 fileUtil = NULL;
8566 }
8567
8568 try{
8569 cout << endl << "TEST " << ++nOfTest << ": Bonmin solver on rosenbrockorigInt.osil" << endl << endl;
8570
8571 fileUtil = new FileUtil();
8572 osilreader = new OSiLReader();
8573 solver = new BonminSolver();
8574
8575 ok = true;
8576 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorigInt.osil";
8577 osil = fileUtil->getFileAsString( osilFileName.c_str());
8578 solver->osol = "";
8579 solver->osinstance = osilreader->readOSiL( osil);
8580 cout << "call the Bonmin Solver for rosenbrockinteger" << endl;
8581 solver->buildSolverInstance();
8582 solver->solve();
8583 check = 0;
8584 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8585 if (ok)
8586 {
8587#ifdef DEBUG
8588 cout << solver->osrl << endl;
8589#endif
8590 cout << "Bonmin solver solution for rosenbrockorigInt checks." << endl;
8591 }
8592 else
8593 { cout << "Bonmin solver solution for rosenbrockorigInt in error:" << endl;
8594 cout << solver->osrl << endl;
8595 }
8596 if(ok == false) throw ErrorClass(" Fail unit test with Bonmin on rosenbrockorigInt.osil");
8597 delete solver;
8598 solver = NULL;
8599 delete osilreader;
8600 osilreader = NULL;
8601 delete fileUtil;
8602 fileUtil = NULL;
8603 unitTestResult << "TEST " << nOfTest << ": Solved problem rosenbrockorigInt.osil with Bonmin" << std::endl;
8604 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8605 }
8606 catch(const ErrorClass& eclass)
8607 {
8608 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Bonmin Solver:"
8609 << endl << eclass.errormsg << endl;
8610 if (solver != NULL)
8611 delete solver;
8612 solver = NULL;
8613 if (osilreader != NULL)
8614 delete osilreader;
8615 osilreader = NULL;
8616 if (fileUtil != NULL)
8617 delete fileUtil;
8618 fileUtil = NULL;
8619 }
8620} // end of if( THOROUGH )
8621#endif // end of #ifdef COIN_HAS_BONMIN
8622
8623
8624#ifdef COIN_HAS_COUENNE
8625// CouenneSolver *solver = NULL;
8626 try{
8627 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on bonminEx1.osil" << endl << endl;
8628
8629 fileUtil = new FileUtil();
8630 solver = new CouenneSolver();
8631 osilreader = new OSiLReader();
8632 osolreader = new OSoLReader();
8633
8634 ok = true;
8635 osilFileName = dataDir + "osilFiles" + dirsep + "bonminEx1.osil";
8636 osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
8637 osil = fileUtil->getFileAsString( osilFileName.c_str());
8638 osol = fileUtil->getFileAsString( osolFileName.c_str());
8639 solver->sSolverName = "couenne";
8640 solver->osil = osil;
8641 solver->osol = osol;
8642 cout << "call the COIN - Couenne Solver for bonminEx1" << endl;
8643 solver->buildSolverInstance();
8644
8645 std::cout << " CALL SOLVE " << std::endl;
8646 solver->solve();
8647
8648 check = -17.07106795327683;
8649 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8650 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8651 if (ok)
8652 {
8653#ifdef DEBUG
8654 cout << solver->osrl << endl;
8655#endif
8656 cout << "Couenne solver solution for bonminEx1 checks." << endl;
8657 }
8658 else
8659 { cout << "Couenne solver solution for bonminEx1 in error:" << endl;
8660 cout << solver->osrl << endl;
8661 }
8662 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on bonminEx1.osil");
8663
8664 delete solver;
8665 solver = NULL;
8666 delete osilreader;
8667 osilreader = NULL;
8668 delete osolreader;
8669 osolreader = NULL;
8670 delete fileUtil;
8671 fileUtil = NULL;
8672 unitTestResult << "TEST " << nOfTest << ": Solved problem bonminEx1.osil with Couenne" << std::endl;
8673 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8674 }
8675 catch(const ErrorClass& eclass)
8676 {
8677 cout << "OSrL = " << solver->osrl << endl;
8678 cout << endl << endl << endl;
8679 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Couenne Solver:"
8680 << endl << eclass.errormsg << endl;
8681 if (solver != NULL)
8682 delete solver;
8683 solver = NULL;
8684 if (osilreader != NULL)
8685 delete osilreader;
8686 osilreader = NULL;
8687 if (osolreader != NULL)
8688 delete osolreader;
8689 osolreader = NULL;
8690 if (fileUtil != NULL)
8691 delete fileUtil;
8692 fileUtil = NULL;
8693 }
8694
8695if( THOROUGH == true){
8696 try{
8697 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on bonminEx1_Nonlinear.osil" << endl << endl;
8698
8699 fileUtil = new FileUtil();
8700 osilreader = new OSiLReader();
8701 osolreader = new OSoLReader();
8702 solver = new CouenneSolver();
8703
8704 ok = true;
8705 osilFileName = dataDir + "osilFiles" + dirsep + "bonminEx1_Nonlinear.osil";
8706// osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
8707 osil = fileUtil->getFileAsString( osilFileName.c_str());
8708// osol = fileUtil->getFileAsString( osolFileName.c_str());
8709 osol = "";
8710 solver->osil = osil;
8711 solver->osol = osol;
8712
8713// solver->osinstance = osilreader->readOSiL( osil);
8714// solver->osoption = osolreader->readOSoL( osol);
8715 cout << "call the COIN - Couenne Solver for bonminEx1_Nonlinear" << endl;
8716 solver->buildSolverInstance();
8717
8718 std::cout << " CALL SOLVE " << std::endl;
8719 solver->solve();
8720
8721 check = -1.707107;
8722 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8723 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8724 if (ok)
8725 {
8726#ifdef DEBUG
8727 cout << solver->osrl << endl;
8728#endif
8729 cout << "Couenne solver solution for bonminEx1_Nonlinear checks." << endl;
8730 }
8731 else
8732 { cout << "Couenne solver solution for bonminEx1_Nonlinear in error:" << endl;
8733 cout << solver->osrl << endl;
8734 }
8735 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on bonminEx1_Nonlinear.osil");
8736
8737 delete solver;
8738 solver = NULL;
8739 delete osilreader;
8740 osilreader = NULL;
8741 delete osolreader;
8742 osolreader = NULL;
8743 delete fileUtil;
8744 fileUtil = NULL;
8745 unitTestResult << "TEST " << nOfTest << ": Solved problem bonminEx1_Nonlinear with Couenne" << std::endl;
8746 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8747 }
8748 catch(const ErrorClass& eclass)
8749{
8750 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Couenne Solver:"
8751 << endl << eclass.errormsg << endl;
8752 if (solver != NULL)
8753 delete solver;
8754 solver = NULL;
8755 if (osilreader != NULL)
8756 delete osilreader;
8757 osilreader = NULL;
8758 if (osolreader != NULL)
8759 delete osolreader;
8760 osolreader = NULL;
8761 if (fileUtil != NULL)
8762 delete fileUtil;
8763 fileUtil = NULL;
8764 }
8765
8766 try{
8767 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on nonconvex.osil" << endl << endl;
8768
8769 fileUtil = new FileUtil();
8770 osilreader = new OSiLReader();
8771 osolreader = new OSoLReader();
8772 solver = new CouenneSolver();
8773
8774 ok = true;
8775 osilFileName = dataDir + "osilFiles" + dirsep + "nonconvex.osil";
8776// osolFileName = dataDir + "osolFiles" + dirsep + "bonminEx1_Couenne.osol";
8777 osil = fileUtil->getFileAsString( osilFileName.c_str());
8778// osol = fileUtil->getFileAsString( osolFileName.c_str());
8779 osol = "";
8780 solver->osil = osil;
8781 solver->osol = osol;
8782// solver->osinstance = osilreader->readOSiL( osil);
8783// solver->osoption = osolreader->readOSoL( osol);
8784 cout << "call the COIN - Couenne Solver for nonconvex.osil" << endl;
8785 solver->buildSolverInstance();
8786
8787 std::cout << "CALL SOLVE" << std::endl;
8788 solver->solve();
8789
8790 check = -6.551133;
8791 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8792 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8793 if (ok)
8794 {
8795#ifdef DEBUG
8796 cout << solver->osrl << endl;
8797#endif
8798 cout << "Couenne solver solution for nonconvex.osil checks." << endl;
8799 }
8800 else
8801 {
8802 cout << "Couenne solver solution for nonconvex.osil in error:" << endl;
8803 cout << solver->osrl << endl;
8804 }
8805 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on nonconvex.osil");
8806
8807 delete solver;
8808 solver = NULL;
8809 delete osilreader;
8810 osilreader = NULL;
8811 delete osolreader;
8812 osolreader = NULL;
8813 delete fileUtil;
8814 fileUtil = NULL;
8815 unitTestResult << "TEST " << nOfTest << ": Solved problem nonconvex.osil with Couenne" << std::endl;
8816 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8817 }
8818 catch(const ErrorClass& eclass)
8819 {
8820 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Couenne Solver:"
8821 << endl << eclass.errormsg << endl;
8822 if (solver != NULL)
8823 delete solver;
8824 solver = NULL;
8825 if (osilreader != NULL)
8826 delete osilreader;
8827 osilreader = NULL;
8828 if (osolreader != NULL)
8829 delete osolreader;
8830 osolreader = NULL;
8831 if (fileUtil != NULL)
8832 delete fileUtil;
8833 fileUtil = NULL;
8834 }
8835
8836 try{
8837 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on rosenbrockorig.osil" << endl << endl;
8838
8839 fileUtil = new FileUtil();
8840 osilreader = new OSiLReader();
8841 osolreader = new OSoLReader();
8842 solver = new CouenneSolver();
8843
8844 ok = true;
8845 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockorig.osil";
8846// osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockorig_Couenne.osol";
8847 osil = fileUtil->getFileAsString( osilFileName.c_str());
8848// osol = fileUtil->getFileAsString( osolFileName.c_str());
8849 osol = "";
8850 solver->osil = osil;
8851 solver->osol = osol;
8852// solver->osinstance = osilreader->readOSiL( osil);
8853// solver->osoption = osolreader->readOSoL( osol);
8854 cout << "call the COIN - Couenne Solver for rosenbrockorig" << endl;
8855 solver->buildSolverInstance();
8856
8857 std::cout << " CALL SOLVE " << std::endl;
8858 solver->solve();
8859
8860 check = 0;
8861 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8862 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8863 if (ok)
8864 {
8865#ifdef DEBUG
8866 cout << solver->osrl << endl;
8867#endif
8868 cout << "Couenne solver solution for rosenbrockorig checks." << endl;
8869 }
8870 else
8871 { cout << "Couenne solver solution for rosenbrockorig in error:" << endl;
8872
8873 cout << solver->osrl << endl;
8874 }
8875 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on rosenbrockorig.osil");
8876
8877 delete solver;
8878 solver = NULL;
8879 delete osilreader;
8880 osilreader = NULL;
8881 delete osolreader;
8882 osolreader = NULL;
8883 delete fileUtil;
8884 fileUtil = NULL;
8885 unitTestResult << "TEST " << nOfTest << ": Solved problem rosenbrockorig.osil with Couenne" << std::endl;
8886 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8887 }
8888 catch(const ErrorClass& eclass)
8889 {
8890 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Couenne Solver:"
8891 << endl << eclass.errormsg << endl;
8892 if (solver != NULL)
8893 delete solver;
8894 solver = NULL;
8895 if (osilreader != NULL)
8896 delete osilreader;
8897 osilreader = NULL;
8898 if (osolreader != NULL)
8899 delete osolreader;
8900 osolreader = NULL;
8901 if (fileUtil != NULL)
8902 delete fileUtil;
8903 fileUtil = NULL;
8904 }
8905
8906 try{
8907 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on wayneQuadratic.osil" << endl << endl;
8908
8909 fileUtil = new FileUtil();
8910 osilreader = new OSiLReader();
8911 osolreader = new OSoLReader();
8912 solver = new CouenneSolver();
8913
8914 ok = true;
8915 osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
8916
8917// osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockinteger_Couenne.osol";
8918 osil = fileUtil->getFileAsString( osilFileName.c_str());
8919// osol = fileUtil->getFileAsString( osolFileName.c_str());
8920 osol = "";
8921 solver->osinstance = NULL;
8922 solver->osil = osil;
8923 solver->osol = osol;
8924// solver->osinstance = osilreader->readOSiL( osil);
8925// solver->osoption = osolreader->readOSoL( osol);
8926 cout << "call the COIN - Couenne Solver for wayneQuadraticr" << endl;
8927 //solver->buildSolverInstance();
8928 std::cout << " CALL SOLVE " << std::endl;
8929 solver->buildSolverInstance();
8930 solver->setSolverOptions();
8931 solver->solve();
8932 check = 2.925;
8933 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
8934 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
8935 if (ok)
8936 {
8937#ifdef DEBUG
8938 cout << solver->osrl << endl;
8939#endif
8940 cout << "Couenne solver solution for wayneQuadratic checks." << endl;
8941 }
8942 else
8943 { cout << "Couenne solver solution for wayneQuadratic in error:" << endl;
8944 cout << solver->osrl << endl;
8945 }
8946 if(ok == false) throw ErrorClass(" Fail unit test with Couenne on wayneQuadratic.osil");
8947
8948 delete solver;
8949 solver = NULL;
8950 delete osilreader;
8951 osilreader = NULL;
8952 delete osolreader;
8953 osolreader = NULL;
8954 delete fileUtil;
8955 fileUtil = NULL;
8956 unitTestResult << "TEST " << nOfTest << ": Solved problem wayneQuadratic.osil with Couenne (default settings)" << std::endl;
8957 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
8958 }
8959 catch(const ErrorClass& eclass)
8960 {
8961 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Couenne Solver:"
8962 << endl << eclass.errormsg << endl;
8963 if (solver != NULL)
8964 delete solver;
8965 solver = NULL;
8966 if (osilreader != NULL)
8967 delete osilreader;
8968 osilreader = NULL;
8969 if (osolreader != NULL)
8970 delete osolreader;
8971 osolreader = NULL;
8972 if (fileUtil != NULL)
8973 delete fileUtil;
8974 fileUtil = NULL;
8975 }
8976
8977 OSrLWriter *tmp_writer = NULL;
8978 try{
8979
8980 cout << endl << "TEST " << ++nOfTest << ": Couenne solver on wayneQuadratic.osil" << endl << endl;
8981
8982 fileUtil = new FileUtil();
8983 osilreader = new OSiLReader();
8984 osolreader = new OSoLReader();
8985 solver = new CouenneSolver();
8986
8987 ok = true;
8988 osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
8989 osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_Couenne.osol";
8990 osil = fileUtil->getFileAsString( osilFileName.c_str());
8991 osol = fileUtil->getFileAsString( osolFileName.c_str());
8992 solver->osil = osil;
8993 solver->osol = osol;
8994 cout << "call the COIN - Couenne Solver for wayneQuadratic.osil" << endl;
8995 solver->buildSolverInstance();
8996
8997 std::cout << " CALL SOLVE " << std::endl;
8998 solver->solve();
8999
9000 cout << "Here is the Couenne solver solution for wayneQuadratic" << endl;
9001
9002 tmp_writer = new OSrLWriter();
9003 solver->osrl = tmp_writer->writeOSrL(solver->osresult);
9004 delete tmp_writer;
9005 tmp_writer = NULL;
9006
9007 string::size_type pos;
9008 pos = solver->osrl.find( "LIMIT_EXCEEDED[COUENNE]");
9009 if(pos == std::string::npos)
9010 {
9011 cout << solver->osrl << endl << endl;
9012 throw ErrorClass(" Error with wayneQuadratic.osil running on Couenne (incorrect diagnostics)");
9013 }
9014#ifdef DEBUG
9015 else
9016 {
9017 cout << solver->osrl << endl << endl;
9018 }
9019#endif
9020 delete solver;
9021 solver = NULL;
9022 delete osilreader;
9023 osilreader = NULL;
9024 delete osolreader;
9025 osolreader = NULL;
9026 delete fileUtil;
9027 fileUtil = NULL;
9028 unitTestResult << "TEST " << nOfTest << ": Correctly diagnosed wayneQuadratic.osil with Couenne (limit exceeded)" << std::endl;
9029 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9030 }
9031 catch(const ErrorClass& eclass)
9032 {
9033 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Couenne Solver:"
9034 << endl << eclass.errormsg << endl;
9035 if (solver != NULL)
9036 delete solver;
9037 solver = NULL;
9038 if (osilreader != NULL)
9039 delete osilreader;
9040 osilreader = NULL;
9041 if (osolreader != NULL)
9042 delete osolreader;
9043 osolreader = NULL;
9044 if (fileUtil != NULL)
9045 delete fileUtil;
9046 fileUtil = NULL;
9047 }
9048} //end of if (THOROUGH)
9049#endif // end of #ifdef COIN_HAS_COUENNE
9050
9051
9052#ifdef COIN_HAS_CSDP
9053 try{
9054 cout << endl << "TEST " << ++nOfTest << ": CSDP solver on SDPA_ex.osil" << endl << endl;
9055
9056 fileUtil = new FileUtil();
9057 osilreader = new OSiLReader();
9058 solver = new CsdpSolver();
9059
9060 ok = true;
9061 osilFileName = dataDir + "osilFiles" + dirsep + "SDPA_ex.osil";
9062 //osolFileName = dataDir + "osolFiles" + dirsep + "lindoapiaddins_lindo.osol";
9063 osil = fileUtil->getFileAsString( osilFileName.c_str());
9064 //osol = fileUtil->getFileAsString( osolFileName.c_str());
9065 cout << "create a new Csdp Solver for OSiL string solution" << endl;
9066 solver->osinstance = osilreader->readOSiL( osil);
9067 //solver->osol = osol;
9068 cout << "call the Csdp Solver" << endl;
9069 solver->buildSolverInstance();
9070 solver->solve();
9071 check = 2.75;
9072 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
9073 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9074 if (ok)
9075 {
9076#ifdef DEBUG
9077 cout << solver->osrl << endl;
9078#endif
9079 cout << "Csdp solver solution for SDPA_ex checks." << endl;
9080 }
9081 else
9082 { cout << "Csdp solver solution for SDPA_ex in error:" << endl;
9083 cout << solver->osrl << endl;
9084 }
9085 if(ok == false) throw ErrorClass("Fail solving problem SDPA_ex.osil with Csdp");
9086
9087 std::cout << std::endl << "now test matrix extensions to OSrL" << std::endl;
9088// osrl = osrlwriter->writeOSrL( osresult);
9089// std::cout << std::endl << std::endl << "Here is osrl: " << std::endl << std::endl;
9090// std::cout << osrl << std::endl;
9091
9092 OSrLReader* osrlreader = new OSrLReader();
9093 std::cout << std::endl << "Read OSrL string" << std::endl;
9094 OSResult* osresult2 = osrlreader->readOSrL(solver->osrl);
9095
9096 OSrLWriter* osrlwriter2 = new OSrLWriter();
9097 OSrLReader* osrlreader2 = new OSrLReader();
9098 std::cout << std::endl << "Write OSrL string" << std::endl;
9099 std::string osrl2 = osrlwriter2->writeOSrL( osresult2);
9100 OSResult* osresult3 = osrlreader2->readOSrL(osrl2);
9101
9102#ifdef DEBUG
9103 std::cout << std::endl << std::endl << "Here is osrl2: " << std::endl << std::endl;
9104 std::cout << osrl2 << std::endl;
9105#endif
9106
9107 // FIXME OSResult::IsEqual() is buggy, see #70
9108 //ok &= osresult2->IsEqual(osresult3);
9109 //if (!ok) throw ErrorClass("OSrL reader/writer loses information in matrix extensions");
9110
9111
9112// delete osresult2;
9113// osresult2 = NULL;
9114// delete osresult3;
9115// osresult3 = NULL;
9116 delete osrlreader2;
9117 osrlreader2 = NULL;
9118 delete osrlwriter2;
9119 osrlwriter2 = NULL;
9120
9121 solver->osinstance = NULL;
9122 delete solver;
9123 solver = NULL;
9124 delete osilreader;
9125 osilreader = NULL;
9126 delete fileUtil;
9127 fileUtil = NULL;
9128 unitTestResult << "TEST " << nOfTest << ": Solved problem SDPA_ex.osil with Csdp" << std::endl;
9129 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9130 }
9131 catch(const ErrorClass& eclass)
9132 {
9133 //cout << "OSrL = " << solver->osrl << endl;
9134 cout << endl << endl << endl;
9135 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Csdp Solver:"
9136 << endl << eclass.errormsg << endl << endl;
9137 if (solver != NULL)
9138 delete solver;
9139 solver = NULL;
9140 if (osilreader != NULL)
9141 delete osilreader;
9142 osilreader = NULL;
9143 if (fileUtil != NULL)
9144 delete fileUtil;
9145 fileUtil = NULL;
9146 }
9147#endif
9148
9149
9150#ifdef COIN_HAS_LINDO
9151 try{
9152 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on lindoapiaddins.osil" << endl << endl;
9153
9154 fileUtil = new FileUtil();
9155 osilreader = new OSiLReader();
9156 solver = new LindoSolver();
9157
9158 ok = true;
9159 osilFileName = dataDir + "osilFiles" + dirsep + "lindoapiaddins.osil";
9160 osolFileName = dataDir + "osolFiles" + dirsep + "lindoapiaddins_lindo.osol";
9161 osil = fileUtil->getFileAsString( osilFileName.c_str());
9162 osol = fileUtil->getFileAsString( osolFileName.c_str());
9163 cout << "create a new LINDO Solver for OSiL string solution" << endl;
9164 solver->osinstance = osilreader->readOSiL( osil);
9165 solver->osol = osol;
9166 cout << "call the LINDO Solver" << endl;
9167 solver->buildSolverInstance();
9168 solver->solve();
9169 check = 99;
9170 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
9171 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9172 if (ok)
9173 {
9174#ifdef DEBUG
9175 cout << solver->osrl << endl;
9176#endif
9177 cout << "LINDO solver solution for lindoapiaddins checks." << endl;
9178 }
9179 else
9180 { cout << "LINDO solver solution for lindoapiaddins in error:" << endl;
9181 cout << solver->osrl << endl;
9182 }
9183 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on lindoapiaddins.osil");
9184 solver->osinstance = NULL;
9185 delete solver;
9186 solver = NULL;
9187 delete osilreader;
9188 osilreader = NULL;
9189 delete fileUtil;
9190 fileUtil = NULL;
9191 unitTestResult << "TEST " << nOfTest << ": Solved problem lindoapiaddins.osil with Lindo" << std::endl;
9192 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9193 }
9194 catch(const ErrorClass& eclass)
9195 {
9196 //cout << "OSrL = " << solver->osrl << endl;
9197 cout << endl << endl << endl;
9198 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the LINDO Solver:"
9199 << endl << eclass.errormsg << endl << endl;
9200 if (solver != NULL)
9201 delete solver;
9202 solver = NULL;
9203 if (osilreader != NULL)
9204 delete osilreader;
9205 osilreader = NULL;
9206 if (fileUtil != NULL)
9207 delete fileUtil;
9208 fileUtil = NULL;
9209 }
9210
9211if (THOROUGH == true){
9212 try{
9213 // now solve the rosenbrock problem from the OSiL paper
9214 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on rosenbrockmod.osil" << endl << endl;
9215
9216 fileUtil = new FileUtil();
9217 solver = new LindoSolver();
9218
9219 osilFileName = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
9220 osolFileName = dataDir + "osolFiles" + dirsep + "rosenbrockmod_lindo.osol";
9221 osil = fileUtil->getFileAsString( osilFileName.c_str());
9222 osol = fileUtil->getFileAsString( osolFileName.c_str());
9223 solver->osil = osil;
9224 solver->osol = osol;
9225 solver->osinstance = NULL;
9226 cout << "call the LINDO Solver" << endl;
9227 solver->buildSolverInstance();
9228 solver->solve();
9229 check = 6.7279;
9230 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
9231 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9232 if (ok)
9233 {
9234#ifdef DEBUG
9235 cout << solver->osrl << endl;
9236#endif
9237 cout << "LINDO solver solution for rosenbrockmod checks." << endl;
9238 }
9239 else
9240 { cout << "LINDO solver solution for rosenbrockmod in error:" << endl;
9241 cout << solver->osrl << endl;
9242 }
9243 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on rosenbrockmod.osil");
9244 solver->osinstance = NULL;
9245 delete solver;
9246 solver = NULL;
9247 delete fileUtil;
9248 fileUtil = NULL;
9249 unitTestResult << "TEST " << nOfTest << ": Solved problem rosenbrockmod.osil with Lindo" << std::endl;
9250 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9251 }
9252 catch(const ErrorClass& eclass)
9253 {
9254 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the Lindo Solver:"
9255 << endl << eclass.errormsg << endl;
9256 if (solver != NULL)
9257 delete solver;
9258 solver = NULL;
9259 if (fileUtil != NULL)
9260 delete fileUtil;
9261 fileUtil = NULL;
9262 }
9263
9264 try{
9265 // now solve a pure quadratic
9266 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on parincQuadratic.osil" << endl << endl;
9267
9268 fileUtil = new FileUtil();
9269 osolreader = new OSoLReader();
9270 solver = new LindoSolver();
9271
9272 osilFileName = dataDir + "osilFiles" + dirsep + "parincQuadratic.osil";
9273 osolFileName = dataDir + "osolFiles" + dirsep + "parincQuadratic_lindo.osol";
9274 osil = fileUtil->getFileAsString( osilFileName.c_str());
9275 osol = fileUtil->getFileAsString( osolFileName.c_str());
9276 solver->osil = osil;
9277 solver->osol = osol;
9278 solver->osinstance = NULL;
9279 solver->osoption = osolreader->readOSoL( osol);
9280 cout << "call the LINDO Solver" << endl;
9281 solver->buildSolverInstance();
9282 solver->solve();
9283 check = 49920.5;
9284 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
9285 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9286 if (ok)
9287 {
9288#ifdef DEBUG
9289 cout << solver->osrl << endl;
9290#endif
9291 cout << "LINDO solver solution for parincQuadratic checks." << endl;
9292 }
9293 else
9294 { cout << "LINDO solver solution for parincQuadratic in error:" << endl;
9295 cout << solver->osrl << endl;
9296 }
9297 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on parincQuadratic.osil");
9298 delete solver;
9299 solver = NULL;
9300 delete osolreader;
9301 osolreader = NULL;
9302 delete fileUtil;
9303 fileUtil = NULL;
9304 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.osil with Lindo" << std::endl;
9305 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9306 }
9307 catch(const ErrorClass& eclass)
9308 {
9309 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the LINDO Solver:"
9310 << endl << eclass.errormsg << endl;
9311 if (solver != NULL)
9312 delete solver;
9313 solver = NULL;
9314 if (osolreader != NULL)
9315 delete osolreader;
9316 osolreader = NULL;
9317 if (fileUtil != NULL)
9318 delete fileUtil;
9319 fileUtil = NULL;
9320 }
9321
9322 try{
9323 // now solve a quadratic binary problem
9324 // wayneQuadratic.osil
9325 /*
9326 cout << endl << "TEST " << ++nOfTest << ": Lindo solver on wayneQuadratic.osil" << endl << endl;
9327 osilFileName = dataDir + "osilFiles" + dirsep + "wayneQuadratic.osil";
9328 osolFileName = dataDir + "osolFiles" + dirsep + "wayneQuadratic_lindo.osol";
9329 osil = fileUtil->getFileAsString( osilFileName.c_str());
9330 osol = fileUtil->getFileAsString( osolFileName.c_str());
9331 osilreader = new OSiLReader();
9332 solver = new LindoSolver();
9333 solver->osil = osil;
9334 solver->osol = osol;
9335 solver->osinstance = osilreader->readOSiL( osil);
9336 cout << "call the LINDO Solver" << endl;
9337 solver->buildSolverInstance();
9338 solver->solve();
9339 check = 2.925;
9340 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-10 , 1e-10);
9341 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9342 if (ok)
9343 {
9344#ifdef DEBUG
9345 cout << solver->osrl << endl;
9346#endif
9347 cout << "LINDO solver solution for wayneQuadratic checks." << endl;
9348 }
9349 else
9350 { cout << "LINDO solver solution for wayneQuadratic in error:" << endl;
9351 cout << solver->osrl << endl;
9352 }
9353 if(ok == false) throw ErrorClass(" Fail unit test with LINDO on wayneQuadratic.osil");
9354 delete solver;
9355 solver = NULL;
9356 delete osolreader;
9357 osolreader = NULL;
9358 unitTestResult << "TEST " << nOfTest << ": Solved problem wayneQuadratic.osil with Lindo" << std::endl;
9359 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9360 }
9361 catch(const ErrorClass& eclass)
9362 {
9363 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the LINDO Solver:"
9364 << endl << eclass.errormsg << endl;
9365 if (solver != NULL)
9366 delete solver;
9367 solver = NULL;
9368 if (osilreader != NULL)
9369 delete osilreader;
9370 osilreader = NULL;
9371 if (osolreader != NULL)
9372 delete osolreader;
9373 osolreader = NULL;
9374 }
9375 */
9376} // end of if( THOROUGH)
9377#endif // end of #ifdef COIN_HAS_LINDO
9378} // end of if(SOLVER_TESTS)
9379
9380
9381
9382// now solve with an OSInstance created from an MPS file
9383if (OTHER_TESTS){
9384 try{
9385 cout << endl << "TEST " << ++nOfTest << ": Cbc solver using MPS file" << endl << endl;
9386
9387 mpsFileName = dataDir + "mpsFiles" + dirsep + "parinc.mps";
9388 mps2osil = new OSmps2OS( mpsFileName);
9389 solver = new CoinSolver();
9390
9391 ok = true;
9392// cout << endl;
9393// cout << "Start testing MPS file conversion" << endl << endl;
9394 cout << "create a COIN Solver for MPS - OSInstance solution" << endl;
9395 solver->sSolverName = "cbc";
9396 mps2osil->createOSObjects();
9397 solver->osinstance = mps2osil->osinstance;
9398 osol = "<osol></osol>";
9399 solver->osol = osol;
9400 cout << "call COIN Solve" << endl;
9401 solver->buildSolverInstance();
9402 solver->solve();
9403 check = -7668;
9404 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
9405 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9406 if (ok)
9407 {
9408#ifdef DEBUG
9409 cout << solver->osrl << endl;
9410#endif
9411 cout << "COIN solver solution for parinc.mps checks." << endl;
9412 }
9413 else
9414 { cout << "COIN solver solution for parinc.mps in error:" << endl;
9415 cout << solver->osrl << endl;
9416 }
9417 if(ok == false) throw ErrorClass(" Fail unit test with COIN Solver on MPS test problem parincLinear.mps");
9418 delete solver;
9419 solver = NULL;
9420 delete mps2osil;
9421 mps2osil = NULL;
9422// cout << endl;
9423// cout << "Done with MPS testing" << endl;
9424 unitTestResult << "TEST " << nOfTest << ": Test the MPS -> OSiL converter on parinc.mps using Cbc" << std::endl;
9425 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9426 }
9427 catch(const ErrorClass& eclass)
9428 {
9429 cout << "OSrL = " << solver->osrl << endl;
9430 cout << endl << endl << endl;
9431 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the MPS converter:"
9432 << endl << eclass.errormsg << endl;
9433
9434 if (solver != NULL)
9435 delete solver;
9436 solver = NULL;
9437 if (mps2osil != NULL)
9438 delete mps2osil;
9439 mps2osil = NULL;
9440 }
9441
9442#ifdef COIN_HAS_IPOPT
9443 try{
9444 // solve another problem
9445 // a problem that is a pure quadratic
9446 cout << endl << "TEST " << ++nOfTest << ": Ipopt solver on parincQuadratic.mps" << endl << endl;
9447
9448 mpsFileName = dataDir + "mpsFiles" + dirsep + "parincQuadratic.mps";
9449 mps2osil = new OSmps2OS( mpsFileName);
9450 solver = new IpoptSolver();
9451
9452 ok = true;
9453// cout << endl;
9454// cout << "Start testing MPS file conversion" << endl << endl;
9455 cout << "create an IPOPT Solver for MPS - OSInstance solution" << endl;
9456 solver->sSolverName = "ipopt";
9457 mps2osil->createOSObjects();
9458
9459 solver->osinstance = mps2osil->osinstance;
9460 osol = "<osol></osol>";
9461 solver->osol = osol;
9462 cout << "call the IPOPT Solver" << endl;
9463 solver->buildSolverInstance();
9464 solver->solve();
9465
9466 check = -49920.5;
9467 //ok &= NearEqual(getObjVal( ipoptSolver->osrl) , check, 1e-10 , 1e-10);
9468 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9469 if (ok)
9470 {
9471#ifdef DEBUG
9472 cout << solver->osrl << endl;
9473#endif
9474 cout << "IPOPT solver solution for parincQuadratic checks." << endl;
9475 }
9476 else
9477 {
9478 cout << "IPOPT solver solution for parincQuadratic in error:" << endl;
9479 cout << solver->osrl << endl;
9480 }
9481
9482 if (ok == false) throw ErrorClass(" Fail unit test with Ipopt on parincQuadratic.mps");
9483 delete solver;
9484 solver = NULL;
9485 delete mps2osil;
9486 mps2osil = NULL;
9487 unitTestResult << "TEST " << nOfTest << ": Solved problem parincQuadratic.mps with Ipopt" << std::endl;
9488 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9489 }
9490 catch(const ErrorClass& eclass)
9491 {
9492 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the quadratic MPS converter:"
9493 << endl << eclass.errormsg<< endl;
9494 if (solver != NULL)
9495 delete solver;
9496 solver = NULL;
9497 if (mps2osil != NULL)
9498 delete mps2osil;
9499 mps2osil = NULL;
9500 }
9501#endif
9502
9503
9504// test reading a GAMS file
9505
9506#if 0
9507#ifdef COIN_HAS_GAMSUTILS
9508 OSgams2osil *gams2osil;
9509 try{
9510 std::cout << "Working with GAMSIO " << std::endl;
9511
9512 //std::string gmsControlFile = "/home/kmartin/bin/gams/23.2/225a/gamscntr.dat";
9513 std::string gmsControlFile = dataDir + "gamsFiles" + dirsep + "225a" + dirsep + "gamscntr.dat";
9514 gams2osil = new OSgams2osil( gmsControlFile);
9515
9516 gams2osil->createOSInstance();
9517 std::cout << gams2osil->osinstance->printModel() << std::endl;
9518 std::cout << "Done Working with GAMSIO " << std::endl;
9519 delete gams2osil;
9520 gams2osil = NULL;
9521 }
9522 catch(const ErrorClass& eclass)
9523 {
9524 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the GAMS interface:"
9525 << endl << eclass.errormsg << endl;
9526
9527 if (gams2osil != NULL)
9528 delete gams2osil;
9529 gams2osil = NULL;
9530 }
9531#endif
9532#endif
9533
9534// now solve with an OSInstance created from an AMPL nl file
9535#ifdef COIN_HAS_ASL
9536 try{
9537 cout << endl << "TEST " << ++nOfTest << ": AMPL solver interface" << endl << endl;
9538
9539 nlFileName = dataDir + "amplFiles" + dirsep + "parinc.nl";
9540
9541 ASL *cw, *rw, *asl;
9542 cw = ASL_alloc(ASL_read_fg);
9543 rw = ASL_alloc(ASL_read_fg);
9544 asl = cw;
9545
9546 jac0dim((char*)nlFileName.c_str(), (fint)strlen(nlFileName.c_str()));
9547
9548 OSnl2OS *nl2osil = new OSnl2OS(cw, rw, asl);
9549
9550 nl2osil->readNl(nlFileName) ;
9551
9552 solver = new CoinSolver();
9553
9554 cout << "create a cbc Solver for AMPL nl - OSInstance solution" << endl;
9555 solver->sSolverName = "cbc";
9556 nl2osil->createOSObjects();
9557 solver->osinstance = nl2osil->osinstance;
9558 solver->osoption = nl2osil->osoption;
9559
9560 OSiLWriter tmp_osil_writer;
9561 tmp_osil_writer.m_bWhiteSpace = true;
9562 //std::cout << tmp_osil_writer.writeOSiL( solver->osinstance) << std::endl;
9563
9564// osol = ""; //<osol></osol>";
9565// solver->osol = osol;
9566 cout << "call Cbc Solve" << endl;
9567 solver->buildSolverInstance();
9568 solver->solve();
9569 check = 7668;
9570
9571 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
9572 if (ok)
9573 {
9574#ifdef DEBUG
9575 cout << solver->osrl << endl;
9576#endif
9577 cout << "COIN cbc solver solution for parinc.nl checks." << endl;
9578 }
9579 else
9580 {
9581 cout << "COIN cbc solver solution for parinc.nl in error:" << endl;
9582 cout << solver->osrl << endl;
9583 throw ErrorClass(" Fail unit test with OSnl2osil on problem parinc.nl");
9584 }
9585
9586 solver->osinstance = NULL;
9587 delete solver;
9588 solver = NULL;
9589 delete nl2osil;
9590 nl2osil = NULL;
9591 unitTestResult << "TEST " << nOfTest << ": Test the AMPL nl -> OSiL converter on parinc.nl using Cbc" << std::endl;
9592 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
9593 }
9594 catch(const ErrorClass& eclass)
9595 {
9596 cout << "OSrL = " << solver->osrl << endl;
9597 cout << endl << endl << endl;
9598 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing the AMPL interface:"
9599 << endl << eclass.errormsg << endl;
9600
9601 if (solver != NULL)
9602 delete solver;
9603 solver = NULL;
9604 if (nl2osil != NULL)
9605 delete nl2osil;
9606 nl2osil = NULL;
9607 }
9608
9609// test the AMPL solution writer and suffix handling
9610 OSResult *osresult = NULL;
9611 OSnl2OS *nl2osil = NULL;
9612 OSosrl2ampl *solWriter = NULL;
9613 OSrLWriter *temp_writer = NULL;
9614 double *xval = NULL;
9615 double *zval = NULL;
9616 int* IBS = NULL;
9617
9618 try
9619 {
9620 cout << endl << "TEST " << ++nOfTest << ": AMPL suffix handler and solution writer" << endl << endl;
9621
9622 nlFileName = dataDir + "amplFiles" + dirsep + "suffixTest.nl";
9623
9624 ASL *cw, *rw, *asl;
9625 cw = ASL_alloc(ASL_read_fg);
9626 rw = ASL_alloc(ASL_read_fg);
9627 asl = cw;
9628
9629 jac0dim((char*)nlFileName.c_str(), (fint)strlen(nlFileName.c_str()));
9630
9631 nl2osil = new OSnl2OS(cw, rw, asl);
9632
9633 nl2osil->readNl(nlFileName);
9634
9635 fileUtil = new FileUtil();
9636 osolFileName = dataDir + "osolFiles" + dirsep + "suffixTest.osol";
9637 nl2osil->osol = fileUtil->getFileAsString( osolFileName.c_str());
9638 delete fileUtil;
9639 fileUtil = NULL;
9640
9641 std::cout << std::endl << "Create OS objects" << std::endl << std::endl;
9642
9643 nl2osil->createOSObjects();
9644
9645// transfer suffix information from osol to osrl
9646
9647 std::cout << "transfer suffix information from osol to osrl" << std::endl;
9648
9649 int nVars = nl2osil->osinstance->getVariableNumber();
9650 int nObjs = nl2osil->osinstance->getObjectiveNumber();
9651 int nCons = nl2osil->osinstance->getConstraintNumber();
9652
9653 osresult = new OSResult();
9654
9659
9660 xval = new double[nVars];
9661 for (int i=0; i < nVars; i++)
9662 xval[i] = 1.2345;
9663
9664 zval = new double[nCons];
9665 for (int i=0; i < nCons; i++)
9666 zval[i] = 1.3131;
9667
9669 throw ErrorClass(" Fail setting primal variables in AMPL suffix handler");
9670 if (!osresult->setDualVariableValuesDense(0, zval))
9671 throw ErrorClass(" Fail setting dual variables in AMPL suffix handler");
9672
9673 for (int status=0; status < ENUM_BASIS_STATUS_NUMBER_OF_STATES; status++)
9674 {
9676 if (nvar > 0)
9677 {
9678
9679 std::cout << "transfer basis info for variables - " << returnBasisStatusString((ENUM_BASIS_STATUS)status) << std::endl;
9680
9681 IBS = new int[nvar];
9683 throw ErrorClass(" Fail basis retrieval in AMPL suffix handler");
9684 if (!osresult->setBasisStatus(0, ENUM_PROBLEM_COMPONENT_variables, status, IBS, nvar) )
9685 throw ErrorClass(" Fail basis transfer in AMPL suffix handler");
9686 delete[] IBS; IBS = NULL;
9687 }
9688 }
9689
9690 for (int status=0; status < ENUM_BASIS_STATUS_NUMBER_OF_STATES; status++)
9691 {
9693 if (ncon > 0)
9694 {
9695
9696 std::cout << "transfer basis info for slacks - " << returnBasisStatusString((ENUM_BASIS_STATUS)status) << std::endl;
9697
9698 IBS = new int[ncon];
9700 throw ErrorClass(" Fail basis retrieval in AMPL suffix handler");
9701 if (!osresult->setBasisStatus(0, ENUM_PROBLEM_COMPONENT_constraints, status, IBS, ncon) )
9702 throw ErrorClass(" Fail basis transfer in AMPL suffix handler");
9703 delete[] IBS; IBS = NULL;
9704 }
9705 }
9706
9707 // now transfer other variable information
9708
9709 int nOther = nl2osil->osoption->getNumberOfOtherVariableOptions();
9710 if (!osresult->setNumberOfOtherVariableResults(0, nOther + 3))
9711 throw ErrorClass(" Fail setting numberOfOtherVariableResults in AMPL suffix handler");
9712 for (int i=0; i<nOther; i++)
9713 {
9714 OtherVariableOption *otherVar = nl2osil->osoption->getOtherVariableOption(i);
9715
9716
9717 std::cout << "transfer variable suffix " << otherVar->name << std::endl;
9718
9719
9721 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9723 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9724 if (!osresult->setOtherVariableResultName(0, i, otherVar->name))
9725 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9726 if (!osresult->setOtherVariableResultType(0, i, otherVar->type))
9727 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9728 if (!osresult->setOtherVariableResultVarType(0, i, otherVar->varType))
9729 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9730 if (!osresult->setOtherVariableResultEnumType(0, i, otherVar->enumType))
9731 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9732 if (!osresult->setOtherVariableResultValue(0, i, otherVar->value))
9733 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9735 throw ErrorClass(" Fail setting OtherVariableResult in AMPL suffix handler");
9736
9737 if (otherVar->var != NULL)
9738 {
9739 for (int j=0; j < otherVar->numberOfVar; j++)
9740 {
9741 if (!osresult->setOtherVariableResultVar(0, i, j, otherVar->var[j]->value))
9742 throw ErrorClass(" Fail setting OtherVariableResult <var> array in AMPL suffix handler");
9743 if (!osresult->setOtherVariableResultVarIdx(0, i, j, otherVar->var[j]->idx))
9744 throw ErrorClass(" Fail setting OtherVariableResult <var> array in AMPL suffix handler");
9745 }
9746 }
9747
9748 if (otherVar->enumeration != NULL)
9749 {
9750 for (int j=0; j < otherVar->numberOfEnumerations; j++)
9751 {
9754 otherVar->enumeration[j]->value, otherVar->enumeration[j]->description,
9755 otherVar->enumeration[j]->el, otherVar->enumeration[j]->numberOfEl) )
9756 throw ErrorClass(" Fail setting OtherVariableResult enumeration in AMPL suffix handler");
9757 }
9758 }
9759 }
9760
9761 // add three special results. The first is "morevarinteger", mentioned in the .mod file with kind=OUT
9762
9763 std::cout << "add variable suffix morevarinteger" << std::endl;
9764
9765
9766 if (!osresult->setOtherVariableResultNumberOfVar(0, nOther, nVars))
9767 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9769 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9770 if (!osresult->setOtherVariableResultName(0, nOther, "morevarinteger"))
9771 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9772 if (!osresult->setOtherVariableResultType(0, nOther, "none"))
9773 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9774 if (!osresult->setOtherVariableResultVarType(0, nOther, "integer"))
9775 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9776 if (!osresult->setOtherVariableResultEnumType(0, nOther, "integer"))
9777 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9778 if (!osresult->setOtherVariableResultValue(0, nOther, ""))
9779 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9780 if (!osresult->setOtherVariableResultDescription(0, nOther, "to test suffixes of kind=OUT that do not show up in the .nl file"))
9781 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9782
9783 for (int j=0; j < nVars; j++)
9784 {
9785 ostringstream oss;
9786 oss << 2*j - 2;
9787 if (!osresult->setOtherVariableResultVar(0, nOther, j, oss.str()))
9788 throw ErrorClass(" Fail setting OtherVariableResult <var> array in AMPL suffix handler");
9789 if (!osresult->setOtherVariableResultVarIdx(0, nOther, j, j))
9790 throw ErrorClass(" Fail setting OtherVariableResult <var> array in AMPL suffix handler");
9791 }
9792
9793
9794
9795 // add one more result, this time with an enumeration, just to be sure...
9796
9797 std::cout << "add variable suffix with enumeration" << std::endl;
9798
9799
9800 if (!osresult->setOtherVariableResultNumberOfVar(0, nOther + 1, 0))
9801 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9803 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9804 if (!osresult->setOtherVariableResultName(0, nOther + 1, "TestVarEnum"))
9805 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9806 if (!osresult->setOtherVariableResultType(0, nOther + 1, "none"))
9807 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9808 if (!osresult->setOtherVariableResultVarType(0, nOther + 1, "triple"))
9809 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9810 if (!osresult->setOtherVariableResultEnumType(0, nOther + 1, "integer"))
9811 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9812 if (!osresult->setOtherVariableResultValue(0, nOther + 1, ""))
9813 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9814 if (!osresult->setOtherVariableResultDescription(0, nOther + 1, "To make sure that at least one of the options has an enumeration"))
9815 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9816
9817 int enumArray[2];
9818
9819 enumArray[0] = 1;
9820 enumArray[1] = 2;
9822 0, "11", "First value", enumArray, 2) )
9823 throw ErrorClass(" Fail adding OtherVariableResult enumeration in AMPL suffix handler");
9824
9825 enumArray[0] = 3;
9826 enumArray[1] = 0;
9828 1, "12", "Last value",
9829 enumArray, 2) )
9830 throw ErrorClass(" Fail adding OtherVariableResult enumeration in AMPL suffix handler");
9831
9832 // ...and another with just a single value
9833
9834 std::cout << "add variable suffix with value only" << std::endl;
9835
9836
9837 if (!osresult->setOtherVariableResultNumberOfVar(0, nOther + 2, 0))
9838 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9840 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9841 if (!osresult->setOtherVariableResultName(0, nOther + 2, "TestVarValue"))
9842 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9843 if (!osresult->setOtherVariableResultType(0, nOther + 2, "real"))
9844 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9845 if (!osresult->setOtherVariableResultVarType(0, nOther + 2, "double"))
9846 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9847 if (!osresult->setOtherVariableResultEnumType(0, nOther + 2, "none"))
9848 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9849 if (!osresult->setOtherVariableResultValue(0, nOther + 2, "3.14"))
9850 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9851 if (!osresult->setOtherVariableResultDescription(0, nOther + 2, "To make sure that at least one of the options has no array"))
9852 throw ErrorClass(" Fail adding OtherVariableResult in AMPL suffix handler");
9853
9854 // next: transfer constraint/dual information
9855
9856 nOther = nl2osil->osoption->getNumberOfOtherConstraintOptions();
9857 if (!osresult->setNumberOfOtherConstraintResults(0, nOther + 3))
9858 throw ErrorClass(" Fail setting numberOfOtherConstraintResults in AMPL suffix handler");
9859 for (int i=0; i<nOther; i++)
9860 {
9862
9863 std::cout << "transfer constraint suffix " << otherCon->name << std::endl;
9864
9865
9867 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9869 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9870 if (!osresult->setOtherConstraintResultName(0, i, otherCon->name))
9871 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9872 if (!osresult->setOtherConstraintResultType(0, i, otherCon->type))
9873 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9874 if (!osresult->setOtherConstraintResultConType(0, i, otherCon->conType))
9875 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9876 if (!osresult->setOtherConstraintResultEnumType(0, i, otherCon->enumType))
9877 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9878 if (!osresult->setOtherConstraintResultValue(0, i, otherCon->value))
9879 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9881 throw ErrorClass(" Fail setting OtherConstraintResult in AMPL suffix handler");
9882
9883 if (otherCon->con != NULL)
9884 {
9885 for (int j=0; j < otherCon->numberOfCon; j++)
9886 {
9887 if (!osresult->setOtherConstraintResultCon(0, i, j, otherCon->con[j]->value))
9888 throw ErrorClass(" Fail setting OtherConstraintResult <con> array in AMPL suffix handler");
9889 if (!osresult->setOtherConstraintResultConIdx(0, i, j, otherCon->con[j]->idx))
9890 throw ErrorClass(" Fail setting OtherConstraintResult <con> array in AMPL suffix handler");
9891 }
9892 }
9893
9894 if (otherCon->enumeration != NULL)
9895 {
9896 for (int j=0; j < otherCon->numberOfEnumerations; j++)
9897 {
9900 otherCon->enumeration[j]->value, otherCon->enumeration[j]->description,
9901 otherCon->enumeration[j]->el, otherCon->enumeration[j]->numberOfEl) )
9902 throw ErrorClass(" Fail setting OtherConstraintResult enumeration in AMPL suffix handler");
9903 }
9904 }
9905 }
9906
9907 // add three special results. The first is "moreconinteger", mentioned in the .mod file with kind=OUT
9908
9909 std::cout << "add variable suffix moreconinteger" << std::endl;
9910
9911
9912 if (!osresult->setOtherConstraintResultNumberOfCon(0, nOther, nCons))
9913 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9915 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9916 if (!osresult->setOtherConstraintResultName(0, nOther, "moreconinteger"))
9917 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9918 if (!osresult->setOtherConstraintResultType(0, nOther, "none"))
9919 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9920 if (!osresult->setOtherConstraintResultConType(0, nOther, "integer"))
9921 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9922 if (!osresult->setOtherConstraintResultEnumType(0, nOther, "integer"))
9923 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9924 if (!osresult->setOtherConstraintResultValue(0, nOther, ""))
9925 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9926 if (!osresult->setOtherConstraintResultDescription(0, nOther, "to test suffixes of kind=OUT that do not show up in the .nl file"))
9927 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9928
9929 for (int j=0; j < nCons; j++)
9930 {
9931 if (!osresult->setOtherConstraintResultCon(0, nOther, j, "23"))
9932 throw ErrorClass(" Fail setting OtherConstraintResult <con> array in AMPL suffix handler");
9933 if (!osresult->setOtherConstraintResultConIdx(0, nOther, j, j))
9934 throw ErrorClass(" Fail setting OtherConstraintResult <con> array in AMPL suffix handler");
9935 }
9936
9937
9938 // add one more result, this time with an enumeration, just to be sure...
9939
9940 std::cout << "add constraint suffix with enumeration" << std::endl;
9941
9942
9943 if (!osresult->setOtherConstraintResultNumberOfCon(0, nOther+1, 0))
9944 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9946 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9947 if (!osresult->setOtherConstraintResultName(0, nOther+1, "TestConEnum"))
9948 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9949 if (!osresult->setOtherConstraintResultType(0, nOther+1, "none"))
9950 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9951 if (!osresult->setOtherConstraintResultConType(0, nOther+1, "triple"))
9952 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9953 if (!osresult->setOtherConstraintResultEnumType(0, nOther+1, "integer"))
9954 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9955 if (!osresult->setOtherConstraintResultValue(0, nOther+1, ""))
9956 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9957 if (!osresult->setOtherConstraintResultDescription(0, nOther+1, "To make sure that at least one of the options has an enumeration"))
9958 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9959
9960 enumArray[0] = 2;
9961 enumArray[1] = 3;
9963 0, "21", "First value", enumArray, 2) )
9964 throw ErrorClass(" Fail adding OtherConstraintResult enumeration in AMPL suffix handler");
9965
9966 enumArray[0] = 1;
9967 enumArray[1] = 0;
9969 1, "22", "Last value",
9970 enumArray, 2) )
9971 throw ErrorClass(" Fail adding OtherConstraintResult enumeration in AMPL suffix handler");
9972
9973 // ...and another with just a single value
9974
9975 std::cout << "add constraint suffix with value only" << std::endl;
9976
9977
9978 if (!osresult->setOtherConstraintResultNumberOfCon(0, nOther + 2, 0))
9979 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9981 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9982 if (!osresult->setOtherConstraintResultName(0, nOther + 2, "TestConValue"))
9983 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9984 if (!osresult->setOtherConstraintResultType(0, nOther + 2, "real"))
9985 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9986 if (!osresult->setOtherConstraintResultConType(0, nOther + 2, "double"))
9987 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9988 if (!osresult->setOtherConstraintResultEnumType(0, nOther + 2, "none"))
9989 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9990 if (!osresult->setOtherConstraintResultValue(0, nOther + 2, "2.71828"))
9991 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9992 if (!osresult->setOtherConstraintResultDescription(0, nOther + 2, "To make sure that at least one of the options has no array"))
9993 throw ErrorClass(" Fail adding OtherConstraintResult in AMPL suffix handler");
9994
9995
9996 // next: transfer objective information
9997
9998 nOther = nl2osil->osoption->getNumberOfOtherObjectiveOptions();
9999 if (!osresult->setNumberOfOtherObjectiveResults(0, nOther + 3))
10000 throw ErrorClass(" Fail setting numberOfOtherVariableResults in AMPL suffix handler");
10001 for (int i=0; i<nOther; i++)
10002 {
10003 OtherObjectiveOption *otherObj = nl2osil->osoption->getOtherObjectiveOption(i);
10004
10005 std::cout << "transfer objective suffix " << otherObj->name << std::endl;
10006
10007
10009 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10011 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10012 if (!osresult->setOtherObjectiveResultName(0, i, otherObj->name))
10013 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10014 if (!osresult->setOtherObjectiveResultType(0, i, otherObj->type))
10015 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10016 if (!osresult->setOtherObjectiveResultObjType(0, i, otherObj->objType))
10017 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10018 if (!osresult->setOtherObjectiveResultEnumType(0, i, otherObj->enumType))
10019 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10020 if (!osresult->setOtherObjectiveResultValue(0, i, otherObj->value))
10021 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10023 throw ErrorClass(" Fail setting OtherObjectiveResult in AMPL suffix handler");
10024
10025 if (otherObj->obj != NULL)
10026 {
10027 for (int j=0; j < otherObj->numberOfObj; j++)
10028 {
10029 if (!osresult->setOtherObjectiveResultObj(0, i, j, otherObj->obj[j]->value))
10030 throw ErrorClass(" Fail setting OtherObjectiveResult <obj> array in AMPL suffix handler");
10031 if (!osresult->setOtherObjectiveResultObjIdx(0, i, j, otherObj->obj[j]->idx))
10032 throw ErrorClass(" Fail setting OtherObjectiveResult <obj> array in AMPL suffix handler");
10033 }
10034 }
10035
10036 if (otherObj->enumeration != NULL)
10037 {
10038 for (int j=0; j < otherObj->numberOfEnumerations; j++)
10039 {
10042 otherObj->enumeration[j]->value, otherObj->enumeration[j]->description,
10043 otherObj->enumeration[j]->el, otherObj->enumeration[j]->numberOfEl) )
10044 throw ErrorClass(" Fail setting OtherObjectiveResult enumeration in AMPL suffix handler");
10045 }
10046 }
10047 }
10048
10049
10050 // add three special results. The first is "moreobjinteger", mentioned in the .mod file with kind=OUT
10051
10052 std::cout << "add variable suffix moreobjinteger" << std::endl;
10053
10054
10055 if (!osresult->setOtherObjectiveResultNumberOfObj(0, nOther, nObjs))
10056 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10058 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10059 if (!osresult->setOtherObjectiveResultName(0, nOther, "moreobjinteger"))
10060 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10061 if (!osresult->setOtherObjectiveResultType(0, nOther, "none"))
10062 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10063 if (!osresult->setOtherObjectiveResultObjType(0, nOther, "integer"))
10064 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10065 if (!osresult->setOtherObjectiveResultEnumType(0, nOther, "integer"))
10066 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10067 if (!osresult->setOtherObjectiveResultValue(0, nOther, ""))
10068 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10069 if (!osresult->setOtherObjectiveResultDescription(0, nOther, "to test suffixes of kind=OUT that do not show up in the .nl file"))
10070 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10071
10072 for (int j=0; j < nObjs; j++)
10073 {
10074 if (!osresult->setOtherObjectiveResultObj(0, nOther, j, "8"))
10075 throw ErrorClass(" Fail setting OtherObjectiveResult <obj> array in AMPL suffix handler");
10076 if (!osresult->setOtherObjectiveResultObjIdx(0, nOther, j, -1 - j))
10077 throw ErrorClass(" Fail setting OtherObjectiveResult <obj> array in AMPL suffix handler");
10078 }
10079
10080 // add one more result, this time with an enumeration, just to be sure...
10081
10082 std::cout << "add objective suffix with enumeration" << std::endl;
10083
10084
10085 if (!osresult->setOtherObjectiveResultNumberOfObj(0, nOther + 1, 0))
10086 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10088 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10089 if (!osresult->setOtherObjectiveResultName(0, nOther + 1, "TestObjEnum"))
10090 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10091 if (!osresult->setOtherObjectiveResultType(0, nOther + 1, "none"))
10092 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10093 if (!osresult->setOtherObjectiveResultObjType(0, nOther + 1, "triple"))
10094 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10095 if (!osresult->setOtherObjectiveResultEnumType(0, nOther + 1, "integer"))
10096 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10097 if (!osresult->setOtherObjectiveResultValue(0, nOther + 1, ""))
10098 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10099 if (!osresult->setOtherObjectiveResultDescription(0, nOther + 1, "To make sure that at least one of the options has an enumeration"))
10100 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10101
10102 int objArray[1];
10103 objArray[0] = -1;
10105 0, "31", "Only value",
10106 objArray, 1) )
10107 throw ErrorClass(" Fail adding OtherObjectiveResult enumeration in AMPL suffix handler");
10108
10109 // ...and another with just a single value
10110
10111 std::cout << "add objective suffix with value only" << std::endl;
10112
10113
10114 if (!osresult->setOtherObjectiveResultNumberOfObj(0, nOther + 2, 0))
10115 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10117 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10118 if (!osresult->setOtherObjectiveResultName(0, nOther + 2, "TestObjValue"))
10119 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10120 if (!osresult->setOtherObjectiveResultType(0, nOther + 2, "real"))
10121 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10122 if (!osresult->setOtherObjectiveResultObjType(0, nOther + 2, "double"))
10123 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10124 if (!osresult->setOtherObjectiveResultEnumType(0, nOther + 2, "none"))
10125 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10126 if (!osresult->setOtherObjectiveResultValue(0, nOther + 2, "2.71828"))
10127 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10128 if (!osresult->setOtherObjectiveResultDescription(0, nOther + 2, "To make sure that at least one of the options has no array"))
10129 throw ErrorClass(" Fail adding OtherObjectiveResult in AMPL suffix handler");
10130
10131 // make sure to add a solution status for schema conformance...
10132
10133 if (!osresult->setSolutionStatus(0, "optimal", "") )
10134 throw ErrorClass(" Fail setting solution status in AMPL suffix handler");
10135
10136
10137 // write osrl to suffixtest.sol
10138
10139 std::cout << std::endl << "convert OSResult to string" << std::endl << std::endl;
10140
10141 temp_writer = new OSrLWriter();
10142
10143 std::string osrl = temp_writer->writeOSrL( osresult);
10144 std::cout << osrl << std::endl;
10145
10146 bool writeOK;
10147 solWriter = new OSosrl2ampl();
10148
10149 std::cout << std::endl << "write AMPL solution file" << std::endl << std::endl;
10150
10151 writeOK = solWriter->writeSolFile(osrl, nl2osil->getASL("asl"), dataDir + "amplFiles" + dirsep + "suffixTest.sol");
10152
10153
10154// compare suffixtest.sol to suffixtest.cmp
10155
10156 std::cout << std::endl << "compare results" << std::endl << std::endl;
10157
10158 std::string osrl1FileName = dataDir + "amplFiles" + dirsep + "suffixTest.sol";
10159 std::string osrl2FileName = dataDir + "amplFiles" + dirsep + "suffixTest.cmp";
10160
10161 fileUtil = new FileUtil();
10162 std::string osrl1 = fileUtil->getFileAsString( osrl1FileName.c_str());
10163 std::string osrl2 = fileUtil->getFileAsString( osrl2FileName.c_str());
10164
10165 if (osrl1 == osrl2)
10166 {
10167#ifdef DEBUG
10168 cout << osrl1 << endl;
10169#endif
10170 cout << "AMPL .sol file writer creates consistent output" << endl;
10171 }
10172 else
10173 {
10174 cout << "AMPL .sol file writer creates incorrect output" << endl;
10175 cout << osrl1 << endl;
10176 throw ErrorClass(" Fail unit test with AMPL .sol writer");
10177 }
10178
10179
10180// Garbage collection
10181
10182 delete nl2osil;
10183 nl2osil = NULL;
10184 delete fileUtil;
10185 fileUtil = NULL;
10186 delete solWriter;
10187 solWriter = NULL;
10188 delete osresult;
10189 osresult = NULL;
10190 delete[] xval;
10191 xval = NULL;
10192 delete[] zval;
10193 zval = NULL;
10194 delete solWriter;
10195 solWriter = NULL;
10196 delete temp_writer;
10197 temp_writer = NULL;
10198
10199 unitTestResult << "TEST " << nOfTest << ": Test the AMPL .sol writer" << std::endl;
10200 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
10201 }
10202 catch(const ErrorClass& eclass)
10203 {
10204 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing AMPL .sol writer:"
10205 << endl << eclass.errormsg << endl;
10206
10207// Catch garbage collection
10208 if (nl2osil != NULL)
10209 delete nl2osil;
10210 nl2osil = NULL;
10211
10212 if (fileUtil != NULL)
10213 delete fileUtil;
10214 fileUtil = NULL;
10215 if (solWriter != NULL)
10216 delete solWriter;
10217 solWriter = NULL;
10218 if (temp_writer != NULL)
10219 delete temp_writer;
10220 temp_writer = NULL;
10221 if (osresult != NULL)
10222 delete osresult;
10223 osresult = NULL;
10224 if (xval != NULL)
10225 delete[] xval;
10226 xval = NULL;
10227 if (zval != NULL)
10228 delete[] zval;
10229 zval = NULL;
10230 if (IBS != NULL)
10231 delete IBS;
10232 IBS = NULL;
10233 }
10234#endif // end of ifdef COIN_HAS_ASL
10235
10236 //
10237 // Now read an mps file and write in b64 format to test the b64 feature
10238 //
10239 try{
10240 cout << endl << "TEST " << ++nOfTest << ": b64 operations" << endl << endl;
10241
10242 mpsFileName = dataDir + "mpsFiles" + dirsep + "parinc.mps";
10243 mps2osil = new OSmps2OS( mpsFileName);
10244 solver = new CoinSolver();
10245
10246 ok = true;
10247 OSiLWriter osilwriter;
10248 osilwriter.m_bWriteBase64 = true;
10249 solver->sSolverName = "cbc";
10250 solver->osinstance = NULL;
10251 osol = "<osol></osol>";
10252 solver->osol = osol;
10253 mps2osil->createOSObjects();
10254 solver->osil = osilwriter.writeOSiL( mps2osil->osinstance);
10255 //std::cout << solver->osil << std::endl;
10256 solver->buildSolverInstance();
10257 solver->solve();
10258 cout << endl << endl;
10259 check = -7668;
10260 //ok &= NearEqual(getObjVal( solver->osrl) , check, 1e-1 , 1e-1);
10261 ok = ( fabs(check - getObjVal( solver->osrl) )/(fabs( check) + OS_NEAR_EQUAL) <= OS_NEAR_EQUAL) ? true : false;
10262 if (ok)
10263 { cout << "COIN solution of an OSiL string in b64 format." << endl;
10264#ifdef DEBUG
10265 cout << solver->osrl << endl;
10266#endif
10267 }
10268 else
10269 {
10270 cout << "COIN solution of a OSiL string in b64 format:" << endl;
10271 cout << solver->osrl << endl;
10272 }
10273 if(ok == false) throw ErrorClass(" Fail unit test with COIN Cbc Solver on b64 test problem parincLinear.mps");
10274 solver->osinstance = NULL;
10275 delete solver;
10276 solver = NULL;
10277 delete mps2osil;
10278 mps2osil = NULL;
10279 unitTestResult << "TEST " << nOfTest << ": Test a problem written in b64 and then converted to OSInstance" << std::endl;
10280 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
10281 }
10282 catch(const ErrorClass& eclass)
10283 {
10284 cout << endl << endl;
10285 cout << eclass.errormsg << endl << endl;
10286 cout << "OSrL = " << solver->osrl << endl;
10287 cout << endl << endl << endl;
10288 unitTestResultFailure << "Test " << nOfTest << ": Unit Test Failed Testing Use of Base 64" << endl;
10289
10290 if (solver != NULL)
10291 delete solver;
10292 solver = NULL;
10293 if (mps2osil != NULL)
10294 delete mps2osil;
10295 mps2osil = NULL;
10296 }
10297
10298
10299 // now test postfix and prefix routines
10300 try{
10301 cout << endl << "TEST " << ++nOfTest << ": postfix and prefix routines" << endl << endl;
10302
10303 fileUtil = new FileUtil();
10304 osilreader = new OSiLReader();
10305
10306 std::string expTreeTest = dataDir + "osilFiles" + dirsep + "rosenbrockmod.osil";
10307 osil = fileUtil->getFileAsString( expTreeTest.c_str() ) ;
10308 //create an osinstance
10309 osinstance = osilreader->readOSiL( osil);
10310 ScalarExpressionTree* expTree = osinstance->getNonlinearExpressionTree( -1);
10311 if(expTree == NULL) throw ErrorClass(" Null expression tree when testing prefix and postfix routines");
10312 std::vector<ExprNode*> postfixVec;
10313 //postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
10314 postfixVec = osinstance->getNonlinearExpressionTreeInPostfix( -1);
10315
10316 unsigned int n = postfixVec.size();
10317 unsigned int i;
10318 nodeNames1 = new std::string[ n];
10319 nodeNames2 = new std::string[ n];
10320 for (i = 0 ; i < n; i++){
10321 //std::cout << postfixVec[i]->getTokenName() << std::endl;
10322 nodeNames1[i] = postfixVec[i]->getTokenName();
10323 }
10324
10325 // now create back the expression tree
10326 expTree->m_treeRoot = ((OSnLNode*)postfixVec[ n - 1])->createExpressionTreeFromPostfix( postfixVec);
10327
10328 // now get in prefix
10329 std::vector<ExprNode*> prefixVec;
10330 //prefixVec = expTree->m_treeRoot->getPrefixFromExpressionTree();
10331 prefixVec = osinstance->getNonlinearExpressionTreeInPrefix( -1);
10332
10333 // now create back the expression tree
10334 expTree->m_treeRoot = ((OSnLNode*)prefixVec[ 0])->createExpressionTreeFromPrefix( prefixVec);
10335
10336 // now get postfix vector again and compare with original
10337 postfixVec = expTree->m_treeRoot->getPostfixFromExpressionTree();
10338 //postfixVec = osinstance->getNonlinearExpressionTreeInPostfix( -1);
10339 if(postfixVec.size() != n) throw ErrorClass(" Problem with creating expression trees");
10340 //std::cout << std::endl << std::endl;
10341 for (i = 0 ; i < n; i++){
10342 //std::cout << postfixVec[i]->getTokenName() << std::endl;
10343 nodeNames2[i] = postfixVec[i]->getTokenName();
10344 if( nodeNames1[i] != nodeNames2[ i]) throw ErrorClass(" Problem with creating expression trees");
10345 }
10346
10347 delete[] nodeNames1;
10348 nodeNames1 = NULL;
10349 delete[] nodeNames2;
10350 nodeNames2 = NULL;
10351 delete osilreader;
10352 osilreader = NULL;
10353 delete fileUtil;
10354 fileUtil = NULL;
10355 unitTestResult << "TEST " << nOfTest << ": Successful test of prefix and postfix conversion routines" << std::endl;
10356 cout << endl << "TEST " << nOfTest << ": Completed successfully" << endl << endl;
10357 }
10358 catch(const ErrorClass& eclass)
10359 {
10360 cout << endl << endl << endl;
10361 unitTestResultFailure << "Test " << nOfTest << ": prefix and postfix conversion"
10362 << endl << eclass.errormsg << endl;
10363 if (osilreader != NULL)
10364 delete osilreader;
10365 osilreader = NULL;
10366 if (nodeNames1 != NULL)
10367 delete[] nodeNames1;
10368 nodeNames1 = NULL;
10369 if (nodeNames2 != NULL)
10370 delete[] nodeNames2;
10371 nodeNames2 = NULL;
10372 if (fileUtil != NULL)
10373 delete fileUtil;
10374 fileUtil = NULL;
10375 }
10376} //end of if (OTHER_TESTS)
10377
10378 if(unitTestResultFailure.str().length() > 0){
10379 cout << endl << "THE UNIT TEST PASSED THE FOLLOWING:" << endl << endl;
10380 cout << unitTestResult.str() << endl << endl;
10381 cout << "UNFORTUNATELY, YOU FAILED ON THE FOLLOWING:" << endl << endl;
10382 cout << unitTestResultFailure.str() << endl << endl;
10383 cout << "Conclusion: FAILURE" << endl;
10384 return 1;
10385 }
10386 else{
10387 cout << endl << "THE UNIT TEST PASSED THE FOLLOWING:" << endl << endl;
10388 cout << unitTestResult.str() << endl << endl;
10389 cout << "All tests completed successfully" << endl << endl;
10390#ifdef GUS_DEBUG
10391 cout << "Make sure to #undef GUS_DEBUG before committing!!!" << endl << endl;
10392#endif
10393 return 0;
10394 }
10395
10396}//end main
10397
10398double getObjVal( std::string osrl){
10399 std::string sObjVal;
10400 double dObjVal;
10401 string::size_type pos2;
10402 string::size_type pos1 = osrl.find( "<obj ");
10403 if(pos1 != std::string::npos){
10404 // get the end of the obj start tag
10405 pos1 = osrl.find(">", pos1 + 1);
10406 if(pos1 != std::string::npos){
10407 // get the start of obj end tag
10408
10409 pos2 = osrl.find( "</obj", pos1 + 1);
10410 if( pos2 != std::string::npos){
10411 // get the substring
10412 sObjVal = osrl.substr( pos1 + 1, pos2 - pos1 - 1);
10413 //std::cout << "HERE IS THE OBJECTIVE FUNCTION VALUE SUBSTRING " << sObjVal<< std::endl;
10414 // return dObjVal = strtod(sObjVal.c_str(), NULL);
10415 return dObjVal = os_strtod(sObjVal.c_str(), NULL);
10416 }
10417 }
10418 }
10419 return OSNaN();
10420}
10421
10422//#if 0
10423int getItCount( std::string osrl)
10424{
10425 OSrLReader *osrlreader = NULL;
10426 try
10427 {
10428 OSResult *osresult = NULL;
10429 osrlreader = new OSrLReader();
10430 osresult = osrlreader->readOSrL(osrl);
10431 int nIter;
10432
10433 std::string temp = osresult->getOtherSolutionResultValue(0, 0);
10434
10435 nIter = atoi(temp.c_str());
10436 if (osrlreader != NULL) delete osrlreader;
10437 osrlreader = NULL;
10438 return nIter;
10439 }
10440 catch(const ErrorClass& eclass)
10441 {
10442 if (osrlreader != NULL) delete osrlreader;
10443 osrlreader = NULL;
10444 return -1;
10445 }
10446}
10447//#endif
10448
10449
10451{
10452 std::cout << "Print out array content" << std::endl;
10453 for (int i=0; i < os->optimization->numberOfSolutions; ++i)
10454 {
10455 std::cout << "solution " << i << std::endl << std::endl;
10456 std::cout << "variables basic ";
10457 std::cout << os->optimization->solution[i]->variables->basisStatus->basic->el[0] << " ";
10458 std::cout << os->optimization->solution[i]->variables->basisStatus->basic->el[1] << " ";
10459 std::cout << os->optimization->solution[i]->variables->basisStatus->basic->el[2] << endl;
10460 std::cout << "variables atLower ";
10461 std::cout << os->optimization->solution[i]->variables->basisStatus->atLower->el[0] << " ";
10462 std::cout << os->optimization->solution[i]->variables->basisStatus->atLower->el[1] << " ";
10463 std::cout << os->optimization->solution[i]->variables->basisStatus->atLower->el[2] << endl;
10464 std::cout << "variables atUpper ";
10465 std::cout << os->optimization->solution[i]->variables->basisStatus->atUpper->el[0] << " ";
10466 std::cout << os->optimization->solution[i]->variables->basisStatus->atUpper->el[1] << " ";
10467 std::cout << os->optimization->solution[i]->variables->basisStatus->atUpper->el[2] << endl;
10468 std::cout << "variables atEquality ";
10469 std::cout << os->optimization->solution[i]->variables->basisStatus->atEquality->el[0] << " ";
10470 std::cout << os->optimization->solution[i]->variables->basisStatus->atEquality->el[1] << " ";
10471 std::cout << os->optimization->solution[i]->variables->basisStatus->atEquality->el[2] << endl;
10472 std::cout << "variables isFree ";
10473 std::cout << os->optimization->solution[i]->variables->basisStatus->isFree->el[0] << " ";
10474 std::cout << os->optimization->solution[i]->variables->basisStatus->isFree->el[1] << " ";
10475 std::cout << os->optimization->solution[i]->variables->basisStatus->isFree->el[2] << endl;
10476 std::cout << "variables superbasic ";
10477 std::cout << os->optimization->solution[i]->variables->basisStatus->superbasic->el[0] << " ";
10478 std::cout << os->optimization->solution[i]->variables->basisStatus->superbasic->el[1] << " ";
10479 std::cout << os->optimization->solution[i]->variables->basisStatus->superbasic->el[2] << endl;
10480 std::cout << "variables unknown ";
10481 std::cout << os->optimization->solution[i]->variables->basisStatus->unknown->el[0] << " ";
10482 std::cout << os->optimization->solution[i]->variables->basisStatus->unknown->el[1] << " ";
10483 std::cout << os->optimization->solution[i]->variables->basisStatus->unknown->el[2] << endl;
10484
10485 std::cout << std::endl;
10486
10487
10488 std::cout << "objectives basic ";
10489 std::cout << os->optimization->solution[i]->objectives->basisStatus->basic->el[0] << " ";
10490 std::cout << os->optimization->solution[i]->objectives->basisStatus->basic->el[1] << " ";
10491 std::cout << os->optimization->solution[i]->objectives->basisStatus->basic->el[2] << endl;
10492 std::cout << "objectives atLower ";
10493 std::cout << os->optimization->solution[i]->objectives->basisStatus->atLower->el[0] << " ";
10494 std::cout << os->optimization->solution[i]->objectives->basisStatus->atLower->el[1] << " ";
10495 std::cout << os->optimization->solution[i]->objectives->basisStatus->atLower->el[2] << endl;
10496 std::cout << "objectives atUpper ";
10497 std::cout << os->optimization->solution[i]->objectives->basisStatus->atUpper->el[0] << " ";
10498 std::cout << os->optimization->solution[i]->objectives->basisStatus->atUpper->el[1] << " ";
10499 std::cout << os->optimization->solution[i]->objectives->basisStatus->atUpper->el[2] << endl;
10500 std::cout << "objectives atEquality ";
10501 std::cout << os->optimization->solution[i]->objectives->basisStatus->atEquality->el[0] << " ";
10502 std::cout << os->optimization->solution[i]->objectives->basisStatus->atEquality->el[1] << " ";
10503 std::cout << os->optimization->solution[i]->objectives->basisStatus->atEquality->el[2] << endl;
10504 std::cout << "objectives isFree ";
10505 std::cout << os->optimization->solution[i]->objectives->basisStatus->isFree->el[0] << " ";
10506 std::cout << os->optimization->solution[i]->objectives->basisStatus->isFree->el[1] << " ";
10507 std::cout << os->optimization->solution[i]->objectives->basisStatus->isFree->el[2] << endl;
10508 std::cout << "objectives superbasic ";
10509 std::cout << os->optimization->solution[i]->objectives->basisStatus->superbasic->el[0] << " ";
10510 std::cout << os->optimization->solution[i]->objectives->basisStatus->superbasic->el[1] << " ";
10511 std::cout << os->optimization->solution[i]->objectives->basisStatus->superbasic->el[2] << endl;
10512 std::cout << "objectives unknown ";
10513 std::cout << os->optimization->solution[i]->objectives->basisStatus->unknown->el[0] << " ";
10514 std::cout << os->optimization->solution[i]->objectives->basisStatus->unknown->el[1] << " ";
10515 std::cout << os->optimization->solution[i]->objectives->basisStatus->unknown->el[2] << endl;
10516
10517 std::cout << std::endl;
10518
10519 std::cout << "constraints basic ";
10520 std::cout << os->optimization->solution[i]->constraints->basisStatus->basic->el[0] << " ";
10521 std::cout << os->optimization->solution[i]->constraints->basisStatus->basic->el[1] << " ";
10522 std::cout << os->optimization->solution[i]->constraints->basisStatus->basic->el[2] << endl;
10523 std::cout << "constraints atLower ";
10524 std::cout << os->optimization->solution[i]->constraints->basisStatus->atLower->el[0] << " ";
10525 std::cout << os->optimization->solution[i]->constraints->basisStatus->atLower->el[1] << " ";
10526 std::cout << os->optimization->solution[i]->constraints->basisStatus->atLower->el[2] << endl;
10527 std::cout << "constraints atUpper ";
10528 std::cout << os->optimization->solution[i]->constraints->basisStatus->atUpper->el[0] << " ";
10529 std::cout << os->optimization->solution[i]->constraints->basisStatus->atUpper->el[1] << " ";
10530 std::cout << os->optimization->solution[i]->constraints->basisStatus->atUpper->el[2] << endl;
10531 std::cout << "constraints atEquality ";
10532 std::cout << os->optimization->solution[i]->constraints->basisStatus->atEquality->el[0] << " ";
10533 std::cout << os->optimization->solution[i]->constraints->basisStatus->atEquality->el[1] << " ";
10534 std::cout << os->optimization->solution[i]->constraints->basisStatus->atEquality->el[2] << endl;
10535 std::cout << "constraints isFree ";
10536 std::cout << os->optimization->solution[i]->constraints->basisStatus->isFree->el[0] << " ";
10537 std::cout << os->optimization->solution[i]->constraints->basisStatus->isFree->el[1] << " ";
10538 std::cout << os->optimization->solution[i]->constraints->basisStatus->isFree->el[2] << endl;
10539 std::cout << "constraints superbasic ";
10540 std::cout << os->optimization->solution[i]->constraints->basisStatus->superbasic->el[0] << " ";
10541 std::cout << os->optimization->solution[i]->constraints->basisStatus->superbasic->el[1] << " ";
10542 std::cout << os->optimization->solution[i]->constraints->basisStatus->superbasic->el[2] << endl;
10543 std::cout << "constraints unknown ";
10544 std::cout << os->optimization->solution[i]->constraints->basisStatus->unknown->el[0] << " ";
10545 std::cout << os->optimization->solution[i]->constraints->basisStatus->unknown->el[1] << " ";
10546 std::cout << os->optimization->solution[i]->constraints->basisStatus->unknown->el[2] << endl;
10547
10548 std::cout << std::endl;
10549
10550 for (int k=0; k < os->optimization->solution[i]->variables->other[2]->numberOfEnumerations; k++)
10551 {
10552
10553 std::cout << "other variable results --- enum " << k;
10554 std::cout << " " << os->optimization->solution[i]->variables->other[2]->enumeration[k]->el[0];
10555 std::cout << " " << os->optimization->solution[i]->variables->other[2]->enumeration[k]->el[1];
10556 std::cout << " " << os->optimization->solution[i]->variables->other[2]->enumeration[k]->el[2];
10557
10558 std::cout << std::endl;
10559 }
10560
10561 std::cout << std::endl;
10562
10563 for (int k=0; k < os->optimization->solution[i]->objectives->other[2]->numberOfEnumerations; k++)
10564 {
10565 std::cout << "other objective results --- enum " << k;
10566 std::cout << " " << os->optimization->solution[i]->objectives->other[2]->enumeration[k]->el[0];
10567 std::cout << " " << os->optimization->solution[i]->objectives->other[2]->enumeration[k]->el[1];
10568 std::cout << " " << os->optimization->solution[i]->objectives->other[2]->enumeration[k]->el[2];
10569
10570 std::cout << std::endl;
10571 }
10572
10573 std::cout << std::endl;
10574
10575 for (int k=0; k < os->optimization->solution[i]->constraints->other[2]->numberOfEnumerations; k++)
10576 {
10577 std::cout << "other constraint results --- enum " << k;
10578 std::cout << " " << os->optimization->solution[i]->constraints->other[2]->enumeration[k]->el[0];
10579 std::cout << " " << os->optimization->solution[i]->constraints->other[2]->enumeration[k]->el[1];
10580 std::cout << " " << os->optimization->solution[i]->constraints->other[2]->enumeration[k]->el[2];
10581
10582 std::cout << std::endl;
10583 }
10584 return;
10585 }
10586}
10587
double OSNaN()
returns the value for NaN used in OS
OSOption * osoption
double os_strtod(const char *s00, char **se)
Definition OSdtoa.cpp:2541
a data structure to represent an LP basis on both input and output
Definition OSGeneral.h:646
IntVector * isFree
Definition OSGeneral.h:652
IntVector * atEquality
Definition OSGeneral.h:651
IntVector * unknown
Definition OSGeneral.h:654
IntVector * basic
Definition OSGeneral.h:648
IntVector * atLower
Definition OSGeneral.h:649
IntVector * atUpper
Definition OSGeneral.h:650
IntVector * superbasic
Definition OSGeneral.h:653
The BonminSolver class solves problems using Ipopt.
the BranchingWeight class.
Definition OSOption.h:1612
std::string name
optional variable name
Definition OSOption.h:1619
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.
virtual void solve()
The implementation of the corresponding virtual function.
The in-memory representation of the <con> element.
Definition OSInstance.h:219
the ConstraintOption class.
Definition OSOption.h:3264
BasisStatus * initialBasisStatus
initial basis status for the slack variables
Definition OSOption.h:3277
OtherConstraintResult ** other
a pointer to an array of other pointer objects for constraint functions
Definition OSResult.h:1879
BasisStatus * basisStatus
a pointer to a BasisStatus object
Definition OSResult.h:1874
The in-memory representation of the <constraints> element.
Definition OSInstance.h:252
int numberOfConstraints
numberOfConstraints is the number of constraints in the instance
Definition OSInstance.h:264
Constraint ** con
con is pointer to an array of Constraint object pointers
Definition OSInstance.h:268
The CouenneSolver class solves problems using Ipopt.
The CsdpSolver class solves problems using Csdp.
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 setSolverOptions()=0
setSolverOptions is a virtual function – the actual solvers will implement their own setSolverOptions...
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.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
a sparse matrix data structure for matrices that can hold nonconstant values and have block structure...
Definition OSMatrix.h:1769
int blockNumber
blockNumber gives the number of blocks (which is the size of the blockRows and blockColumns arrays).
Definition OSMatrix.h:1793
GeneralSparseMatrix ** blocks
blocks holds the blocks that make up the matrix.
Definition OSMatrix.h:1838
bool isBlockDiagonal()
a method to determine whether the collection is blockDiagonal
GeneralSparseMatrix * getBlock(int rowIdx, int colIdx)
a method to retrieve a particular block from a collection
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.
a sparse matrix data structure for matrices that can hold nonconstant values
Definition OSMatrix.h:1655
bool isDiagonal()
a method to determine whether the matrix is diagonal
int valueSize
valueSize is the dimension of the index and value arrays
Definition OSMatrix.h:1696
the InitConValue class.
Definition OSOption.h:2764
the InitDualVarValue class.
Definition OSOption.h:2925
the InitObjBound class.
Definition OSOption.h:2344
the InitObjValue class.
Definition OSOption.h:2183
the InitVarValue class.
Definition OSOption.h:1160
the InitVarValueString class.
Definition OSOption.h:1321
Variables * variables
variables is a pointer to a Variables object
QuadraticCoefficients * quadraticCoefficients
quadraticCoefficients is a pointer to a QuadraticCoefficients object
Constraints * constraints
constraints is a pointer to a Constraints object
NonlinearExpressions * nonlinearExpressions
nonlinearExpressions is a pointer to a NonlinearExpressions object
Matrices * matrices
matrices is a pointer to a Matrices object
Objectives * objectives
objectives is a pointer to a Objectives object
LinearConstraintCoefficients * linearConstraintCoefficients
linearConstraintCoefficients is a pointer to a LinearConstraintCoefficients object
int numberOfEl
Definition OSGeneral.h:483
int * el
Definition OSGeneral.h:484
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
Definition OSInstance.h:315
int numberOfValues
numberOfValues is the number of nonzero elements stored in the <linearConstraintCoefficients> element
Definition OSInstance.h:301
OSMatrix ** matrix
matrix is a pointer to an array of OSMatrix object pointers
Definition OSInstance.h:499
GeneralSparseMatrix * getMatrixCoefficientsInColumnMajor()
Definition OSMatrix.cpp:274
ExpandedMatrixBlocks * getBlocks(int *rowPartition, int rowPartitionSize, int *colPartition, int colPartitionSize, bool rowMajor, bool appendToBlockArray)
A method to extract a block from a larger matrix The result is a sparse matrix object,...
GeneralSparseMatrix * getMatrixCoefficientsInRowMajor()
The in-memory representation of the <nl> element.
Definition OSInstance.h:411
Nl ** nl
nl is pointer to an array of Nl object pointers
Definition OSInstance.h:469
The in-memory representation of an OSiL instance..
double * getObjectiveWeights()
Get objective weights.
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.
double * getConstraintLowerBounds()
Get constraint lower bounds.
int getNumberOfQuadraticTerms()
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients.
bool setInstanceLicence(std::string licence)
set the instance licence.
bool copyLinearConstraintCoefficients(int numberOfValues, bool isColumnMajor, double *values, int valuesBegin, int valuesEnd, int *indexes, int indexesBegin, int indexesEnd, int *starts, int startsBegin, int startsEnd)
copy linear constraint coefficients: perform a deep copy of the sparse matrix
double * getVariableUpperBounds()
Get variable upper bounds.
bool setTimeDomainStages(int number, std::string *names)
This sets the number (and optionally names) of the time stages.
bool setInstanceCreator(std::string fileCreator)
set the instance creator.
SparseJacobianMatrix * getJacobianSparsityPattern()
bool setTimeDomainStageConstraintsUnordered(int numberOfStages, int *numberOfConstraints, int **conIndex)
This sets the constraints associated with each time domain stage in srbitrary order.
std::string printModel()
Print the infix representation of the problem.
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.
bool setNonlinearExpressions(int nexpr, Nl **root)
set nonlinear expressions
bool getLinearConstraintCoefficientMajor()
Get whether the constraint coefficients is in column major (true) or row major (false).
std::string getInstanceDescription()
Get instance description.
std::string getInstanceSource()
Get instance source.
std::vector< ExprNode * > getNonlinearExpressionTreeInPrefix(int rowIdx)
Get the prefix tokens for a given row index.
int getConstraintNumber()
Get number of constraints.
bool setQuadraticCoefficients(int number, int *rowIndexes, int *varOneIndexes, int *varTwoIndexes, double *coefficients, int begin, int end)
set quadratic coefficients into the QuadraticCoefficients->qTerm data structure
double * getConstraintConstants()
Get constraint constants.
int * getTimeDomainStageNumberOfVariables()
Get the number of variables contained in each time stage.
int getLinearConstraintCoefficientNumber()
Get number of specified (usually nonzero) linear constraint coefficient values.
int ** getTimeDomainStageObjList()
Get the list of objectives in each stage.
SparseMatrix * getLinearConstraintCoefficientsInRowMajor()
Get linear constraint coefficients in row major.
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.
char * getVariableTypes()
Get variable initial values.
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.
SparseMatrix * getLinearConstraintCoefficientsInColumnMajor()
Get linear constraint coefficients in column major.
bool setTimeDomainStageConstraintsOrdered(int numberOfStages, int *numberOfConstraints, int *startIdx)
This sets the constraints associated with each time domain stage in temporal order.
bool setVariables(int number, std::string *names, double *lowerBounds, double *upperBounds, char *types)
set all the variable related elements.
std::string getInstanceCreator()
Get instance fileCreator.
bool setInstanceSource(std::string source)
set the instance source.
std::string getInstanceLicence()
Get instance licence.
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.
int getNumberOfNonlinearExpressions()
Get number of nonlinear expressions.
SparseHessianMatrix * getLagrangianHessianSparsityPattern()
SparseVector ** getObjectiveCoefficients()
Get objective coefficients.
SparseHessianMatrix * calculateHessian(double *x, int idx, bool new_x)
Calculate the Hessian of a constraint or objective function.
QuadraticTerms * getQuadraticTerms()
Get all the quadratic terms in the instance.
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.
double * getObjectiveConstants()
Get objective constants.
std::string * getObjectiveNames()
Get objective names.
double * getVariableLowerBounds()
Get variable lower bounds.
int getVariableNumber()
Get number of variables.
bool setTimeDomainStageObjectivesOrdered(int numberOfStages, int *numberOfObjectives, int *startIdx)
This sets the objectives associated with each time domain stage in temporal order.
bool setInstanceDescription(std::string description)
set the instance description.
bool setTimeDomainInterval(double start, double horizon)
This sets the start and end of the time interval.
std::string * getVariableNames()
Get variable names.
bool setObjectives(int number, std::string *names, std::string *maxOrMins, double *constants, double *weights, SparseVector **objectitiveCoefficients)
set all the objectives related elements.
std::string getInstanceName()
Get instance name.
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 setInstanceName(std::string name)
set the instance name.
bool setConstraints(int number, std::string *names, double *lowerBounds, double *upperBounds, double *constants)
set all the constraint related elements.
std::string * getConstraintNames()
Get constraint names.
std::string * getObjectiveMaxOrMins()
Get objective maxOrMins.
double * getConstraintUpperBounds()
Get constraint upper bounds.
int getObjectiveNumber()
Get number of objectives.
bool IsEqual(OSInstance *that)
A function to check for the equality of two objects.
The Option Class.
Definition OSOption.h:3565
SolverOption ** getAllSolverOptions()
Get all solver options.
double getMinDiskSpace()
Get the minimum required disk space.
std::string getFileCreator()
Get the name of the person who created the file.
bool setAnotherSOSVariableBranchingWeight(int sosIdx, int nvar, double weight, int *idx, double *value, std::string *name)
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.
std::string getInstanceLocationType()
Get the location type.
bool setAnOtherConstraintOption(OtherConstraintOption *optionValue)
bool setHeader(std::string name, std::string source, std::string description, std::string fileCreator, std::string licence)
A function to populate an instance of the option header element.
InitDualVarValue ** getInitDualVarValuesSparse()
Get the initial bounds associated with the dual variables in sparse form.
int getMinCPUNumber()
Get the minimum required number of CPUs.
std::string * getJobDependencies()
Get the array of job dependencies.
int getNumberOfRequiredDirectories()
Get the number of required directories.
OtherConstraintOption ** getAllOtherConstraintOptions()
Get all <other> constraint options.
bool setMinDiskSpace(std::string unit, std::string description, double value)
Set the minimum disk space required for the current job.
bool setAnotherDirectoryToMake(std::string path)
int getNumberOfDirectoriesToMake()
Get the number of directories to make.
bool setAnOtherSystemOption(std::string name, std::string value, std::string description)
PathPair ** getOutputFilesToMove()
Get the array of output files to move.
bool setAnotherInitDualVarValue(int idx, double lbValue, double ubValue)
std::string getFileName()
Get the name of the file.
std::string getFileDescription()
Get a description for the file or problem.
BranchingWeight ** getIntegerVariableBranchingWeightsSparse()
Get the integer branching weights in sparse form.
bool setAnOtherJobOption(std::string name, std::string value, std::string description)
bool setInstanceName(std::string instanceName)
Set the instance name.
bool IsEqual(OSOption *that)
A function to check for the equality of two objects.
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)
bool setOtherObjectiveOptions(int numberOfObj, OtherObjectiveOption **obj)
std::string getContactTransportType()
Get the transport type.
int getNumberOfSOS()
Get the number of special ordered sets for which branching weights are provided.
bool setServiceURI(std::string serviceURI)
Set the serviceURI.
bool setAnotherInitBasisStatus(int type, int idx, int status)
Set the basis status for another variable, objective or constraint/slack.
bool setSolverToInvoke(std::string solverToInvoke)
Set the solver to be invoked.
bool setFilesToDelete(int numberOfPaths, std::string *paths)
bool setInputFilesToMove(int numberOfPathPairs, PathPair **pathPair)
int getNumberOfOtherSystemOptions()
Get the number of <other> options in the <system> element.
int getNumberOfOutputDirectoriesToMove()
Get the number of output directories to move.
int getNumberOfInputDirectoriesToMove()
Get the number of input directories to move.
bool setInputDirectoriesToMove(int numberOfPathPairs, PathPair **pathPair)
PathPair ** getOutputDirectoriesToMove()
Get the array of output directories to move.
bool setInstanceLocation(std::string instanceLocation)
Set the instance location.
bool setMaxTime(double value, std::string unit)
std::string * getDirectoriesToMake()
Get the array of directories to make.
bool setMaxTimeUnit(std::string unit)
std::string getMinCPUSpeedUnit()
Get the CPU speed unit.
std::string getSolverToInvoke()
Get the solver name.
std::string getMinCPUSpeedDescription()
Get the CPU speed description.
bool setInitConValuesSparse(int numberOfCon, InitConValue **con)
bool setInitObjValuesSparse(int numberOfObj, InitObjValue **obj)
InitObjBound ** getInitObjBoundsSparse()
Get the initial bounds associated with the objectives in sparse form.
bool setJobID(std::string jobID)
Set the job ID.
int getNumberOfRequiredFiles()
Get the number of required files.
bool setOtherJobOptions(int numberOfOptions, OtherOption **other)
std::string getMaxTimeUnit()
Get the time unit.
bool setContact(std::string contact)
Set the contact information.
double getMinCPUSpeed()
Get the minimum required CPU speed.
std::string getJobID()
Get the job ID.
InitConValue ** getInitConValuesSparse()
Get the initial values associated with the constraints in sparse form.
std::string getMinMemoryDescription()
get the memory description
bool setInitVarValuesStringSparse(int numberOfVar, InitVarValueString **var)
bool setAnotherInputFileToMove(std::string fromPath, std::string toPath, bool makeCopy)
double getMinMemorySize()
Get the minimum required memory.
std::string * getRequiredDirectories()
Get the array of required directories.
std::string getServiceType()
Get the service type.
bool setAnOtherGeneralOption(std::string name, std::string value, std::string description)
Add another general option to the <other> option array.
bool setOtherServiceOptions(int numberOfOptions, OtherOption **other)
std::string getPassword()
Get the password.
bool setRequiredFiles(int numberOfPaths, std::string *paths)
bool setSolverOptions(int numberOfSolverOptions, SolverOption **solverOption)
std::string getMinCPUNumberDescription()
Get the CPU description.
bool deepCopyFrom(OSOption *that)
A function to make a deep copy of an OSOption object.
InitVarValueString ** getInitVarValuesStringSparse()
Get the initial value strings associated with the variables in sparse form.
OtherVariableOption ** getAllOtherVariableOptions()
Get all <other> variable options.
std::string getContact()
Get the contact information.
OtherObjectiveOption * getOtherObjectiveOption(int optionNumber)
Get one particular <other> objective option from the array of options.
int getNumberOfInitObjBounds()
Get the number of initial objective bounds.
bool setOtherVariableOptions(int numberOfVar, OtherVariableOption **var)
int getNumberOfProcessesToKill()
Get the number of processes to kill.
bool setAnotherInitVarValueString(int idx, std::string value)
OtherOption ** getOtherServiceOptions()
Get the array of other options associated with the <service> element.
int getNumberOfOtherServiceOptions()
Get the number of <other> options in the <service> element.
InitVarValue ** getInitVarValuesSparse()
Get the initial values associated with the variables in sparse form.
bool setAnOtherServiceOption(std::string name, std::string value, std::string description)
bool setInitDualVarValuesSparse(int numberOfCon, InitDualVarValue **con)
bool setOutputDirectoriesToMove(int numberOfPathPairs, PathPair **pathPair)
bool setAnotherProcessToKill(std::string process)
OtherOption ** getOtherGeneralOptions()
Get the array of other options associated with the <general> element.
std::string getMinMemoryUnit()
Get the memory unit.
OtherOption ** getOtherJobOptions()
Get the array of other options associated with the <job> element.
bool setInitVarValuesDense(int numberOfVar, double *value)
bool setAnOtherObjectiveOption(OtherObjectiveOption *objOption)
int getNumberOfInitObjValues()
Get the number of initial objective values.
bool setNumberOfObjectives(int numberOfObjectives)
std::string * getFilesToDelete()
Get the array of files to delete.
PathPair ** getInputFilesToMove()
Get the array of input files to move.
std::string getInstanceName()
Get the instance name.
bool setAnotherInitVarValue(int idx, double value)
bool setInitBasisStatus(int object, int status, int *i, int ni)
PathPair ** getInputDirectoriesToMove()
Get the array of input directories to move.
bool setDirectoriesToMake(int numberOfPaths, std::string *paths)
bool setIntegerVariableBranchingWeightsSparse(int numberOfVar, BranchingWeight **var)
int getNumberOfIntegerVariableBranchingWeights()
Get the number of variables for which integer branching weights are provided.
bool setAnotherOutputDirectoryToMove(std::string fromPath, std::string toPath, bool makeCopy)
int getNumberOfFilesToDelete()
Get the number of files to delete.
bool setAnotherFileToMake(std::string path)
int getNumberOfDirectoriesToDelete()
Get the number of directories to delete.
std::string * getFilesToMake()
Get the array of files to make.
std::string getMinDiskSpaceDescription()
get the disk space description
std::string getFileSource()
Get the source of the file or problem.
int getNumberOfInitVarValues()
Get the number of initial variable values.
bool setUserName(std::string userName)
Set the username.
bool setOutputFilesToMove(int numberOfPathPairs, PathPair **pathPair)
int getNumberOfInitialBasisElements(int type, int status)
Get the number of initial basis elements for a particular variable type and basis status.
bool setFilesToMake(int numberOfPaths, std::string *paths)
bool setAnotherOutputFileToMove(std::string fromPath, std::string toPath, bool makeCopy)
bool setAnotherInputDirectoryToMove(std::string fromPath, std::string toPath, bool makeCopy)
bool setNumberOfVariables(int numberOfVariables)
OtherConstraintOption * getOtherConstraintOption(int optionNumber)
Get one particular <other> constraint option from the array of options.
std::string getServiceURI()
Get the service URI.
bool setAnotherRequiredDirectory(std::string path)
bool setAnotherRequiredFile(std::string path)
bool setOtherSystemOptions(int numberOfOptions, OtherOption **other)
int getNumberOfOtherVariableOptions()
Get the number of other variable options.
std::string getUserName()
Get the user name.
double getMaxTime()
Get the maximum allowed time.
bool setAnOtherVariableOption(OtherVariableOption *varOption)
bool setContactTransportType(std::string transportType)
Set the transport type for contact.
int getNumberOfOtherJobOptions()
Get the number of <other> options in the <job> element.
bool setAnotherJobDependency(std::string jobID)
OtherObjectiveOption ** getAllOtherObjectiveOptions()
Get all <other> objective options.
bool setMinCPUSpeed(std::string unit, std::string description, double value)
Set the minimum CPU speed required for the current job.
bool setAnotherDirectoryToDelete(std::string path)
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.
int getOptionInt(std::string optionName)
Get any of the integer-valued options.
bool setAnotherFileToDelete(std::string path)
std::string getRequestedStartTime()
Get the requested starting time.
SOSWeights ** getSOSVariableBranchingWeightsSparse()
Get the SOS branching weights in sparse form.
bool setPassword(std::string password)
Set the password.
int getNumberOfInputFilesToMove()
Get the number of input files to move.
int getNumberOfInitDualVarValues()
Get the number of initial dual variable values.
bool setAnotherIntegerVariableBranchingWeight(int idx, double value)
std::string * getProcessesToKill()
Get the array of processes to kill.
std::string getInstanceLocation()
Get the instance location.
bool setOtherGeneralOptions(int numberOfOptions, OtherOption **other)
Set the other general options as an entire array.
std::string * getRequiredFiles()
Get the array of required files.
bool setSOSVariableBranchingWeights(int numberOfSOS, SOSWeights **sos)
int getNumberOfInitVarValuesString()
Get the number of initial variable strings.
int getNumberOfJobDependencies()
Get the number of job dependencies.
int getNumberOfOtherConstraintOptions()
Get the number of other constraint options.
bool setRequestedStartTime(std::string time)
OtherOption ** getOtherSystemOptions()
Get the array of other options associated with the <system> element.
bool setAnotherSolverOption(std::string name, std::string value, std::string solver, std::string category, std::string type, std::string description)
int getNumberOfInitConValues()
Get the number of initial constraint values.
int getNumberOfOtherGeneralOptions()
Get the number of <other> options in the <general> element.
int getNumberOfFilesToMake()
Get the number of files to make.
std::string getMinDiskSpaceUnit()
Get the disk space unit.
bool setServiceType(std::string serviceType)
set() options in the <service> element
bool setInitVarValuesSparse(int numberOfVar, InitVarValue **var)
int getNumberOfSolverOptions()
Get the number of solver options.
bool setAnotherInitConValue(int idx, double value)
std::string getFileLicence()
Get licence information associated with the file.
int getNumberOfOutputFilesToMove()
Get the number of output files to move.
std::string * getDirectoriesToDelete()
Get the array of directories to delete.
bool getInitialBasisElements(int type, int status, int *elem)
Get the initial basis elements for a particular variable type and basis status.
bool setNumberOfConstraints(int numberOfConstraints)
std::string getServiceName()
Get the service name.
int getNumberOfOtherObjectiveOptions()
Get the number of other objective options.
InitObjValue ** getInitObjValuesSparse()
Get the initial values associated with the objectives in sparse form.
OtherVariableOption * getOtherVariableOption(int optionNumber)
Get one particular <other> variable option from the array of options.
bool setOtherConstraintOptions(int numberOfOptions, OtherConstraintOption **other)
bool setJobDependencies(int numberOfDependencies, std::string *jobDependencies)
The Result Class.
Definition OSResult.h:2549
bool setAvailableDiskSpaceDescription(std::string description)
Set the description of available disk space.
double getUsedCPUSpeedValue()
bool setNumberOfOtherServiceResults(int num)
Set number of other service results.
int getOtherObjectiveResultEnumerationNumberOfEl(int solIdx, int otherIdx, int enumIdx)
Get the size of an enum associated with an <other> result for some solution.
bool setVarValue(int solIdx, int number, int idx, std::string name, double val)
Set a primal variable value.
bool setOtherVariableResultVarType(int solIdx, int otherIdx, std::string varType)
Set the varType of another (non-standard/solver specific) variable-related result,...
std::string getOtherConstraintResultEnumerationDescription(int solIdx, int otherIdx, int enumIdx)
Get the description of an enum associated with an <other> result for some solution.
std::string getServiceName()
Get service name.
int getNumberOfVarValuesString(int solIdx)
bool setOtherConstraintResultType(int solIdx, int otherIdx, std::string type)
Set the type of another (non-standard/solver specific) constraint-related result, for the [i]th solut...
int getNumberOfDualValues(int solIdx)
bool setGeneralMessage(std::string message)
Set the general message.
std::string getSolverOutputItem(int otherIdx, int itemIdx)
int getSolverOutputNumberOfItems(int otherIdx)
bool setTimeStamp(std::string timeStamp)
Set time stamp.
bool setVarValueString(int solIdx, int number, int idx, std::string name, std::string str)
Set a string-valued primal variable value.
int getOtherVariableResultNumberOfVar(int solIdx, int otherIdx)
bool setOtherObjectiveResultObjIdx(int solIdx, int otherIdx, int objIdx, int idx)
Set the index of another (non-standard/solver specific) objective-related result, for the [i]th solut...
bool setOtherObjectiveResultObj(int solIdx, int otherIdx, int objIdx, std::string value)
Set the value of another (non-standard/solver specific) objective-related result, for the [i]th solut...
bool setOtherVariableResultNumberOfVar(int solIdx, int otherIdx, int numberOfVar)
Set the number of children of another (non-standard/solver specific) variable-related result,...
bool setJobID(std::string jobID)
Set job id.
bool setNumberOfOtherJobResults(int num)
Set number of other job results.
bool setJobStatus(std::string status)
Set the job status.
bool setOtherVariableResultType(int solIdx, int otherIdx, std::string type)
Set the type of another (non-standard/solver specific) variable-related result, for the [i]th solutio...
std::string getGeneralSubstatusName(int i)
Get the i_th general substatus name.
std::string getTimingInfoDescription(int idx)
std::string getVarValueString(int solIdx, int varIdx)
std::string getSolverInvoked()
Get the solver invoked.
std::string getGeneralStatusDescription()
Get the general status description.
std::string getOtherVariableResultEnumerationDescription(int solIdx, int otherIdx, int enumIdx)
Get the description of an enum associated with an <other> result for some solution.
std::string getOtherConstraintResultValue(int solIdx, int otherIdx)
bool setUsedDiskSpaceValue(double value)
Set the amount of used disk space.
std::string getOtherObjectiveResultEnumerationValue(int solIdx, int otherIdx, int enumIdx)
Get the value of an enum associated with an <other> result for some solution.
bool setOtherConstraintResultConType(int solIdx, int otherIdx, std::string conType)
Set the conType of another (non-standard/solver specific) constraint-related result,...
std::string getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index.
std::string getOtherSolutionResultName(int solIdx, int otherIdx)
bool setAvailableCPUNumberDescription(std::string description)
Set the description of available number of CPUs.
std::string getOtherVariableResultValue(int solIdx, int otherIdx)
std::string getGeneralSubstatusDescription(int i)
Get the i_th general substatus description.
bool setUsedCPUNumberDescription(std::string description)
Set the description of used number of CPUs.
std::string getOtherSolutionResultItem(int solIdx, int otherIdx, int itemIdx)
std::string getOtherObjectiveResultObj(int solIdx, int otherIdx, int objIdx)
std::string getTimeServiceStarted()
int getUsedCPUNumberValue()
int getNumberOfObjValues(int solIdx)
bool setOtherVariableResultValue(int solIdx, int otherIdx, std::string value)
Set the value of another (non-standard/solver specific) variable-related result, for the [i]th soluti...
std::string getInstanceName()
Get instance name.
bool setOtherVariableResultVar(int solIdx, int otherIdx, int varIdx, std::string value)
Set the value of another (non-standard/solver specific) variable-related result, for the [i]th soluti...
bool setGeneralStatusDescription(std::string description)
Set the general status description.
bool setSolutionNumber(int number)
set the number of solutions.
int getNumberOfOtherJobResults()
std::string getJobStatus()
std::string getOtherConstraintResultDescription(int solIdx, int otherIdx)
bool setOtherSystemResultValue(int idx, std::string value)
Set the system otherResult value.
bool setOtherGeneralResultName(int idx, std::string name)
Set the general otherResult name.
bool setAvailableCPUSpeedValue(double value)
Set the available CPU speed.
std::string getOtherObjectiveResultName(int solIdx, int otherIdx)
int getOtherConstraintResultNumberOfCon(int solIdx, int otherIdx)
std::string getSolutionSubstatusDescription(int solIdx, int substatusIdx)
bool setSolverOutputItem(int otherIdx, int itemIdx, std::string item)
Set one item associated with the [j]th solver output.
std::string getOtherGeneralResultValue(int idx)
int getBasisStatusNumberOfEl(int solIdx, int object, int status)
Get the number of indices that belong to a particular basis status.
bool setInstanceName(std::string instanceName)
Set instance name.
bool setOtherJobResultName(int idx, std::string name)
Set the job otherResult name.
bool setSolutionSubstatusDescription(int solIdx, int substatusIdx, std::string description)
Set the solution substatus description.
double getAvailableCPUSpeedValue()
std::string getUsedDiskSpaceDescription()
bool setSolverOutputNumberOfItems(int otherIdx, int numberOfItems)
Set the number of items associated with the [j]th solver output.
std::string getOtherGeneralResultName(int idx)
Get the name of the i-th other result in the <general> element.
bool setJobSubmitTime(std::string submitTime)
Set the time when the job was submitted.
std::string getOtherVariableResultDescription(int solIdx, int otherIdx)
bool setOtherOptionOrResultEnumeration(int solIdx, int otherIdx, int object, int enumIdx, std::string value, std::string description, int *i, int ni)
Set the value and corresponding indices of another (non-standard/solver specific) variable-related re...
std::string getActualStartTime()
bool setNumberOfDualValues(int solIdx, int numberOfCon)
Set the number of constraints to be given a value.
bool setNumberOfSolutionSubstatuses(int solIdx, int num)
Set the [i]th optimization solution's number of substatus elements.
double getAvailableMemoryValue()
bool setOtherServiceResultDescription(int idx, std::string description)
Set the service otherResult description.
int getOtherConstraintResultNumberOfEnumerations(int solIdx, int otherIdx)
int getOtherVariableResultEnumerationEl(int solIdx, int otherIdx, int enumIdx, int j)
Get one index of an enum associated with an <other> result for some solution.
bool setOtherSolutionResultName(int solIdx, int otherIdx, std::string name)
Set the name associated with the [j]th other solution result of solution [i].
int getNumberOfOtherConstraintResults(int solIdx)
bool setUsedCPUSpeedUnit(std::string unit)
Set the unit in which used CPU speed is measured.
bool setTimeServiceStarted(std::string startTime)
Set the time the service was started.
std::string getAvailableCPUNumberDescription()
std::string getOtherJobResultDescription(int idx)
int getOtherVariableResultEnumerationNumberOfEl(int solIdx, int otherIdx, int enumIdx)
Get the size of an enum associated with an <other> result for some solution.
std::string getSolutionStatusDescription(int solIdx)
Get the [i]th optimization solution status description, where i equals the given solution index.
bool setNumberOfOtherVariableResults(int solIdx, int numberOfOtherVariableResults)
Set the [i]th optimization solution's other (non-standard/solver specific) variable-related results,...
std::string getJobSubmitTime()
bool setOtherObjectiveResultNumberOfEnumerations(int solIdx, int otherIdx, int numberOfObj)
Set the number of <enumeration> children of another (non-standard/solver specific) objective-related ...
std::string getTimingInfoType(int idx)
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
std::string getOtherObjectiveResultValue(int solIdx, int otherIdx)
bool setNumberOfTimes(int numberOfTimes)
Set the number of time measurements and initial the time array.
bool setObjectiveNumber(int objectiveNumber)
Set the objective number.
std::string getSolverOutputDescription(int otherIdx)
bool setOtherServiceResultValue(int idx, std::string value)
Set the service otherResult value.
bool setSolutionTargetObjectiveName(int solIdx, std::string objectiveName)
Set the [i]th optimization solution's objective name, where i equals the given solution index.
bool setCurrentJobCount(int jobCount)
Set the current job count.
int getNumberOfSolverOutputs()
bool getSolutionWeightedObjectives(int solIdx)
Get the [i]th optimization solution form of the objective.
bool setOtherConstraintResultCon(int solIdx, int otherIdx, int conIdx, std::string value)
Set the value of another (non-standard/solver specific) constraint-related result,...
std::string getAvailableCPUSpeedDescription()
int getObjValueIdx(int solIdx, int objIdx)
std::string getVarValueName(int solIdx, int varIdx)
bool setNumberOfOtherSolutionResults(int solIdx, int numberOfOtherSolutionResults)
Set the [i]th optimization solution's other (non-standard/solver specific) solution-related results,...
bool setTotalJobsSoFar(int number)
Set the total number of jobs so far.
int getOtherObjectiveResultNumberOfEnumerations(int solIdx, int otherIdx)
std::string getJobEndTime()
std::string getScheduledStartTime()
bool setSolverOutputName(int otherIdx, std::string name)
Set the name associated with the [j]th solver output.
std::string getOtherServiceResultValue(int idx)
bool setAvailableMemoryUnit(std::string unit)
Set the unit in which available memory is measured.
bool setActualStartTime(std::string actualStartTime)
Set the job's actual start time.
int getObjectiveNumber()
Get objective number.
bool setNumberOfOtherGeneralResults(int num)
Set number of other general results.
int getNumberOfOtherGeneralResults()
Get the number of other results in the <general> element.
bool setOtherJobResultValue(int idx, std::string value)
Set the job otherResult value.
bool setPrimalVariableValuesDense(int solIdx, double *x)
Set the [i]th optimization solution's primal variable values, where i equals the given solution index...
bool setAvailableCPUNumberValue(int value)
Set the available number of CPUs.
int getOtherConstraintResultEnumerationNumberOfEl(int solIdx, int otherIdx, int enumIdx)
Get the size of an enum associated with an <other> result for some solution.
std::string getOtherSystemResultValue(int idx)
std::string getSolutionTargetObjectiveName(int solIdx)
bool setOtherConstraintResultName(int solIdx, int otherIdx, std::string name)
Set the name of another (non-standard/solver specific) constraint-related result, for the [i]th solut...
int getOtherConstraintResultEnumerationEl(int solIdx, int otherIdx, int enumIdx, int j)
Get one index of an enum associated with an <other> result for some solution.
bool setUsedCPUNumberValue(int value)
Set the used number of CPUs.
int getNumberOfSolutionSubstatuses(int solIdx)
int getNumberOfGeneralSubstatuses()
Get the number of substatuses.
std::string getUsedDiskSpaceUnit()
OptimizationResult * optimization
optimization holds the fifth child of the OSResult specified by the OSrL Schema.
Definition OSResult.h:2581
bool setOtherConstraintResultNumberOfEnumerations(int solIdx, int otherIdx, int numberOfCon)
Set the number of <enumeration> children of another (non-standard/solver specific) constraint-related...
bool setUsedMemoryValue(double value)
Set the amount of used memory.
bool setOtherVariableResultVarIdx(int solIdx, int otherIdx, int varIdx, int idx)
Set the index of another (non-standard/solver specific) variable-related result, for the [i]th soluti...
std::string getTimingInfoUnit(int idx)
std::string getSolutionMessage(int solIdx)
Get the [i]th optimization solution message, where i equals the given solution index.
bool setOtherConstraintResultEnumType(int solIdx, int otherIdx, std::string enumType)
Set the enumType of another (non-standard/solver specific) constraint-related result,...
int getVarValueStringIdx(int solIdx, int varIdx)
double getVarValue(int solIdx, int varIdx)
int getNumberOfVarValues(int solIdx)
std::string getJobID()
Get the job id.
bool setOtherObjectiveResultNumberOfObj(int solIdx, int otherIdx, int numberOfObj)
Set the number of <obj> children of another (non-standard/solver specific) objective-related result,...
std::string getOtherVariableResultEnumerationValue(int solIdx, int otherIdx, int enumIdx)
Get the value of an enum associated with an <other> result for some solution.
bool setServiceName(std::string serviceName)
Set service name.
double getTimingInfoValue(int idx)
std::string getSolverOutputCategory(int otherIdx)
bool setUsedMemoryDescription(std::string description)
Set the description of used memory.
bool setAvailableDiskSpaceValue(double value)
Set the amount of available disk space.
bool setSolverInvoked(std::string solverInvoked)
Set solver invoked.
std::string getAvailableCPUSpeedUnit()
bool setOtherObjectiveResultEnumType(int solIdx, int otherIdx, std::string enumType)
Set the enumType of another (non-standard/solver specific) objective-related result,...
std::string getOtherConstraintResultName(int solIdx, int otherIdx)
bool setNumberOfOtherObjectiveResults(int solIdx, int numberOfOtherObjectiveResults)
Set the [i]th optimization solution's other (non-standard/solver specific) objective-related results,...
double getAvailableDiskSpaceValue()
bool setOtherSolutionResultDescription(int solIdx, int otherIdx, std::string description)
Set the description associated with the [j]th other solution result of solution [i].
bool setVariableNumber(int variableNumber)
Set the variable number.
int getNumberOfOtherSystemResults()
int getBasisStatusEl(int solIdx, int object, int status, int j)
Get an entry in the array of indices that belong to a particular basis status.
bool setAvailableCPUSpeedDescription(std::string description)
Set the description of available CPU speed.
bool setOtherObjectiveResultName(int solIdx, int otherIdx, std::string name)
Set the name of another (non-standard/solver specific) objective-related result, for the [i]th soluti...
std::string getOtherSolutionResultCategory(int solIdx, int otherIdx)
int getNumberOfOtherServiceResults()
bool setOtherVariableResultDescription(int solIdx, int otherIdx, std::string description)
Set the description of another (non-standard/solver specific) variable-related result,...
std::string getGeneralMessage()
Get the general message.
std::string getTimingInfoCategory(int idx)
bool setNumberOfGeneralSubstatuses(int num)
Set the number of substatus elements.
std::string getOtherJobResultValue(int idx)
int getSolutionNumber()
get the number of solutions.
std::string getUsedMemoryUnit()
bool setDualVariableValuesDense(int solIdx, double *y)
Set the [i]th optimization solution's dual variable values, where i equals the given solution index.
int getOtherVariableResultVarIdx(int solIdx, int otherIdx, int varIdx)
bool setSolutionSubstatusType(int solIdx, int substatusIdx, std::string type)
Set the solution substatus type.
bool setUsedCPUSpeedValue(double value)
Set the used CPU speed.
int getOtherObjectiveResultEnumerationEl(int solIdx, int otherIdx, int enumIdx, int j)
Get one index of an enum associated with an <other> result for some solution.
std::string getSolutionSubstatusType(int solIdx, int substatusIdx)
std::string getOtherSolutionResultValue(int solIdx, int otherIdx)
int getVarValueIdx(int solIdx, int varIdx)
bool setUsedDiskSpaceUnit(std::string unit)
Set the unit in which used disk space is measured.
int getSolutionTargetObjectiveIdx(int solIdx)
std::string getOtherObjectiveResultEnumerationDescription(int solIdx, int otherIdx, int enumIdx)
Get the description of an enum associated with an <other> result for some solution.
bool setOtherSolutionResultItem(int solIdx, int otherIdx, int itemIdx, std::string item)
Set one item associated with the [j]th other solution result of solution [i].
bool setOtherJobResultDescription(int idx, std::string description)
Set the job otherResult description.
bool setUsedDiskSpaceDescription(std::string description)
Set the description of used disk space.
int getTotalJobsSoFar()
bool setSolverOutputDescription(int otherIdx, std::string description)
Set the description associated with the [j]th solver output.
bool setGeneralSubstatusName(int idx, std::string name)
Set the general substatus name.
bool setSolutionMessage(int solIdx, std::string msg)
Set the [i]th optimization solution's message, where i equals the given solution index.
std::string getSolverOutputName(int otherIdx)
std::string getUsedCPUSpeedUnit()
bool setUsedMemoryUnit(std::string unit)
Set the unit in which used memory is measured.
bool setCurrentState(std::string currentState)
Set the current state of the service.
std::string getCurrentState()
std::string getOtherObjectiveResultDescription(int solIdx, int otherIdx)
int getNumberOfTimes()
bool setOtherObjectiveResultValue(int solIdx, int otherIdx, std::string value)
Set the value of another (non-standard/solver specific) objective-related result, for the [i]th solut...
double getUsedDiskSpaceValue()
int getOtherSolutionResultNumberOfItems(int solIdx, int otherIdx)
bool setOtherConstraintResultConIdx(int solIdx, int otherIdx, int conIdx, int idx)
Set the index of another (non-standard/solver specific) constraint-related result,...
bool setSolutionStatusDescription(int solIdx, std::string description)
Set the [i]th optimization solution status description.
int getNumberOfOtherSolutionResults(int solIdx)
double getUsedMemoryValue()
bool setOtherGeneralResultDescription(int idx, std::string description)
Set the general otherResult description.
bool setSolutionStatus(int solIdx, std::string type, std::string description)
Set the [i]th optimization solution status, where i equals the given solution index.
std::string getAvailableDiskSpaceDescription()
bool setObjValue(int solIdx, int number, int idx, std::string name, double val)
Set an objective value.
bool setOtherSolutionResultNumberOfItems(int solIdx, int otherIdx, int numberOfItems)
Set the number of items associated with the [j]th other solution result of solution [i].
std::string getAvailableMemoryUnit()
bool setUsedCPUSpeedDescription(std::string description)
Set the description of used CPU speed.
std::string getOtherSystemResultDescription(int idx)
std::string getVarValueStringName(int solIdx, int varIdx)
bool setOtherObjectiveResultDescription(int solIdx, int otherIdx, std::string description)
Set the description of another (non-standard/solver specific) objective-related result,...
int getConstraintNumber()
Get constraint number.
std::string getAvailableDiskSpaceUnit()
bool setTimingInformation(int idx, std::string type, std::string category, std::string unit, std::string description, double value)
Set timing information.
std::string getOtherVariableResultVar(int solIdx, int otherIdx, int varIdx)
std::string getSystemInformation()
bool setSolutionWeightedObjectives(int solIdx, bool weightedObjectives)
Record whether the [i]th optimization solution uses weighted objectives, where i equals the given sol...
std::string getOtherSolutionResultDescription(int solIdx, int otherIdx)
std::string getOtherVariableResultName(int solIdx, int otherIdx)
int getAvailableCPUNumberValue()
std::string getObjValueName(int solIdx, int objIdx)
bool setOtherVariableResultNumberOfEnumerations(int solIdx, int otherIdx, int numberOfEnumerations)
Set the number of <enumeration> children of another (non-standard/solver specific) variable-related r...
bool setSolverOutputCategory(int otherIdx, std::string category)
Set the category associated with the [j]th solver output.
bool setConstraintNumber(int constraintNumber)
Set the constraint number.
double getObjValue(int solIdx, int objIdx)
std::string getOtherGeneralResultDescription(int idx)
bool IsEqual(OSResult *that)
A function to check for the equality of two objects.
double getServiceUtilization()
bool setNumberOfOtherSystemResults(int num)
Set number of other system results.
bool setBasisStatus(int solIdx, int object, int status, int *i, int ni)
Set the basis status of a number of variables/constraints/objectives.
std::string getOtherConstraintResultEnumerationValue(int solIdx, int otherIdx, int enumIdx)
Get the value of an enum associated with an <other> result for some solution.
bool setAvailableMemoryValue(double value)
Set the amount of available memory.
bool setJobEndTime(std::string endTime)
Set the time when the job finished.
bool setServiceUtilization(double value)
Set the service utilitzation.
std::string getAvailableMemoryDescription()
int getCurrentJobCount()
bool setNumberOfOtherConstraintResults(int solIdx, int numberOfOtherConstraintResults)
Set the [i]th optimization solution's other (non-standard/solver specific) constraint-related results...
bool setOtherObjectiveResultObjType(int solIdx, int otherIdx, std::string objType)
Set the objType of another (non-standard/solver specific) objective-related result,...
bool setNumberOfObjValues(int solIdx, int numberOfObj)
Set the number of objectives to be given a value.
std::string getOtherConstraintResultCon(int solIdx, int otherIdx, int conIdx)
int getOtherVariableResultNumberOfEnumerations(int solIdx, int otherIdx)
bool setOtherObjectiveResultType(int solIdx, int otherIdx, std::string type)
Set the type of another (non-standard/solver specific) objective-related result, for the [i]th soluti...
bool setAvailableCPUSpeedUnit(std::string unit)
Set the unit in which available CPU speed is measured.
bool setOtherVariableResultEnumType(int solIdx, int otherIdx, std::string enumType)
Set the enumType of another (non-standard/solver specific) variable-related result,...
std::string getOtherServiceResultDescription(int idx)
bool setNumberOfVarValuesString(int solIdx, int numberOfVar)
Set the number of string-valued primal variables to be given a value.
std::string getOtherServiceResultName(int idx)
int getOtherConstraintResultConIdx(int solIdx, int otherIdx, int conIdx)
std::string getUsedMemoryDescription()
bool setScheduledStartTime(std::string scheduledStartTime)
Set the job's scheduled start time.
bool setServiceURI(std::string serviceURI)
Set service uri.
std::string getDualValueName(int solIdx, int objIdx)
int getDualValueIdx(int solIdx, int conIdx)
double getDualValue(int solIdx, int conIdx)
bool setDualValue(int solIdx, int number, int idx, std::string name, double val)
Set a dual value.
int getNumberOfOtherVariableResults(int solIdx)
Get numberOfOtherVariableResult.
bool setOtherServiceResultName(int idx, std::string name)
Set the service otherResult name.
std::string getTimeStamp()
Get the time stamp.
bool setOtherConstraintResultValue(int solIdx, int otherIdx, std::string value)
Set the value of another (non-standard/solver specific) constraint-related result,...
std::string getUsedCPUNumberDescription()
int getVariableNumber()
Get variable number.
bool setGeneralSubstatusDescription(int idx, std::string description)
Set the general substatus description.
bool setOtherVariableResultName(int solIdx, int otherIdx, std::string name)
Set the name of another (non-standard/solver specific) variable-related result, for the [i]th solutio...
bool setSolutionTargetObjectiveIdx(int solIdx, int objectiveIdx)
Set the [i]th optimization solution's objective index, where i equals the given solution index.
bool setAvailableDiskSpaceUnit(std::string unit)
Set the unit in which available disk space is measured.
bool setOtherSystemResultDescription(int idx, std::string description)
Set the system otherResult description.
bool setSystemInformation(std::string systemInformation)
Set the system information.
std::string getOtherJobResultName(int idx)
bool setAvailableMemoryDescription(std::string description)
Set the description of available memory.
bool setSolutionStatusType(int solIdx, std::string type)
Set the [i]th optimization solution status type.
bool setOtherGeneralResultValue(int idx, std::string value)
Set the general otherResult value.
std::string getOtherSystemResultName(int idx)
int getNumberOfOtherObjectiveResults(int solIdx)
bool setNumberOfSolverOutputs(int numberOfSolverOutputs)
Set the number of other solver outputs.
std::string getServiceURI()
Get service uri.
std::string getGeneralStatusType()
Get the general status type, which can be: success, error, warning.
bool setOtherConstraintResultNumberOfCon(int solIdx, int otherIdx, int numberOfCon)
Set the number of <con> children of another (non-standard/solver specific) constraint-related result,...
std::string getUsedCPUSpeedDescription()
bool setOtherSystemResultName(int idx, std::string name)
Set the system otherResult name.
bool setOtherSolutionResultCategory(int solIdx, int otherIdx, std::string category)
Set the category associated with the [j]th other solution result of solution [i].
int getOtherObjectiveResultNumberOfObj(int solIdx, int otherIdx)
bool setOtherConstraintResultDescription(int solIdx, int otherIdx, std::string description)
Set the description of another (non-standard/solver specific) constraint-related result,...
bool setNumberOfVarValues(int solIdx, int numberOfVar)
Set the number of primal variables to be given a value.
int getOtherObjectiveResultObjIdx(int solIdx, int otherIdx, int objIdx)
Creating a OSInstance from a GAMS model given as GAMS Modeling Object (GMO).
bool createOSInstance()
Creates an OSInstance from the GAMS smag instance representation.
OSInstance * osinstance
Used to read an OSiL string.
Definition OSiLReader.h:38
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.
Definition OSiLWriter.h:30
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
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 OSmps2OS Class.
Definition OSmps2OS.h:40
bool createOSObjects()
create an OSInstance from the MPS instance representation and an OSOption in case of nonstandard sect...
Definition OSmps2OS.cpp:192
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the instance represented in M...
Definition OSmps2OS.h:65
The OSnLNode Class for nonlinear expressions.
Definition OSnLNode.h:180
OSnLNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OS...
Definition OSnLNode.cpp:413
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
Definition OSnLNode.cpp:468
OSnLNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a scalar-valued OSE...
Definition OSnLNode.cpp:381
virtual double calculateFunction(double *x)=0
Calculate the function value given the current variable values.
The OSnl2OS Class.
Definition OSnl2OS.h:79
ASL * getASL(std::string name)
return a pointer to an ASL object
Definition OSnl2OS.cpp:87
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the information in the nl fil...
Definition OSnl2OS.h:172
bool readNl(std::string stub)
read the nl file
Definition OSnl2OS.cpp:109
bool createOSObjects()
create an OSInstance and OSOption representation from the AMPL nl content (Some of the information in...
Definition OSnl2OS.cpp:504
OSOption * osoption
osoption is a pointer to the OSOption object that gets created from the information in the nl file (a...
Definition OSnl2OS.h:177
std::string osol
osol is a string containing the content of the OS option file (it may be empty if no option file was ...
Definition OSnl2OS.h:183
Used to read an OSoL string.
Definition OSoLReader.h:38
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.
Definition OSoLWriter.h:30
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
The OSosrl2ampl Class.
Definition OSosrl2ampl.h:45
bool writeSolFile(std::string osrl, ASL *asl, std::string filename)
Convert the solution to AMPL .sol format.
The OSrLReader Class.
Definition OSrLReader.h:43
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.
Definition OSrLWriter.h:31
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
The in-memory representation of the <obj> element.
Definition OSInstance.h:142
OtherObjectiveResult ** other
a pointer to an array of other pointer objects for objective functions
Definition OSResult.h:1555
BasisStatus * basisStatus
a pointer to a BasisStatus object
Definition OSResult.h:1550
The in-memory representation of the <objectives> element.
Definition OSInstance.h:189
int numberOfObjectives
numberOfObjectives is the number of objective functions in the instance
Definition OSInstance.h:201
Objective ** obj
coef is pointer to an array of ObjCoef object pointers
Definition OSInstance.h:205
the OptimizationOption class.
Definition OSOption.h:3496
VariableOption * variables
the options for the variables
Definition OSOption.h:3509
ConstraintOption * constraints
the options for the constraints
Definition OSOption.h:3515
int numberOfSolutions
numberOfSolutions is the number of objective functions reported.
Definition OSResult.h:2480
OptimizationSolution ** solution
solution is an array of pointers to OptimizationSolution objects
Definition OSResult.h:2500
VariableSolution * variables
variables holds the solution information for the variables
Definition OSResult.h:2291
ObjectiveSolution * objectives
objectives holds the solution information for the objectives
Definition OSResult.h:2300
ConstraintSolution * constraints
constraints holds the solution information for the constraints
Definition OSResult.h:2295
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 conType
type of the values in the con array
Definition OSOption.h:3188
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
std::string type
type of the option value (integer, double, boolean, string)
Definition OSOption.h:3179
OtherOptionOrResultEnumeration ** enumeration
Definition OSOption.h:3194
std::string description
description of the option
Definition OSOption.h:3182
std::string enumType
type of the values in the enumeration array
Definition OSOption.h:3197
int numberOfEnumerations
number of <enumeration> child elements
Definition OSOption.h:3164
std::string value
value of the option
Definition OSOption.h:3170
int numberOfEnumerations
the number of distinct values for this particular type of result
Definition OSResult.h:1779
OtherOptionOrResultEnumeration ** enumeration
Definition OSResult.h:1814
int idx
variable index
Definition OSOption.h:2514
std::string value
value of the option
Definition OSOption.h:2520
the OtherObjectiveOption class.
Definition OSOption.h:2575
OtherObjOption ** obj
array of option values
Definition OSOption.h:2603
int numberOfObj
number of <obj> children
Definition OSOption.h:2579
std::string name
name of the option
Definition OSOption.h:2585
std::string value
value of the option
Definition OSOption.h:2588
int numberOfEnumerations
number of <enumeration> child elements
Definition OSOption.h:2582
std::string objType
type of the values in the obj array
Definition OSOption.h:2606
std::string type
type of the option value (integer, double, boolean, string)
Definition OSOption.h:2597
std::string description
description of the option
Definition OSOption.h:2600
std::string enumType
type of the values in the enumeration array
Definition OSOption.h:2615
OtherOptionOrResultEnumeration ** enumeration
Definition OSOption.h:2612
int numberOfEnumerations
the number of distinct values for this particular type of result
Definition OSResult.h:1455
OtherOptionOrResultEnumeration ** enumeration
Definition OSResult.h:1490
the OtherOption class.
Definition OSOption.h:153
the OtherVarOption class.
Definition OSOption.h:1928
std::string value
value of the option
Definition OSOption.h:1938
std::string ubValue
lower bound on the value
Definition OSOption.h:1944
int idx
variable index
Definition OSOption.h:1932
std::string lbValue
lower bound on the value
Definition OSOption.h:1941
the OtherVariableOption class.
Definition OSOption.h:1990
int numberOfVar
number of child elements
Definition OSOption.h:1994
int numberOfEnumerations
number of <enumeration> child elements
Definition OSOption.h:1997
std::string type
type of the option value (integer, double, boolean, string)
Definition OSOption.h:2012
std::string name
name of the option
Definition OSOption.h:2000
std::string enumType
type of the values in the enumeration array
Definition OSOption.h:2030
OtherOptionOrResultEnumeration ** enumeration
Definition OSOption.h:2027
OtherVarOption ** var
array of option values
Definition OSOption.h:2018
std::string description
description of the option
Definition OSOption.h:2015
std::string varType
type of the values in the var array
Definition OSOption.h:2021
std::string value
value of the option
Definition OSOption.h:2003
int numberOfEnumerations
the number of distinct values for this particular type of result
Definition OSResult.h:1136
OtherOptionOrResultEnumeration ** enumeration
Definition OSResult.h:1171
the PathPair class.
Definition OSOption.h:852
a data structure for holding quadratic terms
Definition OSGeneral.h:432
int * varTwoIndexes
varTwoIndexes holds an integer array of the second variable indexes of all the quadratic terms.
Definition OSGeneral.h:450
int * rowIndexes
rowIndexes holds an integer array of row indexes of all the quadratic terms.
Definition OSGeneral.h:440
double * coefficients
coefficients holds a double array all the quadratic term coefficients.
Definition OSGeneral.h:455
int * varOneIndexes
varOneIndexes holds an integer array of the first variable indexes of all the quadratic terms.
Definition OSGeneral.h:445
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
Used to hold part of the instance in memory.
OSnLNode * m_treeRoot
m_treeRoot holds the root node (of OSnLNode type) of the expression tree.
the SolverOption class.
Definition OSOption.h:3345
The in-memory representation of a SparseHessianMatrix..
Definition OSGeneral.h:377
double * hessValues
hessValues is a double array of the Hessian values.
Definition OSGeneral.h:404
a sparse matrix data structure
Definition OSGeneral.h:224
int * indexes
indexes holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix).
Definition OSGeneral.h:258
int * starts
starts holds an integer array of start elements in coefMatrix (AMatrix), which points to the start of...
Definition OSGeneral.h:252
double * values
values holds a double array of value elements in coefMatrix (AMatrix), which contains nonzero element...
Definition OSGeneral.h:264
a sparse vector data structure
Definition OSGeneral.h:123
double * values
values holds a double array of nonzero values.
Definition OSGeneral.h:164
The in-memory representation of the variable element.
Definition OSInstance.h:45
the VariableOption class.
Definition OSOption.h:2097
BasisStatus * initialBasisStatus
initial basis information
Definition OSOption.h:2110
SOSVariableBranchingWeights * sosVariableBranchingWeights
branching weights for SOS variables and groups
Definition OSOption.h:2116
OtherVariableResult ** other
a pointer to an array of other pointer objects for variables
Definition OSResult.h:1238
BasisStatus * basisStatus
a pointer to a BasisStatus object
Definition OSResult.h:1233
The in-memory representation of the variables element.
Definition OSInstance.h:84
int numberOfVariables
numberOfVariables is the number of variables in the instance
Definition OSInstance.h:94
Variable ** var
Here we define a pointer to an array of var pointers.
Definition OSInstance.h:97
#define OS_NEAR_EQUAL
we use OS_NEAR_EQUAL in unitTest to see if we are close to the optimal obj value
std::string returnBasisStatusString(ENUM_BASIS_STATUS status)
ENUM_BASIS_STATUS
Enumeration for the different states that can be used in representating a basis The last state,...
@ ENUM_BASIS_STATUS_isFree
@ ENUM_BASIS_STATUS_unknown
@ ENUM_BASIS_STATUS_basic
@ ENUM_BASIS_STATUS_NUMBER_OF_STATES
@ ENUM_BASIS_STATUS_atLower
@ ENUM_BASIS_STATUS_atEquality
@ ENUM_BASIS_STATUS_superbasic
@ ENUM_BASIS_STATUS_atUpper
@ ENUM_PROBLEM_COMPONENT_objectives
@ ENUM_PROBLEM_COMPONENT_constraints
@ ENUM_PROBLEM_COMPONENT_variables
double getObjVal(std::string osrl)
int main(int argC, char *argV[])
Definition unitTest.cpp:269
void tempPrintArrays(OSResult *os)
int getItCount(std::string osrl)
OSResult * osresult