Why using JuMP or AMPL gives different number of nonzeros in Lagrangian Hessian?

Hi @slmontes, welcome to the forum :smile:

You can safely ignore the differences in the non-zero count between Ipopt.jl and AmplNLWriter.jl. As you can see from the logs, Ipopt takes identical sequences of iterations.

The differences are due to two reasons:

  1. Multiple non-zeros can be specified for the same element in the Hessian. These are summed together and have no effect on the output.
  2. JuMP’s sparsity detection is conservative. It may have “non-zeros” in the Hessian which are in fact always 0.0.

In some rare cases there might be a different sequence of iterations due to small numerical round off differences in how the Hessian matrix is evaluated.