Closed jhu-gh closed 3 years ago
When the solver complains that "There is no available solver for the optimization program", the line
std::cout<<"cost convex? "<<mp.quadratic_costs().back().evaluator()->is_convex()<<std::endl;
returns False.
But your cost is actually convex (as it is the sum of squared norm). So when Drake checks the convexity of the cost, it returns the wrong result. The easy fix is to change the line
mp.AddQuadraticCost(e);
to
mp.AddQuadraticCost(e, true);
where the flag true
explicitly tells Drake that the cost is convex, and then Drake doesn't check its convexity.
The deeper reason why Drake thinks the cost is non-convex, while the cost is actually convex, is that Drake uses Eigen's LDLT solver to do a Cholesky decomposition. Apparently this Cholesky decomposition by Eigen is inaccurate for your problem.
@jhu-gh This was a great question. We'd strongly encourage you to post this kind of thing in stackoverflow with the drake
tag. In fact, it's probably worth taking your original post and adding it there specifically. More users will directly benefit from your question and @hongkai-dai's answer.
I'm going to close this issue as "solved" (based on @hongkai-dai's response). If you want to take the conversation further, I recommend you open the stackoverflow issue (and link to it here).
Hello all,
I'm trying to implement the MILP formulation mentioned in: Global Inverse Kinematics via Mixed-integer Convex Optimization by Hongkai Dai, Gregory Izatt and Russ Tedrake, ISRR, 2017. Sometimes when I use different data points, the convexity of the cost function changes, and throws error saying "There is no available solver for the optimization program". The following is code to reproduce the issue:
one translation vector in
genData()
gives convex cost while the other doesn't. I'm not sure if it's because I'm not defining the cost correctly.On a side note,
is_convex()
returns true for the quadratic function mentioned here, not sure if they're related.Please let me know if this is not the right place to ask this question. Thanks.