MadNLP / MadNLP.jl

A solver for nonlinear programming
MIT License
160 stars 14 forks source link

Invalid number in NLP Hessian Lagrangian detrected / error in MadNLP #239

Closed ChrisNabold closed 1 year ago

ChrisNabold commented 1 year ago

using JuMP, MadNLP m = Model(MadNLP.Optimizer) @variable(m, x) @variable(m, y) @NLobjective(m, Min, (x-5)^2 + (y-8)^2) @NLconstraint(m, x*y==5) optimize!(m) this small example errors in MadNLP. This example runs fine with Ipopt

frapac commented 1 year ago

This is indeed an issue with MadNLP. When the initial point is not provided, the solver sets x0 to 0. This is a problem in this case, as the Jacobian is null in 0, leading to the formulation of a degenerate KKT system. Then the KKT system is solved to estimate the initial multiplier (returning NaN in this degenerate case) which is itself use in the evaluation of the Hessian (inheriting the NaN values from the multiplier). As a result, MadNLP is returning an error.

The quick fix is to provide an initial value to JuMP. In this case, MadNLP is returning the same solution as Ipopt:

using MadNLP
using JuMP

m = Model(Ipopt.Optimizer)
@variable(m, x, start=1.0)
@variable(m, y, start=1.0)
@NLobjective(m, Min, (x-5)^2 + (y-8)^2)
@NLconstraint(m, x*y==5)
optimize!(m)

But we have to address this issue properly in MadNLP. I see two workarounds:

  1. Use a dual regularization if the initial KKT system is degenerate to compute a valid initial multiplier.
  2. Assume directly the initial multiplier is equal to 0.0.

I will investigate what Ipopt is doing in this case.

vinhpb commented 1 year ago

Hi, I am using MadNLP with JuMP and also get this Invalid number in Hessian Lagrangian problem. When I tried to query the termination status with termination_status(model), I got an error "MethodError: Cannot 'convert' an object of type MathOptInterface.ResultStatusCode to an object of type MathOptInterface.TerminationStatusCode". I could only see in the report that the error was due to this Invalid number in Hessian Lagrangian if I did not use set_silent to the JuMP model. Is there any way I can get this "Invalid number in Hessian Lagrangian"/did not solve successfully information with something similar to termination_status(model)? Thank you.

frapac commented 1 year ago

Solved by #243