Skip to content

Public API ​

This page lists exported symbols of CTBase.Data.


From CTBase.Data ​

CTBase.Data [Module] ​

CTBase.Data Module
julia
Data

Data structures including vector fields and Hamiltonian vector fields with traits.

This module defines the VectorField and HamiltonianVectorField types which encapsulate vector-field functions together with their time-dependence and variable-dependence traits.

AbstractConstrainedPseudoHamiltonian [Abstract Type] ​

CTBase.Data.AbstractConstrainedPseudoHamiltonian Type
julia
abstract type AbstractConstrainedPseudoHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for scalar constrained pseudo-Hamiltonian functions together with their time-dependence and variable-dependence traits.

A constrained pseudo-Hamiltonian is the function of the maximum principle for a problem with path constraints:

where the multiplier μ is an explicit argument, like the control u. The extremals are given by the partial derivatives of H with respect to x and p, at fixed u and μ; see CTBase.Data.freeze_multiplier.

It is not an CTBase.Data.AbstractPseudoHamiltonian: its call signatures have one more argument.

Type Parameters

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Interface Requirements

A subtype H <: AbstractConstrainedPseudoHamiltonian{TD,VD} implements two calls:

  • the natural call of its traits: H(x, p, u, μ), H(t, x, p, u, μ), H(x, p, u, μ, v) or H(t, x, p, u, μ, v);

  • the uniform call H(t, x, p, u, μ, v), which ignores the arguments its traits do not use.

The traits and the dynamics trait come from the abstract type. With these two calls, CTBase.Data.freeze_multiplier and CTBase.Data.ComposedConstrainedHamiltonian accept the subtype, and so do the gradient primitives of CTBase.Differentiation through them. CTBase.Data.ConstrainedPseudoHamiltonian is the subtype that wraps a plain function.

Notes

  • The uniform signature (t, x, p, u, μ, v) is used internally by flows.

  • The dynamics trait is always HamiltonianDynamics.

See also: CTBase.Data.ConstrainedPseudoHamiltonian, CTBase.Data.AbstractPseudoHamiltonian, CTBase.Data.ComposedConstrainedHamiltonian.

AbstractControlLaw [Abstract Type] ​

