Skip to content

Public API

This page lists exported symbols of CTFlows.Flows.


From CTFlows.Flows

CTFlows.Flows [Module]

CTFlows.Flows Module
julia
Flows

Flow types and contracts for CTFlows.

This module defines the AbstractFlow type and its required methods:

  • (flow)(t0, x0, tf): callable interface for state integration

  • (flow)(t0, x0, p0, tf): callable interface for state + costate integration

  • system: returns the system associated with the flow

  • integrator: returns the integrator used by the flow

AbstractFlow [Abstract Type]

CTFlows.Flows.AbstractFlow Type
julia
abstract type AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Abstract type for all flows in CTFlows.

An AbstractFlow is a callable object that combines an AbstractSystem with an AbstractIntegrator. It carries no business logic of its own — its job is to expose the integration protocol.

Interface Requirements

All subtypes must implement:

  • system(flow::AbstractFlow): Return the associated AbstractSystem.

  • integrator(flow::AbstractFlow): Return the associated AbstractIntegrator.

Traits

All AbstractFlow subtypes automatically support time-dependence and variable-dependence trait queries encoded in their type parameters:

  • time_dependence(flow): Returns the time-dependence trait type.

  • variable_dependence(flow): Returns the variable-dependence trait type.

  • is_autonomous(flow), is_nonautonomous(flow): Time-dependence predicates.

  • is_variable(flow), is_nonvariable(flow), has_variable(flow): Variable-dependence predicates.

Example

julia
julia> using CTFlows.Flows

julia> MyFlow <: Flows.AbstractFlow
true

See also: CTFlows.Flows.Flow, CTFlows.Systems.AbstractSystem, CTSolvers.Integrators.AbstractIntegrator.

AbstractHamiltonianFlow [Abstract Type]

CTFlows.Flows.AbstractHamiltonianFlow Type
julia
abstract type AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Alias for Hamiltonian flows.

Matches any AbstractFlow with HamiltonianDynamics as the dynamics parameter.

Type Parameters

  • TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)

  • VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)

Example

julia
julia> using CTFlows.Flows

julia> Flow(hvf) isa Flows.AbstractHamiltonianFlow
true

See also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.AbstractStateFlow.

AbstractStateFlow [Abstract Type]

CTFlows.Flows.AbstractStateFlow Type
julia
abstract type AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}

Alias for state flows.

Matches any AbstractFlow with StateDynamics as the dynamics parameter.

Type Parameters

  • TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)

  • VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)

Example

julia
julia> using CTFlows.Flows

julia> Flow(vf) isa Flows.AbstractStateFlow
true

See also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.AbstractHamiltonianFlow.

ControlledFlow [Struct]

CTFlows.Flows.ControlledFlow Type
julia
struct ControlledFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, IF, M, L} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}

State flow of a controlled dynamical system with an OpenLoop or ClosedLoop control law, built by CTFlows.Flows.Flow from Flow(ocp, law) or Flow(fc, law).

Unlike an CTFlows.Flows.OptimalControlFlow (Hamiltonian, with a costate), this is a state flow: point evaluation is f(t0, x0, tf; variable) (no costate) and a trajectory call returns a CTFlows.Trajectories.StateFlowTrajectory.

Type Parameters

  • TD, VD: time/variable dependence, inherited from the inner flow.

  • IF: type of the inner state flow.

  • M: type of the OCP model, or Nothing (for Flow(fc, law)).

  • L: type of the control law.

Fields

  • flow::IF: the inner state flow integrating ẋ = g(t, x, v).

  • ocp::M: the OCP model (for the objective), or nothing.

  • law::L: the control law, used to reconstruct u(t).

See also: CTFlows.Trajectories.StateFlowTrajectory, CTFlows.Flows.Flow.

Flow [Struct]

CTFlows.Flows.Flow Type
julia
struct Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait, S<:CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}, I<:CTSolvers.Integrators.AbstractIntegrator} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Concrete flow combining an AbstractSystem with an AbstractIntegrator.

