Skip to content

Restore the optimization cache interface on using ParallelParticleSwarms - #127

Merged
ChrisRackauckas merged 1 commit into
mainfrom
restore-documented-reexports
Aug 23, 2026
Merged

ChrisRackauckas merged 1 commit into
mainfrom
restore-documented-reexports

Conversation

@ChrisRackauckas

Copy link
Copy Markdown
Member

What broke

66e277f ("Migrate QA to SciMLTesting 2.4", #116) removed
@reexport using SciMLBase. That commit then restored all 185 SciMLBase names as
explicit exports, and b27522a ("docs: narrow public reexports and QA", #123)
narrowed the list to three:

const REEXPORTS = (:OptimizationProblem, :SimpleLBFGS, :solve)

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

  1. The package implements them. SciMLBase.init (src/init.jl:56, :88, :143),
    SciMLBase.solve! (src/solve.jl:5, :11, :36 and src/hybrid.jl:47, :100) and
    SciMLBase.reinit! (src/init.jl:117) are ParallelParticleSwarms methods. The
    init / reinit! / solve! cache workflow is a feature of this package, and
    none of its three entry points was reachable from using ParallelParticleSwarms.
  2. The repo's own examples need OptimizationFunction. Every problem built in
    test/ uses OptimizationFunction{false}(f, ...) -- the out-of-place form is
    mandatory for the SVector objectives this package is built around, since
    OptimizationProblem(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.jl and test/gpu.jl all obtain it via
    an explicit using SciMLBase, which is what kept CI green while the public
    surface was broken.
  3. names(ParallelParticleSwarms) vs names(SciMLBase) to confirm what was
    actually lost, and to confirm what was not: AutoForwardDiff / AutoEnzyme
    are ADTypes names that SciMLBase never exported, so they were never part of this
    package's surface and are deliberately not added here.

Restored names

NullParameters, OptimizationFunction, OptimizationProblem, OptimizationSolution,
OptimizationStats, ReturnCode, init, reinit!, remake, solve, solve!,
successful_retcode

SimpleLBFGS (from SimpleOptimization) is unchanged. Everything else from
SciMLBase -- 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.md gains a Reexported SciML common interface section that
lists the names grouped by role (problems and functions / solutions / solving /
return status), links each group to the owning SciMLBase documentation, shows both
the single-solve and the init/solve!/reinit! cache workflows, and closes
with the explicit boundary line. The docs list, the export block in
src/ParallelParticleSwarms.jl and the REEXPORTS tuple in test/qa/qa.jl are
the same list in three places.

Why this is not breaking

Every name here was exported by using ParallelParticleSwarms before 66e277f.
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.jl runs clean locally: Quality Assurance 21/21 pass (Aqua,
    ExplicitImports including all_explicit_imports_are_public, the public-API
    documentation check and No unapproved public reexports) and the
    Reexport surface testset 27/27 pass.
  • A documented end-to-end workflow runs from a bare
    using ParallelParticleSwarms, StaticArrays, KernelAbstractions:
    OptimizationFunction{false} + OptimizationProblem + solve(..., SerialPSO)
    reaching objective 3.8e-7, then init + reinit! + solve! on
    ParallelPSOKernel, plus remake and successful_retcode.
  • names(ParallelParticleSwarms) contains all twelve restored names.
  • Runic reports no formatting changes for the touched Julia files.
  • The GPU test groups were not run (no CUDA device here); CI covers them.

Unrelated observation while testing: the README example
OptimizationProblem(rosenbrock, x0, p; lb, ub) errors today, because the
two-argument objective is detected as in-place while x0 is an SVector. It
needs OptimizationFunction{false}. Left for a separate PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rmh6B9eoW3N8oCbuuVPVxJ

…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
@ChrisRackauckas
ChrisRackauckas merged commit a39e1e8 into main Aug 23, 2026
10 of 11 checks passed
@ChrisRackauckas
ChrisRackauckas deleted the restore-documented-reexports branch August 23, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant