Open sethaxen opened 1 year ago
@ValentinKaisermayer I think this type-noninferrability may have been introduced in #406 . Is this something that can be fixed?
@sethaxen thanks for the issue. I plan to prioritize this, have been stuck at getting the CI to pass on #553 hence the delay.
We had an update to the caching after #406 in #536 also. Did you git bisect to find #406 as the point where it started showing up?
git bisect starting with c67d6301b128d567ea9233481f0d86b8342869fe as a good commit terminates with #406, but the above code fails then with a different error:
julia> @inferred solve(prob, optimizer)
ERROR: MethodError: Cannot `convert` an object of type Nothing to an object of type SciMLBase.AbstractOptimizationCache
Closest candidates are:
convert(::Type{T}, ::T) where T
@ Base Base.jl:64
Stacktrace:
[1] init(::OptimizationProblem{true, OptimizationFunction{true, SciMLBase.NoAD, typeof(f), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::NelderMead{Optim.AffineSimplexer, Optim.AdaptiveParameters}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ SciMLBase ~/.julia/packages/SciMLBase/s9wrq/src/solve.jl:149
[2] init(::OptimizationProblem{true, OptimizationFunction{true, SciMLBase.NoAD, typeof(f), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::NelderMead{Optim.AffineSimplexer, Optim.AdaptiveParameters})
@ SciMLBase ~/.julia/packages/SciMLBase/s9wrq/src/solve.jl:146
[3] solve(::OptimizationProblem{true, OptimizationFunction{true, SciMLBase.NoAD, typeof(f), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::NelderMead{Optim.AffineSimplexer, Optim.AdaptiveParameters}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ SciMLBase ~/.julia/packages/SciMLBase/s9wrq/src/solve.jl:83
[4] solve(::OptimizationProblem{true, OptimizationFunction{true, SciMLBase.NoAD, typeof(f), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, SciMLBase.NullParameters, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::NelderMead{Optim.AffineSimplexer, Optim.AdaptiveParameters})
@ SciMLBase ~/.julia/packages/SciMLBase/s9wrq/src/solve.jl:80
[5] top-level scope
@ REPL[8]:1
I made some attempts on this but haven't been successful yet. The parametric types in OptimizationSolution
for some fields are not inferred which doesn't make sense immediately.
Before v3.13.1, which implemented
init
, callingsolve(prob, optimizer)
was type-inferrable, but with v3.13.1, it became non-type-inferrable.on v3.13.0:
on v3.13.1 and master: