Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

This PR updates all uses of supports_opt_cache_interface across the Optimization.jl ecosystem to check for availability in both SciMLBase and OptimizationBase packages, ensuring compatibility regardless of which package defines the function.

Changes Made

  • 20+ files updated across optimization algorithm packages
  • Applied compatibility pattern:
    if isdefined(SciMLBase, :supports_opt_cache_interface)
        SciMLBase.supports_opt_cache_interface(::Alg) = true
    elseif isdefined(OptimizationBase, :supports_opt_cache_interface)
        OptimizationBase.supports_opt_cache_interface(::Alg) = true
    end
  • Handles various patterns: Simple single-line definitions, complex macro-generated definitions, and multi-signature function definitions
  • Comprehensive coverage: Core algorithms (LBFGS, Sophia, AugLag) and all external optimization libraries

Files Modified

Core algorithms:

  • src/lbfgsb.jl
  • src/sophia.jl
  • src/auglag.jl

Optimization libraries:

  • lib/OptimizationOptimJL/src/OptimizationOptimJL.jl
  • lib/OptimizationMetaheuristics/src/OptimizationMetaheuristics.jl
  • lib/OptimizationGCMAES/src/OptimizationGCMAES.jl
  • lib/OptimizationCMAEvolutionStrategy/src/OptimizationCMAEvolutionStrategy.jl
  • lib/OptimizationEvolutionary/src/OptimizationEvolutionary.jl
  • lib/OptimizationBBO/src/OptimizationBBO.jl
  • lib/OptimizationSciPy/src/OptimizationSciPy.jl
  • lib/OptimizationMultistartOptimization/src/OptimizationMultistartOptimization.jl
  • lib/OptimizationODE/src/OptimizationODE.jl
  • lib/OptimizationMOI/src/OptimizationMOI.jl
  • lib/OptimizationIpopt/src/OptimizationIpopt.jl
  • lib/OptimizationPRIMA/src/OptimizationPRIMA.jl
  • lib/OptimizationManopt/src/OptimizationManopt.jl
  • lib/OptimizationOptimisers/src/OptimizationOptimisers.jl
  • lib/OptimizationSpeedMapping/src/OptimizationSpeedMapping.jl
  • lib/OptimizationNLopt/src/OptimizationNLopt.jl
  • lib/OptimizationPyCMA/src/OptimizationPyCMA.jl

Problem Solved

This addresses compatibility issues where supports_opt_cache_interface might be defined in either SciMLBase or OptimizationBase depending on package version combinations. The compatibility layer ensures that both versions work correctly for all optimization algorithms.

Previously, all files used:

SciMLBase.supports_opt_cache_interface(::AlgType) = true

Now they use the compatibility pattern that checks both packages, ensuring the function works regardless of where it's defined.

Test Plan

  • Julia environment activation succeeds
  • No old pattern remnants found in codebase
  • All syntax changes validated
  • Run full test suite to ensure no regressions
  • Test with different SciMLBase/OptimizationBase version combinations

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

ChrisRackauckas and others added 4 commits September 15, 2025 07:13
This change updates all uses of supports_opt_cache_interface to check
for availability in both SciMLBase and OptimizationBase packages,
ensuring compatibility regardless of which package defines the function.

Changes made:
- Updated all optimization algorithm packages to use isdefined checks
- Applied to both simple single-line and complex macro-generated definitions
- Covers 20+ files across the entire optimization ecosystem

This addresses compatibility issues where supports_opt_cache_interface
might be defined in either SciMLBase or OptimizationBase depending on
version combinations.

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

Co-Authored-By: Claude <[email protected]>
Changed from elseif to separate if statements to ensure both
SciMLBase and OptimizationBase compatibility patterns are defined
when both packages are available.

This allows the supports_opt_cache_interface function to be defined
for algorithms in both packages simultaneously, providing better
compatibility coverage.

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

Co-Authored-By: Claude <[email protected]>
Changed all isdefined checks to @static if for better performance
since these conditions can be evaluated at compile time.

This ensures the supports_opt_cache_interface compatibility checks
are resolved during compilation rather than runtime, providing
optimal performance.

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

Co-Authored-By: Claude <[email protected]>
Version bumps for compatibility changes:
- Optimization.jl: 4.6.0 → 4.7.0 (minor bump)
- OptimizationBBO: 0.4.1 → 0.4.2
- OptimizationCMAEvolutionStrategy: 0.3.1 → 0.3.2
- OptimizationEvolutionary: 0.4.1 → 0.4.2
- OptimizationGCMAES: 0.3.0 → 0.3.1
- OptimizationIpopt: 0.1.1 → 0.1.2
- OptimizationManopt: 0.0.4 → 0.0.5
- OptimizationMetaheuristics: 0.3.0 → 0.3.1
- OptimizationMOI: 0.5.5 → 0.5.6
- OptimizationMultistartOptimization: 0.3.0 → 0.3.1
- OptimizationNLopt: 0.3.2 → 0.3.3
- OptimizationODE: 0.1.0 → 0.1.1
- OptimizationOptimisers: 0.3.9 → 0.3.10
- OptimizationOptimJL: 0.4.3 → 0.4.4
- OptimizationPRIMA: 0.3.0 → 0.3.1
- OptimizationPyCMA: 1.0.0 → 1.1.0 (minor bump)
- OptimizationSciPy: 0.4.1 → 0.4.2
- OptimizationSpeedMapping: 0.2.0 → 0.2.1

Following semver convention: for 0.x.y increment patch (y),
for x.y.z where x≥1 increment minor (y).

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

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit b1a447d into SciML:master Sep 15, 2025
38 of 71 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