Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

This PR completes the migration of the optimization solve interface that was removed from SciMLBase (between v2.120.0 and master) to OptimizationBase, as referenced in SciML/SciMLBase.jl@v2.120.0...master.

Changes

Updated: lib/OptimizationBase/src/solve.jl

  • Add comprehensive documentation for solve() function including:
    • Full parameter documentation (maxiters, maxtime, abstol, reltol, callback)
    • Detailed callback function documentation
    • Complete callback example with code samples
    • Documentation for global optimizer local method parameters
  • Add documentation for init() function
  • Maintain all existing error types and validation logic

Updated: lib/OptimizationBase/src/OptimizationBase.jl

  • Import and export optimizer trait functions from SciMLBase:
    • allowsbounds, requiresbounds
    • allowsconstraints, requiresconstraints
    • allowscallback, requiresgradient
    • requireshessian, requiresconsjac, requiresconshess
    • supports_opt_cache_interface
  • Export error types: IncompatibleOptimizerError, OptimizerMissingError

Updated: lib/OptimizationBase/test/solver_missing_error_messages.jl

  • Add comprehensive tests for optimizer error conditions
  • Test trait validation for various optimizer requirements
  • Ensure proper error messages are displayed

Notes

This PR builds on existing work in OptimizationBase and adds the complete documentation and interface that was previously in SciMLBase. The code has been formatted using JuliaFormatter with SciMLStyle.

Test Plan

  • Added comprehensive tests for error handling
  • Tests verify that optimizer trait validation works correctly
  • Tests ensure proper error messages are displayed

🤖 Generated with Claude Code

ChrisRackauckas and others added 3 commits October 12, 2025 03:17
This PR completes the migration of the optimization solve interface that was
removed from SciMLBase (between v2.120.0 and master) to OptimizationBase.

Changes:
- Update `src/solve.jl` with complete documentation from SciMLBase:
  - Full docstrings for solve(), init(), and solve!() functions
  - Detailed callback documentation with examples
  - Complete parameter documentation

- Update `src/OptimizationBase.jl`:
  - Import and export optimizer trait functions from SciMLBase
  - Export new error types

- Update `test/solver_missing_error_messages.jl`:
  - Comprehensive tests for optimizer error conditions
  - Tests for trait validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The `__init` and `__solve` functions are internal hooks, but the actual
dispatches should be to CommonSolve.jl's `init`, `solve`, and `solve!`
functions (which are imported via SciMLBase).

Changes:
- Import `init`, `solve`, `solve!`, `__init`, and `__solve` from SciMLBase
- Change function definitions from `SciMLBase.solve` to `solve` to properly
  extend the CommonSolve interface
- Remove `SciMLBase.` prefix from function calls to use the imported functions
  directly
- Keep type annotations with `SciMLBase.` prefix (these are correct)

This matches the pattern used in other SciML packages like OrdinaryDiffEq.jl
and aligns with the CommonSolve.jl interface design.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Author

Fixed the solve interface to use CommonSolve dispatches correctly.

Issue

The __init and __solve functions are internal SciMLBase hooks, but the actual public interface dispatches should be to CommonSolve.jl's init, solve, and solve! functions (which are imported via SciMLBase).

Changes Made

  1. Imported init, solve, solve!, __init, and __solve from SciMLBase into OptimizationBase
  2. Changed function definitions from SciMLBase.solve(...) to solve(...) to properly extend the CommonSolve interface
  3. Removed SciMLBase. prefix from function calls to use the imported functions directly
  4. Kept type annotations with SciMLBase. prefix (these remain correct)

Rationale

This pattern matches what's used in other SciML packages like OrdinaryDiffEq.jl and aligns with the CommonSolve.jl interface design. The CommonSolve functions (init, solve, solve!) are the public interface, while __init and __solve are internal hooks that allow SciMLBase to provide common error checking before dispatching to package-specific implementations.

Commit: 51bd57a

Changes:
- Add CommonSolve as a direct dependency in Project.toml
- Import init, solve, solve! directly from CommonSolve instead of SciMLBase
- Keep __init and __solve imported from SciMLBase (internal hooks)
- Remove unnecessary comment about DiffEqBase

This makes the dependency on CommonSolve explicit and clarifies that
the solve interface comes from CommonSolve.jl.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Author

Now importing CommonSolve interface functions directly from CommonSolve.jl instead of through SciMLBase.

Changes in commit 29388ffb2:

  • Added CommonSolve as a direct dependency
  • Import init, solve, solve! from CommonSolve (the actual interface)
  • Keep __init and __solve imported from SciMLBase (internal dispatch hooks)
  • Removed unnecessary comment about DiffEqBase

This makes the dependency explicit and clarifies the interface structure.

Match DiffEqBase style by importing all solve interface functions from
SciMLBase rather than directly from CommonSolve. SciMLBase already
imports from CommonSolve and exports these functions, so all packages
in the ecosystem should import from SciMLBase for consistency.

Changes:
- Remove CommonSolve as a direct dependency
- Import solve, init, solve!, __init, __solve from SciMLBase
- Keep all other SciMLBase imports organized together

This matches exactly how DiffEqBase handles the solve interface.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Author

Updated to follow DiffEqBase pattern exactly.

Changes in commit 2bce34b

Following the DiffEqBase style guide, all solve interface functions should be imported from SciMLBase, not directly from CommonSolve:

import SciMLBase: solve, init, solve!, __init, __solve,
                  OptimizationProblem,
                  ...

This is the standard pattern across the SciML ecosystem:

  • CommonSolve.jl defines the interface (solve, init, solve!)
  • SciMLBase.jl imports from CommonSolve and exports these functions
  • All ecosystem packages (DiffEqBase, OptimizationBase, etc.) import from SciMLBase

This keeps the dependency graph clean and ensures consistency across all SciML packages.

@ChrisRackauckas ChrisRackauckas merged commit 449d084 into SciML:master Oct 12, 2025
40 of 77 checks passed
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.

2 participants