Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodError: reducing over an empty collection #142

Open
odow opened this issue Dec 4, 2024 · 1 comment
Open

MethodError: reducing over an empty collection #142

odow opened this issue Dec 4, 2024 · 1 comment

Comments

@odow
Copy link
Contributor

odow commented Dec 4, 2024

julia> using JuMP, EAGO

julia> begin
           model = Model(EAGO.Optimizer)
           @variable(model, x == 2)
           @variable(model, y == 3)
           @constraint(model, sqrt(x * y) <= 3)
           optimize!(model)
       end
ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] reduce_empty(op::Base.MappingRF{EAGO.var"#1#2"{EAGO.var"#134#135"{EAGO.GlobalOptimizer{}}}, Base.BottomRF{typeof(EAGO._rf_findmax)}}, ::Type{Pair{Int64, Int64}})
    @ Base ./reduce.jl:361
  [2] reduce_empty_iter
    @ ./reduce.jl:384 [inlined]
  [3] reduce_empty_iter
    @ ./reduce.jl:383 [inlined]
  [4] foldl_impl
    @ ./reduce.jl:49 [inlined]
  [5] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
  [6] mapfoldl
    @ ./reduce.jl:175 [inlined]
  [7] map_findmax
    @ ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/utilities.jl:35 [inlined]
  [8] map_argmax
    @ ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/utilities.jl:36 [inlined]
  [9] _select_branch_variable_width
    @ ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/nonconvex/stack_management.jl:95 [inlined]
 [10] select_branch_variable
    @ ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/nonconvex/stack_management.jl:106 [inlined]
 [11] branch_node!(t::EAGO.DefaultExt, m::EAGO.GlobalOptimizer{EAGO.Incremental{Cbc.Optimizer}, EAGO.Incremental{Ipopt.Optimizer}, EAGO.DefaultExt})
    @ EAGO ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/nonconvex/stack_management.jl:137
 [12] branch_node!
    @ ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/nonconvex/stack_management.jl:179 [inlined]
 [13] global_solve!(m::EAGO.GlobalOptimizer{EAGO.Incremental{Cbc.Optimizer}, EAGO.Incremental{Ipopt.Optimizer}, EAGO.DefaultExt})
    @ EAGO ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/optimize_nonconvex.jl:425
 [14] optimize!
    @ ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/optimize_nonconvex.jl:493 [inlined]
 [15] optimize!(m::Optimizer{EAGO.Incremental{Cbc.Optimizer}, EAGO.Incremental{Ipopt.Optimizer}, EAGO.DefaultExt})
    @ EAGO ~/.julia/packages/EAGO/oWEmA/src/eago_optimizer/optimize/optimize.jl:40
 [16] optimize!
    @ ~/.julia/packages/MathOptInterface/gLl4d/src/Bridges/bridge_optimizer.jl:367 [inlined]
 [17] optimize!
    @ ~/.julia/packages/MathOptInterface/gLl4d/src/MathOptInterface.jl:122 [inlined]
 [18] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{…}, MathOptInterface.Utilities.UniversalFallback{…}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/gLl4d/src/Utilities/cachingoptimizer.jl:321
 [19] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})
    @ JuMP ~/.julia/packages/JuMP/i68GU/src/optimizer_interface.jl:595
 [20] optimize!(model::Model)
    @ JuMP ~/.julia/packages/JuMP/i68GU/src/optimizer_interface.jl:546
 [21] top-level scope
    @ REPL[16]:6
Some type information was truncated. Use `show(err)` to see complete types.

(ipopt) pkg> st
Status `/private/tmp/ipopt/Project.toml`
  [bb8be931] EAGO v0.8.2
  [4076af6c] JuMP v1.23.5
@DimitriAlston
Copy link
Member

This is because of EAGO's branch-and-bound routine that gets called when given a nonlinear problem. The variables are fixed so they are not labeled as branch variables, which returns this error. I will have to add some checks so that EAGO doesn't try to branch in a case like this. Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants