Public API
This page lists exported symbols of CTBase.Data.
From CTBase.Data
CTBase.Data [Module]
CTBase.Data Module
DataData 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.
AbstractControlLaw [Abstract Type]
CTBase.Data.AbstractControlLaw Type
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, orDynClosedLoopFeedback.TD <: TimeDependence:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
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.
See also: CTBase.Data.ControlLaw, CTBase.Traits.AbstractFeedback, CTBase.Traits.TimeDependence, CTBase.Traits.VariableDependence.
AbstractControlledVectorField [Abstract Type]
CTBase.Data.AbstractControlledVectorField Type
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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
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
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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
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
abstract type AbstractHamiltonianVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait}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 dependenceReturns the combined state-costate derivative vector
Example
julia> using CTBase.Data
julia> HamiltonianVectorField <: Data.AbstractHamiltonianVectorField
trueSee also: CTBase.Data.AbstractVectorField, CTBase.Data.HamiltonianVectorField, CTBase.Data.Hamiltonian.
AbstractMultiplier [Abstract Type]
CTBase.Data.AbstractMultiplier Type
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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
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
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, orMixedConstraintKind.TD <: TimeDependence:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
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
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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
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.
AbstractVectorField [Abstract Type]
CTBase.Data.AbstractVectorField Type
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:AutonomousorNonAutonomousVD <: Traits.VariableDependence:FixedorNonFixedMD <: Traits.AbstractMutabilityTrait:InPlaceorOutOfPlace
Trait accessors are implemented at the abstract level and work for all subtypes.
Example
using CTBase.Data
using CTBase.Traits
# Define a concrete vector field
struct MyVectorField{F, TD, VD, MD} <: 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 OutOfPlaceSee also: CTBase.Data.VectorField, CTBase.Data.HamiltonianVectorField, CTBase.Traits.time_dependence, CTBase.Traits.variable_dependence, CTBase.Traits.mutability.
ClosedLoop [Function]
CTBase.Data.ClosedLoop Function
ClosedLoop(
f;
is_autonomous,
is_variable
) -> CTBase.Data.ControlLaw{F, CTBase.Traits.ClosedLoopFeedback} where F<:FunctionConstruct 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()).
Example
julia> using CTBase.Data
julia> u = 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.
ComposedHamiltonian [Struct]
CTBase.Data.ComposedHamiltonian Type
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<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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 (NonAutonomousif either depends on time).VD <: VariableDependence: variable dependence — the join of the two variable dependences (NonFixedif either depends on the variable).PH <: PseudoHamiltonian: concrete pseudo-Hamiltonian type.L <: ControlLaw: concrete control-law type (must carryDynClosedLoopFeedback).
Fields
h̃::PH: the pseudo-HamiltonianH̃(t, x, p, u, v).law::L: the dynamic closed-loop control lawu(t, x, p, v).
Construction
ComposedHamiltonian(h̃, law) # law must carry DynClosedLoopFeedbackThe 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
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<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, 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 carryOpenLoopFeedbackorClosedLoopFeedback).
Fields
fc::CVF: the controlled vector fieldfc(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.
ControlConstraint [Function]
CTBase.Data.ControlConstraint Function
ControlConstraint(
f;
is_autonomous,
is_variable
) -> CTBase.Data.PathConstraint{F, CTBase.Traits.ControlConstraintKind} where F<:FunctionConstruct 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> using CTBase.Data
julia> g = 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
struct ControlLaw{F<:Function, FB<:CTBase.Traits.AbstractFeedback, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractControlLaw{FB<:CTBase.Traits.AbstractFeedback, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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, orDynClosedLoopFeedback.TD <: TimeDependence:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
Fields
f::F: the control law function.
Construction
Use the user-facing constructors OpenLoop, ClosedLoop, or DynClosedLoop:
OpenLoop(u; is_autonomous = true, is_variable = false) # default: u()
ClosedLoop(u; is_autonomous = true, is_variable = false) # default: u(x)
DynClosedLoop(u; is_autonomous = true, is_variable = false) # default: u(x, p)Call Signatures
Every ControlLaw is callable via its natural signature (matching the traits), and via a uniform signature that depends on the feedback trait:
| Feedback | Natural (Aut, Fixed) | Uniform |
|---|---|---|
OpenLoop | u() | u(t, v) |
ClosedLoop | u(x) | u(t, x, v) |
DynClosedLoop | u(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
struct ControlledVectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractControlledVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
Fields
f::F: the controlled vector-field function.
Construction
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) | natural | uniform |
|---|---|---|
(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
DynClosedLoop(
f;
is_autonomous,
is_variable
) -> CTBase.Data.ControlLaw{F, CTBase.Traits.DynClosedLoopFeedback} where F<:FunctionConstruct 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()).
Example
julia> using CTBase.Data
julia> u = 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
struct Hamiltonian{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
Fields
f::F: the Hamiltonian function.
Construction
Use the keyword constructor:
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> using CTBase.Data
julia> h = 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 = 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
struct HamiltonianVectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractHamiltonianVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait}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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.MD <: AbstractMutabilityTrait:InPlaceorOutOfPlace.
Fields
f::F: the Hamiltonian vector field function.
Construction
Use the keyword constructor:
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
MixedConstraint(
f;
is_autonomous,
is_variable
) -> CTBase.Data.PathConstraint{F, CTBase.Traits.MixedConstraintKind} where F<:FunctionConstruct 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> using CTBase.Data
julia> g = 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
struct Multiplier{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractMultiplier{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
Fields
f::F: the multiplier function.
Construction
Use the keyword constructor:
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> using CTBase.Data
julia> μ = 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
OpenLoop(
f;
is_autonomous,
is_variable
) -> CTBase.Data.ControlLaw{F, CTBase.Traits.OpenLoopFeedback} where F<:FunctionConstruct an open-loop ControlLaw.
An open-loop control law depends only on time (and optionally the variable), not on the state or 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()).
Example
julia> using CTBase.Data
julia> u = OpenLoop(() -> 1.0)
ControlLaw: open-loop, autonomous, fixed (no variable)
natural call: u()
uniform call: u(t, v)
julia> u = OpenLoop((t, v) -> t * v; is_autonomous=false, is_variable=true)
ControlLaw: open-loop, non-autonomous, 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
struct PathConstraint{F<:Function, K<:CTBase.Traits.AbstractConstraintKind, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractPathConstraint{K<:CTBase.Traits.AbstractConstraintKind, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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, orMixedConstraintKind.TD <: TimeDependence:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
Fields
f::F: the path-constraint function.
Construction
Use the user-facing constructors StateConstraint, ControlConstraint, or MixedConstraint:
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:
| Kind | Natural (Aut, Fixed) | Uniform |
|---|---|---|
StateConstraint | g(x) | g(t, x, u, v) |
ControlConstraint | g(u) | g(t, x, u, v) |
MixedConstraint | g(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
struct PseudoHamiltonian{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence} <: CTBase.Data.AbstractPseudoHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.
Fields
f::F: the pseudo-Hamiltonian function.
Construction
Use the keyword constructor:
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.
StateConstraint [Function]
CTBase.Data.StateConstraint Function
StateConstraint(
f;
is_autonomous,
is_variable
) -> CTBase.Data.PathConstraint{F, CTBase.Traits.StateConstraintKind} where F<:FunctionConstruct 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> using CTBase.Data
julia> g = 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
struct VectorField{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTBase.Data.AbstractVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait}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:AutonomousorNonAutonomous.VD <: VariableDependence:FixedorNonFixed.MD <: AbstractMutabilityTrait:InPlaceorOutOfPlace.
Fields
f::F: the vector-field function.
Construction
Use the keyword constructor:
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
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.
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
controlled_vector_field(
g::CTBase.Data.ComposedVectorField
) -> CTBase.Data.ControlledVectorFieldReturn the underlying controlled vector field of a CTBase.Data.ComposedVectorField.
See also: CTBase.Data.ComposedVectorField, CTBase.Data.control_law.
pseudo_hamiltonian [Function]
CTBase.Data.pseudo_hamiltonian Function
pseudo_hamiltonian(
h::CTBase.Data.ComposedHamiltonian
) -> CTBase.Data.PseudoHamiltonianReturn the underlying pseudo-Hamiltonian H̃ of a CTBase.Data.ComposedHamiltonian.
See also: CTBase.Data.ComposedHamiltonian, CTBase.Data.control_law.