Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ authors = ["Olivier Cots <olivier.cots@toulouse-inp.fr>"]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
CTModels = "34c4fa32-2049-4079-8329-de33c2a22e2d"
CTSolvers = "d3e8d392-8e4b-4d9b-8e92-d7d4e3650ef6"
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Expand All @@ -35,10 +33,8 @@ CTFlowsStaticArrays = ["StaticArrays"]
[compat]
ADTypes = "1"
Aqua = "0.8"
CTBase = "0.20"
CTModels = "0.11"
CTSolvers = "0.4"
CommonSolve = "0.2"
CTBase = "0.21"
CTModels = "0.12"
DiffEqBase = "6, 7"
DifferentiationInterface = "0.7"
DocStringExtensions = "0.9"
Expand Down
6 changes: 3 additions & 3 deletions ext/CTFlowsSciMLIntegrator/CTFlowsSciMLIntegrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ This extension provides:
- `Integrators.build_problem` — converts CTFlows systems to `ODEProblem`
- `Integrators.solve_problem` — solves an `ODEProblem` and returns a `SciMLIntegrationResult`

This is the backend layer intended to eventually migrate to CTSolvers.
This is the backend layer intended to eventually migrate to CTBase.Strategies.
The user-facing `Flow(::AbstractODEFunction)` and `Flow(::AbstractODEProblem)` constructors
live in the `CTFlowsSciMLFlows` extension.
"""
module CTFlowsSciMLIntegrator

import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES
import CTBase.Exceptions
import CTSolvers.Strategies
import CTSolvers.Options
import CTBase.Strategies
import CTBase.Options

using CTFlows: CTFlows
using CTFlows.Common: Common
Expand Down
10 changes: 5 additions & 5 deletions src/Common/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ module Common
# External package imports
# ==============================================================================

import Base: only
import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES
import CTBase.Exceptions
using ADTypes: ADTypes

# ==============================================================================
# Sibling imports (temporary - will be removed after full refactoring)
# Re-exported from CTBase.Core (moved out of CTFlows)
# ==============================================================================

# `AbstractTag`, `AbstractCache` and `make_coerce` now live in CTBase.Core.
# They are re-exported here so existing `Common.<symbol>` call sites are unchanged.
import CTBase.Core: AbstractTag, AbstractCache, make_coerce

# ==============================================================================
# Includes
# ==============================================================================

include(joinpath(@__DIR__, "helpers.jl"))
include(joinpath(@__DIR__, "abstract_tag.jl"))
include(joinpath(@__DIR__, "abstract_cache.jl"))
include(joinpath(@__DIR__, "ode_parameters.jl"))
include(joinpath(@__DIR__, "default.jl"))
include(joinpath(@__DIR__, "internal_norm.jl"))
Expand Down
26 changes: 0 additions & 26 deletions src/Common/abstract_cache.jl

This file was deleted.

36 changes: 0 additions & 36 deletions src/Common/abstract_tag.jl

This file was deleted.

34 changes: 0 additions & 34 deletions src/Common/helpers.jl

This file was deleted.

4 changes: 2 additions & 2 deletions src/Differentiation/Differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The concrete strategy `DifferentiationInterface` wraps DifferentiationInterface.
## Dependencies

- `ADTypes.jl` (hard dependency) — provides `AutoForwardDiff` type
- `CTSolvers.Strategies` (from CTSolvers) — strategy contract
- `CTBase.Strategies` — strategy contract
- `CTBase.Exceptions` — `NotImplemented` for stub methods
- `Common` (sibling) — `AbstractCache` type

Expand Down Expand Up @@ -52,7 +52,7 @@ module Differentiation

import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES
import CTBase.Exceptions
using CTSolvers: CTSolvers
import CTBase.Strategies
using ADTypes: ADTypes # Hard dep — provides AutoForwardDiff

# ==============================================================================
Expand Down
6 changes: 3 additions & 3 deletions src/Differentiation/abstract_ad_backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ scalar Hamiltonian function. Concrete backends (e.g., `DifferentiationInterface`
implement the contract methods to provide actual gradient computation.

# Notes
- `AbstractADBackend` subtypes `CTSolvers.Strategies.AbstractStrategy` — they are
first-class strategies in the CTSolvers ecosystem.
- `AbstractADBackend` subtypes `CTBase.Strategies.AbstractStrategy` — they are
first-class strategies in the CTBase.Strategies ecosystem.
- The contract consists of two methods: `hamiltonian_gradient` and `variable_gradient`.
- Gradient methods return **non-negated** partial derivatives; the RHS closures
apply the signs (ṗ = -∂H/∂x, ṽ = -∂H/∂v).
Expand All @@ -22,7 +22,7 @@ See also: [`CTFlows.Differentiation.DifferentiationInterface`](@ref),
[`CTFlows.Differentiation.hamiltonian_gradient`](@ref),
[`CTFlows.Differentiation.variable_gradient`](@ref).
"""
abstract type AbstractADBackend <: CTSolvers.Strategies.AbstractStrategy end
abstract type AbstractADBackend <: Strategies.AbstractStrategy end

# ==============================================================================
# Contract Methods
Expand Down
18 changes: 9 additions & 9 deletions src/Differentiation/differentiation_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ See also: [`CTFlows.Differentiation.AbstractADBackend`](@ref),
[`CTFlows.Differentiation.variable_gradient`](@ref),
[`CTFlows.Differentiation.prepare_cache`](@ref).
"""
struct DifferentiationInterface{O<:CTSolvers.Strategies.StrategyOptions} <:
struct DifferentiationInterface{O<:Strategies.StrategyOptions} <:
AbstractADBackend
options::O
end
Expand All @@ -44,37 +44,37 @@ Constructor for `DifferentiationInterface` with a specific backend.
- `DifferentiationInterface`: A new backend strategy instance.
"""
function DifferentiationInterface(; mode::Symbol=:strict, kwargs...)
opts = CTSolvers.Strategies.build_strategy_options(DifferentiationInterface; mode=mode, kwargs...)
opts = Strategies.build_strategy_options(DifferentiationInterface; mode=mode, kwargs...)
return DifferentiationInterface{typeof(opts)}(opts)
end

# ==============================================================================
# CTSolvers.Strategies Contract
# CTBase.Strategies Contract
# ==============================================================================

"""
$(TYPEDSIGNATURES)

Return the strategy identifier for `DifferentiationInterface`.
"""
CTSolvers.Strategies.id(::Type{<:DifferentiationInterface}) = :di
Strategies.id(::Type{<:DifferentiationInterface}) = :di

"""
$(TYPEDSIGNATURES)

Return a human-readable description of the `DifferentiationInterface` strategy.
"""
CTSolvers.Strategies.description(::Type{<:DifferentiationInterface}) =
Strategies.description(::Type{<:DifferentiationInterface}) =
"AD backend wrapping DifferentiationInterface.jl backends (e.g., AutoForwardDiff)."