CTBase.Data.AbstractControlLaw Type
julia
abstract type AbstractControlLaw{FB<:CTBase.Traits.AbstractFeedback, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for control laws together with their feedback, time-dependence, and variable-dependence traits.

A control law is a function u(...) that provides the control input for an optimal control problem. The feedback trait (CTBase.Traits.AbstractFeedback) determines which arguments the control law depends on:

  • Open-loop: u(t[, v]) — depends on time (and variable) only.

  • Closed-loop: u(t, x[, v]) — depends on time and state.

  • Dynamic closed-loop: u(t, x, p[, v]) — depends on time, state, and costate.

Type Parameters

  • FB <: AbstractFeedback: OpenLoopFeedback, ClosedLoopFeedback, or DynClosedLoopFeedback.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Notes

  • All control law types support both natural and uniform call signatures.

  • The uniform signature depends on the feedback trait:

    • OpenLoop: u(t, v) — no state, no costate.

    • ClosedLoop: u(t, x, v) — state but no costate.

    • DynClosedLoop: u(t, x, p, v) — state and costate.

  • OpenLoop is always NonAutonomous: u(t[, v]) is unconditional — there is no autonomous/zero-argument form. Autonomy is a property of the OCP, not of an open-loop control (see control-toolbox/CTBase.jl#515), so the OpenLoop constructor rejects is_autonomous as a meaningful choice (it is accepted only as a misuse detector, see CTBase.Data.OpenLoop). Once constructed, Traits.time_dependence/Traits.is_autonomous on an OpenLoop control law answer honestly — NonAutonomous/false — the trait is not hidden, it is simply fixed. ClosedLoop/DynClosedLoop are unaffected.

See also: CTBase.Data.ControlLaw, CTBase.Traits.AbstractFeedback, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

AbstractControlledVectorField [Abstract Type] ​

CTBase.Data.AbstractControlledVectorField Type
julia
abstract type AbstractControlledVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for controlled vector-field functions together with their time-dependence and variable-dependence traits.

A controlled vector field is a function fc(t, x, u[, v]) returning the state derivative, with an explicit control argument u. It is the state-space analogue of CTBase.Data.AbstractPseudoHamiltonian: where a pseudo-Hamiltonian carries the control alongside the costate, a controlled vector field carries the control alongside the state. It is always out-of-place (returns the derivative), so unlike CTBase.Data.AbstractVectorField it has no mutability trait.

Composing a controlled vector field with an open-loop or closed-loop control law eliminates the control and yields a plain CTBase.Data.ComposedVectorField.

Type Parameters

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Notes

  • All controlled vector fields support both natural and uniform call signatures.

  • The uniform signature (t, x, u, v) is used internally by composition.

  • The dynamics trait is always StateDynamics.

See also: CTBase.Data.ControlledVectorField, CTBase.Data.ComposedVectorField, CTBase.Data.AbstractPseudoHamiltonian.

AbstractHamiltonian [Abstract Type] ​

CTBase.Data.AbstractHamiltonian Type
julia
abstract type AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for scalar Hamiltonian functions together with their time-dependence and variable-dependence traits.

A Hamiltonian is a scalar function H(t, x, p[, v]) → ℝ from which a Hamiltonian vector field can be derived via automatic differentiation. Unlike vector fields, a Hamiltonian has no mutability trait (in-place vs out-of-place) because a scalar return has no meaningful in-place form.

Type Parameters

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Notes

  • All Hamiltonian types support both natural and uniform call signatures.

  • The uniform signature (t, x, p, v) is used internally by systems.

See also: CTBase.Data.Hamiltonian, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

AbstractHamiltonianVectorField [Abstract Type] ​

CTBase.Data.AbstractHamiltonianVectorField Type
julia
abstract type AbstractHamiltonianVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractVectorField{TD, VD, MD}

Abstract supertype for Hamiltonian vector fields.

A Hamiltonian vector field represents the dynamics of a Hamiltonian system, combining state and costate evolution according to Hamilton's equations. It extends AbstractVectorField with the additional structure required for Hamiltonian mechanics.

Type Parameters

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

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

  • MD <: AbstractMutabilityTrait: Mutability trait (InPlace or OutOfPlace)

Interface Requirements

All subtypes must implement:

  • Call signature: (t, x, p) or (x, p) depending on time dependence

  • Returns the combined state-costate derivative vector

Example

julia
julia> using CTBase: Data

julia> Data.HamiltonianVectorField <: Data.AbstractHamiltonianVectorField
true

See also: CTBase.Data.AbstractVectorField, CTBase.Data.HamiltonianVectorField, CTBase.Data.Hamiltonian.

AbstractMultiplier [Abstract Type] ​

CTBase.Data.AbstractMultiplier Type
julia
abstract type AbstractMultiplier{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for path-constraint multiplier functions together with their time-dependence and variable-dependence traits.

A multiplier is a function μ(t, x, p[, v]) returning the Lagrange multiplier associated with a path constraint. It has the same call structure as a CTBase.Data.AbstractHamiltonian (it depends on the state and costate), but carries no dynamics semantics of its own.

Type Parameters

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Notes

  • All multiplier types support both natural and uniform call signatures.

  • The uniform signature (t, x, p, v) is used internally by flows.

See also: CTBase.Data.Multiplier, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

AbstractPathConstraint [Abstract Type] ​

CTBase.Data.AbstractPathConstraint Type
julia
abstract type AbstractPathConstraint{K<:CTBase.Traits.AbstractConstraintKind, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for path constraints together with their constraint-kind, time-dependence, and variable-dependence traits.

A path constraint is a function g(...) evaluated along the trajectory of an optimal control problem. The constraint-kind trait (CTBase.Traits.AbstractConstraintKind) determines which primal variables the constraint depends on:

  • State: g(x) — depends on the state (and optionally time and variable).

  • Control: g(u) — depends on the control (and optionally time and variable).

  • Mixed: g(x, u) — depends on both state and control.

Type Parameters

  • K <: AbstractConstraintKind: StateConstraintKind, ControlConstraintKind, or MixedConstraintKind.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Notes

  • All path constraint types support both natural and uniform call signatures.

  • The uniform signature is always g(t, x, u, v), ignoring the unused arguments.

See also: CTBase.Data.PathConstraint, CTBase.Traits.AbstractConstraintKind, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

AbstractPseudoHamiltonian [Abstract Type] ​

CTBase.Data.AbstractPseudoHamiltonian Type
julia
abstract type AbstractPseudoHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Abstract supertype for scalar pseudo-Hamiltonian functions together with their time-dependence and variable-dependence traits.

A pseudo-Hamiltonian is a scalar function H̃(t, x, p, u[, v]) → ℝ that extends the standard Hamiltonian with an explicit control argument u. Unlike CTBase.Data.AbstractHamiltonian, which encodes the control implicitly, a pseudo-Hamiltonian takes the control as an additional argument, enabling dynamic closed-loop flows where the control is computed from the pseudo-Hamiltonian's maximisation condition.

Type Parameters

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Notes

  • All pseudo-Hamiltonian types support both natural and uniform call signatures.

  • The uniform signature (t, x, p, u, v) is used internally by flow integrators.

  • The dynamics trait is always HamiltonianDynamics, as pseudo-Hamiltonians involve both state and costate.

See also: CTBase.Data.PseudoHamiltonian, CTBase.Data.AbstractHamiltonian, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

AbstractPseudoHamiltonianVectorField [Abstract Type] ​

CTBase.Data.AbstractPseudoHamiltonianVectorField Type
julia
abstract type AbstractPseudoHamiltonianVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractVectorField{TD, VD, MD}

Abstract supertype for pseudo-Hamiltonian vector fields.

A pseudo-Hamiltonian vector field represents the already-differentiated dynamics (ẋ, ṗ) = (dx, dp)(t, x, p, u[, v]) of a pseudo-Hamiltonian system, with an explicit control argument u — the vector-field analogue of CTBase.Data.AbstractPseudoHamiltonian, exactly as CTBase.Data.AbstractHamiltonianVectorField is the vector-field analogue of CTBase.Data.AbstractHamiltonian. It extends AbstractVectorField with the additional structure required for Hamiltonian mechanics.

AbstractPseudoHamiltonianVectorField is a sibling of CTBase.Data.AbstractHamiltonianVectorField, not a subtype of it — mirroring how CTBase.Data.AbstractPseudoHamiltonian is a sibling of, not a subtype of, CTBase.Data.AbstractHamiltonian: a pseudo-Hamiltonian vector field's natural call signature carries an extra control argument u that a plain Hamiltonian vector field does not have.

Type Parameters

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

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

  • MD <: AbstractMutabilityTrait: Mutability trait (InPlace or OutOfPlace)

Interface Requirements

All subtypes must implement:

  • Call signature: (t, x, p, u) or (x, p, u) depending on time dependence, plus v for non-fixed problems.

  • Returns the combined state-costate derivative (dx, dp).

See also: CTBase.Data.AbstractVectorField, CTBase.Data.PseudoHamiltonianVectorField, CTBase.Data.AbstractHamiltonianVectorField, CTBase.Data.AbstractPseudoHamiltonian.

AbstractVectorField [Abstract Type] ​

CTBase.Data.AbstractVectorField Type
julia
abstract type AbstractVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait}

Abstract type for all vector fields in the control-toolbox ecosystem.

An AbstractVectorField represents a vector field function with time-dependence, variable-dependence, and mutability traits encoded in the type parameters.

Contract

All subtypes must have type parameters:

  • TD <: Traits.TimeDependence: Autonomous or NonAutonomous

  • VD <: Traits.VariableDependence: Fixed or NonFixed

  • MD <: Traits.AbstractMutabilityTrait: InPlace or OutOfPlace

Trait accessors are implemented at the abstract level and work for all subtypes.

Example

julia
using CTBase: Data
using CTBase: Traits

# Define a concrete vector field
struct MyVectorField{F, TD, VD, MD} <: Data.AbstractVectorField{TD, VD, MD}
    f::F
end

# Trait accessors work automatically
vf = MyVectorField(x -> -x, Traits.Autonomous, Traits.Fixed, Traits.OutOfPlace)
Traits.time_dependence(vf)  # Returns Autonomous
Traits.variable_dependence(vf)  # Returns Fixed
Traits.mutability(vf)  # Returns OutOfPlace

See also: CTBase.Data.VectorField, CTBase.Data.HamiltonianVectorField, CTBase.Traits.time_dependence, CTBase.Traits.variable_dependence, CTBase.Traits.mutability.

ClosedLoop [Function] ​

CTBase.Data.ClosedLoop Function
julia
ClosedLoop(
    f;
    is_autonomous::Bool,
    is_variable::Bool
) -> CTBase.Data.ControlLaw{F, CTBase.Traits.ClosedLoopFeedback} where F<:Function

Construct a closed-loop ControlLaw.

A closed-loop control law depends on the state (and optionally time and variable), but not on the costate.

Arguments

  • f::Function: The control law function.

  • is_autonomous::Bool: If true, control law is autonomous (default: __is_autonomous()).

  • is_variable::Bool: If true, control law depends on variable (default: __is_variable()).

Expected signature

f(x) by default; f(t, x) if is_autonomous=false; f(x, v) if is_variable=true; f(t, x, v) if both. The signature is not checked at construction: a mismatch surfaces as a MethodError at the first call.

Example

julia
julia> using CTBase: Data

julia> u = Data.ClosedLoop(x -> -x)
ControlLaw: closed-loop, autonomous, fixed (no variable)
  natural call: u(x)
  uniform call: u(t, x, v)

See also: CTBase.Data.OpenLoop, CTBase.Data.DynClosedLoop, CTBase.Data.ControlLaw.

ComposedConstrainedHamiltonian [Struct] ​

CTBase.Data.ComposedConstrainedHamiltonian Type
julia
struct ComposedConstrainedHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, PH<:CTBase.Data.AbstractConstrainedPseudoHamiltonian, L<:CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}, M<:CTBase.Data.Multiplier} <: CTBase.Data.AbstractHamiltonian{TD, VD}

Hamiltonian obtained by eliminating the control and the multiplier from a constrained pseudo-Hamiltonian (any CTBase.Data.AbstractConstrainedPseudoHamiltonian, such as a CTBase.Data.ConstrainedPseudoHamiltonian), with a dynamic closed-loop CTBase.Data.ControlLaw and a CTBase.Data.Multiplier, both in feedback form:

It is a functor, so automatic differentiation goes through the control law and the multiplier: its gradient is the total derivative (the :total mode of a flow), which differs from the partial derivatives of the maximum principle by the terms ∂H/∂u · ∂u/∂x and ∂H/∂μ · ∂μ/∂x. On an optimal arc these terms vanish; for the partial derivatives at any point, see CTBase.Data.freeze_multiplier.

It subtypes CTBase.Data.AbstractHamiltonian: all trait accessors are inherited, and it can be used anywhere a Hamiltonian is expected.

Type Parameters

  • TD <: TimeDependence: the join of the time dependences of the three inputs (NonAutonomous if any of them depends on time).

  • VD <: VariableDependence: the join of the three variable dependences (NonFixed if any of them depends on the variable).

  • PH <: AbstractConstrainedPseudoHamiltonian: type of the constrained pseudo-Hamiltonian.

  • L <: ControlLaw: concrete control-law type (must carry DynClosedLoopFeedback).

  • M <: Multiplier: concrete multiplier type.

Fields

  • h::PH: the constrained pseudo-Hamiltonian H(t, x, p, u, μ, v).

  • law::L: the dynamic closed-loop control law u(t, x, p, v).

  • μ::M: the multiplier μ(t, x, p, v).

Construction

julia
ComposedConstrainedHamiltonian(H, law, μ)   # law must carry DynClosedLoopFeedback

Example

julia
julia> using CTBase: Data

julia> H = Data.ConstrainedPseudoHamiltonian((x, p, u, μ) -> p * u - x^2 + μ * (x - 0.1));

julia> h = Data.ComposedConstrainedHamiltonian(
           H, Data.DynClosedLoop((x, p) -> 0.0), Data.Multiplier((x, p) -> 2x)
       );

julia> h(1.0, 2.0) == H(1.0, 2.0, 0.0, 2.0)
true

See also: CTBase.Data.ConstrainedPseudoHamiltonian, CTBase.Data.ComposedHamiltonian, CTBase.Data.DynClosedLoop, CTBase.Data.Multiplier.

ComposedHamiltonian [Struct] ​

CTBase.Data.ComposedHamiltonian Type
julia
struct ComposedHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}} <: CTBase.Data.AbstractHamiltonian{TD, VD}

Hamiltonian obtained by eliminating the control from a CTBase.Data.PseudoHamiltonian with a dynamic closed-loop CTBase.Data.ControlLaw:

It is a functor (a struct with call methods), not a closure, so it aligns with the ecosystem philosophy and can be differentiated through the control law by automatic differentiation (the total derivative, :total mode of the OCP flow).

Since it subtypes CTBase.Data.AbstractHamiltonian, it is a Hamiltonian: all trait accessors are inherited, and it can be stored anywhere an AbstractHamiltonian is expected.

Type Parameters

  • TD <: TimeDependence: time dependence of the composed Hamiltonian — the join of the pseudo-Hamiltonian's and the control law's time dependences (NonAutonomous if either depends on time).

  • VD <: VariableDependence: variable dependence — the join of the two variable dependences (NonFixed if either depends on the variable).

  • PH <: PseudoHamiltonian: concrete pseudo-Hamiltonian type.

  • L <: ControlLaw: concrete control-law type (must carry DynClosedLoopFeedback).

Fields

  • h̃::PH: the pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: the dynamic closed-loop control law u(t, x, p, v).

Construction

julia
ComposedHamiltonian(h̃, law)   # law must carry DynClosedLoopFeedback

The composed time/variable dependences are the join of the two inputs, so a time-varying feedback on an autonomous pseudo-Hamiltonian correctly yields a NonAutonomous composed Hamiltonian.

See also: CTBase.Data.PseudoHamiltonian, CTBase.Data.ControlLaw, CTBase.Data.DynClosedLoop, CTBase.Data.AbstractHamiltonian.

ComposedVectorField [Struct] ​