The dynamics axis is encoded in the type parameter D:

  • D = StateDynamics → state flow (access via StateFlow alias)

  • D = HamiltonianDynamics → Hamiltonian flow (access via HamiltonianFlow alias)

Type Parameters

  • TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)

  • VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)

  • D <: AbstractDynamicsTrait: Dynamics trait (StateDynamics or HamiltonianDynamics)

  • S <: AbstractSystem{TD, VD, D}: The system type

  • I <: AbstractIntegrator: The integrator type

Fields

  • system::S: The system to integrate

  • integrator::I: The integrator to use for integration

Example

julia
julia> using CTFlows.Flows, CTFlows.Systems, CTFlows.Integrators

julia> system = VectorFieldSystem(VectorField(x -> -x))

julia> integrator = SciML()

julia> flow = StateFlow(system, integrator)
StateFlow{...}

See also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.StateFlow, CTFlows.Flows.HamiltonianFlow.

HamiltonianFlow [Struct]

CTFlows.Flows.HamiltonianFlow Type
julia
struct Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics, S<:CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}, I<:CTSolvers.Integrators.AbstractIntegrator} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Alias for Hamiltonian flows: Flow{TD, VD, HamiltonianDynamics, S, I}.

See also: CTFlows.Flows.Flow, CTFlows.Flows.StateFlow.

OptimalControlFlow [Struct]

CTFlows.Flows.OptimalControlFlow Type
julia
struct OptimalControlFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, IF, M, CL, SF} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Flow of the Hamiltonian system associated with a (control-free) optimal control problem, built by CTFlows.Flows.Flow from a CTModels.Models.Model.

It is a thin CTFlows.Flows.AbstractFlow wrapper around an inner HamiltonianFlow: point evaluation delegates to the inner flow (returning the final state–costate pair), while a trajectory call integrates the system and rebuilds a full CTModels.Solutions.Solution from the problem.

Type Parameters

  • TD <: TimeDependence: time-dependence trait, inherited from the problem.

  • VD <: VariableDependence: variable-dependence trait, inherited from the problem.

  • IF: type of the inner HamiltonianFlow.

  • M: type of the wrapped optimal control problem model.

  • CL: type of the control law (Nothing for a control-free OCP, a CTBase.Data.ControlLaw when the flow was built from an OCP and a control law).

  • SF: type of the inner control-free state flow (Nothing unless the OCP is control-free — see state_flow).

Fields

  • flow::IF: the inner Hamiltonian flow doing the integration.

  • ocp::M: the optimal control problem, kept so trajectory calls can build a solution.

  • law::CL: the control law, used to reconstruct u(t) along the trajectory (or nothing for control-free problems).

  • state_flow::SF: inner state flow of ẋ = f(t,x,∅,v), built only for a control-free OCP (Flow(ocp), no law); nothing otherwise. Backs the basic (no-costate) call arities f(t0,x0,tf) / f((t0,tf),x0) — see CTFlows.Flows._ocp_state_vector_field.

See also: CTFlows.Flows.Flow, CTModels.Solutions.Solution.

StateFlow [Struct]

CTFlows.Flows.StateFlow Type
julia
struct Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics, S<:CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}, I<:CTSolvers.Integrators.AbstractIntegrator} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}

Alias for state flows: Flow{TD, VD, StateDynamics, S, I}.

See also: CTFlows.Flows.Flow, CTFlows.Flows.HamiltonianFlow.

__unsafe [Function]

CTFlows.Flows.__unsafe Function
julia
__unsafe() -> Bool

Default value for unsafe flag in integration functions.

Returns false by default, meaning ODE solver retcodes are checked and failures throw exceptions unless explicitly bypassed.

__variable [Function]

CTFlows.Flows.__variable Function
julia
__variable() -> CTBase.Core.NotProvidedType

Default value for variable parameter in user-facing API calls.

