Skip to content

Conversation

@ChrisRackauckas
Copy link
Member

No description provided.

@ChrisRackauckas ChrisRackauckas merged commit d1072ad into master Sep 19, 2025
41 of 64 checks passed
@ChrisRackauckas ChrisRackauckas deleted the ChrisRackauckas-patch-2 branch September 19, 2025 00:11
@drbergman
Copy link

drbergman commented Oct 14, 2025

This PR seems to be breaking backwards compatibility for me. I can confirm that my package compiled with v2.120.0 and then errored on v2.121.0. Error message below. It looks like this function was removed and is the cause of the error:

function init(prob::OptimizationProblem, alg, args...; kwargs...)::AbstractOptimizationCache
    if prob.u0 !== nothing && !isconcretetype(eltype(prob.u0))
        throw(NonConcreteEltypeError(eltype(prob.u0)))
    end
    _check_opt_alg(prob::OptimizationProblem, alg; kwargs...)
    cache = __init(prob, alg, args...; prob.kwargs..., kwargs...)
    return cache
end

My package uses (no SciMLBase here except in their deps)

[compat]
...
Optimization = "4.1.0"
OptimizationOptimJL = "0.4.1"
...

Any recommendations for how to get around this?

In case it helps, here's the call I make to these Optimization packages:

optf = OptimizationFunction(objfn, Optimization.AutoForwardDiff())
prob = OptimizationProblem(optf, [atan(y, x)], [x; y; a; b], lb=[-pi], ub=[pi])
sol = solve(prob, BFGS())

Finally, here's the error output:

ERROR: LoadError: MethodError: no method matching init(::SciMLBase.OptimizationProblem{true, SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, OptimizationOptimJL.var"#obj_f#38", 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, Nothing, Nothing, Nothing}, Vector{Float64}, Tuple{Matrix{Float64}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, Nothing, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}}, ::Optim.LBFGS{Nothing, LineSearches.InitialStatic{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Returns{Nothing}}; maxiters::Int64, maxtime::Int64)
Stacktrace:
 [1] solve(::SciMLBase.OptimizationProblem{true, SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, OptimizationOptimJL.var"#obj_f#38", 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, Nothing, Nothing, Nothing}, Vector{Float64}, Tuple{Matrix{Float64}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, Nothing, @Kwargs{}}, ::Vararg{Any}; kwargs::@Kwargs{maxiters::Int64, maxtime::Int64})
   @ CommonSolve ~/.julia/packages/CommonSolve/JfpfI/src/CommonSolve.jl:23
 [2] (::OptimizationOptimJL.var"#solve_nonnegative_least_squares#39"{OptimizationOptimJL.var"#obj_f#38"})(A::Matrix{Float64}, b::Vector{Float64}, solver::Optim.LBFGS{Nothing, LineSearches.InitialStatic{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Returns{Nothing}})
   @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/pe3SX/src/OptimizationOptimJL.jl:491
 [3] macro expansion
   @ ~/.julia/packages/OptimizationOptimJL/pe3SX/src/OptimizationOptimJL.jl:502 [inlined]
 [4] macro expansion
   @ ~/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:78 [inlined]
 [5] top-level scope
   @ ~/.julia/packages/OptimizationOptimJL/pe3SX/src/OptimizationOptimJL.jl:480
 [6] include
   @ ./Base.jl:495 [inlined]
 [7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
   @ Base ./loading.jl:2292
 [8] top-level scope
   @ stdin:4
in expression starting at /home/runner/.julia/packages/OptimizationOptimJL/pe3SX/src/OptimizationOptimJL.jl:1
in expression starting at stdin:4

@drbergman
Copy link

OK, it seems like OptimizationOptimJL is now a submodule of Optimization and just removing that explicit dep works.

@drbergman
Copy link

Well, it now compiles but it doesn't run. The sample at the Optimization.jl docs errors:

# Import the package and define the problem to optimize
using Optimization, Zygote
rosenbrock(u, p) = (p[1] - u[1])^2 + p[2] * (u[2] - u[1]^2)^2
u0 = zeros(2)
p = [1.0, 100.0]

optf = OptimizationFunction(rosenbrock, AutoZygote())
prob = OptimizationProblem(optf, u0, p)

sol = solve(prob, Optimization.LBFGS())
ERROR: MethodError: no method matching init(::OptimizationProblem{…}, ::Optimization.LBFGS)
The function `init` exists, but no method is defined for this combination of argument types.
Stacktrace:
 [1] solve(::OptimizationProblem{true, OptimizationFunction{…}, Vector{…}, Vector{…}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, @Kwargs{}}, ::Vararg{Any}; kwargs::@Kwargs{})
   @ CommonSolve ~/.julia/packages/CommonSolve/JfpfI/src/CommonSolve.jl:23

@drbergman
Copy link

OK, final comment on this: I have pkg> add [email protected] to my package and then set the [compat] entry to SciMLBase = "~2.120.0" to not allow it to upgrade to 2.121.0.

@ChrisRackauckas
Copy link
Member Author

Okay, finally fixed this code movement. Sorry, this change has been a mess.

@drbergman
Copy link

All good now! To me, this is the exception that proves the rule: the julia ecosystem does a great job with version control and making updates smooth. And I include you in that. Thank you for all you do with SciML!

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 this pull request may close these issues.

3 participants