CTBase.Data.ComposedVectorField Type
julia
struct ComposedVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CVF<:CTBase.Data.ControlledVectorField, L<:CTBase.Data.ControlLaw{<:Function, <:Union{CTBase.Traits.ClosedLoopFeedback, CTBase.Traits.OpenLoopFeedback}}} <: CTBase.Data.AbstractVectorField{TD, VD, CTBase.Traits.OutOfPlace}

Vector field obtained by eliminating the control from a CTBase.Data.ControlledVectorField with an open-loop or closed-loop CTBase.Data.ControlLaw:

where the control is u(t, v) for an open-loop law and u(t, x, v) for a closed-loop law. It is the state-space analogue of CTBase.Data.ComposedHamiltonian.

It is a functor (not a closure), out-of-place, and subtypes CTBase.Data.AbstractVectorField with OutOfPlace mutability — so it is a vector field usable anywhere one is expected.

Type Parameters

  • TD <: TimeDependence, VD <: VariableDependence: the join of the controlled vector field's and the control law's dependences.

  • CVF <: ControlledVectorField: concrete controlled vector-field type.

  • L <: ControlLaw: concrete control-law type (must carry OpenLoopFeedback or ClosedLoopFeedback).

Fields

  • fc::CVF: the controlled vector field fc(t, x, u, v).

  • law::L: the open-loop or closed-loop control law.

See also: CTBase.Data.ControlledVectorField, CTBase.Data.ControlLaw, CTBase.Data.OpenLoop, CTBase.Data.ClosedLoop, CTBase.Data.ComposedHamiltonian.

ConstrainedPseudoHamiltonian [Struct] ​

CTBase.Data.ConstrainedPseudoHamiltonian Type
julia
struct ConstrainedPseudoHamiltonian{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractConstrainedPseudoHamiltonian{TD, VD}

Parametric container for a scalar constrained pseudo-Hamiltonian function together with its time-dependence and variable-dependence traits:

The multiplier μ is an explicit argument, like the control u: this is the pseudo-Hamiltonian of the maximum principle for a problem with path constraints. How the constraint term is written (sign of p⁰, normalisation of g) belongs to the function f; this container only carries the traits and the call signatures.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the constrained pseudo-Hamiltonian function, with its natural arity.

Construction

julia
ConstrainedPseudoHamiltonian(f; is_autonomous = true, is_variable = false)    # H(x, p, u, μ)
ConstrainedPseudoHamiltonian((t, x, p, u, μ) -> ...; is_autonomous = false)  # H(t, x, p, u, μ)
ConstrainedPseudoHamiltonian((x, p, u, μ, v) -> ...; is_variable = true)     # H(x, p, u, μ, v)
ConstrainedPseudoHamiltonian(f, TD, VD)                                      # typed traits

Call Signatures

Every ConstrainedPseudoHamiltonian is callable via its natural signature (matching the traits), and via a uniform signature (t, x, p, u, μ, v) that ignores unused arguments.

TD / VDNaturalUniform
Autonomous / FixedH(x, p, u, μ)H(t, x, p, u, μ, v)
NonAutonomous / FixedH(t, x, p, u, μ)H(t, x, p, u, μ, v)
Autonomous / NonFixedH(x, p, u, μ, v)H(t, x, p, u, μ, v)
NonAutonomous / NonFixedH(t, x, p, u, μ, v)H(t, x, p, u, μ, v)

Example

julia
julia> using CTBase: Data

julia> H = Data.ConstrainedPseudoHamiltonian((x, p, u, μ) -> p * u - x^2 + μ * (x - 0.1))
ConstrainedPseudoHamiltonian: autonomous, fixed (no variable)
  natural call: H(x, p, u, μ)
  uniform call: H(t, x, p, u, μ, v)

julia> H(1.0, 2.0, 0.5, 3.0)
2.7

See also: CTBase.Data.AbstractConstrainedPseudoHamiltonian, CTBase.Data.freeze_multiplier, CTBase.Data.ComposedConstrainedHamiltonian, CTBase.Data.PseudoHamiltonian.

ControlConstraint [Function] ​

CTBase.Data.ControlConstraint Function
julia
ControlConstraint(
    f;
    is_autonomous::Bool,
    is_variable::Bool
) -> CTBase.Data.PathConstraint{F, CTBase.Traits.ControlConstraintKind} where F<:Function

Construct a pure control PathConstraint.

A control constraint depends on the control (and optionally time and variable), but not on the state.

Arguments

  • f::Function: The path-constraint function.

  • is_autonomous::Bool: If true, constraint is autonomous (default: __is_autonomous()).

  • is_variable::Bool: If true, constraint depends on variable (default: __is_variable()).

Example

julia
julia> using CTBase: Data

julia> g = Data.ControlConstraint(u -> u[1])
PathConstraint: control, autonomous, fixed (no variable)
  natural call: g(u)
  uniform call: g(t, x, u, v)

See also: CTBase.Data.StateConstraint, CTBase.Data.MixedConstraint, CTBase.Data.PathConstraint.

ControlLaw [Struct] ​

CTBase.Data.ControlLaw Type
julia
struct ControlLaw{F<:Function, FB<:CTBase.Traits.AbstractFeedback, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractControlLaw{FB, TD, VD}

Parametric container for a control law function together with its feedback, time-dependence, and variable-dependence traits.

The function provides the control input u(...) for an optimal control problem. The feedback trait determines which arguments the control law depends on (see CTBase.Data.AbstractControlLaw).

Type Parameters

  • F: concrete type of the wrapped function.

