Skip to content

Migration: implement parameter contract method for all strategies (CTBase v0.28.0-beta) #171

Description

@ocots

Context

CTBase v0.28.0-beta introduces a breaking change in the strategy parameter contract. See control-toolbox/CTBase.jl#497 for the full PR.

What changed in CTBase

  • get_parameter_type is removed from the public API.
  • A new parameter(::Type{<:S}) contract method is added to AbstractStrategy. Every concrete strategy must implement it:
    • Non-parameterized: Strategies.parameter(::Type{<:MyStrategy}) = nothing
    • Parameterized: Strategies.parameter(::Type{<:MyStrategy{P}}) where {P<:Strategies.AbstractStrategyParameter} = P
    • The default stub throws Exceptions.NotImplemented so any strategy that forgets to implement it fails loudly at load time.
  • _default_parameter is renamed to default_parameter (now exported).
  • parameter and default_parameter are now exported from CTBase.Strategies.

Migration steps

  1. For each concrete strategy struct in CTSolvers, add a parameter method:

    # Non-parameterized strategy
    CTBase.Strategies.parameter(::Type{<:Ipopt}) = nothing
    
    # Parameterized strategy
    CTBase.Strategies.parameter(::Type{<:MadNLP{P}}) where {P<:CTBase.Strategies.AbstractStrategyParameter} = P
  2. Rename all _default_parameter calls to default_parameter:

    # Before
    CTBase.Strategies._default_parameter(::Type{<:MadNLP}) = CTBase.Strategies.CPU
    
    # After
    CTBase.Strategies.default_parameter(::Type{<:MadNLP}) = CTBase.Strategies.CPU
  3. Remove any usage of get_parameter_type — replace with parameter.

  4. Run tests against CTBase feature/parameter-contract branch (or main after merge).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions