Commit ee118df0 authored by Gabriele Buondonno's avatar Gabriele Buondonno
Browse files

[unittest] [eiquadprog-fast] test_nonconvex

parent e01c633e
......@@ -414,5 +414,60 @@ BOOST_AUTO_TEST_CASE ( test_unbounded )
BOOST_WARN(status==expected);
}
// min -||x||^2
// s.t.
// 0<= x[0] <= 1
// 0<= x[1] <= 1
// DOES NOT WORK!
BOOST_AUTO_TEST_CASE ( test_nonconvex )
{
EiquadprogFast qp;
qp.reset(2,0,4);
Eigen::MatrixXd Q(2,2);
Q.setZero();
Q(0,0) = -1.0;
Q(1,1) = -1.0;
Eigen::VectorXd C(2);
C.setZero();
Eigen::MatrixXd Aeq(0,2);
Eigen::VectorXd Beq(0);
Eigen::MatrixXd Aineq(4,2);
Aineq.setZero();
Aineq(0,0) = 1.;
Aineq(1,0) = -1.;
Aineq(2,1) = 1.;
Aineq(3,1) = -1.;
Eigen::VectorXd Bineq(4);
Bineq(0) = 0.;
Bineq(1) = -1.;
Bineq(2) = 0.;
Bineq(3) = -1.;
Eigen::VectorXd x(2);
Eigen::VectorXd solution(2);
solution(0) = 1.;
solution(1) = 1.;
double val = -1.;
EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL;
EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
BOOST_WARN(status==expected);
BOOST_WARN_CLOSE(qp.getObjValue(),val,1e-6);
BOOST_WARN(x.isApprox(solution));
}
BOOST_AUTO_TEST_SUITE_END ()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment