EAGO.jl: LoadError: Invalid upper bound value NaN

I’ve been trying to solve the following nonlinear optimization program with EAGO.jl in order to find a global solution:

using JuMP
using EAGO
  
model = Model(EAGO.Optimizer)
  
n = 2
r = 0.15
  
@variable(model, 0 <= e[1:n, 1:n] <= 1)
@NLobjective(model, Max, -sum(e[i, j] * log(e[i, j]) for i in 1:n, j in 1:n))
@constraint(model, sum(e) == 1)
@constraint(model, sum(e[i, i] for i in 1:n) - (1-r)*sum(sum(e[i,j] for j in 1:n)*sum(e[j,i] for j in 1:n) for i in 1:n) - r == 0)
  
optimize!(model)

This is an entropy maximization problem with a linear and quadratic constraint (described formally here).

When I run this on Julia 1.6.3, I get the following error:

ERROR: LoadError: Invalid upper bound value NaN.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] add_constraint(model::Ipopt.Optimizer, v::MathOptInterface.SingleVariable, lt::MathOptInterface.LessThan{Float64})
    @ Ipopt ~/.julia/packages/Ipopt/P1XLY/src/MOI_wrapper.jl:535
  [3] solve_local_nlp!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_convex.jl:106
  [4] upper_problem!
    @ ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:981 [inlined]
  [5] upper_problem!
    @ ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:1053 [inlined]
  [6] global_solve!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:1110
  [7] optimize!(#unused#::Val{EAGO.MINCVX}, m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:1162
  [8] optimize!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize.jl:37
  [9] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/YDdD3/src/Utilities/cachingoptimizer.jl:252
 [10] optimize!(b::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}})
    @ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/YDdD3/src/Bridges/bridge_optimizer.jl:319
 [11] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/YDdD3/src/Utilities/cachingoptimizer.jl:252
 [12] optimize!(model::Model, optimizer_factory::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JuMP ~/.julia/packages/JuMP/qhoVb/src/optimizer_interface.jl:130
 [13] optimize! (repeats 2 times)
    @ ~/.julia/packages/JuMP/qhoVb/src/optimizer_interface.jl:106 [inlined]
 [14] top-level scope
    @ ~/WRK/proj/asbm/global.jl:14
 [15] include(fname::String)
    @ Base.MainInclude ./client.jl:444
 [16] top-level scope
    @ REPL[2]:1
in expression starting at /home/marnix/WRK/proj/asbm/global.jl:14

If I use the Ipopt.Optimizer, the program runs fine and returns a valid local optimum. When using Gurobi.Optimizer by using model = Model(optimizer_with_attributes(EAGO.Optimizer, "relaxed_optimizer" => Gurobi.Optimizer())), I get a similar error:

ERROR: LoadError: Gurobi Error 10003: Element 0 of a double array is Nan.
Stacktrace:
  [1] _check_ret
    @ ~/.julia/packages/Gurobi/BAtIN/src/MOI_wrapper/MOI_wrapper.jl:326 [inlined]
  [2] set(model::Gurobi.Optimizer, #unused#::MathOptInterface.ConstraintSet, c::MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable, MathOptInterface.LessThan{Float64}}, s::MathOptInterface.LessThan{Float64})
    @ Gurobi ~/.julia/packages/Gurobi/BAtIN/src/MOI_wrapper/MOI_wrapper.jl:1713
  [3] update_relaxed_problem_box!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:647
  [4] obbt!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/domain_reduction.jl:266
  [5] preprocess!(t::EAGO.DefaultExt, m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:607
  [6] preprocess!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:1050
  [7] global_solve!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:1085
  [8] optimize!(#unused#::Val{EAGO.MINCVX}, m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize_nonconvex.jl:1162
  [9] optimize!(m::Optimizer)
    @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize.jl:37
 [10] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/YDdD3/src/Utilities/cachingoptimizer.jl:252
 [11] optimize!(b::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}})
    @ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/YDdD3/src/Bridges/bridge_optimizer.jl:319
 [12] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/YDdD3/src/Utilities/cachingoptimizer.jl:252
 [13] optimize!(model::Model, optimizer_factory::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JuMP ~/.julia/packages/JuMP/qhoVb/src/optimizer_interface.jl:130
 [14] optimize! (repeats 2 times)
    @ ~/.julia/packages/JuMP/qhoVb/src/optimizer_interface.jl:106 [inlined]
 [15] top-level scope
    @ ~/WRK/proj/asbm/global.jl:16
 [16] include(fname::String)
    @ Base.MainInclude ./client.jl:444
 [17] top-level scope
    @ REPL[4]:1
in expression starting at /home/marnix/WRK/proj/asbm/global.jl:16

I’ve tried changing the rounding mode as well, but this did not affect the error.

Does anyone have an idea what seems to be the problem?

The problem persists when I remove the quadratic constraint.

Looks like a bug in EAGO.jl. You should open an issue at their GitHub repository.

The error reporting could be improved, but I’m guessing that the NaN comes from log(e[i, j]) in the objective. Try enforcing the variables to be strictly positive.

1 Like

That did it! I simply replaced @variable(model, 0 <= e[1:n, 1:n] <= 1) by @variable(model, 0.001 <= e[1:n, 1:n] <= 1). Thank you very much.