Private API

This page lists non-exported (internal) symbols of CTFlows.Flows.


From CTFlows.Flows

_FLOW_DESCRIPTION [Constant]

CTFlows.Flows._FLOW_DESCRIPTIONConstant

Strategy family description for flow construction.

This constant identifies the strategy families used in flow construction:

  • :di - DifferentiationInterface family for AD backends
  • :sciml - SciML family for ODE integrators

Type

  • Tuple{Symbol, Symbol}: Tuple of strategy family identifiers.

Notes

See also: CTFlows.Flows._route_flow_options, CTFlows.Flows._build_flow_components, CTFlows.Flows._flow_families.

_FLOW_REGISTRY [Constant]

CTFlows.Flows._FLOW_REGISTRYConstant

Strategy registry for flow construction.

This constant holds the precomputed strategy registry that maps abstract strategy types to their concrete implementations for flow construction:

  • Differentiation.AbstractADBackendDifferentiation.DifferentiationInterface
  • Integrators.AbstractIntegratorIntegrators.SciML

Type

  • CTBase.Strategies.StrategyRegistry: Registry mapping abstract types to concrete implementations.

Notes

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

_build_flow_components [Function]

CTFlows.Flows._build_flow_componentsFunction
_build_flow_components(
    routed
) -> NamedTuple{(:backend, :integrator), <:Tuple{Any, Any}}

Build concrete strategy instances from routed options.

Each strategy is constructed via CTBase.Orchestration.build_strategy_from_resolved using the options that were routed to its family by _route_flow_options.

Arguments

Returns

  • NamedTuple{(:backend, :integrator)}: Concrete strategy instances.

Example

# Build concrete strategies from routed options
routed = Flows._route_flow_options((; reltol=1e-8))
components = Flows._build_flow_components(routed)
# components.backend isa CTBase.Differentiation.DifferentiationInterface
# components.integrator isa CTFlows.Integrators.SciML

See also: _route_flow_options, flow_registry, CTBase.Orchestration.build_strategy_from_resolved

_core_invoke_flow [Function]

CTFlows.Flows._core_invoke_flowFunction
_core_invoke_flow(
    flow::CTFlows.Flows.AbstractFlow,
    config::CTFlows.Configs.AbstractConfig;
    variable,
    unsafe
)

Internal implementation body for flow integration.

This function performs the actual ODE integration workflow after trait-based dispatch has validated the variable parameter. It extracts the system and integrator from the flow, prepares cache, builds the ODE problem, solves it, and constructs the solution.

Arguments

  • flow::CTFlows.Flows.AbstractFlow: The flow to solve.
  • config::CTFlows.Configs.AbstractConfig: The integration configuration.
  • variable: The variable parameter value (may be nothing for Fixed systems).
  • unsafe: If true, bypass ODE solver retcode checking.

Returns

  • The packaged solution (type varies by config type).

Notes

This is an internal function called by the trait-dispatch overloads of _invoke_flow. Users should call the public _invoke_flow function instead.

See also: _invoke_flow, CTFlows.Integrators.build_problem, CTFlows.Integrators.solve_problem, CTFlows.Trajectories.build_trajectory.

_flow_families [Function]

CTFlows.Flows._flow_familiesFunction
_flow_families(

) -> @NamedTuple{backend::DataType, integrator::DataType}

Return the strategy families used for option routing in flow construction.

The returned NamedTuple maps family names to their abstract types, as expected by CTBase.Orchestration.route_all_options.

Returns

  • NamedTuple: (backend, integrator) mapped to their abstract types

Example

# Get the strategy families for flow construction
fam = Flows._flow_families()
# Returns: (backend = CTBase.Differentiation.AbstractADBackend, integrator = CTFlows.Integrators.AbstractIntegrator)

See also: _route_flow_options, flow_registry

_indent_continuation [Function]

CTFlows.Flows._indent_continuationFunction
_indent_continuation(s::String, n::Int) -> String

Indent every line of a multiline string by n spaces, except the first line.

Arguments

  • s::String: The multiline string to indent.
  • n::Int: Number of spaces to indent continuation lines.

Returns

  • String: The indented string.

Example

_indent_continuation("line1\nline2\nline3", 4)  # Returns "line1\n    line2\n    line3"

_invoke_flow [Function]

CTFlows.Flows._invoke_flowFunction
_invoke_flow(
    flow::CTFlows.Flows.AbstractFlow,
    config::CTFlows.Configs.AbstractConfig;
    variable,
    unsafe
)

Solve an ODE problem using a flow with trait-based dispatch on the variable parameter.

This function dispatches to one of four specialized implementations based on:

  1. The flow's VariableDependence trait (Fixed or NonFixed)
  2. Whether the variable parameter was provided (NotProvided vs any other type)

Dispatch Rules

  • Fixed + NotProvided: Variable not required, proceeds with variable=nothing.
  • Fixed + provided: Throws PreconditionError (Fixed systems must not receive a variable).
  • NonFixed + provided: Variable required, proceeds with the provided value.
  • NonFixed + NotProvided: Throws PreconditionError (NonFixed systems require a variable).

Arguments

  • flow::CTFlows.Flows.AbstractFlow: The flow to solve.
  • config::CTFlows.Configs.AbstractConfig: The integration configuration (e.g., StateEndPointConfig, StateTrajectoryConfig).
  • variable: The variable parameter value (required for NonFixed systems, must be omitted for Fixed systems).
  • unsafe: If true, bypass ODE solver retcode checking; if false, throw SolverFailure on integration failure.

Returns

  • The packaged solution (type varies by config type).

Throws

  • CTBase.Exceptions.PreconditionError: If the variable parameter violates the flow's trait contract.

Example

# Fixed flow: no variable parameter allowed
flow_fixed = Flow(system_fixed, integrator)
config = CTFlows.Configs.StateTrajectoryConfig((0.0, 1.0), [1.0, 0.0])
sol = _invoke_flow(flow_fixed, config; unsafe=false)  # OK, no variable

# NonFixed flow: variable parameter required
flow_nonfixed = Flow(system_nonfixed, integrator)
sol = _invoke_flow(flow_nonfixed, config; variable=0.5, unsafe=false)  # OK, variable provided

See also: CTFlows.Flows.AbstractFlow, CTBase.Traits.VariableDependence, CTBase.Core.NotProvided, CTFlows.Integrators.build_problem, CTFlows.Integrators.solve_problem, CTFlows.Trajectories.build_trajectory.

_invoke_flow(
    ::Type{CTBase.Traits.NonFixed},
    ::Type{CTBase.Core.NotProvidedType},
    flow,
    config;
    unsafe,
    variable
)

Dispatch for NonFixed flows when the variable parameter was not provided.

This overload is selected when a NonFixed flow (which requires a variable) is called without providing the variable argument. It throws a PreconditionError to enforce the contract that NonFixed systems must receive a variable parameter.

Throws

  • CTBase.Exceptions.PreconditionError: Always, with message explaining that a variable is required.

See also

CTBase.Traits.NonFixed, CTBase.Core.NotProvided.

_invoke_flow(
    ::Type{CTBase.Traits.Fixed},
    ::Type{CTBase.Core.NotProvidedType},
    flow,
    config;
    unsafe,
    variable
)

Dispatch for Fixed flows when the variable parameter was not provided.

This overload is selected when a Fixed flow (which does not require a variable) is called without providing the variable argument. This is the expected and valid case, so it forwards to _core_invoke_flow with variable=nothing.

Returns

  • The result of _core_invoke_flow.

See also

CTBase.Traits.Fixed, CTBase.Core.NotProvided, _core_invoke_flow.

_invoke_flow(
    ::Type{CTBase.Traits.NonFixed},
    ::Type{VT},
    flow,
    config;
    unsafe,
    variable
)

Dispatch for NonFixed flows when a variable parameter is provided.

This overload is selected when a NonFixed flow (which requires a variable) is called with a provided variable parameter. This is the expected and valid case, so it forwards to _core_invoke_flow with the provided variable value.

Returns

  • The result of _core_invoke_flow.

See also

CTBase.Traits.NonFixed, _core_invoke_flow.

_invoke_flow(
    ::Type{CTBase.Traits.Fixed},
    ::Type{VT},
    flow,
    config;
    unsafe,
    variable
)

Dispatch for Fixed flows when a variable parameter is provided.

This overload is selected when a Fixed flow (which does not require a variable) is called with a provided variable parameter. This violates the contract that Fixed systems must not receive a variable parameter, so it throws a PreconditionError.

Throws

  • CTBase.Exceptions.PreconditionError: Always, with message explaining that variables must not be provided to Fixed flows.

See also

CTBase.Traits.Fixed.

_invoke_flow_variable_costate [Function]

CTFlows.Flows._invoke_flow_variable_costateFunction
_invoke_flow_variable_costate(
    flow::CTFlows.Flows.AbstractHamiltonianFlow,
    config::CTFlows.Configs.AbstractHamiltonianConfig;
    variable,
    unsafe
)

Call a Hamiltonian flow with variable costate integration.

Dispatches on the flow's variable_costate_trait to determine if augmented integration is supported.

Arguments

  • flow::AbstractHamiltonianFlow: The Hamiltonian flow.
  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian point configuration.
  • variable: The variable parameter value.
  • unsafe: If true, bypass ODE solver retcode checking.

Returns

  • The augmented solution (xf, pf, pvf) if supported, or throws an error.

Throws

  • CTBase.Exceptions.IncorrectArgument: If the flow does not support variable costate.

