DyLP
1.10.4
|
Utility methods for OSI unit tests. More...
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <map>
Go to the source code of this file.
Classes | |
class | OsiUnitTest::TestOutcome |
A single test outcome record. More... | |
class | OsiUnitTest::TestOutcomes |
Utility class to maintain a list of test outcomes. More... | |
Namespaces | |
OsiUnitTest | |
A namespace so we can define a few `global' variables to use during tests. | |
Macros | |
#define | OSIUNITTEST_QUOTEME_(x) #x |
Convert parameter to a string (stringification) More... | |
#define | OSIUNITTEST_QUOTEME(x) OSIUNITTEST_QUOTEME_(x) |
Convert to string with one level of expansion of the parameter. More... | |
#define | OSIUNITTEST_ADD_OUTCOME(component, testname, testcondition, severity, expected) |
Add a test outcome to the list held in OsiUnitTest::outcomes. More... | |
#define | OSIUNITTEST_ASSERT_SEVERITY_EXPECTED(condition, failurecode, component, testname, severity, expected) |
Test for a condition and record the result. More... | |
#define | OSIUNITTEST_ASSERT_ERROR(condition, failurecode, component, testname) |
Perform a test with severity OsiUnitTest::TestOutcome::ERROR, failure not expected. More... | |
#define | OSIUNITTEST_ASSERT_WARNING(condition, failurecode, component, testname) |
Perform a test with severity OsiUnitTest::TestOutcome::WARNING, failure not expected. More... | |
#define | OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname,severity, expected) |
Perform a test surrounded by a try/catch block. More... | |
#define | OSIUNITTEST_CATCH_ERROR(trycode, catchcode, component, testname) OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::ERROR, false) |
Perform a try/catch test with severity OsiUnitTest::TestOutcome::ERROR, failure not expected. More... | |
#define | OSIUNITTEST_CATCH_WARNING(trycode, catchcode, component, testname) OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::WARNING, false) |
Perform a try/catch test with severity OsiUnitTest::TestOutcome::WARNING, failure not expected. More... | |
Functions | |
void | OsiSolverInterfaceMpsUnitTest (const std::vector< OsiSolverInterface * > &vecEmptySiP, const std::string &mpsDir) |
A function that tests that a lot of problems given in MPS files (mostly the NETLIB problems) solve properly with all the specified solvers. More... | |
void | OsiSolverInterfaceCommonUnitTest (const OsiSolverInterface *emptySi, const std::string &mpsDir, const std::string &netlibDir) |
A function that tests the methods in the OsiSolverInterface class. More... | |
void | OsiColCutUnitTest (const OsiSolverInterface *baseSiP, const std::string &mpsDir) |
A function that tests the methods in the OsiColCut class. More... | |
void | OsiRowCutUnitTest (const OsiSolverInterface *baseSiP, const std::string &mpsDir) |
A function that tests the methods in the OsiRowCut class. More... | |
void | OsiRowCutDebuggerUnitTest (const OsiSolverInterface *siP, const std::string &mpsDir) |
A function that tests the methods in the OsiRowCutDebugger class. More... | |
void | OsiCutsUnitTest () |
A function that tests the methods in the OsiCuts class. More... | |
void | OsiUnitTest::failureMessage (const std::string &solverName, const std::string &message) |
Print an error message. More... | |
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) |
Print an error message, specifying the test name and condition. More... | |
void | OsiUnitTest::failureMessage (const OsiSolverInterface &si, const std::string &testname, const std::string &testcond) |
void | OsiUnitTest::testingMessage (const char *const msg) |
Print a message. More... | |
bool | OsiUnitTest::equivalentVectors (const OsiSolverInterface *si1, const OsiSolverInterface *si2, double tol, const double *v1, const double *v2, int size) |
Utility method to check equality. More... | |
bool | OsiUnitTest::compareProblems (OsiSolverInterface *osi1, OsiSolverInterface *osi2) |
Compare two problems for equality. More... | |
bool | OsiUnitTest::isEquivalent (const CoinPackedVectorBase &pv, int n, const double *fv) |
Compare a packed vector with an expanded vector. More... | |
bool | OsiUnitTest::processParameters (int argc, const char **argv, std::map< std::string, std::string > &parms, const std::map< std::string, int > &ignorekeywords=std::map< std::string, int >()) |
Process command line parameters. More... | |
template<typename Component > | |
bool | OsiUnitTest::OsiUnitTestAssertSeverityExpected (bool condition, const char *condition_str, const char *filename, int line, const Component &component, const std::string &testname, TestOutcome::SeverityLevel severity, bool expected) |
Variables | |
unsigned int | OsiUnitTest::verbosity |
Verbosity level of unit tests. More... | |
unsigned int | OsiUnitTest::haltonerror |
Behaviour on failing a test. More... | |
TestOutcomes | OsiUnitTest::outcomes |
Test outcomes. More... | |
Utility methods for OSI unit tests.
Definition in file OsiUnitTests.hpp.
#define OSIUNITTEST_QUOTEME_ | ( | x | ) | #x |
Convert parameter to a string (stringification)
Definition at line 234 of file OsiUnitTests.hpp.
#define OSIUNITTEST_QUOTEME | ( | x | ) | OSIUNITTEST_QUOTEME_(x) |
Convert to string with one level of expansion of the parameter.
Definition at line 236 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ADD_OUTCOME | ( | component, | |
testname, | |||
testcondition, | |||
severity, | |||
expected | |||
) |
Add a test outcome to the list held in OsiUnitTest::outcomes.
Definition at line 276 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ASSERT_SEVERITY_EXPECTED | ( | condition, | |
failurecode, | |||
component, | |||
testname, | |||
severity, | |||
expected | |||
) |
Test for a condition and record the result.
Test condition
and record the result in OsiUnitTest::outcomes. If it succeeds, record the result as OsiUnitTest::TestOutcome::PASSED and print a message for OsiUnitTest::verbosity >= 2. If it fails, record the test as failed with severity
and expected
and react as specified by OsiUnitTest::haltonerror.
failurecode
is executed when failure is not fatal.
Definition at line 289 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ASSERT_ERROR | ( | condition, | |
failurecode, | |||
component, | |||
testname | |||
) |
Perform a test with severity OsiUnitTest::TestOutcome::ERROR, failure not expected.
Definition at line 301 of file OsiUnitTests.hpp.
#define OSIUNITTEST_ASSERT_WARNING | ( | condition, | |
failurecode, | |||
component, | |||
testname | |||
) |
Perform a test with severity OsiUnitTest::TestOutcome::WARNING, failure not expected.
Definition at line 308 of file OsiUnitTests.hpp.
#define OSIUNITTEST_CATCH_SEVERITY_EXPECTED | ( | trycode, | |
catchcode, | |||
component, | |||
testname, | |||
severity, | |||
expected | |||
) |
Perform a test surrounded by a try/catch block.
trycode
is executed in a try/catch block; if there's no throw the test is deemed to have succeeded and is recorded in OsiUnitTest::outcomes with status OsiUnitTest::TestOutcome::PASSED. If the trycode
throws a CoinError, the failure is recorded with status severity
and expected
and the value of OsiUnitTest::haltonerror is consulted. If the failure is not fatal, catchcode
is executed. If any other error is thrown, the failure is recorded as for a CoinError and catchcode
is executed (haltonerror is not consulted).
Definition at line 322 of file OsiUnitTests.hpp.
#define OSIUNITTEST_CATCH_ERROR | ( | trycode, | |
catchcode, | |||
component, | |||
testname | |||
) | OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::ERROR, false) |
Perform a try/catch test with severity OsiUnitTest::TestOutcome::ERROR, failure not expected.
Definition at line 376 of file OsiUnitTests.hpp.
#define OSIUNITTEST_CATCH_WARNING | ( | trycode, | |
catchcode, | |||
component, | |||
testname | |||
) | OSIUNITTEST_CATCH_SEVERITY_EXPECTED(trycode, catchcode, component, testname, OsiUnitTest::TestOutcome::WARNING, false) |
Perform a try/catch test with severity OsiUnitTest::TestOutcome::WARNING, failure not expected.
Definition at line 382 of file OsiUnitTests.hpp.
void OsiSolverInterfaceMpsUnitTest | ( | const std::vector< OsiSolverInterface * > & | vecEmptySiP, |
const std::string & | mpsDir | ||
) |
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.
void OsiSolverInterfaceCommonUnitTest | ( | const OsiSolverInterface * | emptySi, |
const std::string & | mpsDir, | ||
const std::string & | netlibDir | ||
) |
A function that tests the methods in the OsiSolverInterface class.
Some time ago, if this method is compiled with optimization, the compilation took 10-15 minutes and the machine pages (has 256M core memory!)...
void OsiColCutUnitTest | ( | const OsiSolverInterface * | baseSiP, |
const std::string & | mpsDir | ||
) |
A function that tests the methods in the OsiColCut class.
void OsiRowCutUnitTest | ( | const OsiSolverInterface * | baseSiP, |
const std::string & | mpsDir | ||
) |
A function that tests the methods in the OsiRowCut class.
void OsiRowCutDebuggerUnitTest | ( | const OsiSolverInterface * | siP, |
const std::string & | mpsDir | ||
) |
A function that tests the methods in the OsiRowCutDebugger class.
void OsiCutsUnitTest | ( | ) |
A function that tests the methods in the OsiCuts class.