  • FB <: AbstractFeedback: OpenLoopFeedback, ClosedLoopFeedback, or DynClosedLoopFeedback.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the control law function.

Construction

Use the user-facing constructors OpenLoop, ClosedLoop, or DynClosedLoop:

julia
OpenLoop(u; is_variable = false)                               # default: u(t)
ClosedLoop(u; is_autonomous = true, is_variable = false)      # default: u(x)
DynClosedLoop(u; is_autonomous = true, is_variable = false)   # default: u(x, p)

OpenLoop's is_autonomous is not a real choice — an open-loop control is unconditionally NonAutonomous and always depends on time (see CTBase.Data.OpenLoop).

Call Signatures

Every ControlLaw is callable via its natural signature (matching the traits), and via a uniform signature that depends on the feedback trait:

FeedbackNatural (Aut, Fixed)Uniform
OpenLoopu(t) (Aut is always NonAutonomous)u(t, v)
ClosedLoopu(x)u(t, x, v)
DynClosedLoopu(x, p)u(t, x, p, v)

The uniform signature is used by flow integrators. Unused arguments are ignored.

See also: CTBase.Data.AbstractControlLaw, CTBase.Data.OpenLoop, CTBase.Data.ClosedLoop, CTBase.Data.DynClosedLoop, CTBase.Traits.AbstractFeedback.

ControlledVectorField [Struct] ​

CTBase.Data.ControlledVectorField Type
julia
struct ControlledVectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractControlledVectorField{TD, VD}

Parametric container for a controlled vector-field function together with its time-dependence and variable-dependence traits.

The function returns the state derivative fc(t, x, u[, v]) with an explicit control argument u, out-of-place. It is the state-space analogue of CTBase.Data.PseudoHamiltonian, and composing it with an open-loop or closed-loop control law gives a CTBase.Data.ComposedVectorField.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the controlled vector-field function.

Construction

julia
ControlledVectorField(f; is_autonomous = true, is_variable = false)   # default: fc(x, u)
ControlledVectorField((t, x, u) -> ...; is_autonomous = false)        # fc(t, x, u)
ControlledVectorField((x, u, v) -> ...; is_variable = true)           # fc(x, u, v)

Call Signatures

Callable via its natural signature (matching the traits) and via a uniform signature (t, x, u, v) that ignores unused arguments.

(TD, VD)naturaluniform
(Autonomous, Fixed)fc(x, u)fc(t, x, u, v)
(NonAutonomous, Fixed)fc(t, x, u)fc(t, x, u, v)
(Autonomous, NonFixed)fc(x, u, v)fc(t, x, u, v)
(NonAutonomous, NonFixed)fc(t, x, u, v)fc(t, x, u, v)

See also: CTBase.Data.AbstractControlledVectorField, CTBase.Data.ComposedVectorField, CTBase.Data.PseudoHamiltonian.

DynClosedLoop [Function] ​

CTBase.Data.DynClosedLoop Function
julia
DynClosedLoop(
    f;
    is_autonomous::Bool,
    is_variable::Bool
) -> CTBase.Data.ControlLaw{F, CTBase.Traits.DynClosedLoopFeedback} where F<:Function

Construct a dynamic closed-loop ControlLaw.

A dynamic closed-loop control law depends on both the state and the costate (and optionally time and variable).

Arguments

  • f::Function: The control law function.

  • is_autonomous::Bool: If true, control law is autonomous (default: __is_autonomous()).

  • is_variable::Bool: If true, control law depends on variable (default: __is_variable()).

Expected signature

f(x, p) by default; f(t, x, p) if is_autonomous=false; f(x, p, v) if is_variable=true; f(t, x, p, v) if both. The signature is not checked at construction: a mismatch surfaces as a MethodError at the first call.

Example

julia
julia> using CTBase: Data

julia> u = Data.DynClosedLoop((x, p) -> -x - p)
ControlLaw: dyn-closed-loop, autonomous, fixed (no variable)
  natural call: u(x, p)
  uniform call: u(t, x, p, v)

See also: CTBase.Data.OpenLoop, CTBase.Data.ClosedLoop, CTBase.Data.ControlLaw.

Hamiltonian [Struct] ​

CTBase.Data.Hamiltonian Type
julia
struct Hamiltonian{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractHamiltonian{TD, VD}

Parametric container for a scalar Hamiltonian function together with its time-dependence and variable-dependence traits.

The function returns a scalar value H(t, x, p[, v]) → ℝ representing the Hamiltonian of the system.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the Hamiltonian function.

Construction

Use the keyword constructor:

julia
Hamiltonian(f; is_autonomous = true, is_variable = false)        # default: h(x, p)
Hamiltonian((t, x, p) -> ...; is_autonomous = false)             # h(t, x, p)
Hamiltonian((x, p, v) -> ...; is_variable = true)                # h(x, p, v)
Hamiltonian((t, x, p, v) -> ...; is_autonomous = false, is_variable = true)

Call Signatures

Every Hamiltonian is callable via its natural signature (matching the traits), and via a uniform signature (t, x, p, v) that ignores the unused arguments.

For Autonomous/Fixed: natural h(x, p), uniform h(t, x, p, v). For NonAutonomous/Fixed: natural h(t, x, p), uniform h(t, x, p, v). For Autonomous/NonFixed: natural h(x, p, v), uniform h(t, x, p, v). For NonAutonomous/NonFixed: natural h(t, x, p, v), uniform h(t, x, p, v).

Example

julia
julia> using CTBase: Data

julia> h = Data.Hamiltonian((x, p) -> dot(x, p))  # Uses defaults: is_autonomous=true, is_variable=false
Hamiltonian: autonomous, fixed (no variable)
  natural call: h(x, p)
  uniform call: h(t, x, p, v)

julia> h = Data.Hamiltonian((t, x, p) -> t * dot(x, p); is_autonomous=false)
Hamiltonian: non-autonomous, fixed (no variable)
  natural call: h(t, x, p)
  uniform call: h(t, x, p, v)

See also: CTBase.Data.AbstractHamiltonian, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

HamiltonianVectorField [Struct] ​

CTBase.Data.HamiltonianVectorField Type
julia
struct HamiltonianVectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractHamiltonianVectorField{TD, VD, MD}

Parametric container for a Hamiltonian vector field function together with its time-dependence, variable-dependence, and mutability traits.

The function returns a tuple (dx, dp) representing the derivatives of state x and costate p according to Hamiltonian dynamics.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

  • MD <: AbstractMutabilityTrait: InPlace or OutOfPlace.

Fields