See also: CTBase.Traits.variable_costate_trait, CTBase.Traits.SupportsVariableCostate, CTBase.Traits.NoVariableCostate.

_invoke_flow_variable_costate(
    ::Type{CTBase.Traits.NoVariableCostate},
    ::Type{VT},
    flow::CTFlows.Flows.AbstractHamiltonianFlow,
    config::CTFlows.Configs.HamiltonianEndPointConfig;
    variable,
    unsafe
)

Variable costate call for flows that do not support it.

This method handles the error case where a flow does not support variable costate computation (typically because the Hamiltonian is not variable-dependent).

Throws

  • CTBase.Exceptions.PreconditionError: Always, with a descriptive message indicating that the flow does not support variable costate.

See also: CTBase.Traits.NoVariableCostate.

_invoke_flow_variable_costate(
    ::Type{CTBase.Traits.SupportsVariableCostate},
    ::Type{VT},
    flow::CTFlows.Flows.AbstractHamiltonianFlow,
    config::CTFlows.Configs.HamiltonianEndPointConfig;
    variable,
    unsafe
)

Variable costate call for flows that support it.

Constructs an AugmentedHamiltonianEndPointConfig with zero initial variable costate and calls the flow with it.

Arguments

  • ::Type{Traits.SupportsVariableCostate}: The capability trait.
  • flow::AbstractHamiltonianFlow: The Hamiltonian flow.
  • config::Configs.HamiltonianEndPointConfig: The base Hamiltonian point configuration.
  • variable: The variable parameter value.
  • unsafe: If true, bypass ODE solver retcode checking.

Returns

  • Tuple{AbstractVector, AbstractVector, AbstractVector}: The augmented solution (xf, pf, pvf).

See also: CTBase.Traits.SupportsVariableCostate, CTFlows.Configs.AugmentedHamiltonianEndPointConfig.

_invoke_flow_variable_costate(
    ::Type{CTBase.Traits.SupportsVariableCostate},
    ::Type{CTBase.Core.NotProvidedType},
    flow::CTFlows.Flows.AbstractHamiltonianFlow,
    config::CTFlows.Configs.HamiltonianEndPointConfig;
    variable,
    unsafe
)

Variable costate call when the variable parameter is not provided.

This method handles the error case where a flow supports variable costate computation but the user did not provide the required variable parameter.

Throws

  • CTBase.Exceptions.PreconditionError: Always, with a descriptive message indicating that the variable parameter must be provided.

See also: CTBase.Traits.SupportsVariableCostate, CTBase.Core.NotProvided.

_invoke_flow_variable_costate(
    ::Type{CTBase.Traits.SupportsVariableCostate},
    ::Type{VT},
    flow::CTFlows.Flows.AbstractHamiltonianFlow,
    config::CTFlows.Configs.HamiltonianTrajectoryConfig;
    variable,
    unsafe
)

Variable costate call for trajectory configurations.

Variable costate computation is only supported for point configurations, not trajectory configurations. This method throws an error when attempting to use variable_costate=true with a trajectory configuration.

Throws

  • CTBase.Exceptions.PreconditionError: Always, with a descriptive message indicating that variable_costate is only supported for point configurations.

See also: CTBase.Traits.SupportsVariableCostate, CTFlows.Configs.HamiltonianTrajectoryConfig.

_print_user_options [Function]

CTFlows.Flows._print_user_optionsFunction
_print_user_options(io::IO, integ::Integrators.AbstractIntegrator)

Print user-supplied integrator options inline: (key = val, …). Silently does nothing when no user options are set.

Arguments

  • io::IO: The IO stream to write to.
  • integ::Integrators.AbstractIntegrator: The integrator to inspect for user options.

Example

# If user options are set: prints " (abstol = 1e-8, reltol = 1e-6)"
# If no user options: prints nothing

_route_flow_options [Function]

CTFlows.Flows._route_flow_optionsFunction
_route_flow_options(
    kwargs
) -> NamedTuple{(:action, :strategies), <:Tuple{NamedTuple, NamedTuple}}

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

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

Arguments

  • kwargs: All keyword arguments from the user's Flow call (strategy options only, no action-level options).

Returns

  • NamedTuple with fields:
    • action: action-level options (always empty for flows)
    • strategies: NamedTuple with backend and integrator sub-tuples

Throws

Example

# Route options to backend and integrator
routed = Flows._route_flow_options((; reltol=1e-8, ad_backend=ADTypes.AutoForwardDiff()))
# routed.strategies.integrator contains (reltol = 1e-8,)
# routed.strategies.backend contains (ad_backend = AutoForwardDiff(),)

Notes

  • This function uses :description source mode for user-friendly error messages.
  • No action-level options are defined for flows (empty OptionDefinition array).

See also: _flow_families, _build_flow_components, CTBase.Orchestration.route_all_options