Returns CTBase.Core.NotProvided by default, meaning the variable parameter is optional unless required by the system's trait (e.g., NonFixed systems).

See also: CTBase.Traits.VariableDependence, CTBase.Traits.Fixed, CTBase.Traits.NonFixed.

__variable_costate [Function]

CTFlows.Flows.__variable_costate Function
julia
__variable_costate() -> Bool

Default value for variable_costate flag in Hamiltonian flow calls.

Returns false by default, meaning the flow does not integrate the augmented variable costate equation ṗᵥ = -∂H/∂v unless explicitly requested.

Returns

  • Bool: The default value for the variable_costate parameter.

See also: CTFlows.Configs.AugmentedHamiltonianEndPointConfig.

build_flow [Function]

CTFlows.Flows.build_flow Function
julia
build_flow(
    system::CTFlows.Systems.AbstractSystem,
    integrator::CTSolvers.Integrators.AbstractIntegrator
) -> CTFlows.Flows.Flow

Build a Flow from a system and an integrator.

See also: CTFlows.Flows.Flow.

flow_registry [Function]

CTFlows.Flows.flow_registry Function
julia
flow_registry() -> CTBase.Strategies.StrategyRegistry

Return the strategy registry for flow construction.

The registry maps abstract strategy families to their concrete implementations for automatic differentiation backends and ODE integrators.

Returns

  • CTBase.Strategies.StrategyRegistry: Registry with :di (DifferentiationInterface) and :sciml (SciML) strategies registered.

Notes

  • This registry is used by CTFlows.Flows._route_flow_options to resolve and build concrete strategy instances from keyword arguments.

  • The registry is precomputed and cached in _FLOW_REGISTRY for performance.

See also: CTFlows.Flows._route_flow_options, CTFlows.Flows._build_flow_components, CTBase.Strategies.create_registry

integrator [Function]

CTFlows.Flows.integrator Function
julia
integrator(
    flow::CTFlows.Flows.AbstractFlow
) -> CTSolvers.Integrators.AbstractIntegrator

Return the associated AbstractIntegrator for the flow.

Throws

  • CTBase.Exceptions.NotImplemented: If not implemented by the concrete type.

See also: CTFlows.Flows.AbstractFlow, CTSolvers.Integrators.AbstractIntegrator.

julia
integrator(
    f::CTFlows.Flows.Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait, S<:CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}, I<:CTSolvers.Integrators.AbstractIntegrator}
) -> CTSolvers.Integrators.AbstractIntegrator

Return the integrator associated with a Flow.

See also: CTFlows.Flows.Flow, CTFlows.Flows.system.

julia
integrator(F::CTFlows.Flows.ControlledFlow) -> Any

Return the underlying CTSolvers.Integrators.AbstractIntegrator of the inner state flow.

julia
integrator(mpsf::CTFlows.MultiPhase.MultiPhaseFlow) -> Any

Return the integrators associated with a multi-phase flow as a tuple.

See also: CTFlows.Flows.integrator.

system [Function]

CTFlows.Flows.system Function
julia
system(flow::CTFlows.Flows.AbstractFlow)

Return the associated AbstractSystem for the flow.

Throws

  • CTBase.Exceptions.NotImplemented: If not implemented by the concrete type.

See also: CTFlows.Flows.AbstractFlow, CTFlows.Systems.AbstractSystem.

julia
system(
    f::CTFlows.Flows.Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait, S<:CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}, I<:CTSolvers.Integrators.AbstractIntegrator}
) -> Any

Return the system associated with a Flow.

See also: CTFlows.Flows.Flow, CTFlows.Flows.integrator.

julia
system(F::CTFlows.Flows.ControlledFlow) -> Any

Return the underlying CTFlows.Systems.AbstractSystem of the inner state flow.

julia
system(mpsf::CTFlows.MultiPhase.MultiPhaseFlow) -> Any

Return the systems associated with a multi-phase flow as a tuple.

See also: CTFlows.Flows.system.