PSORLab / EAGO.jl

A development environment for robust and global optimization
MIT License
140 stars 16 forks source link

JuMP+EAGO+@NLexpressions gives numeric instability #88

Closed mzagorowska closed 1 year ago

mzagorowska commented 3 years ago

I posted an issues here: https://discourse.julialang.org/t/jump-eago-nlexpressions-gives-numeric-instability/61093 and they sent me to bug report.

I want to use EAGO.jl as an alternative solver to ipopt for nonlinear problems. I ran the example from the website (GitHub - PSORLab/EAGO.jl: A development environment for robust and global optimization) and it works fine. When I slightly rewrite the problem using @NLexpressions, the problem does not work anymore. Running optimize!() breaks Julia and gives me: image

This keeps going on and on, I have to force quit the editor. Any ideas what can be wrong are welcome.

The rewritten problem:

using JuMP, EAGO

m = Model(EAGO.Optimizer)

# Define bounded variables
xL = [10.0; 0.0; 0.0; 0.0; 0.0; 85.0; 90.0; 3.0; 1.2; 145.0]
xU = [2000.0; 16000.0; 120.0; 5000.0; 2000.0; 93.0; 95.0; 12.0; 4.0; 162.0]
@variable(m, xL[i] <= x[i=1:10] <= xU[i])

# Define nonlinear constraints
@NLconstraint(m, e1, -x[1]*(1.12+0.13167*x[8]-0.00667* (x[8])^2)+x[4] == 0.0)
@NLconstraint(m, e3, -0.001*x[4]*x[9]*x[6]/(98-x[6])+x[3] == 0.0)

###Original constraints
##@NLconstraint(m, e4, -(1.098*x[8]-0.038* (x[8])^2)-0.325*x[6]+x[7] == 57.425)
##@NLconstraint(m, e5, -(x[2]+x[5])/x[1]+x[8] == 0.0)

###Rewritten constraints
@NLexpressions(m, begin
 ex1, -(x[2]+x[5])/x[1]+x[8]
 ex2, -(1.098*x[8]-0.038* (x[8])^2)-0.325*x[6]+x[7]
end)
@NLconstraint(m, e4, ex2 == 57.425)
@NLconstraint(m, e5, ex1 == 0.0)

# Define linear constraints
@constraint(m, e2, -x[1]+1.22*x[4]-x[5] == 0.0)
@constraint(m, e6, x[9]+0.222*x[10] == 35.82)
@constraint(m, e7, -3*x[7]+x[10] == -133.0)

# Define nonlinear objective
@NLobjective(m, Max, 0.063*x[4]*x[7] - 5.04*x[1] - 0.035*x[2] - 10*x[3] - 3.36*x[5])

# Solve the optimization problem
JuMP.optimize!(m)

I should add that if I split the expressions into two separate @NLexpression, the problem persists, but if I do only one constraint as @NLexpression and the other as @NLconstraint, there are no issues. I tried other solvers (ipopt and percival) and ipopt works fine, whereas percival has similar issues as EAGO (runs out of time, doesn’t break Julia). It looks like an error in handling multiple @NLexpression?

mewilhel commented 3 years ago

@mzagorowska Thanks for the feedback regarding your problem. I'll look into this shortly. We didn't initially include tests for multiple expressions so I agree that it's likely an error with that. I'm currently reworking the nonlinear expression backend part of EAGO so I'll be sure to include this test prior to updating that functionality (a few days to a week).

odow commented 3 years ago

I'll post the same comment here as from Discourse:

The “numerical instability” issue is coming from GLPK. I’ve seen it frequently in cutting plane type problems.

Try a different solver: https://psorlab.github.io/EAGO.jl/stable/Optimizer/high_performance/#LP-Solver-Selection