Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/OptimizationAuglag/src/OptimizationAuglag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ using LinearAlgebra: norm
ϵ = 1e-8
end

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(::AugLag) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(::AugLag) = true
end
OptimizationBase.supports_opt_cache_interface(::AugLag) = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it's in scimlbase

SciMLBase.allowsbounds(::AugLag) = true
SciMLBase.requiresgradient(::AugLag) = true
SciMLBase.allowsconstraints(::AugLag) = true
Expand Down
7 changes: 1 addition & 6 deletions lib/OptimizationBBO/src/OptimizationBBO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ abstract type BBO end

SciMLBase.requiresbounds(::BBO) = true
SciMLBase.allowsbounds(::BBO) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::BBO) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::BBO) = true
end
OptimizationBase.supports_opt_cache_interface(opt::BBO) = true

for j in string.(BlackBoxOptim.SingleObjectiveMethodNames)
eval(Meta.parse("Base.@kwdef struct BBO_" * j * " <: BBO method=:" * j * " end"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ export CMAEvolutionStrategyOpt
struct CMAEvolutionStrategyOpt end

SciMLBase.allowsbounds(::CMAEvolutionStrategyOpt) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::CMAEvolutionStrategyOpt) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::CMAEvolutionStrategyOpt) = true
end
OptimizationBase.supports_opt_cache_interface(opt::CMAEvolutionStrategyOpt) = true
SciMLBase.requiresgradient(::CMAEvolutionStrategyOpt) = false
SciMLBase.requireshessian(::CMAEvolutionStrategyOpt) = false
SciMLBase.requiresconsjac(::CMAEvolutionStrategyOpt) = false
Expand Down
7 changes: 1 addition & 6 deletions lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ using SciMLBase

SciMLBase.allowsbounds(opt::Evolutionary.AbstractOptimizer) = true
SciMLBase.allowsconstraints(opt::Evolutionary.AbstractOptimizer) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::Evolutionary.AbstractOptimizer) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::Evolutionary.AbstractOptimizer) = true
end
OptimizationBase.supports_opt_cache_interface(opt::Evolutionary.AbstractOptimizer) = true
SciMLBase.requiresgradient(opt::Evolutionary.AbstractOptimizer) = false
SciMLBase.requiresgradient(opt::Evolutionary.NSGA2) = false
SciMLBase.requireshessian(opt::Evolutionary.AbstractOptimizer) = false
Expand Down
7 changes: 1 addition & 6 deletions lib/OptimizationGCMAES/src/OptimizationGCMAES.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ struct GCMAESOpt end
SciMLBase.requiresbounds(::GCMAESOpt) = true
SciMLBase.allowsbounds(::GCMAESOpt) = true
SciMLBase.allowscallback(::GCMAESOpt) = false
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::GCMAESOpt) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::GCMAESOpt) = true
end
OptimizationBase.supports_opt_cache_interface(opt::GCMAESOpt) = true
SciMLBase.requiresgradient(::GCMAESOpt) = true
SciMLBase.requireshessian(::GCMAESOpt) = false
SciMLBase.requiresconsjac(::GCMAESOpt) = false
Expand Down
11 changes: 2 additions & 9 deletions lib/OptimizationIpopt/src/OptimizationIpopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,8 @@ https://coin-or.github.io/Ipopt/OPTIONS.html
additional_options::Dict{String, Any} = Dict{String, Any}()
end

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
function SciMLBase.supports_opt_cache_interface(alg::IpoptOptimizer)
true
end
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
function OptimizationBase.supports_opt_cache_interface(alg::IpoptOptimizer)
true
end
function OptimizationBase.supports_opt_cache_interface(alg::IpoptOptimizer)
true
end

