stack-of-tasks / eiquadprog

C++ reimplementation of eiquadprog
GNU Lesser General Public License v3.0
34 stars 25 forks source link

Solution mismatch #20

Closed ihmc3jn09hk closed 3 years ago

ihmc3jn09hk commented 3 years ago

Hi, thanks for the sharing the solver.

I found the solution of eiquadprog is different from the one given in Quadratic Programming (Alberto Santini) from the example here.

The setup for eiquadprog is following:


  EiquadprogFast qp;
  qp.reset(3, 0, 3);

  Eigen::MatrixXd Q(2, 2);
  Q.setIdentity();

  Eigen::VectorXd C(3);
  C(0) = 0.0;
  C(1) = 5.0;
  C(2) = 0.0;

  Eigen::MatrixXd Aeq(0, 3);
  Eigen::VectorXd Beq(3);

  Eigen::MatrixXd Aineq(3, 3);
  Aineq(0, 0) = -4.0; Aineq(0, 1) = 2.0; Aineq(0, 2) = 0.0;
  Aineq(1, 0) = -3.0; Aineq(1, 1) = 1.0; Aineq(1, 2) = -2.0;
  Aineq(2, 0) =  0.0; Aineq(2, 1) = 0.0; Aineq(2, 2) = 1.0;

  Eigen::VectorXd Bineq(3);
  Bineq(0) = -8.0;
  Bineq(1) = 2.0.;
  Bineq(2) = 0.0;

  Eigen::VectorXd x(3);

  EiquadprogFast_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);

  //The solution found in x = [-3.6, -3.2, 0.0] which differ from the example [0.4762, 1.048, 2.095]

Is the setup of the formulation wrong ?

ihmc3jn09hk commented 3 years ago

  Aineq.transpose();

My bad, it should be transposed and the results are identical.