Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Updates for OptimizationBase v2 #789

Merged
merged 31 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9cb1499
Some changes to tests for OptimizationBase updates
Vaibhavdixit02 Jul 20, 2024
3844850
Optimisers epochs
Vaibhavdixit02 Jul 26, 2024
66d9577
Some MOI lagh handling
Vaibhavdixit02 Aug 2, 2024
9f36c85
some moi and optimisers updates
Vaibhavdixit02 Aug 25, 2024
912ee7c
Update Project.toml
Vaibhavdixit02 Aug 26, 2024
f1b9872
Update nlp.jl
Vaibhavdixit02 Aug 26, 2024
0f222b6
pass bools in moi instantiate_function
Vaibhavdixit02 Aug 26, 2024
7af7e73
call cons_vjp if available
baggepinnen Aug 26, 2024
606c96b
Update lib/OptimizationMOI/src/nlp.jl
Vaibhavdixit02 Aug 26, 2024
e24313f
Update lib/OptimizationMOI/src/nlp.jl
Vaibhavdixit02 Aug 29, 2024
33394a2
Merge pull request #811 from baggepinnen/consvjp
Vaibhavdixit02 Aug 29, 2024
e5c6f8b
Update Project.toml
Vaibhavdixit02 Sep 4, 2024
8093d05
Merge branch 'master' into optbasev2
Vaibhavdixit02 Sep 4, 2024
1b650d2
Update tests to be full optimization problems
Vaibhavdixit02 Sep 6, 2024
1face57
get ADtests passing
Vaibhavdixit02 Sep 7, 2024
2031eb7
All tests pass?
Vaibhavdixit02 Sep 9, 2024
43c2897
remove data argument and update tests
Vaibhavdixit02 Sep 9, 2024
52b1f64
optbase v2.0.1
Vaibhavdixit02 Sep 10, 2024
c4d9714
remove data from all sub libs
Vaibhavdixit02 Sep 10, 2024
0b2ef12
more updates to sub libs
Vaibhavdixit02 Sep 10, 2024
4a9737c
pls pass tests
Vaibhavdixit02 Sep 10, 2024
951d661
updates for CI
Vaibhavdixit02 Sep 11, 2024
03c2708
more fixes
Vaibhavdixit02 Sep 11, 2024
d2a6b81
add RD for second order
Vaibhavdixit02 Sep 11, 2024
d09cf00
more fixes
Vaibhavdixit02 Sep 11, 2024
5cf459a
separate out fixed parameter and dataloader cases explictly for now
Vaibhavdixit02 Sep 11, 2024
6e1999d
tests pass now pls
Vaibhavdixit02 Sep 12, 2024
2a803ff
tests pass now pls
Vaibhavdixit02 Sep 13, 2024
6e4616f
use callback to terminate minibatch tests
Vaibhavdixit02 Sep 14, 2024
6654e4b
Fix nlopt traits, moi lagh with constraints and mark reinit test in o…
Vaibhavdixit02 Sep 17, 2024
ceb503a
mtk doesn't have lagh
Vaibhavdixit02 Sep 17, 2024
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
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- OptimizationBBO
- OptimizationCMAEvolutionStrategy
- OptimizationEvolutionary
- OptimizationFlux
- OptimizationGCMAES
- OptimizationManopt
- OptimizationMetaheuristics
Expand Down Expand Up @@ -62,7 +61,7 @@ jobs:
GROUP: ${{ matrix.group }}
- uses: julia-actions/julia-processcoverage@v1
with:
directories: src,lib/OptimizationBBO/src,lib/OptimizationCMAEvolutionStrategy/src,lib/OptimizationEvolutionary/src,lib/OptimizationFlux/src,lib/OptimizationGCMAES/src,lib/OptimizationMOI/src,lib/OptimizationMetaheuristics/src,lib/OptimizationMultistartOptimization/src,lib/OptimizationNLopt/src,lib/OptimizationNOMAD/src,lib/OptimizationOptimJL/src,lib/OptimizationOptimisers/src,lib/OptimizationPolyalgorithms/src,lib/OptimizationQuadDIRECT/src,lib/OptimizationSpeedMapping/src
directories: src,lib/OptimizationBBO/src,lib/OptimizationCMAEvolutionStrategy/src,lib/OptimizationEvolutionary/src,lib/OptimizationGCMAES/src,lib/OptimizationManopt/src,lib/OptimizationMOI/src,lib/OptimizationMetaheuristics/src,lib/OptimizationMultistartOptimization/src,lib/OptimizationNLopt/src,lib/OptimizationNOMAD/src,lib/OptimizationOptimJL/src,lib/OptimizationOptimisers/src,lib/OptimizationPolyalgorithms/src,lib/OptimizationQuadDIRECT/src,lib/OptimizationSpeedMapping/src
- uses: codecov/codecov-action@v4
with:
file: lcov.info
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LBFGSB = "5be7bae1-8223-5378-bac3-9e7378a2f6e6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
OptimizationBase = "bca83a33-5cc9-4baa-983d-23429ab6bcbb"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
Expand All @@ -28,7 +29,8 @@ LBFGSB = "0.4.1"
LinearAlgebra = "1.10"
Logging = "1.10"
LoggingExtras = "0.4, 1"
OptimizationBase = "1.3.3"
MLUtils = "0.4.4"
OptimizationBase = "2.0.3"
Printf = "1.10"
ProgressLogging = "0.1"
Reexport = "1.2"
Expand Down
11 changes: 0 additions & 11 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,48 +182,37 @@ to add the specific wrapper packages.
url = {https://doi.org/10.5281/zenodo.7738525},
year = 2023}
```

## Reproducibility

```@raw html
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
```

```@example
using Pkg # hide
Pkg.status() # hide
```

```@raw html
</details>
```

```@raw html
<details><summary>and using this machine and Julia version.</summary>
```

```@example
using InteractiveUtils # hide
versioninfo() # hide
```

```@raw html
</details>
```

```@raw html
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
```

```@example
using Pkg # hide
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
```

```@raw html
</details>
```

```@eval
using TOML
using Markdown
Expand Down
40 changes: 5 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,16 @@ 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
x = (cache.f(θ, cache.p),)
return x[1]
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
x = cache.f(θ, cache.p)
return first(x)
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,15 +85,14 @@ 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

maxiters = Optimization._check_and_convert_maxiters(cache.solver_args.maxiters)
maxtime = Optimization._check_and_convert_maxtime(cache.solver_args.maxtime)

_loss = function (θ)
x = cache.f(θ, cache.p, cur...)
x = cache.f(θ, cache.p)
return first(x)
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.

Loading
Loading