esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
804 stars 159 forks source link

Question: Use of Hessian with Ipopt #556

Open castrovictor opened 9 months ago

castrovictor commented 9 months ago

I have an optimization problem I want to solve with Ipopt. I have implemented the problem both with Pagmo using Ipopt solver, and directly over the Ipopt interface.

So far, I have managed to get the same results for both interfaces, using Hessian approximation. I wanted to implement now the exact Hessian. My problem is implemented in an external class, and I just call the corresponding methods in pagmo/Ipopt interface and adapt the input/output.

With the exact Hessian, I am getting similar results, but not exactly the same ones. I wanted to ask if my understanding to implement the Hessian with Pagmo is correct.

Following the docs, I use the default Hessian pattern, i.e, assume a dense matrix. I have 2 variables, and 2 constraint functions. therefore, my hessians function in Pagmo, returns something like this for a certain vector x:

hessian = [ [1.48304e-10 , 2.77556e-15, 5.55334e-11], [2, 0, 0], [-2, 0, 0] ]

In Ipopt, for the same vector and exactly the same setUp, I return:

hessian = [ 1.48304e-10, 2.77556e-15, 5.55334e-11]

So the computation of the Hessian is the same, the difference (constraints cancel out in this case) is just the format required, as Pagmo requires the Hessian of each constraint function. I know it's pretty hard to tell what it could be wrong, so my question is more about:

Thank you for your time.