Osi trunk
|
#include <string>
#include <vector>
#include <list>
Go to the source code of this file.
Classes | |
class | OsiUnitTest::TestOutcome |
class | OsiUnitTest::TestOutcomes |
Namespaces | |
namespace | OsiUnitTest |
Defines | |
#define | OSIUNITTEST_QUOTEME_(x) #x |
#define | OSIUNITTEST_QUOTEME(x) OSIUNITTEST_QUOTEME_(x) |
#define | OSIUNITTEST_ADD_OUTCOME(component, testname, testcondition, severity, expected) OsiUnitTest::outcomes.add(component, testname, testcondition, severity, __FILE__, __LINE__, expected) |
#define | OSIUNITTEST_ASSERT_SEVERITY_EXPECTED(condition, failurecode, component, testname, severity, expected) |
#define | OSIUNITTEST_ASSERT_ERROR(condition, failurecode, component, testname) OSIUNITTEST_ASSERT_SEVERITY_EXPECTED(condition, failurecode, component, testname, OsiUnitTest::TestOutcome::ERROR, false) |
#define | OSIUNITTEST_ASSERT_WARNING(condition, failurecode, component, testname) OSIUNITTEST_ASSERT_SEVERITY_EXPECTED(condition, failurecode, component, testname, OsiUnitTest::TestOutcome::WARNING, false) |
#define | OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, severity, expected) |
#define | OSIUNITTEST_CATCH_ERROR(trycode, catchcode, component, testname) OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::ERROR, false) |
#define | OSIUNITTEST_CATCH_WARNING(trycode, catchcode, component, testname) OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::WARNING, false) |
Functions | |
int | OsiSolverInterfaceMpsUnitTest (const std::vector< OsiSolverInterface * > &vecEmptySiP, const std::string &mpsDir) |
Run solvers on NetLib problems. | |
int | OsiSolverInterfaceCommonUnitTest (const OsiSolverInterface *emptySi, const std::string &mpsDir, const std::string &netlibDir) |
void | OsiUnitTest::failureMessage (const std::string &solverName, const std::string &message) |
void | OsiUnitTest::failureMessage (const OsiSolverInterface &si, const std::string &message) |
void | OsiUnitTest::failureMessage (const std::string &solverName, const std::string &testname, const std::string &testcond) |
void | OsiUnitTest::failureMessage (const OsiSolverInterface &si, const std::string &testname, const std::string &testcond) |
void | OsiUnitTest::testingMessage (const char *const msg) |
bool | OsiUnitTest::equivalentVectors (const OsiSolverInterface *si1, const OsiSolverInterface *si2, double tol, const double *v1, const double *v2, int size) |
bool | OsiUnitTest::compareProblems (OsiSolverInterface *osi1, OsiSolverInterface *osi2) |
bool | OsiUnitTest::isEquivalent (const CoinPackedVectorBase &pv, int n, const double *fv) |
Variables | |
unsigned int | OsiUnitTest::verbosity |
verbosity level of unit tests 0 (= default) for minimal output | |
TestOutcomes | OsiUnitTest::outcomes |
a global TestOutcomes object to store test outcomes during a run of the Osi unittest |
#define OSIUNITTEST_QUOTEME_ | ( | x | ) | #x |
Definition at line 115 of file OsiUnitTests.hpp.
#define OSIUNITTEST_QUOTEME | ( | x | ) | OSIUNITTEST_QUOTEME_(x) |
Definition at line 116 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ADD_OUTCOME | ( | component, | |
testname, | |||
testcondition, | |||
severity, | |||
expected | |||
) | OsiUnitTest::outcomes.add(component, testname, testcondition, severity, __FILE__, __LINE__, expected) |
Definition at line 118 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ASSERT_SEVERITY_EXPECTED | ( | condition, | |
failurecode, | |||
component, | |||
testname, | |||
severity, | |||
expected | |||
) |
{ \ if( condition ) { \ OSIUNITTEST_ADD_OUTCOME(component, testname, #condition, OsiUnitTest::TestOutcome::PASSED, false); \ if (OsiUnitTest::verbosity >= 2) { \ std::string successmsg(__FILE__ ":" OSIUNITTEST_QUOTEME(__LINE__) ": "); \ successmsg = successmsg + testname; \ successmsg = successmsg + " (condition \'" #condition "\') passed.\n"; \ OsiUnitTest::testingMessage(successmsg.c_str()); \ } \ } else { \ OSIUNITTEST_ADD_OUTCOME(component, testname, #condition, severity, expected); \ OsiUnitTest::failureMessage(component, testname, #condition); \ failurecode; \ } \ }
Definition at line 121 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ASSERT_ERROR | ( | condition, | |
failurecode, | |||
component, | |||
testname | |||
) | OSIUNITTEST_ASSERT_SEVERITY_EXPECTED(condition, failurecode, component, testname, OsiUnitTest::TestOutcome::ERROR, false) |
Definition at line 138 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ASSERT_WARNING | ( | condition, | |
failurecode, | |||
component, | |||
testname | |||
) | OSIUNITTEST_ASSERT_SEVERITY_EXPECTED(condition, failurecode, component, testname, OsiUnitTest::TestOutcome::WARNING, false) |
Definition at line 141 of file OsiUnitTests.hpp.
#define OSIUNITTEST_CATCH_SEVERITY_EXPECTED | ( | trycode, | |
catchcode, | |||
component, | |||
testname, | |||
severity, | |||
expected | |||
) |
{\ try {\ trycode; \ OSIUNITTEST_ADD_OUTCOME(component, testname, #trycode " did not threw exception", OsiUnitTest::TestOutcome::PASSED, false); \ if (OsiUnitTest::verbosity >= 2) { \ std::string successmsg( __FILE__ ":" OSIUNITTEST_QUOTEME(__LINE__) ": "); \ successmsg = successmsg + testname; \ successmsg = successmsg + " (code \'" #trycode "\') did not throw exception.\n"; \ OsiUnitTest::testingMessage(successmsg.c_str()); \ } \ } catch (CoinError& e) { \ std::string errmsg; \ errmsg = #trycode; \ errmsg = errmsg + " threw CoinError: " + e.message(); \ OSIUNITTEST_ADD_OUTCOME(component, testname, errmsg.c_str(), severity, expected); \ OsiUnitTest::failureMessage(component, testname, errmsg.c_str()); \ catchcode; \ } catch (...) { \ std::string errmsg; \ errmsg = #trycode; \ errmsg = errmsg + " threw unknown exception"; \ OSIUNITTEST_ADD_OUTCOME(component, testname, errmsg.c_str(), severity, false); \ OsiUnitTest::failureMessage(component, testname, errmsg.c_str()); \ catchcode; \ } \ }
Definition at line 144 of file OsiUnitTests.hpp.
#define OSIUNITTEST_CATCH_ERROR | ( | trycode, | |
catchcode, | |||
component, | |||
testname | |||
) | OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::ERROR, false) |
Definition at line 172 of file OsiUnitTests.hpp.
#define OSIUNITTEST_CATCH_WARNING | ( | trycode, | |
catchcode, | |||
component, | |||
testname | |||
) | OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::WARNING, false) |
Definition at line 175 of file OsiUnitTests.hpp.
int OsiSolverInterfaceMpsUnitTest | ( | const std::vector< OsiSolverInterface * > & | vecEmptySiP, |
const std::string & | mpsDir | ||
) |
Run solvers on NetLib problems.
A function that tests that a lot of problems given in MPS files (mostly the NETLIB problems) solve properly with all the specified solvers.
The routine creates a vector of NetLib problems (problem name, objective, various other characteristics), and a vector of solvers to be tested.
Each solver is run on each problem. The run is deemed successful if the solver reports the correct problem size after loading and returns the correct objective value after optimization.
If multiple solvers are available, the results are compared pairwise against the results reported by adjacent solvers in the solver vector. Due to limitations of the volume solver, it must be the last solver in vecEmptySiP.
int OsiSolverInterfaceCommonUnitTest | ( | const OsiSolverInterface * | emptySi, |
const std::string & | mpsDir, | ||
const std::string & | netlibDir | ||
) |
The only reason for it not to be a member method is that this way it doesn't have to be compiled into the library. And that's a gain, because the library should be compiled with optimization on, but this method should be compiled with debugging. Also, if this method is compiled with optimization, the compilation takes 10-15 minutes and the machine pages (has 256M core memory!)...