function SciMLBase.requiresgradient(opt::IpoptOptimizer)
Expand Down
7 changes: 1 addition & 6 deletions lib/OptimizationLBFGSB/src/OptimizationLBFGSB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ References
ϵ = 1e-8
end

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(::LBFGSB) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(::LBFGSB) = true
end
OptimizationBase.supports_opt_cache_interface(::LBFGSB) = true
SciMLBase.allowsbounds(::LBFGSB) = true
SciMLBase.requiresgradient(::LBFGSB) = true
SciMLBase.allowsconstraints(::LBFGSB) = true
Expand Down
14 changes: 3 additions & 11 deletions lib/OptimizationMOI/src/OptimizationMOI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,9 @@ end
include("nlp.jl")
include("moi.jl")

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
function SciMLBase.supports_opt_cache_interface(alg::Union{MOI.AbstractOptimizer,
MOI.OptimizerWithAttributes})
true
end
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
function OptimizationBase.supports_opt_cache_interface(alg::Union{MOI.AbstractOptimizer,
MOI.OptimizerWithAttributes})
true
end
function OptimizationBase.supports_opt_cache_interface(alg::Union{MOI.AbstractOptimizer,
MOI.OptimizerWithAttributes})
true
end

function SciMLBase.__init(prob::OptimizationProblem,
Expand Down
7 changes: 1 addition & 6 deletions lib/OptimizationManopt/src/OptimizationManopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ internal state.
"""
abstract type AbstractManoptOptimizer end

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::AbstractManoptOptimizer) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::AbstractManoptOptimizer) = true
end
OptimizationBase.supports_opt_cache_interface(opt::AbstractManoptOptimizer) = true

function __map_optimizer_args!(cache::OptimizationBase.OptimizationCache,
opt::AbstractManoptOptimizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ using SciMLBase
SciMLBase.requiresbounds(opt::Metaheuristics.AbstractAlgorithm) = true
SciMLBase.allowsbounds(opt::Metaheuristics.AbstractAlgorithm) = true
SciMLBase.allowscallback(opt::Metaheuristics.AbstractAlgorithm) = false
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::Metaheuristics.AbstractAlgorithm) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::Metaheuristics.AbstractAlgorithm) = true
end
OptimizationBase.supports_opt_cache_interface(opt::Metaheuristics.AbstractAlgorithm) = true

function initial_population!(opt, cache, bounds, f)
opt_init = deepcopy(opt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ using SciMLBase
SciMLBase.requiresbounds(opt::MultistartOptimization.TikTak) = true
SciMLBase.allowsbounds(opt::MultistartOptimization.TikTak) = true
SciMLBase.allowscallback(opt::MultistartOptimization.TikTak) = false
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::MultistartOptimization.TikTak) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::MultistartOptimization.TikTak) = true
end
OptimizationBase.supports_opt_cache_interface(opt::MultistartOptimization.TikTak) = true

function SciMLBase.__init(prob::SciMLBase.OptimizationProblem,
opt::MultistartOptimization.TikTak,
Expand Down
8 changes: 2 additions & 6 deletions lib/OptimizationNLopt/src/OptimizationNLopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ using OptimizationBase: deduce_retcode
(f::NLopt.Algorithm)() = f

SciMLBase.allowsbounds(opt::Union{NLopt.Algorithm, NLopt.Opt}) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::Union{NLopt.Algorithm, NLopt.Opt}) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::Union{NLopt.Algorithm, NLopt.Opt}) = true
end

OptimizationBase.supports_opt_cache_interface(opt::Union{NLopt.Algorithm, NLopt.Opt}) = true

function SciMLBase.requiresgradient(opt::Union{NLopt.Algorithm, NLopt.Opt})
# https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L18C7-L18C16
Expand Down
14 changes: 7 additions & 7 deletions lib/OptimizationODE/src/OptimizationODE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DAEMassMatrix() = DAEOptimizer(Rodas5P(autodiff = false))
SciMLBase.requiresbounds(::ODEOptimizer) = false
SciMLBase.allowsbounds(::ODEOptimizer) = false
SciMLBase.allowscallback(::ODEOptimizer) = true
SciMLBase.supports_opt_cache_interface(::ODEOptimizer) = true
OptimizationBase.supports_opt_cache_interface(::ODEOptimizer) = true
SciMLBase.requiresgradient(::ODEOptimizer) = true
SciMLBase.requireshessian(::ODEOptimizer) = false
SciMLBase.requiresconsjac(::ODEOptimizer) = false
Expand All @@ -41,7 +41,7 @@ SciMLBase.requiresbounds(::DAEOptimizer) = false
SciMLBase.allowsbounds(::DAEOptimizer) = false
SciMLBase.allowsconstraints(::DAEOptimizer) = true
SciMLBase.allowscallback(::DAEOptimizer) = true
SciMLBase.supports_opt_cache_interface(::DAEOptimizer) = true
OptimizationBase.supports_opt_cache_interface(::DAEOptimizer) = true
SciMLBase.requiresgradient(::DAEOptimizer) = true
SciMLBase.requireshessian(::DAEOptimizer) = false
SciMLBase.requiresconsjac(::DAEOptimizer) = true
Expand Down Expand Up @@ -109,7 +109,7 @@ function solve_ode(cache, dt, maxit, u0, p)
else
solve_kwargs = Dict{Symbol, Any}()
end

if !isnothing(maxit)
solve_kwargs[:maxiters] = maxit
end
Expand Down Expand Up @@ -170,7 +170,7 @@ function solve_dae_mass_matrix(cache, dt, maxit, u0, p)
else
solve_kwargs = Dict{Symbol, Any}()
end

solve_kwargs[:progress] = cache.progress
if maxit !== nothing; solve_kwargs[:maxiters] = maxit; end
if dt !== nothing; solve_kwargs[:dt] = dt; end
Expand All @@ -179,7 +179,7 @@ function solve_dae_mass_matrix(cache, dt, maxit, u0, p)
# if sol.retcode ≠ ReturnCode.Success
# # you may still accept Default or warn
# end
u_ext = sol.u
u_ext = sol.u
u_final = u_ext[1:n]
return SciMLBase.build_solution(cache, cache.opt, u_final, cache.f(u_final, p);
retcode = sol.retcode)
Expand Down Expand Up @@ -221,7 +221,7 @@ function solve_dae_implicit(cache, dt, maxit, u0, p)
else
solve_kwargs = Dict{Symbol, Any}()
end

solve_kwargs[:progress] = cache.progress

if maxit !== nothing; solve_kwargs[:maxiters] = maxit; end
Expand All @@ -237,4 +237,4 @@ function solve_dae_implicit(cache, dt, maxit, u0, p)
end


end
end
13 changes: 3 additions & 10 deletions lib/OptimizationOptimJL/src/OptimizationOptimJL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@ SciMLBase.allowsbounds(opt::Optim.AbstractOptimizer) = true
SciMLBase.allowsbounds(opt::Optim.SimulatedAnnealing) = false
SciMLBase.requiresbounds(opt::Optim.Fminbox) = true
SciMLBase.requiresbounds(opt::Optim.SAMIN) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::Optim.AbstractOptimizer) = true
SciMLBase.supports_opt_cache_interface(opt::Union{Optim.Fminbox, Optim.SAMIN}) = true
SciMLBase.supports_opt_cache_interface(opt::Optim.ConstrainedOptimizer) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::Optim.AbstractOptimizer) = true
OptimizationBase.supports_opt_cache_interface(opt::Union{Optim.Fminbox, Optim.SAMIN}) = true
OptimizationBase.supports_opt_cache_interface(opt::Optim.ConstrainedOptimizer) = true
end
OptimizationBase.supports_opt_cache_interface(opt::Optim.AbstractOptimizer) = true
OptimizationBase.supports_opt_cache_interface(opt::Union{Optim.Fminbox, Optim.SAMIN}) = true
OptimizationBase.supports_opt_cache_interface(opt::Optim.ConstrainedOptimizer) = true
function SciMLBase.requiresgradient(opt::Optim.AbstractOptimizer)
!(opt isa Optim.ZerothOrderOptimizer)
end
Expand Down
7 changes: 1 addition & 6 deletions lib/OptimizationOptimisers/src/OptimizationOptimisers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ using Reexport, Printf, ProgressLogging
@reexport using Optimisers, OptimizationBase
using SciMLBase

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::AbstractRule) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::AbstractRule) = true
end
OptimizationBase.supports_opt_cache_interface(opt::AbstractRule) = true
SciMLBase.requiresgradient(opt::AbstractRule) = true
SciMLBase.allowsfg(opt::AbstractRule) = true

Expand Down
9 changes: 2 additions & 7 deletions lib/OptimizationPRIMA/src/OptimizationPRIMA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ struct BOBYQA <: PRIMASolvers end
struct LINCOA <: PRIMASolvers end
struct COBYLA <: PRIMASolvers end

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(::PRIMASolvers) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(::PRIMASolvers) = true
end
OptimizationBase.supports_opt_cache_interface(::PRIMASolvers) = true
SciMLBase.allowsconstraints(::Union{LINCOA, COBYLA}) = true
SciMLBase.allowsbounds(opt::Union{BOBYQA, LINCOA, COBYLA}) = true
SciMLBase.requiresconstraints(opt::COBYLA) = true
Expand All @@ -35,7 +30,7 @@ function OptimizationBase.OptimizationCache(prob::SciMLBase.OptimizationProblem,
reinit_cache = OptimizationBase.ReInitCache(prob.u0, prob.p)
num_cons = prob.ucons === nothing ? 0 : length(prob.ucons)
if prob.f.adtype isa SciMLBase.NoAD && opt isa COBYLA
throw("We evaluate the jacobian and hessian of the constraints once to automatically detect
throw("We evaluate the jacobian and hessian of the constraints once to automatically detect
linear and nonlinear constraints, please provide a valid AD backend for using COBYLA.")
else
if opt isa COBYLA
Expand Down
9 changes: 2 additions & 7 deletions lib/OptimizationPyCMA/src/OptimizationPyCMA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ end

# Defining the SciMLBase interface for PyCMAOpt
SciMLBase.allowsbounds(::PyCMAOpt) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(opt::PyCMAOpt) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(opt::PyCMAOpt) = true
end
OptimizationBase.supports_opt_cache_interface(opt::PyCMAOpt) = true
SciMLBase.allowscallback(::PyCMAOpt) = true
SciMLBase.requiresgradient(::PyCMAOpt) = false
SciMLBase.requireshessian(::PyCMAOpt) = false
Expand All @@ -43,7 +38,7 @@ function __map_optimizer_args(prob::OptimizationBase.OptimizationCache, opt::PyC
end

# Converting OptimizationBase.jl args to PyCMA opts
# OptimizationBase.jl kwargs will overwrite PyCMA kwargs supplied to solve()
# OptimizationBase.jl kwargs will overwrite PyCMA kwargs supplied to solve()

mapped_args = Dict{String, Any}()

Expand Down
21 changes: 3 additions & 18 deletions lib/OptimizationSciPy/src/OptimizationSciPy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,32 +216,17 @@ for opt_type in [:ScipyMinimize, :ScipyDifferentialEvolution, :ScipyBasinhopping
:ScipyLinprog, :ScipyMilp]
@eval begin
SciMLBase.allowsbounds(::$opt_type) = true
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(::$opt_type) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(::$opt_type) = true
end
OptimizationBase.supports_opt_cache_interface(::$opt_type) = true
end
end

for opt_type in [:ScipyMinimizeScalar, :ScipyRootScalar, :ScipyLeastSquares]
@eval begin
@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(::$opt_type) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(::$opt_type) = true
end
OptimizationBase.supports_opt_cache_interface(::$opt_type) = true
end
end

@static if isdefined(SciMLBase, :supports_opt_cache_interface)
SciMLBase.supports_opt_cache_interface(::ScipyRoot) = true
end
@static if isdefined(OptimizationBase, :supports_opt_cache_interface)
OptimizationBase.supports_opt_cache_interface(::ScipyRoot) = true
end
OptimizationBase.supports_opt_cache_interface(::ScipyRoot) = true

function SciMLBase.requiresgradient(opt::ScipyMinimize)
gradient_free = ["Nelder-Mead", "Powell", "COBYLA", "COBYQA"]
Expand Down
Loading
Loading