From 54e7e84c21382d79cf1eb799d8763844b6d50a02 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 29 Jun 2016 15:08:38 -0400 Subject: [PATCH] [TEST] HS118 no also tests for correctness of actual solution found. Removed debug statements. QPS files with ranges now work correctly. --- gtsam_unstable/linear/RawQP.cpp | 16 ++++++++++------ gtsam_unstable/linear/tests/testQPSolver.cpp | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gtsam_unstable/linear/RawQP.cpp b/gtsam_unstable/linear/RawQP.cpp index 95a259f5f..26a83e099 100644 --- a/gtsam_unstable/linear/RawQP.cpp +++ b/gtsam_unstable/linear/RawQP.cpp @@ -81,20 +81,21 @@ void RawQP::addRangeSingle( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector> const & vars) { - std::cout << "SINGLE RANGE ADDED" << std::endl; std::string var_(at_c < 1 > (vars).begin(), at_c < 1 > (vars).end()); std::string row_(at_c < 3 > (vars).begin(), at_c < 3 > (vars).end()); double range = at_c < 5 > (vars); ranges[row_] = range; - std::cout << "VAR:" << var_ << " ROW: " << row_ << " RANGE: " << range - << std::endl; + if (debug) { + std::cout << "SINGLE RANGE ADDED" << std::endl; + std::cout << "VAR:" << var_ << " ROW: " << row_ << " RANGE: " << range + << std::endl; + } } void RawQP::addRangeDouble( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector, std::vector, std::vector, double> const & vars) { - std::cout << "DOUBLE RANGE ADDED" << std::endl; std::string var_(at_c < 1 > (vars).begin(), at_c < 1 > (vars).end()); std::string row1_(at_c < 3 > (vars).begin(), at_c < 3 > (vars).end()); std::string row2_(at_c < 7 > (vars).begin(), at_c < 7 > (vars).end()); @@ -102,8 +103,11 @@ void RawQP::addRangeDouble( double range2 = at_c < 9 > (vars); ranges[row1_] = range1; ranges[row2_] = range2; - std::cout << "VAR: " << var_ << " ROW1: " << row1_ << " RANGE1: " << range1 - << " ROW2: " << row2_ << " RANGE2: " << range2 << std::endl; + if (debug) { + std::cout << "DOUBLE RANGE ADDED" << std::endl; + std::cout << "VAR: " << var_ << " ROW1: " << row1_ << " RANGE1: " << range1 + << " ROW2: " << row2_ << " RANGE2: " << range2 << std::endl; + } } diff --git a/gtsam_unstable/linear/tests/testQPSolver.cpp b/gtsam_unstable/linear/tests/testQPSolver.cpp index 47cfff6e2..1851c01bf 100644 --- a/gtsam_unstable/linear/tests/testQPSolver.cpp +++ b/gtsam_unstable/linear/tests/testQPSolver.cpp @@ -285,12 +285,14 @@ TEST(QPSolver, HS118) { QP problem = QPSParser("HS118.QPS").Parse(); VectorValues actualSolution; VectorValues expectedSolution; -// expectedSolution.insert(Symbol('X',1), 2.0*I_1x1); -// expectedSolution.insert(Symbol('X',2), 0.0*I_1x1); + double solutionValues[15] = {8,49,3,1,56,0,1,63,6,3,70,12,5,77,18}; + for (int index = 0; index < 15; ++index) { + expectedSolution.insert(Symbol('X',index+1), solutionValues[index]); + } boost::tie(actualSolution, boost::tuples::ignore) = QPSolver(problem).optimize(); double error_actual = problem.cost.error(actualSolution); CHECK(assert_equal(6.64820452e2,error_actual, 1e-7)) -// CHECK(assert_equal(expectedSolution, actualSolution)) + CHECK(assert_equal(expectedSolution, actualSolution)) } /* ************************************************************************* */