How to access the exit of MadNLP solver directly

Hi all,

I wonder if it is possible to access the exit of a solver directly from JuMP0, i.e. the exit we get when not setting the JuMP model in silent as shown in the screenshot below. I would really appreciate it if you could provide me some hints on this.
image

Regards.

You can do this in a solver-independent fashion using:

termination_status(model)

In this case, the return should be INVALID_MODEL, and it likely means you have something like log(x) where x <= 0 in your model.

I don’t know if there is an easy way to access the exact string. After solving, you can access the MadNLP.Optimizer object with mad = unsafe_backend(model). You’d have to explore. Perhaps mad.result.status.

Hi,
The reason I asked is because sometimes termination_status(model) does not work, in a sense that it does not give INVALID_MODEL but instead MethodError: Cannot 'convert' an object of type MathOptInterface.ResultStatusCode to an object of type MathOptInterface.TerminationStatusCode. That was what happened when I tried this example:

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)
println(termination_status(model))

The fact that MadNLP returns an error in this case is a known issue (as mentioned in Invalid number in NLP Hessian Lagrangian detrected / error in MadNLP · Issue #239 · MadNLP/MadNLP.jl · GitHub), but I do not understand why I cannot use termination_status(model) in this case.

The convert error looks like a bug. I’ll take a look

That would be great. Thanks. :grinning:

It was a bug: Fix invalid return code in MOI.TerminationStatus by odow · Pull Request #241 · MadNLP/MadNLP.jl · GitHub. Thanks for finding and reporting it!

1 Like