"""
$(TYPEDSIGNATURES)

Return metadata defining `DifferentiationInterface` options and their specifications.
"""
function CTSolvers.Strategies.metadata(::Type{<:DifferentiationInterface})
return CTSolvers.Strategies.StrategyMetadata(
CTSolvers.Strategies.OptionDefinition(;
function Strategies.metadata(::Type{<:DifferentiationInterface})
return Strategies.StrategyMetadata(
Strategies.OptionDefinition(;
name = :ad_backend,
type = ADTypes.AbstractADType,
default = Common.__ad_backend(),
Expand Down Expand Up @@ -103,6 +103,6 @@ See also: [`CTFlows.Differentiation.ad_backend`](@ref),
[`CTFlows.Systems.hamiltonian_vector_field`](@ref).
"""
ad_backend(backend::DifferentiationInterface) =
Base.get(CTSolvers.Strategies.options(backend), Val(:ad_backend))
Base.get(Strategies.options(backend), Val(:ad_backend))


4 changes: 3 additions & 1 deletion src/Flows/Flows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ module Flows
# 1. External-package imports (qualified, pollution-free)
import DocStringExtensions: TYPEDEF, TYPEDSIGNATURES
import CTBase.Exceptions
using CTSolvers: CTSolvers
import CTBase.Strategies
import CTBase.Options
import CTBase.Orchestration
import CTModels

# ==============================================================================
Expand Down
6 changes: 3 additions & 3 deletions src/Flows/abstract_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ Silently does nothing when no user options are set.
\`\`\`
"""
function _print_user_options(io::IO, integ::Integrators.AbstractIntegrator)
opts = CTSolvers.Strategies.options(integ)
opts = Strategies.options(integ)
user_opts = sort!(
[(k, CTSolvers.value(v)) for (k, v) in pairs(opts.options)
if CTSolvers.is_user(opts, k)];
[(k, Options.value(v)) for (k, v) in pairs(opts.options)
if Options.is_user(opts, k)];
by = x -> string(x[1]),
)
isempty(user_opts) && return
Expand Down
4 changes: 2 additions & 2 deletions src/Flows/building.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ High-level constructor for `Flow` from vector field data.
This constructor builds a complete flow by:
1. Building a `VectorFieldSystem` from the vector field data
2. Building a `SciML` integrator with the given options
3. Routing options through the integrator's CTSolvers strategy
3. Routing options through the integrator's CTBase.Strategies strategy
4. Combining them into a callable `Flow`

# Arguments
Expand Down Expand Up @@ -40,7 +40,7 @@ High-level constructor for `HamiltonianFlow` from Hamiltonian vector field data.
This constructor builds a complete Hamiltonian flow by:
1. Building a `HamiltonianVectorFieldSystem` from the Hamiltonian vector field data
2. Building a `SciML` integrator with the given options
3. Routing options through the integrator's CTSolvers strategy
3. Routing options through the integrator's CTBase.Strategies strategy
4. Combining them into a callable `HamiltonianFlow`

# Arguments
Expand Down
22 changes: 11 additions & 11 deletions src/Flows/flow_routing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(TYPEDSIGNATURES)
Return the strategy families used for option routing in flow construction.

The returned `NamedTuple` maps family names to their abstract types, as expected
by [`CTSolvers.Orchestration.route_all_options`](@extref).
by [`CTBase.Orchestration.route_all_options`](@extref).

# Returns
- `NamedTuple`: `(backend, integrator)` mapped to their abstract types
Expand Down Expand Up @@ -39,7 +39,7 @@ This constant identifies the strategy families used in flow construction:

# Notes
- Used by [`CTFlows.Flows._route_flow_options`](@ref) and [`CTFlows.Flows._build_flow_components`](@ref).
- Passed to [`CTSolvers.Orchestration.route_all_options`](@extref) and [`CTSolvers.Orchestration.resolve_method`](@extref).
- Passed to [`CTBase.Orchestration.route_all_options`](@extref) and [`CTBase.Orchestration.resolve_method`](@extref).

See also: [`CTFlows.Flows._route_flow_options`](@ref), [`CTFlows.Flows._build_flow_components`](@ref), [`CTFlows.Flows._flow_families`](@ref).
"""
Expand All @@ -50,7 +50,7 @@ $(TYPEDSIGNATURES)

Route all keyword options to the appropriate strategy families for flow construction.

This function wraps [`CTSolvers.Orchestration.route_all_options`](@extref) with the
This function wraps [`CTBase.Orchestration.route_all_options`](@extref) with the
families specific to CTFlows flow construction. Options are routed to either the
backend family (`:di`) or the integrator family (`:sciml`).

Expand Down Expand Up @@ -80,13 +80,13 @@ routed = Flows._route_flow_options((; reltol=1e-8, ad_backend=ADTypes.AutoForwar
- No action-level options are defined for flows (empty `OptionDefinition` array).

See also: [`_flow_families`](@ref), [`_build_flow_components`](@ref),
[`CTSolvers.Orchestration.route_all_options`](@extref)
[`CTBase.Orchestration.route_all_options`](@extref)
"""
function _route_flow_options(kwargs)
return CTSolvers.Orchestration.route_all_options(
return Orchestration.route_all_options(
_FLOW_DESCRIPTION,
_flow_families(),
CTSolvers.Options.OptionDefinition[],
Options.OptionDefinition[],
(; kwargs...),
flow_registry();
source_mode = :description,
Expand All @@ -99,7 +99,7 @@ $(TYPEDSIGNATURES)
Build concrete strategy instances from routed options.

Each strategy is constructed via
[`CTSolvers.Orchestration.build_strategy_from_resolved`](@extref) using the options
[`CTBase.Orchestration.build_strategy_from_resolved`](@extref) using the options
that were routed to its family by [`_route_flow_options`](@ref).

# Arguments
Expand All @@ -118,18 +118,18 @@ components = Flows._build_flow_components(routed)
```

See also: [`_route_flow_options`](@ref), [`flow_registry`](@ref),
[`CTSolvers.Orchestration.build_strategy_from_resolved`](@extref)
[`CTBase.Orchestration.build_strategy_from_resolved`](@extref)
"""
function _build_flow_components(routed)
families = _flow_families()
resolved = CTSolvers.Orchestration.resolve_method(
resolved = Orchestration.resolve_method(
_FLOW_DESCRIPTION, families, flow_registry()
)
backend = CTSolvers.Orchestration.build_strategy_from_resolved(
backend = Orchestration.build_strategy_from_resolved(
resolved, :backend, families, flow_registry();
routed.strategies.backend...
)
integrator = CTSolvers.Orchestration.build_strategy_from_resolved(
integrator = Orchestration.build_strategy_from_resolved(
resolved, :integrator, families, flow_registry();
routed.strategies.integrator...
)
Expand Down
Loading