Skip to content

Commit 7f25ce1

Browse files
ChrisRackauckas-ClaudeChrisRackauckasclaude
authored
[AI] Curate the public API instead of blanket-reexporting dependencies (#1286)
* Curate the public API instead of blanket-reexporting dependencies Every package in the monorepo `@reexport`ed its dependencies wholesale, so `using Optimization` put 263 names in scope and `using OptimizationOptimJL` put 298 — none of which either package owned. 34 came from SciMLOperators (`AddVector`, `BlockDiagonalOperator`, `update_coefficients!`), and the surface included `DynamicalSDEFunction`, `DDEProblem` and `EigenvalueProblem`. Of the 263, the entire repo referenced 65. OptimizationBase now `using`s SciMLBase/ADTypes/SciMLLogging and states its public API in explicit `export` lists: its own types plus the problem/solution API and the nine `Auto*` types a user needs. Optimization re-exports that curated set and nothing else. The solver packages stop passing OptimizationBase through and expose only their own solvers, so `using OptimizationOptimJL` now means `LBFGS`, `BFGS`, `IPNewton` and friends. Users load `Optimization` alongside the solver package, which is what the docs already showed everywhere but one page. Optimization 263 public, 0 owned -> 39 OptimizationBase 262 public, 6 owned -> 38 OptimizationOptimJL 298 public, 0 owned -> 36 Dropping the reexports exposed five defects they had been masking: - OptimizationMOI and OptimizationIpopt use `ADTypes.AutoSymbolics` and `ADTypes.AutoSparse` qualified without declaring ADTypes at all; they compiled only because the reexport chain happened to bind the name. - OptimizationCMAEvolutionStrategy imported the SciMLBase *module* from OptimizationBase, and OptimizationLBFGSB took `ReturnCode` from there rather than from SciMLBase, which owns it. - OptimizationPyCMA marked `all_qualified_accesses_via_owners` as broken; it passes once accesses go to their owners, so the marker is removed. 17 packages used `@SciMLMessage` without depending on SciMLLogging and now declare it. `run_qa`'s reexport audit is satisfied without disabling it: the nine glue packages allow exactly their backend module, the two umbrella packages list their curated re-surface, and the remaining 18 need no allow-list because they expose nothing they do not own. Breaking: Optimization and OptimizationBase 5 -> 6, sublibraries by their SemVer rule, with intra-monorepo compat bounds updated to match. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014Uj4Pu1LKHYqLSTLfPYDPo * docs: use OptimizationBase in the PyCMA example Matches getting_started.md and the LBFGSB/PRIMA/Sophia pages. Addresses review feedback on the pycma.md hunk. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9dFnCQK2GVSNTCJP6ZMG2 * docs: use OptimizationBase as the entry package throughout The docs were split between `using Optimization` and `using OptimizationBase`, with getting_started.md, lbfgsb.md, prima.md and sophia.md already on the latter. Settle on OptimizationBase everywhere, per review feedback on the pycma.md hunk. names(Optimization) is names(OptimizationBase) plus the symbol :Optimization, and solve/init/solve!/reinit!/AutoForwardDiff/OptimizationProblem resolve to identical bindings in both, so this is behaviour-preserving. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9dFnCQK2GVSNTCJP6ZMG2 * docs: stop relying on the SciMLBase binding leaked by @reexport `@reexport using SciMLBase` exported names(SciMLBase), which always contains the symbol SciMLBase itself, so the module binding landed in every namespace that did `using Optimization`. Curating the exports removes it, and the docs were depending on it in two places: - 21 `SciMLBase.OptimizationProblem`/`OptimizationFunction` calls, 18 of them in executed @example blocks, which would throw UndefVarError and fail the build (@example errors are not covered by the existing warnonly list). OptimizationBase exports both names, so drop the qualification. - 5 @docs entries under API/ naming SciMLBase types. No page sets CurrentModule, so Documenter resolves them in Main; make.jl now binds SciMLBase explicitly. rosenbrock.md, linearandinteger.md and ode.md `using SciMLBase` for real and are left as they are. Verified on Julia 1.11: master binds SciMLBase and ADTypes for all four entry-package x solver combinations tested, this branch binds neither. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9dFnCQK2GVSNTCJP6ZMG2 * docs: say which of Optimization/OptimizationBase to install Every example now loads OptimizationBase, so README and the index install instructions pointed at a package the docs never use. Both now lead with OptimizationBase, and index.md gains a short section on the relationship. `Optimization` re-exports OptimizationBase and adds nothing else — it pulls in Logging/ConsoleProgressMonitor/TerminalLoggers/LoggingExtras but never references them — so the new text says the two are interchangeable rather than inventing a distinction between them. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9dFnCQK2GVSNTCJP6ZMG2 * OptimizationBase: drop the now-stale Reexport dependency Removing every `@reexport` from OptimizationBase left Reexport in [deps] and [compat] with no user, which fails Aqua's stale-dependency check. The reexport check itself already passed; this is the leftover. QA on OptimizationBase: 19 pass / 1 fail / 1 broken before, 20 pass / 1 broken after. The remaining broken is `ei_broken = (:no_implicit_imports,)`, which is already on master. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9dFnCQK2GVSNTCJP6ZMG2 * OptimizationLBFGSB: drop the now-stale OptimizationFunction import `using SciMLBase: OptimizationStats, OptimizationFunction` predates this branch, but on master `@reexport using OptimizationBase` re-exported every name in names(OptimizationBase), OptimizationFunction among them — and exporting a name counts as using it, so the import was not stale. Removing the reexport orphans it, and ExplicitImports' no_stale_explicit_imports errors. The name is used nowhere else in the package. QA on OptimizationLBFGSB, Julia 1.11: master: 18 pass, 2 fail (JET + reexports), 1 broken before: 19 pass, 1 fail (JET), 1 error (stale import), 1 broken after: 19 pass, 1 fail (JET), 1 broken The remaining JET failure is byte-identical to master's (same 9 toplevel errors, from the LBFGSB struct colliding with the LBFGSB package binding) and is already tracked as a follow-up. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9dFnCQK2GVSNTCJP6ZMG2 --------- Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 7ba3fc0 commit 7f25ce1

141 files changed

Lines changed: 562 additions & 361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Optimization"
22
uuid = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
3-
version = "5.6.6"
3+
version = "6.0.0"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -47,9 +47,9 @@ MLUtils = "0.4"
4747
ModelingToolkit = "11"
4848
Optim = "2"
4949
Optimisers = ">= 0.2.5"
50-
OptimizationBase = "5"
51-
OptimizationOptimJL = "0.4.10"
52-
OptimizationOptimisers = "0.3.16"
50+
OptimizationBase = "6"
51+
OptimizationOptimJL = "0.5"
52+
OptimizationOptimisers = "0.4"
5353
OrdinaryDiffEqTsit5 = "1, 2"
5454
Pkg = "1"
5555
Printf = "1.10"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ unified interface.
2222
## Installation
2323

2424
Assuming that you already have Julia correctly installed, it suffices to import
25-
Optimization.jl in the standard way:
25+
OptimizationBase in the standard way:
2626

2727
```julia
2828
using Pkg
29-
Pkg.add("Optimization")
29+
Pkg.add("OptimizationBase")
3030
```
3131

3232
The packages relevant to the core functionality of Optimization.jl will be imported
@@ -71,7 +71,7 @@ the documentation, which contains the unreleased features.
7171
## Examples
7272

7373
```julia
74-
using Optimization
74+
using OptimizationBase
7575
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
7676
x0 = zeros(2)
7777
p = [1.0, 100.0]

docs/Project.toml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -165,40 +165,40 @@ ModelingToolkit = "10.23, 11"
165165
NLPModels = "0.21, 0.22"
166166
NLPModelsTest = "0.10"
167167
NLopt = "0.6, 1"
168-
Optimization = "5.5"
169-
OptimizationAuglag = "1.3, 2"
170-
OptimizationBBO = "0.4.6"
171-
OptimizationBase = "5"
172-
OptimizationCMAEvolutionStrategy = "0.3.6"
173-
OptimizationEvolutionary = "0.4.7"
174-
OptimizationGCMAES = "0.3.5"
175-
OptimizationIpopt = "1.1"
176-
OptimizationLBFGSB = "1.4"
177-
OptimizationMOI = "1.2"
178-
OptimizationMadNLP = "2, 1"
179-
OptimizationManopt = "1.2"
180-
OptimizationMetaheuristics = "0.3.5"
181-
OptimizationMultistartOptimization = "0.3.4"
182-
OptimizationNLPModels = "1.2"
183-
OptimizationNLopt = "0.3.9"
184-
OptimizationNOMAD = "0.3.5"
185-
OptimizationODE = "0.1.4"
186-
OptimizationOptimJL = "0.4.10"
187-
OptimizationOptimisers = "0.3.16"
188-
OptimizationPRIMA = "0.3.5"
189-
OptimizationPolyalgorithms = "0.3.5"
190-
OptimizationPyCMA = "1.3"
191-
OptimizationQuadDIRECT = "0.3.4"
192-
OptimizationSciPy = "0.4.6"
193-
OptimizationSophia = "1.3"
194-
OptimizationSpeedMapping = "0.2.3"
168+
Optimization = "6"
169+
OptimizationAuglag = "3"
170+
OptimizationBBO = "0.5"
171+
OptimizationBase = "6"
172+
OptimizationCMAEvolutionStrategy = "0.4"
173+
OptimizationEvolutionary = "0.5"
174+
OptimizationGCMAES = "0.4"
175+
OptimizationIpopt = "2"
176+
OptimizationLBFGSB = "2"
177+
OptimizationMOI = "2"
178+
OptimizationMadNLP = "3"
179+
OptimizationManopt = "2"
180+
OptimizationMetaheuristics = "0.4"
181+
OptimizationMultistartOptimization = "0.4"
182+
OptimizationNLPModels = "2"
183+
OptimizationNLopt = "0.4"
184+
OptimizationNOMAD = "0.4"
185+
OptimizationODE = "0.2"
186+
OptimizationOptimJL = "0.5"
187+
OptimizationOptimisers = "0.4"
188+
OptimizationPRIMA = "0.4"
189+
OptimizationPolyalgorithms = "0.4"
190+
OptimizationPyCMA = "2"
191+
OptimizationQuadDIRECT = "0.4"
192+
OptimizationSciPy = "0.5"
193+
OptimizationSophia = "2"
194+
OptimizationSpeedMapping = "0.3"
195195
OrdinaryDiffEq = "6, 7"
196196
Plots = "1"
197197
Random = "1"
198198
ReverseDiff = ">= 1.9.0"
199199
SciMLBase = "2.122.1, 3"
200200
SciMLSensitivity = "7"
201-
SimpleOptimization = "1"
201+
SimpleOptimization = "2"
202202
Symbolics = "7"
203203
Tracker = ">= 0.2"
204204
Zygote = ">= 0.5"

docs/make.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using Documenter, Optimization
2+
# The `@docs` entries under API/ name SciMLBase types directly; nothing re-exports
3+
# the module binding any more, so bind it here rather than relying on that leak.
4+
using SciMLBase
25
using OptimizationAuglag, OptimizationBBO, OptimizationBase
36
using OptimizationCMAEvolutionStrategy, OptimizationGCMAES, OptimizationIpopt
47
using OptimizationLBFGSB, OptimizationMadNLP, OptimizationManopt

docs/src/index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ Optimization.jl is simply a bundle/interface over many of these dependencies.
3636
It may add some optional higher level behavior in the future but at this time
3737
the top level package does not add any extra behavior.
3838

39+
### `Optimization` or `OptimizationBase`?
40+
41+
`OptimizationBase` defines the interface — `OptimizationProblem`,
42+
`OptimizationFunction`, `solve` — and is what every solver package depends on,
43+
so it is what the examples throughout this documentation load:
44+
45+
```julia
46+
Pkg.add("OptimizationBase")
47+
```
48+
49+
`Optimization` re-exports that same interface and nothing else, so the two are
50+
interchangeable for everything shown here. Install whichever you prefer; you
51+
need only one of them, alongside a solver package.
52+
3953
## Contributing
4054

4155
- Please refer to the

docs/src/optimization_packages/auglag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OptimizationAuglag.AugLag
2020
## Example
2121

2222
```julia
23-
using Optimization, OptimizationAuglag, OptimizationOptimJL, ADTypes
23+
using OptimizationBase, OptimizationAuglag, OptimizationOptimJL, ADTypes
2424

2525
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
2626
cons(res, x, p) = (res .= [x[1]^2 + x[2]^2])

docs/src/optimization_packages/blackboxoptim.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ OptimizationBBO.BBO_borg_moea
7777
The Rosenbrock function can be optimized using the `BBO_adaptive_de_rand_1_bin_radiuslimited()` as follows:
7878

7979
```@example BBO
80-
using Optimization, OptimizationBBO
80+
using OptimizationBase, OptimizationBBO
8181
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
8282
x0 = zeros(2)
8383
p = [1.0, 100.0]
8484
f = OptimizationFunction(rosenbrock)
85-
prob = SciMLBase.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
85+
prob = OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
8686
sol = solve(prob, BBO_adaptive_de_rand_1_bin_radiuslimited(), maxiters = 100000,
8787
maxtime = 1000.0)
8888
```

docs/src/optimization_packages/cmaevolutionstrategy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ OptimizationCMAEvolutionStrategy.CMAEvolutionStrategyOpt
2929
The Rosenbrock function can be optimized using the `CMAEvolutionStrategyOpt()` as follows:
3030

3131
```@example CMAEvolutionStrategy
32-
using Optimization, OptimizationCMAEvolutionStrategy
32+
using OptimizationBase, OptimizationCMAEvolutionStrategy
3333
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
3434
x0 = zeros(2)
3535
p = [1.0, 100.0]
3636
f = OptimizationFunction(rosenbrock)
37-
prob = SciMLBase.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
37+
prob = OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
3838
sol = solve(prob, CMAEvolutionStrategyOpt())
3939
```

docs/src/optimization_packages/evolutionary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ Algorithm-specific options are defined as `kwargs`. See the respective documenta
3333
The Rosenbrock function can be optimized using the `Evolutionary.CMAES()` as follows:
3434

3535
```@example Evolutionary
36-
using Optimization, OptimizationEvolutionary
36+
using OptimizationBase, OptimizationEvolutionary
3737
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
3838
x0 = zeros(2)
3939
p = [1.0, 100.0]
4040
f = OptimizationFunction(rosenbrock)
41-
prob = SciMLBase.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
41+
prob = OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
4242
sol = solve(prob, Evolutionary.CMAES(μ = 40, λ = 100))
4343
```

docs/src/optimization_packages/gcmaes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ OptimizationGCMAES.GCMAESOpt
2929
The Rosenbrock function can be optimized using the `GCMAESOpt()` without utilizing the gradient information as follows:
3030

3131
```@example GCMAES
32-
using Optimization, OptimizationGCMAES
32+
using OptimizationBase, OptimizationGCMAES
3333
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
3434
x0 = zeros(2)
3535
p = [1.0, 100.0]
3636
f = OptimizationFunction(rosenbrock)
37-
prob = SciMLBase.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
37+
prob = OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
3838
sol = solve(prob, GCMAESOpt())
3939
```
4040

@@ -43,6 +43,6 @@ We can also utilize the gradient information of the optimization problem to aid
4343
```@example GCMAES
4444
using ADTypes, ForwardDiff
4545
f = OptimizationFunction(rosenbrock, ADTypes.AutoForwardDiff())
46-
prob = SciMLBase.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
46+
prob = OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
4747
sol = solve(prob, GCMAESOpt())
4848
```

0 commit comments

Comments
 (0)