From c98c772017e2f9d3e4edc2fbc652b5fe4263afb7 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 1 Jul 2016 15:42:23 -0400 Subject: [PATCH] [TEST] added QPTest. Showcases failure to work on indeterminate linear systems. --- examples/Data/QPTEST.QPS | 19 +++++++++++++++++++ gtsam_unstable/linear/tests/testQPSolver.cpp | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 examples/Data/QPTEST.QPS diff --git a/examples/Data/QPTEST.QPS b/examples/Data/QPTEST.QPS new file mode 100644 index 000000000..8f4f17f05 --- /dev/null +++ b/examples/Data/QPTEST.QPS @@ -0,0 +1,19 @@ +NAME QP example +ROWS + N obj + G r1 + L r2 +COLUMNS + c1 r1 2.0 r2 -1.0 + c1 obj 1.5 + c2 r1 1.0 r2 2.0 + c2 obj -2.0 +RHS + rhs1 r1 2.0 r2 6.0 +BOUNDS + UP bnd1 c1 20.0 +QUADOBJ + c1 c1 8.0 + c1 c2 2.0 + c2 c2 10.0 +ENDATA diff --git a/gtsam_unstable/linear/tests/testQPSolver.cpp b/gtsam_unstable/linear/tests/testQPSolver.cpp index c1779161a..25270bab9 100644 --- a/gtsam_unstable/linear/tests/testQPSolver.cpp +++ b/gtsam_unstable/linear/tests/testQPSolver.cpp @@ -367,6 +367,17 @@ TEST_DISABLED(QPSolver, CONT_050) { // Fails with Indeterminant Linear System er CHECK(assert_equal(-4.56385090,error_actual, 1e-7)) } +TEST(QPSolver, QPTEST) { // Fails with Indeterminant Linear System error + QP problem = QPSParser("QPTEST.QPS").Parse(); + GTSAM_PRINT(problem.cost); + GTSAM_PRINT(problem.equalities); + GTSAM_PRINT(problem.inequalities); + VectorValues actualSolution; + boost::tie(actualSolution, boost::tuples::ignore) = QPSolver(problem).optimize(); + double error_actual = problem.cost.error(actualSolution); + CHECK(assert_equal(0.437187500e01,error_actual, 1e-7)) +} + /* ************************************************************************* */ // Create Matlab's test graph as in http://www.mathworks.com/help/optim/ug/quadprog.html QP createTestMatlabQPEx() {