Accuracy Test

release/4.3a0
= 2016-06-18 09:14:03 -04:00
parent d8b658e2ea
commit f3e756805d
3 changed files with 24 additions and 1 deletions

View File

@ -189,6 +189,13 @@ This::buildWorkingGraph(const InequalityFactorGraph& workingSet,
return workingGraph;
}
//******************************************************************************
Template VectorValues
This::evaluateCostFunction(const VectorValues &xk) const {
GaussianFactorGraph costGraph;
costGraph.push_back(POLICY::buildCostFunction(problem_, xk));
return costGraph.optimize();
}
//******************************************************************************
Template typename This::State This::iterate(
const typename This::State& state) const {

View File

@ -167,7 +167,9 @@ public: /// Just for testing...
GaussianFactorGraph buildWorkingGraph(
const InequalityFactorGraph& workingSet,
const VectorValues& xk = VectorValues()) const;
VectorValues evaluateCostFunction(const VectorValues& xk) const;
/// Iterate 1 step, return a new state with a new workingSet and values
State iterate(const State& state) const;

View File

@ -257,6 +257,20 @@ TEST(QPSolver, ParserSemanticTest) {
CHECK(assert_equal(actualSolution, expectedSolution, 1e-7));
}
TEST(QPSolver, QPExampleTest){
QP problem = QPSParser("QPExample.QPS").Parse();
VectorValues actualSolution;
auto solver = QPSolver(problem);
boost::tie(actualSolution, boost::tuples::ignore) = solver.optimize();
VectorValues expectedSolution;
expectedSolution.insert(Symbol('X',1),0.7625*I_1x1);
expectedSolution.insert(Symbol('X',2),0.4750*I_1x1);
VectorValues actualCost = solver.evaluateCostFunction(actualSolution);
VectorValues expectedCost = solver.evaluateCostFunction(expectedCost);
GTSAM_PRINT(actualCost);
CHECK(assert_equal(expectedCost, actualCost))
CHECK(assert_equal(expectedSolution, actualSolution, 1e-7))
}
/* ************************************************************************* */
// Create Matlab's test graph as in http://www.mathworks.com/help/optim/ug/quadprog.html
QP createTestMatlabQPEx() {