Skip to content

Commit

Permalink
remove data from all sub libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Sep 10, 2024
1 parent 52b1f64 commit c4d9714
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 288 deletions.
1 change: 0 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ Pkg.status() # hide
using InteractiveUtils # hide
versioninfo() # hide
```

```@raw html
</details>
```
Expand Down
38 changes: 3 additions & 35 deletions lib/OptimizationBBO/src/OptimizationBBO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{
}
local x, cur, state

if cache.data != Optimization.DEFAULT_DATA
maxiters = length(cache.data)
end

cur, state = iterate(cache.data)

function _cb(trace)
if cache.callback === Optimization.DEFAULT_CALLBACK
cb_call = false
Expand All @@ -138,9 +132,6 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{
BlackBoxOptim.shutdown_optimizer!(trace) #doesn't work
end

if cache.data !== Optimization.DEFAULT_DATA
cur, state = iterate(cache.data, state)
end
cb_call
end

Expand All @@ -149,37 +140,14 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{

_loss = function (θ)
if isa(cache.f, MultiObjectiveOptimizationFunction)
if cache.callback === Optimization.DEFAULT_CALLBACK &&
cache.data === Optimization.DEFAULT_DATA
return cache.f(θ, cache.p)
elseif cache.callback === Optimization.DEFAULT_CALLBACK
return cache.f(θ, cache.p, cur...)
elseif cache.data !== Optimization.DEFAULT_DATA
x = cache.f(θ, cache.p)
return x
else
x = cache.f(θ, cache.p, cur...)
return first(x)
end
return cache.f(θ, cache.p)
else
if cache.callback === Optimization.DEFAULT_CALLBACK &&
cache.data === Optimization.DEFAULT_DATA
return first(cache.f(θ, cache.p))
elseif cache.callback === Optimization.DEFAULT_CALLBACK
return first(cache.f(θ, cache.p, cur...))
elseif cache.data !== Optimization.DEFAULT_DATA
x = cache.f(θ, cache.p)
return first(x)
else
x = cache.f(θ, cache.p, cur...)
return first(x)
end
return first(cache.f(θ, cache.p))
end
end

opt_args = __map_optimizer_args(cache, cache.opt;
callback = cache.callback === Optimization.DEFAULT_CALLBACK &&
cache.data === Optimization.DEFAULT_DATA ?
callback = cache.callback === Optimization.DEFAULT_CALLBACK ?
nothing : _cb,
cache.solver_args...,
maxiters = maxiters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ function SciMLBase.__solve(cache::OptimizationCache{
}
local x, cur, state

if cache.data != Optimization.DEFAULT_DATA
maxiters = length(cache.data)
end

cur, state = iterate(cache.data)

function _cb(opt, y, fvals, perm)
curr_u = opt.logger.xbest[end]
opt_state = Optimization.OptimizationState(; iter = length(opt.logger.fmedian),
Expand All @@ -91,7 +85,6 @@ function SciMLBase.__solve(cache::OptimizationCache{
if !(cb_call isa Bool)
error("The callback should return a boolean `halt` for whether to stop the optimization process.")
end
cur, state = iterate(cache.data, state)
cb_call
end

Expand Down
11 changes: 2 additions & 9 deletions lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ function SciMLBase.__solve(cache::OptimizationCache{
}
local x, cur, state

if cache.data != Optimization.DEFAULT_DATA
maxiters = length(cache.data)
end

cur, state = iterate(cache.data)

function _cb(trace)
curr_u = decompose_trace(trace).metadata["curr_u"]
opt_state = Optimization.OptimizationState(;
Expand All @@ -116,7 +110,6 @@ function SciMLBase.__solve(cache::OptimizationCache{
if !(cb_call isa Bool)
error("The callback should return a boolean `halt` for whether to stop the optimization process.")
end
cur, state = iterate(cache.data, state)
cb_call
end

Expand All @@ -127,10 +120,10 @@ function SciMLBase.__solve(cache::OptimizationCache{

_loss = function (θ)
if isa(f, MultiObjectiveOptimizationFunction)
x = f(θ, cache.p, cur...)
x = f(θ, cache.p)
return x
else
x = f(θ, cache.p, cur...)
x = f(θ, cache.p)
return first(x)
end
end
Expand Down
21 changes: 0 additions & 21 deletions lib/OptimizationFlux/LICENSE

This file was deleted.

25 changes: 0 additions & 25 deletions lib/OptimizationFlux/Project.toml

This file was deleted.

115 changes: 0 additions & 115 deletions lib/OptimizationFlux/src/OptimizationFlux.jl

This file was deleted.

46 changes: 0 additions & 46 deletions lib/OptimizationFlux/test/runtests.jl

This file was deleted.

5 changes: 2 additions & 3 deletions lib/OptimizationGCMAES/src/OptimizationGCMAES.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ function __map_optimizer_args(cache::OptimizationCache, opt::GCMAESOpt;
end

function SciMLBase.__init(prob::SciMLBase.OptimizationProblem,
opt::GCMAESOpt,
data = Optimization.DEFAULT_DATA; σ0 = 0.2,
opt::GCMAESOpt; σ0 = 0.2,
callback = (args...) -> (false),
progress = false, kwargs...)
return OptimizationCache(prob, opt, data; σ0 = σ0, callback = callback,
return OptimizationCache(prob, opt; σ0 = σ0, callback = callback,
progress = progress,
kwargs...)
end
Expand Down
16 changes: 1 addition & 15 deletions lib/OptimizationManopt/src/OptimizationManopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,6 @@ function SciMLBase.__solve(cache::OptimizationCache{
throw(ArgumentError("Manifold not specified in the problem for e.g. `OptimizationProblem(f, x, p; manifold = SymmetricPositiveDefinite(5))`."))
end

if cache.data !== Optimization.DEFAULT_DATA
maxiters = length(cache.data)
else
maxiters = cache.solver_args.maxiters
end

cur, state = iterate(cache.data)

function _cb(x, θ)
opt_state = Optimization.OptimizationState(iter = 0,
u = θ,
Expand All @@ -419,13 +411,7 @@ function SciMLBase.__solve(cache::OptimizationCache{
if !(cb_call isa Bool)
error("The callback should return a boolean `halt` for whether to stop the optimization process.")
end
nx_itr = iterate(cache.data, state)
if isnothing(nx_itr)
true
else
cur, state = nx_itr
cb_call
end
cb_call
end
solver_kwarg = __map_optimizer_args!(cache, cache.opt, callback = _cb,
maxiters = maxiters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ function __map_optimizer_args!(cache::OptimizationCache,
end

function SciMLBase.__init(prob::SciMLBase.OptimizationProblem,
opt::Metaheuristics.AbstractAlgorithm,
data = Optimization.DEFAULT_DATA; use_initial = false,
opt::Metaheuristics.AbstractAlgorithm; use_initial = false,
callback = (args...) -> (false),
progress = false, kwargs...)
return OptimizationCache(prob, opt, data; use_initial = use_initial,
return OptimizationCache(prob, opt; use_initial = use_initial,
callback = callback,
progress = progress,
kwargs...)
Expand Down
Loading

0 comments on commit c4d9714

Please sign in to comment.