Commit 189aad7e authored by Gabriele Buondonno's avatar Gabriele Buondonno
Browse files

eiquadprog-fast with unit test

parent b64bde53
......@@ -44,6 +44,7 @@ ADD_REQUIRED_DEPENDENCY("eigen3")
SET(${PROJECT_NAME}_HEADERS
include/eiquadprog/eiquadprog.hpp
include/eiquadprog/eiquadprog-fast.hpp
include/eiquadprog/eiquadprog-fast.hxx
)
INSTALL(FILES
......
......@@ -15,8 +15,8 @@
// <http://www.gnu.org/licenses/>.
//
#ifndef EIQUADPROGFAST_HH_
#define EIQUADPROGFAST_HH_
#ifndef EIQUADPROGFAST_HPP_
#define EIQUADPROGFAST_HPP_
#include <Eigen/Dense>
......@@ -257,4 +257,7 @@ namespace eiquadprog
} /* namespace solvers */
} /* namespace eiquadprog */
#endif /* EIQUADPROGFAST_HH_ */
/* --- Details -------------------------------------------------------------------- */
#include "eiquadprog/eiquadprog-fast.hxx"
#endif /* EIQUADPROGFAST_HPP_ */
This diff is collapsed.
......@@ -6,14 +6,56 @@
#include "eiquadprog/eiquadprog-fast.hpp"
using namespace eiquadprog::solvers;
/**
* solves the problem
* min. x' Hess x + 2 g0' x
* s.t. CE x + ce0 = 0
* CI x + ci0 >= 0
*/
BOOST_AUTO_TEST_SUITE ( BOOST_TEST_MODULE )
// min ||x||^2
BOOST_AUTO_TEST_CASE ( test_unbiased )
{
std::cout << "Ok" << std::endl;
BOOST_CHECK(true);
EiquadprogFast qp;
qp.reset(2,0,0);
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(2,0);
Eigen::VectorXd Beq(0);
Eigen::MatrixXd Aineq(2,0);
Eigen::VectorXd Bineq(0);
Eigen::VectorXd x(2);
Eigen::VectorXd solution(2);
solution.setZero();
double val = 0.0;
EiquadprogFast_status expected = EIQUADPROG_FAST_OPTIMAL;
EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
BOOST_CHECK(status==expected);
BOOST_CHECK_CLOSE(qp.getObjValue(),val,1e-6);
BOOST_CHECK(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