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

Marine problem issue when trying to set size #315

Closed
farhadrclass opened this issue Dec 2, 2024 · 8 comments · Fixed by #316
Closed

Marine problem issue when trying to set size #315

farhadrclass opened this issue Dec 2, 2024 · 8 comments · Fixed by #316

Comments

@farhadrclass
Copy link

I think we have a bug in ADNLPModels line 473:

When I run this code with n_max_size =10 or smaller than 100 :

all_problem_names = OptimizationProblems.meta[!, :name]
# Initialize problems with type T and size n=n_max_size
all_problems = [eval(Meta.parse(name))(type = T, n = n_max_size) for name in all_problem_names]
# Filter for unconstrained problems
probs_list = [prob for prob in all_problems if (unconstrained(prob) && get_nvar(prob) >= 5)]
# probs_list = [prob for prob in all_problems if (unconstrained(prob))]
# Run the benchmark with the selected solvers and problems
stats = bmark_solvers(solvers, probs_list)

I get this error:

1-element ExceptionStack:
LoadError: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] mapreduce_empty(::typeof(identity), op::Function, T::Type)
    @ Base .\reduce.jl:372
  [2] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, ::Type{Int64})
    @ Base .\reduce.jl:361
  [3] reduce_empty_iter
    @ .\reduce.jl:384 [inlined]
  [4] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Int64}, ItrEltype::Base.HasEltype)
    @ Base .\reduce.jl:380
  [5] _mapreduce
    @ .\reduce.jl:432 [inlined]
  [6] _mapreduce_dim
    @ .\reducedim.jl:365 [inlined]
  [7] mapreduce
    @ .\reducedim.jl:357 [inlined]
  [8] _maximum
    @ .\reducedim.jl:1015 [inlined]
  [9] _maximum
    @ .\reducedim.jl:1014 [inlined]
 [10] maximum
    @ .\reducedim.jl:1010 [inlined]
 [11] ADNLPModel!(f::Function, x0::Vector{Float64}, lvar::Vector{Float64}, uvar::Vector{Float64}, clinrows::Vector{Int64}, clincols::Vector{Int64}, clinvals::Vector{Float64}, c!::OptimizationProblems.ADNLPProblems.var"#c!#1750"{Int64, OptimizationProblems.ADNLPProblems.var"#c!#1740#1751", Vector{Int64}, Rational{Int64}, Int64, Int64}, lcon::Vector{Float64}, ucon::Vector{Float64}; y0::Vector{Float64}, name::String, minimize::Bool, kwargs::@Kwargs{})
    @ ADNLPModels C:\Users\Farhad\.julia\packages\ADNLPModels\hHKR7\src\nlp.jl:473
 [12] ADNLPModel!
    @ C:\Users\Farhad\.julia\packages\ADNLPModels\hHKR7\src\nlp.jl:451 [inlined]
 [13] marine(; n::Int64, nc::Int64, type::Type{Float64}, kwargs::@Kwargs{})
    @ OptimizationProblems.ADNLPProblems C:\Users\Farhad\.julia\packages\OptimizationProblems\G0vFO\src\ADNLPProblems\marine.jl:195
 [14] (::var"#715#717"{DataType, Int64})(name::String)
    @ Main .\none:0
 [15] iterate
    @ .\generator.jl:47 [inlined]
 [16] collect_to!(dest::Vector{ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}}, itr::Base.Generator{Vector{String}, var"#715#717"{DataType, Int64}}, offs::Int64, st::Int64)
    @ Base .\array.jl:892
 [17] collect_to_with_first!(dest::Vector{ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}}, v1::ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}, itr::Base.Generator{Vector{String}, var"#715#717"{DataType, Int64}}, st::Int64)
    @ Base .\array.jl:870
 [18] collect(itr::Base.Generator{Vector{String}, var"#715#717"{DataType, Int64}})
    @ Base .\array.jl:844
 [19] run_benchmark(solvers::Dict{Symbol, Function}; T::Type, problems::Vector{Any}, n_max_size::Int64)
    @ Main C:\Users\Farhad\Documents\Github\Farhad-Phd\iR2_experiments\Experiments_code\current\experiment_update.jl:56
 [20] run_exp(solvers::Dict{Symbol, Function}; problems::Vector{Any}, T::Type, wr_path::String, name::String, n_max_size::Int64, ATOL::Float64, RTOL::Float64)
    @ Main C:\Users\Farhad\Documents\Github\Farhad-Phd\iR2_experiments\Experiments_code\current\experiment_update.jl:91
 [21] my_main(; RUN_FLAG::Int64, problems::Vector{Any}, n_max_size::Int64, T::Type, RTOL::Float64, ATOL::Float64)
    @ Main C:\Users\Farhad\Documents\Github\Farhad-Phd\iR2_experiments\Experiments_code\current\experiment_update.jl:267
 [22] top-level scope
    @ C:\Users\Farhad\Documents\Github\Farhad-Phd\iR2_experiments\Experiments_code\current\experiment_update.jl:307
 [23] include(fname::String)
    @ Base.MainInclude .\client.jl:489
 [24] top-level scope
    @ REPL[20]:1
 [25] eval
    @ .\boot.jl:385 [inlined]
 [26] eval
    @ .\Base.jl:88 [inlined]
 [27] repleval(m::Module, code::Expr, ::String)
    @ VSCodeServer c:\Users\Farhad\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\VSCodeServer\src\repl.jl:229
 [28] (::VSCodeServer.var"#112#114"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer c:\Users\Farhad\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\VSCodeServer\src\repl.jl:192
 [29] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:515
 [30] with_logger
    @ .\logging.jl:627 [inlined]
 [31] (::VSCodeServer.var"#111#113"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer c:\Users\Farhad\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\VSCodeServer\src\repl.jl:193
 [32] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [33] invokelatest(::Any)
    @ Base .\essentials.jl:889
 [34] (::VSCodeServer.var"#64#65")()
    @ VSCodeServer c:\Users\Farhad\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\VSCodeServer\src\eval.jl:34
in expression starting at C:\Users\Farhad\Documents\Github\Farhad-Phd\iR2_experiments\Experiments_code\current\experiment_update.jl:307

I tried to loop through the problem and the issue happens:

n_max_size=10 
T= Float64
solvers = Dict(
            :R2N => nlp -> R2N(nlp; rtol = RTOL, atol = ATOL),
            :lbfgs => nlp -> lbfgs(nlp; rtol = RTOL, atol = ATOL)
        )
all_problem_names = OptimizationProblems.meta[!, :name]
# Initialize problems with type T and size n=n_max_size

for name in all_problem_names
    if name == "marine"
        continue
    end
    println(name)
    println("-------------------------------------------------------------------")
    eval(Meta.parse(name))(type = T, n = n_max_size)
end

The issue is Marine problem: https://github.com/JuliaSmoothOptimizers/OptimizationProblems.jl/blob/main/src/ADNLPProblems/marine.jl

@dpo
Copy link
Member

dpo commented Dec 2, 2024

What error does

marine(type = Float64, n = 10)

raise?

@farhadrclass
Copy link
Author

farhadrclass commented Dec 2, 2024

What error does

marine(type = Float64, n = 10)

raise?
julia> marine(type = Float64, n = 10) ERROR: MethodError: reducing over an empty collection is not allowed; consider supplyinginitto the reducer Stacktrace: [1] mapreduce_empty(::typeof(identity), op::Function, T::Type) @ Base .\reduce.jl:372 [2] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, ::Type{Int64}) @ Base .\reduce.jl:361 [3] reduce_empty_iter @ .\reduce.jl:384 [inlined] [4] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Int64}, ItrEltype::Base.HasEltype) @ Base .\reduce.jl:380 [5] _mapreduce @ .\reduce.jl:432 [inlined] [6] _mapreduce_dim @ .\reducedim.jl:365 [inlined] [7] mapreduce @ .\reducedim.jl:357 [inlined] [8] _maximum @ .\reducedim.jl:1015 [inlined] [9] _maximum @ .\reducedim.jl:1014 [inlined] [10] maximum @ .\reducedim.jl:1010 [inlined] [11] ADNLPModel!(f::Function, x0::Vector{…}, lvar::Vector{…}, uvar::Vector{…}, clinrows::Vector{…}, clincols::Vector{…}, clinvals::Vector{…}, c!::OptimizationProblems.ADNLPProblems.var"#c!#1750"{…}, lcon::Vector{…}, ucon::Vector{…}; y0::Vector{…}, name::String, minimize::Bool, kwargs::@Kwargs{}) @ ADNLPModels C:\Users\Farhad\.julia\packages\ADNLPModels\hHKR7\src\nlp.jl:473 [12] ADNLPModel! @ C:\Users\Farhad\.julia\packages\ADNLPModels\hHKR7\src\nlp.jl:451 [inlined] [13] marine(; n::Int64, nc::Int64, type::Type{Float64}, kwargs::@Kwargs{}) @ OptimizationProblems.ADNLPProblems C:\Users\Farhad\.julia\packages\OptimizationProblems\G0vFO\src\ADNLPProblems\marine.jl:195 [14] top-level scope @ REPL[35]:1 Some type information was truncated. Useshow(err)to see complete types.

@tmigot tmigot transferred this issue from JuliaSmoothOptimizers/OptimizationProblems.jl Dec 6, 2024
@amontoison
Copy link
Member

@farhadrclass
Do you need a new release?

@tmigot
Copy link
Member

tmigot commented Dec 8, 2024

@farhadrclass
Do you need a new release?

Yes, a minor release please.

@amontoison
Copy link
Member

Tangi, the question was for Farhad :)
I plan to do a new release next week if we finalize the support of Enzyme with Michel.
It's why I was asking Farhad if it's urgent or not.

But do you need a new release quickly Tangi?
I can do two releases too.

@tmigot
Copy link
Member

tmigot commented Dec 8, 2024

Okay, but it makes sense to have a release that fix OptimizationProblems first, and then do another later.

@amontoison
Copy link
Member

Done, I tagged the release 0.8.9.

@farhadrclass
Copy link
Author

@tmigot @amontoison thank you for the support and sorry for delays, I need to check my emails more often,.

yes it would be great to have it (I think it is already done anyway :) )

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

Successfully merging a pull request may close this issue.

4 participants