  • f::F: the Hamiltonian vector field function.

Construction

Use the keyword constructor:

julia
HamiltonianVectorField(f; is_autonomous = true, is_variable = false)        # default: f(x, p)
HamiltonianVectorField((t, x, p) -> ...; is_autonomous = false)             # f(t, x, p)
HamiltonianVectorField((x, p, v) -> ...; is_variable = true)                # f(x, p, v)
HamiltonianVectorField((t, x, p, v) -> ...; is_autonomous = false, is_variable = true)

The mutability trait (InPlace/OutOfPlace) is auto-detected from the function signature.

Call Signatures

Every HamiltonianVectorField is callable via its natural signature (matching the traits), and via a uniform signature (t, x, p, v) that ignores the unused arguments.

For InPlace Hamiltonian vector fields, the natural signature includes the derivative buffers as the first two arguments (e.g., (dx, dp, x, p) for Autonomous/Fixed).

See also: CTBase.Data.AbstractVectorField, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence, CTBase.Traits.AbstractMutabilityTrait.

MixedConstraint [Function] ​

CTBase.Data.MixedConstraint Function
julia
MixedConstraint(
    f;
    is_autonomous::Bool,
    is_variable::Bool
) -> CTBase.Data.PathConstraint{F, CTBase.Traits.MixedConstraintKind} where F<:Function

Construct a mixed state–control PathConstraint.

A mixed constraint depends on both the state and the control (and optionally time and variable).

Arguments

  • f::Function: The path-constraint function.

  • is_autonomous::Bool: If true, constraint is autonomous (default: __is_autonomous()).

