Skip to content

Commit 0b2ef12

Browse files
more updates to sub libs
1 parent c4d9714 commit 0b2ef12

File tree

9 files changed

+25
-23
lines changed

9 files changed

+25
-23
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
- OptimizationBBO
2323
- OptimizationCMAEvolutionStrategy
2424
- OptimizationEvolutionary
25-
- OptimizationFlux
2625
- OptimizationGCMAES
2726
- OptimizationManopt
2827
- OptimizationMetaheuristics

lib/OptimizationBBO/src/OptimizationBBO.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{
140140

141141
_loss = function (θ)
142142
if isa(cache.f, MultiObjectiveOptimizationFunction)
143-
return cache.f(θ, cache.p)
143+
x = (cache.f(θ, cache.p),)
144+
return x[1]
144145
else
145-
return first(cache.f(θ, cache.p))
146+
x = cache.f(θ, cache.p)
147+
return first(x)
146148
end
147149
end
148150

lib/OptimizationCMAEvolutionStrategy/src/OptimizationCMAEvolutionStrategy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function SciMLBase.__solve(cache::OptimizationCache{
9292
maxtime = Optimization._check_and_convert_maxtime(cache.solver_args.maxtime)
9393

9494
_loss = function (θ)
95-
x = cache.f(θ, cache.p, cur...)
95+
x = cache.f(θ, cache.p)
9696
return first(x)
9797
end
9898

lib/OptimizationMOI/src/nlp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function MOIOptimizationNLPCache(prob::OptimizationProblem,
114114

115115
num_cons = prob.ucons === nothing ? 0 : length(prob.ucons)
116116
f = Optimization.instantiate_function(prob.f, reinit_cache, prob.f.adtype, num_cons;
117-
g = true, h = false, cons_j = true, cons_vjp = true, lag_h = true)
117+
g = true, h = true, cons_j = true, cons_vjp = true, lag_h = true)
118118
T = eltype(prob.u0)
119119
n = length(prob.u0)
120120

lib/OptimizationManopt/src/OptimizationManopt.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,31 +336,31 @@ function build_loss(f::OptimizationFunction, prob, cb)
336336
end
337337
end
338338

339-
function build_gradF(f::OptimizationFunction{true}, cur)
339+
function build_gradF(f::OptimizationFunction{true})
340340
function g(M::AbstractManifold, G, θ)
341-
f.grad(G, θ, cur...)
341+
f.grad(G, θ)
342342
G .= riemannian_gradient(M, θ, G)
343343
end
344344
function g(M::AbstractManifold, θ)
345345
G = zero(θ)
346-
f.grad(G, θ, cur...)
346+
f.grad(G, θ)
347347
return riemannian_gradient(M, θ, G)
348348
end
349349
end
350350

351-
function build_hessF(f::OptimizationFunction{true}, cur)
351+
function build_hessF(f::OptimizationFunction{true})
352352
function h(M::AbstractManifold, H1, θ, X)
353353
H = zeros(eltype(θ), length(θ))
354-
f.hv(H, θ, X, cur...)
354+
f.hv(H, θ, X)
355355
G = zeros(eltype(θ), length(θ))
356-
f.grad(G, θ, cur...)
356+
f.grad(G, θ)
357357
riemannian_Hessian!(M, H1, θ, G, H, X)
358358
end
359359
function h(M::AbstractManifold, θ, X)
360360
H = zeros(eltype(θ), length(θ), length(θ))
361-
f.hess(H, θ, cur...)
361+
f.hess(H, θ)
362362
G = zeros(eltype(θ), length(θ))
363-
f.grad(G, θ, cur...)
363+
f.grad(G, θ)
364364
return riemannian_Hessian(M, θ, G, H, X)
365365
end
366366
end
@@ -414,7 +414,7 @@ function SciMLBase.__solve(cache::OptimizationCache{
414414
cb_call
415415
end
416416
solver_kwarg = __map_optimizer_args!(cache, cache.opt, callback = _cb,
417-
maxiters = maxiters,
417+
maxiters = cache.solver_args.maxiters,
418418
maxtime = cache.solver_args.maxtime,
419419
abstol = cache.solver_args.abstol,
420420
reltol = cache.solver_args.reltol;
@@ -424,11 +424,11 @@ function SciMLBase.__solve(cache::OptimizationCache{
424424
_loss = build_loss(cache.f, cache, _cb)
425425

426426
if gradF === nothing
427-
gradF = build_gradF(cache.f, cur)
427+
gradF = build_gradF(cache.f)
428428
end
429429

430430
if hessF === nothing
431-
hessF = build_hessF(cache.f, cur)
431+
hessF = build_hessF(cache.f)
432432
end
433433

434434
if haskey(solver_kwarg, :stopping_criterion)

lib/OptimizationOptimJL/test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using OptimizationOptimJL,
22
OptimizationOptimJL.Optim, Optimization, ForwardDiff, Zygote,
3-
Random, ModelingToolkit, OptimizationBase.DifferentiationInterface
3+
Random, ModelingToolkit, Optimization.OptimizationBase.DifferentiationInterface
44
using Test
55

66
struct CallbackTester

lib/OptimizationOptimisers/test/runtests.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ using Zygote
1212

1313
prob = OptimizationProblem(optprob, x0, _p)
1414

15-
sol = Optimization.solve(prob,
16-
OptimizationOptimisers.Sophia(; η = 0.5,
17-
λ = 0.0),
18-
maxiters = 1000)
19-
@test 10 * sol.objective < l1
20-
2115
prob = OptimizationProblem(optprob, x0, _p)
2216
sol = solve(prob, Optimisers.Adam(), maxiters = 1000, progress = false)
2317
@test 10 * sol.objective < l1

lib/OptimizationPRIMA/src/OptimizationPRIMA.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SciMLBase.allowsbounds(opt::Union{BOBYQA, LINCOA, COBYLA}) = true
1717
SciMLBase.requiresconstraints(opt::COBYLA) = true
1818
SciMLBase.requiresgradient(opt::Union{BOBYQA, LINCOA, COBYLA}) = true
1919
SciMLBase.requiresconsjac(opt::Union{LINCOA, COBYLA}) = true
20+
SciMLBase.requiresconshess(opt::COBYLA) = true
2021

2122
function Optimization.OptimizationCache(prob::SciMLBase.OptimizationProblem,
2223
opt::PRIMASolvers;

test/ADtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ end
3030
sol = solve(prob, Optim.Newton())
3131
@test 10 * sol.objective < l1
3232
@test sol.retcode == ReturnCode.Success
33+
34+
sol = Optimization.solve(prob,
35+
Optimization.Sophia(; η = 0.5,
36+
λ = 0.0),
37+
maxiters = 1000)
38+
@test 10 * sol.objective < l1
3339
end
3440

3541
@testset "No constraint" begin

0 commit comments

Comments
 (0)