Repository navigation
Restore the optimization cache interface on using ParallelParticleSwarms - #127
Merged
Merged
Conversation
…arms` `66e277f` (#116) dropped `@reexport using SciMLBase` and then restored the whole 185-name surface as explicit exports; `b27522a` (#123) narrowed that to three names -- `OptimizationProblem`, `solve` and `SimpleLBFGS`. Dropping the bulk of SciMLBase was right, but the narrowing went one step too far: it also removed the rest of the interface a ParallelParticleSwarms user actually calls. `init`, `solve!` and `reinit!` are implemented by this package (`SciMLBase.init`/`solve!`/`reinit!` methods in src/init.jl, src/solve.jl and src/hybrid.jl) and are the documented way to reuse a swarm across runs, yet none of them were reachable from `using ParallelParticleSwarms`. Neither was `OptimizationFunction`, which is required to build a problem from an immutable `SVector` objective (`OptimizationFunction{false}`) -- the form every example in this repo uses. The package's own tests hide this by adding `using SciMLBase`. Restore the optimization interface as an explicit list, in the shape of SciML/Sundials.jl#553: - problems and functions: `OptimizationProblem`, `OptimizationFunction`, `NullParameters` - solutions: `OptimizationSolution`, `OptimizationStats` - solving: `solve`, `init`, `solve!`, `reinit!`, `remake` - return status: `ReturnCode`, `successful_retcode` The ODE/SDE/DAE/nonlinear problem classes, the integrator interface and the SciMLOperators surface stay out: this package does not solve those problems. The reexported surface is now documented in docs/src/index.md, naming SciMLBase as the owner of each name and stating the boundary explicitly, and the `REEXPORTS` tuple in test/qa/qa.jl is kept in sync with the `export` block. Restoring previously exported names is additive, so this is not breaking. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_01Rmh6B9eoW3N8oCbuuVPVxJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
66e277f("Migrate QA to SciMLTesting 2.4", #116) removed@reexport using SciMLBase. That commit then restored all 185 SciMLBase names asexplicit exports, and
b27522a("docs: narrow public reexports and QA", #123)narrowed the list to three:
Dropping the bulk of SciMLBase was correct -- this package does not solve ODEs,
SDEs, DAEs or nonlinear systems, and had no business exporting their problem
types. But the narrowing also removed the rest of the interface a
ParallelParticleSwarms user actually calls.
Evidence used to pick the restored names
SciMLBase.init(src/init.jl:56, :88, :143),SciMLBase.solve!(src/solve.jl:5, :11, :36 and src/hybrid.jl:47, :100) andSciMLBase.reinit!(src/init.jl:117) are ParallelParticleSwarms methods. Theinit/reinit!/solve!cache workflow is a feature of this package, andnone of its three entry points was reachable from
using ParallelParticleSwarms.OptimizationFunction. Every problem built intest/usesOptimizationFunction{false}(f, ...)-- the out-of-place form ismandatory for the
SVectorobjectives this package is built around, sinceOptimizationProblem(f, u0, p)infers the in-place form and errors with"Initial condition incompatible with functional form".
test/reinit.jl,test/constraints.jl,test/regression.jlandtest/gpu.jlall obtain it viaan explicit
using SciMLBase, which is what kept CI green while the publicsurface was broken.
names(ParallelParticleSwarms)vsnames(SciMLBase)to confirm what wasactually lost, and to confirm what was not:
AutoForwardDiff/AutoEnzymeare ADTypes names that SciMLBase never exported, so they were never part of this
package's surface and are deliberately not added here.
Restored names
SimpleLBFGS(from SimpleOptimization) is unchanged. Everything else fromSciMLBase -- the other equation classes, the integrator interface, SciMLOperators
-- stays out, and the docs say so explicitly.
names(ParallelParticleSwarms)goes from 12 to 22.Documentation
docs/src/index.mdgains a Reexported SciML common interface section thatlists the names grouped by role (problems and functions / solutions / solving /
return status), links each group to the owning SciMLBase documentation, shows both
the single-
solveand theinit/solve!/reinit!cache workflows, and closeswith the explicit boundary line. The docs list, the
exportblock insrc/ParallelParticleSwarms.jland theREEXPORTStuple intest/qa/qa.jlarethe same list in three places.
Why this is not breaking
Every name here was exported by
using ParallelParticleSwarmsbefore66e277f.Restoring previously-exported names is additive. No version bump is included; the
release pass handles versions.
What was verified (run, not just inspected)
test/qa/qa.jlruns clean locally: Quality Assurance 21/21 pass (Aqua,ExplicitImports including
all_explicit_imports_are_public, the public-APIdocumentation check and
No unapproved public reexports) and theReexport surface testset 27/27 pass.
using ParallelParticleSwarms, StaticArrays, KernelAbstractions:OptimizationFunction{false}+OptimizationProblem+solve(..., SerialPSO)reaching objective
3.8e-7, theninit+reinit!+solve!onParallelPSOKernel, plusremakeandsuccessful_retcode.names(ParallelParticleSwarms)contains all twelve restored names.Unrelated observation while testing: the README example
OptimizationProblem(rosenbrock, x0, p; lb, ub)errors today, because thetwo-argument objective is detected as in-place while
x0is anSVector. Itneeds
OptimizationFunction{false}. Left for a separate PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01Rmh6B9eoW3N8oCbuuVPVxJ