I use Ipopt to solve a problem with sparse hessian and jacobian matrices.

If I provide the hessian matrix: its structure, and the non zeros elements in the hessian matrix, it will be really fast.

If I do not define the hessian structure but provide the whole hessian matrix, which is almost zeros, the solver will be slow but converges to a better solution!

Does that mean the zeros help the solver find a better solution?

  • 3
    $\begingroup$ Did you try with only one problem? It's not possible to draw any conclusion from the result of a solver on a single problem $\endgroup$
    – fontanf
    Dec 18, 2022 at 15:27
  • 1
    $\begingroup$ If the problem is nonconvex, IPOPT may converge to any local solution. A reasonable approach to at least bypass very bad solutions, is to use different starting points. $\endgroup$ Dec 18, 2022 at 21:52
  • $\begingroup$ Thank you. My question is why solver coverages to a different point if I am using the same starting point. Why does the solver coverage to another point if I provide the whole hessian matrix instead of the nonzeros only? I am not drawing a conclusion I just wanted to know how the solver works. $\endgroup$ Dec 18, 2022 at 23:31
  • $\begingroup$ In addition to the previous comments describing what can happen even if everything is is done correctly, what have you done to verify that the sparse structured Hessian is correct? There is a second order derivative checker which uses finite differences to check the Hessian coin-or.github.io/Ipopt/SPECIALS.html . $\endgroup$ Dec 19, 2022 at 2:01

1 Answer 1


No. Whether you use the sparse derivatives or the full ones, IPOPT will perform nearly the same calculations. The only differences are:

  • speed (the sparse one is much faster for sparse problems), and
  • accumulation of numerical error.

IPOPT is sensitive to small fluctuations in the numbers, so assuming all derivatives you provided are correct and equivalent, the latter is the most likely reason you got a different answer.

Another possibility (depending on how you're running IPOPT) if you actually provided nothing the second time around, is that it switched to finite differences and got a better result by luck. This would also explain the slowness.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.