Constriant in ADNLPModels package

Hi everyone,

I am trying to do a nonlinear optimization with six parameters using the ADNLModles package. For example:

function constriants(para)
    cons=1-para[1]^2-para[2]^2-para[3]^2+2*para[1]*para[2]*para[3]
    return([para[1];para[2];para[3];cons])
end

lb=[-0.999;-0.999;-0.999;0.001]
ub=[0.999;0.999;0.999;Inf]

function obj(para)
         println(para)
          value
return (value)

opt=ADNLPModel(obj,para,constriants,lb,ub)

ipopt(opt)

And I printed out every parameter in the optimization routine, and I found that sometimes the searching area was outside the constraints, and the optimization crashed.

I was wondering if that’s a bug in the package or if there is another optimization package I could use for nonlinear constraints. I would appreciate any advice on making this function work.

Thanks!

Welcome. I’ve moved your question to the Optimization category since it may be more easily seen by someone who can answer it.

Since it sounds like you are solving a small problem, can you post your actual code?

Hi, answering from the phone.

Ipopt is responsible here, it doesn’t guarantee non-bounds constraints are satisfied in intermediate steps. See https://stackoverflow.com/a/39125549
This question was asked kn the past, you can check for more information.
One thing to try is the Percival.jl solver. It is also compliant with adnlpmodels.

Thanks for moving my post! I updated the constraints part in my code (my objective function is too long).

Thanks! It’s exactly my problem. I will try Percival solver.