  • is_variable::Bool: If true, constraint depends on variable (default: __is_variable()).

Example

julia
julia> using CTBase: Data

julia> g = Data.MixedConstraint((x, u) -> x[1] + u[1])
PathConstraint: mixed, autonomous, fixed (no variable)
  natural call: g(x, u)
  uniform call: g(t, x, u, v)

See also: CTBase.Data.StateConstraint, CTBase.Data.ControlConstraint, CTBase.Data.PathConstraint.

Multiplier [Struct] ​

CTBase.Data.Multiplier Type
julia
struct Multiplier{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractMultiplier{TD, VD}

Parametric container for a path-constraint multiplier function together with its time-dependence and variable-dependence traits.

The function returns the Lagrange multiplier μ(t, x, p[, v]) associated with a path constraint. It has the same call structure as a CTBase.Data.Hamiltonian.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the multiplier function.

Construction

Use the keyword constructor:

julia
Multiplier(f; is_autonomous = true, is_variable = false)      # default: μ(x, p)
Multiplier((t, x, p) -> ...; is_autonomous = false)           # μ(t, x, p)
Multiplier((x, p, v) -> ...; is_variable = true)              # μ(x, p, v)
Multiplier((t, x, p, v) -> ...; is_autonomous = false, is_variable = true)

Call Signatures

Every Multiplier is callable via its natural signature (matching the traits), and via a uniform signature (t, x, p, v) that ignores the unused arguments.

For Autonomous/Fixed: natural μ(x, p), uniform μ(t, x, p, v). For NonAutonomous/Fixed: natural μ(t, x, p), uniform μ(t, x, p, v). For Autonomous/NonFixed: natural μ(x, p, v), uniform μ(t, x, p, v). For NonAutonomous/NonFixed: natural μ(t, x, p, v), uniform μ(t, x, p, v).

Example

julia
julia> using CTBase: Data

julia> μ = Data.Multiplier((x, p) -> x[1])
Multiplier: autonomous, fixed (no variable)
  natural call: μ(x, p)
  uniform call: μ(t, x, p, v)

See also: CTBase.Data.AbstractMultiplier, CTBase.Data.Hamiltonian, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

OpenLoop [Function] ​

CTBase.Data.OpenLoop Function
julia
OpenLoop(
    f;
    is_autonomous::Union{CTBase.Core.NotProvidedType, Bool},
    is_variable::Bool
) -> Union{CTBase.Data.ControlLaw{<:Function, CTBase.Traits.OpenLoopFeedback, CTBase.Traits.NonAutonomous, CTBase.Traits.Fixed}, CTBase.Data.ControlLaw{<:Function, CTBase.Traits.OpenLoopFeedback, CTBase.Traits.NonAutonomous, CTBase.Traits.NonFixed}}

Construct an open-loop ControlLaw.

An open-loop control law always depends on time (and optionally the variable) — u(t) or u(t, v) — never on the state or costate. Unlike ClosedLoop/DynClosedLoop, OpenLoop is unconditionally NonAutonomous: autonomy is a property of the OCP, not of an open-loop control (see control-toolbox/CTBase.jl#515), so is_autonomous is not offered as a real choice at construction (see the is_autonomous keyword below) — but Traits.time_dependence/Traits.is_autonomous still answer normally on the constructed law, always NonAutonomous/false.

Arguments

  • f::Function: The control law function, f(t) or f(t, v).

  • is_autonomous: Misuse detector only — has no effect on the constructed law. Left at its default (CTBase.Core.NotProvided), nothing happens. Passed explicitly (true or false), a warning is emitted explaining that OpenLoop always depends on time.

  • is_variable::Bool: If true, control law depends on variable (default: __is_variable()).

Expected signature

f(t) by default, f(t, v) with is_variable=true. A zero-argument function (the pre-#515 "autonomous open loop", () -> c) is no longer valid. The signature is not checked at construction: a mismatch surfaces as a MethodError at the first call.

Example

julia
julia> using CTBase: Data

julia> u = Data.OpenLoop(t -> 1.0)
ControlLaw: open-loop, fixed (no variable)
  natural call: u(t)
  uniform call: u(t, v)

julia> u = Data.OpenLoop((t, v) -> t * v; is_variable=true)
ControlLaw: open-loop, variable
  natural call: u(t, v)
  uniform call: u(t, v)

See also: CTBase.Data.ClosedLoop, CTBase.Data.DynClosedLoop, CTBase.Data.ControlLaw.

PathConstraint [Struct] ​

CTBase.Data.PathConstraint Type
julia
struct PathConstraint{F<:Function, K<:CTBase.Traits.AbstractConstraintKind, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractPathConstraint{K, TD, VD}

Parametric container for a path-constraint function together with its constraint-kind, time-dependence, and variable-dependence traits.

The function returns the value g(...) of a path constraint evaluated along the trajectory of an optimal control problem. The constraint-kind trait determines which primal variables the constraint depends on (see CTBase.Data.AbstractPathConstraint).

Type Parameters

  • F: concrete type of the wrapped function.

  • K <: AbstractConstraintKind: StateConstraintKind, ControlConstraintKind, or MixedConstraintKind.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the path-constraint function.

Construction

Use the user-facing constructors StateConstraint, ControlConstraint, or MixedConstraint:

julia
StateConstraint(g; is_autonomous = true, is_variable = false)     # default: g(x)
ControlConstraint(g; is_autonomous = true, is_variable = false)   # default: g(u)
MixedConstraint(g; is_autonomous = true, is_variable = false)     # default: g(x, u)

Call Signatures

Every PathConstraint is callable via its natural signature (matching the traits), and via the uniform signature g(t, x, u, v) (ignoring unused arguments), used by flow integrators:

KindNatural (Aut, Fixed)Uniform
StateConstraintg(x)g(t, x, u, v)
ControlConstraintg(u)g(t, x, u, v)
MixedConstraintg(x, u)g(t, x, u, v)

See also: CTBase.Data.AbstractPathConstraint, CTBase.Data.StateConstraint, CTBase.Data.ControlConstraint, CTBase.Data.MixedConstraint, CTBase.Traits.AbstractConstraintKind.

PseudoHamiltonian [Struct] ​

CTBase.Data.PseudoHamiltonian Type
julia
struct PseudoHamiltonian{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractPseudoHamiltonian{TD, VD}

Parametric container for a scalar pseudo-Hamiltonian function together with its time-dependence and variable-dependence traits.

The function returns a scalar value H̃(t, x, p, u[, v]) → ℝ representing the pseudo-Hamiltonian of the system, which extends the standard Hamiltonian with an explicit control argument u.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

Fields

  • f::F: the pseudo-Hamiltonian function.

Construction

Use the keyword constructor:

julia
PseudoHamiltonian(f; is_autonomous = true, is_variable = false)        # default: h̃(x, p, u)
PseudoHamiltonian((t, x, p, u) -> ...; is_autonomous = false)          # h̃(t, x, p, u)
PseudoHamiltonian((x, p, u, v) -> ...; is_variable = true)             # h̃(x, p, u, v)
PseudoHamiltonian((t, x, p, u, v) -> ...; is_autonomous = false, is_variable = true)

Call Signatures

Every PseudoHamiltonian is callable via its natural signature (matching the traits), and via a uniform signature (t, x, p, u, v) that ignores unused arguments.

For Autonomous/Fixed: natural h̃(x, p, u), uniform h̃(t, x, p, u, v). For NonAutonomous/Fixed: natural h̃(t, x, p, u), uniform h̃(t, x, p, u, v). For Autonomous/NonFixed: natural h̃(x, p, u, v), uniform h̃(t, x, p, u, v). For NonAutonomous/NonFixed: natural h̃(t, x, p, u, v), uniform h̃(t, x, p, u, v).

See also: CTBase.Data.AbstractPseudoHamiltonian, CTBase.Data.Hamiltonian, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

PseudoHamiltonianVectorField [Struct] ​

CTBase.Data.PseudoHamiltonianVectorField Type
julia
struct PseudoHamiltonianVectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractPseudoHamiltonianVectorField{TD, VD, MD}

Parametric container for a pseudo-Hamiltonian vector field function together with its time-dependence, variable-dependence, and mutability traits.

The function returns a tuple (dx, dp) representing the already-differentiated derivatives of state x and costate p, with an explicit control argument u — the vector-field analogue of CTBase.Data.PseudoHamiltonian, just as CTBase.Data.HamiltonianVectorField is the vector-field analogue of CTBase.Data.Hamiltonian.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

  • MD <: AbstractMutabilityTrait: InPlace or OutOfPlace.

Fields

  • f::F: the pseudo-Hamiltonian vector field function.

Construction

Use the keyword constructor:

julia
PseudoHamiltonianVectorField(f; is_autonomous = true, is_variable = false)        # default: f(x, p, u)
PseudoHamiltonianVectorField((t, x, p, u) -> ...; is_autonomous = false)          # f(t, x, p, u)
PseudoHamiltonianVectorField((x, p, u, v) -> ...; is_variable = true)            # f(x, p, u, v)
PseudoHamiltonianVectorField((t, x, p, u, v) -> ...; is_autonomous = false, is_variable = true)

The mutability trait (InPlace/OutOfPlace) is auto-detected from the function signature.

Call Signatures

Every PseudoHamiltonianVectorField is callable via its natural signature (matching the traits), and via a uniform signature (t, x, p, u, v) that ignores the unused arguments.

For InPlace pseudo-Hamiltonian vector fields, the natural signature includes the derivative buffers as the first two arguments (e.g., (dx, dp, x, p, u) for Autonomous/Fixed).

See also: CTBase.Data.AbstractPseudoHamiltonianVectorField, CTBase.Data.PseudoHamiltonian, CTBase.Data.HamiltonianVectorField, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.

StateConstraint [Function] ​

CTBase.Data.StateConstraint Function
julia
StateConstraint(
    f;
    is_autonomous::Bool,
    is_variable::Bool
) -> CTBase.Data.PathConstraint{F, CTBase.Traits.StateConstraintKind} where F<:Function

Construct a pure state PathConstraint.

A state constraint depends on the state (and optionally time and variable), but not on the control.

Arguments

  • f::Function: The path-constraint function.

  • is_autonomous::Bool: If true, constraint is autonomous (default: __is_autonomous()).

  • is_variable::Bool: If true, constraint depends on variable (default: __is_variable()).

Example

julia
julia> using CTBase: Data

julia> g = Data.StateConstraint(x -> x[1])
PathConstraint: state, autonomous, fixed (no variable)
  natural call: g(x)
  uniform call: g(t, x, u, v)

See also: CTBase.Data.ControlConstraint, CTBase.Data.MixedConstraint, CTBase.Data.PathConstraint.

VectorField [Struct] ​

CTBase.Data.VectorField Type
julia
struct VectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractVectorField{TD, VD, MD}

Parametric container for a vector-field function together with its time-dependence, variable-dependence, and mutability traits.

Type Parameters

  • F: concrete type of the wrapped function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

  • MD <: AbstractMutabilityTrait: InPlace or OutOfPlace.

Fields

  • f::F: the vector-field function.

Construction

Use the keyword constructor:

julia
VectorField(f; is_autonomous = true, is_variable = false)        # default: f(x)
VectorField((t, x) -> ...; is_autonomous = false)                # f(t, x)
VectorField((x, v) -> ...; is_variable = true)                   # f(x, v)
VectorField((t, x, v) -> ...; is_autonomous = false, is_variable = true)

The mutability trait (InPlace/OutOfPlace) is auto-detected from the function signature.

Call Signatures

Every VectorField is callable via its natural signature (matching the traits), and via a uniform signature (t, x, v) that ignores the unused arguments — this uniform form is used internally to build the right-hand side of the ODE in a trait-agnostic way.

For InPlace vector fields, the natural signature includes the derivative buffer as the first argument (e.g., (dx, x) for Autonomous/Fixed).

See also: CTBase.Data.AbstractVectorField, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence, CTBase.Traits.AbstractMutabilityTrait.

control_law [Function] ​

CTBase.Data.control_law Function
julia
control_law(
    h::CTBase.Data.ComposedHamiltonian
) -> CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}

Return the control law u(t, x, p, v) of a CTBase.Data.ComposedHamiltonian.

See also: CTBase.Data.ComposedHamiltonian, CTBase.Data.pseudo_hamiltonian.

julia
control_law(
    h::CTBase.Data.ComposedConstrainedHamiltonian
) -> CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}

Return the control law u(t, x, p, v) of a CTBase.Data.ComposedConstrainedHamiltonian.

See also: CTBase.Data.pseudo_hamiltonian, CTBase.Data.multiplier.

julia
control_law(
    g::CTBase.Data.ComposedVectorField
) -> CTBase.Data.ControlLaw{<:Function, <:Union{CTBase.Traits.ClosedLoopFeedback, CTBase.Traits.OpenLoopFeedback}}

Return the control law of a CTBase.Data.ComposedVectorField.

See also: CTBase.Data.ComposedVectorField, CTBase.Data.controlled_vector_field.

controlled_vector_field [Function] ​

CTBase.Data.controlled_vector_field Function
julia
controlled_vector_field(
    g::CTBase.Data.ComposedVectorField
) -> CTBase.Data.ControlledVectorField

Return the underlying controlled vector field of a CTBase.Data.ComposedVectorField.

See also: CTBase.Data.ComposedVectorField, CTBase.Data.control_law.

freeze_multiplier [Function] ​

CTBase.Data.freeze_multiplier Function
julia
freeze_multiplier(
    h::CTBase.Data.AbstractConstrainedPseudoHamiltonian{TD, VD},
    μ
) where {TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} -> CTBase.Data.PseudoHamiltonian{CTBase.Data._FrozenMultiplier{H, M}} where {H<:CTBase.Data.AbstractConstrainedPseudoHamiltonian, M}

Return the pseudo-Hamiltonian H̃(t, x, p, u, v) = H(t, x, p, u, μ, v) of the constrained pseudo-Hamiltonian H at the fixed value μ of the multiplier, as a CTBase.Data.PseudoHamiltonian with the traits of H.

The multiplier is a constant of the result: differentiating it with respect to x and p gives the partial derivatives of the maximum principle, ∂H/∂x and ∂H/∂p at fixed u and μ (the :partial mode of a flow). The gradient primitives of CTBase.Differentiation, such as CTBase.Differentiation.pseudo_hamiltonian_gradient, apply to it unchanged.

Arguments

  • h::AbstractConstrainedPseudoHamiltonian: the constrained pseudo-Hamiltonian, any subtype that implements the natural and uniform calls of the abstract type.

  • μ: the value of the multiplier, a number or a vector.

Returns

  • PseudoHamiltonian: the pseudo-Hamiltonian at fixed μ.

Example

julia
julia> using CTBase: Data

julia> H = Data.ConstrainedPseudoHamiltonian((x, p, u, μ) -> p * u - x^2 + μ * (x - 0.1));

julia> H̃ = Data.freeze_multiplier(H, 3.0);

julia> H̃(1.0, 2.0, 0.5) == H(1.0, 2.0, 0.5, 3.0)
true

See also: CTBase.Data.ConstrainedPseudoHamiltonian, CTBase.Data.ComposedConstrainedHamiltonian.

hamiltonian [Function] ​

CTBase.Data.hamiltonian Function
julia
hamiltonian(object, args...; kwargs...)

Return the Hamiltonian of object, an CTBase.Data.AbstractHamiltonian.

This generic function has no method in CTBase: it is the single owner of the name, and each package that builds a Hamiltonian adds its own methods to it (for instance the Hamiltonian of an optimal control problem, or the one a Hamiltonian flow integrates), so that every method is reached through one function. It is the counterpart of CTBase.Data.pseudo_hamiltonian.

See also: CTBase.Data.AbstractHamiltonian, CTBase.Data.pseudo_hamiltonian.

multiplier [Function] ​

CTBase.Data.multiplier Function
julia
multiplier(
    h::CTBase.Data.ComposedConstrainedHamiltonian
) -> CTBase.Data.Multiplier

Return the multiplier μ(t, x, p, v) of a CTBase.Data.ComposedConstrainedHamiltonian.

See also: CTBase.Data.pseudo_hamiltonian, CTBase.Data.control_law.

pseudo_hamiltonian [Function] ​

CTBase.Data.pseudo_hamiltonian Function
julia
pseudo_hamiltonian(
    h::CTBase.Data.ComposedHamiltonian
) -> CTBase.Data.PseudoHamiltonian

Return the underlying pseudo-Hamiltonian H̃ of a CTBase.Data.ComposedHamiltonian.

See also: CTBase.Data.ComposedHamiltonian, CTBase.Data.control_law.

julia
pseudo_hamiltonian(
    h::CTBase.Data.ComposedConstrainedHamiltonian
) -> CTBase.Data.AbstractConstrainedPseudoHamiltonian

Return the constrained pseudo-Hamiltonian H(t, x, p, u, μ, v) of a CTBase.Data.ComposedConstrainedHamiltonian.

See also: CTBase.Data.control_law, CTBase.Data.multiplier.