CTBase API
This is just a dump of CTBase API documentation. For more details about CTBase.jl package, see the documentation.
Index
- CTBase.CTBase
- CTBase.AbstractHamiltonian
- CTBase.AmbiguousDescription
- CTBase.Autonomous
- CTBase.BoundaryConstraint
- CTBase.BoundaryConstraint
- CTBase.BoundaryConstraint
- CTBase.BoundaryConstraint
- CTBase.CTCallback
- CTBase.CTCallbacks
- CTBase.CTException
- CTBase.Control
- CTBase.ControlConstraint
- CTBase.ControlConstraint
- CTBase.ControlConstraint
- CTBase.ControlConstraint
- CTBase.ControlLaw
- CTBase.ControlLaw
- CTBase.ControlLaw
- CTBase.ControlLaw
- CTBase.Controls
- CTBase.Costate
- CTBase.Costates
- CTBase.DCostate
- CTBase.DState
- CTBase.Description
- CTBase.Dimension
- CTBase.Dynamics
- CTBase.Dynamics
- CTBase.Dynamics
- CTBase.Dynamics
- CTBase.FeedbackControl
- CTBase.FeedbackControl
- CTBase.FeedbackControl
- CTBase.FeedbackControl
- CTBase.Fixed
- CTBase.Hamiltonian
- CTBase.Hamiltonian
- CTBase.Hamiltonian
- CTBase.Hamiltonian
- CTBase.HamiltonianLift
- CTBase.HamiltonianLift
- CTBase.HamiltonianLift
- CTBase.HamiltonianLift
- CTBase.HamiltonianVectorField
- CTBase.HamiltonianVectorField
- CTBase.HamiltonianVectorField
- CTBase.HamiltonianVectorField
- CTBase.IncorrectArgument
- CTBase.IncorrectMethod
- CTBase.IncorrectOutput
- CTBase.Index
- CTBase.Lagrange
- CTBase.Lagrange
- CTBase.Lagrange
- CTBase.Lagrange
- CTBase.Mayer
- CTBase.Mayer
- CTBase.Mayer
- CTBase.Mayer
- CTBase.MixedConstraint
- CTBase.MixedConstraint
- CTBase.MixedConstraint
- CTBase.MixedConstraint
- CTBase.Multiplier
- CTBase.Multiplier
- CTBase.Multiplier
- CTBase.Multiplier
- CTBase.NonAutonomous
- CTBase.NonFixed
- CTBase.NotImplemented
- CTBase.OCPInit
- CTBase.OptimalControlModel
- CTBase.OptimalControlSolution
- CTBase.ParsingError
- CTBase.PrintCallback
- CTBase.PrintCallback
- CTBase.State
- CTBase.StateConstraint
- CTBase.StateConstraint
- CTBase.StateConstraint
- CTBase.StateConstraint
- CTBase.States
- CTBase.StopCallback
- CTBase.StopCallback
- CTBase.Time
- CTBase.TimeDependence
- CTBase.Times
- CTBase.TimesDisc
- CTBase.UnauthorizedCall
- CTBase.Variable
- CTBase.VariableConstraint
- CTBase.VariableConstraint
- CTBase.VariableDependence
- CTBase.VectorField
- CTBase.VectorField
- CTBase.VectorField
- CTBase.VectorField
- CTBase.ctNumber
- CTBase.ctVector
- CTBase.:⋅
- CTBase.:⋅
- CTBase.:⋅
- CTBase.Lie
- CTBase.Lie
- CTBase.Lie
- CTBase.Lie
- CTBase.Lie
- CTBase.Lift
- CTBase.Lift
- CTBase.Lift
- CTBase.Model
- CTBase.Model
- CTBase.Poisson
- CTBase.Poisson
- CTBase.Poisson
- CTBase.Poisson
- CTBase.Poisson
- CTBase.Poisson
- CTBase.Poisson
- CTBase.add
- CTBase.add
- CTBase.constraint
- CTBase.constraint!
- CTBase.constraint!
- CTBase.constraint!
- CTBase.constraint!
- CTBase.constraint!
- CTBase.constraint!
- CTBase.constraint!
- CTBase.constraint_type
- CTBase.constraints_labels
- CTBase.control!
- CTBase.ct_repl
- CTBase.ctgradient
- CTBase.ctgradient
- CTBase.ctgradient
- CTBase.ctindices
- CTBase.ctinterpolate
- CTBase.ctjacobian
- CTBase.ctjacobian
- CTBase.ctjacobian
- CTBase.ctupperscripts
- CTBase.dynamics!
- CTBase.getFullDescription
- CTBase.get_priority_print_callbacks
- CTBase.get_priority_stop_callbacks
- CTBase.is_max
- CTBase.is_min
- CTBase.is_time_dependent
- CTBase.is_time_independent
- CTBase.is_variable_dependent
- CTBase.is_variable_independent
- CTBase.nlp_constraints
- CTBase.objective!
- CTBase.objective!
- CTBase.remove_constraint!
- CTBase.replace_call
- CTBase.replace_call
- CTBase.state!
- CTBase.time!
- CTBase.time!
- CTBase.time!
- CTBase.time!
- CTBase.time!
- CTBase.variable!
- CTBase.∂ₜ
- CTBase.@Lie
- CTBase.@def
Documentation
CTBase.CTBase — ModuleCTBase module.
Lists all the imported modules and packages:
- Base
- Core
- DataStructures
- DocStringExtensions
- LinearAlgebra
- MLStyle
- Parameters
- Plots
- PrettyTables
- Printf
- ReplMaker
- Unicode
List of all the exported names:
- AbstractHamiltonian
- AmbiguousDescription
- Autonomous
- BoundaryConstraint
- CTCallback
- CTCallbacks
- CTException
- Control
- ControlConstraint
- ControlLaw
- Controls
- Costate
- Costates
- DCostate
- DState
- Description
- Dimension
- Dynamics
- FeedbackControl
- Fixed
- Hamiltonian
- HamiltonianLift
- HamiltonianVectorField
- IncorrectArgument
- IncorrectMethod
- IncorrectOutput
- Index
- Lagrange
- @Lie
- Lie
- Lift
- Mayer
- MixedConstraint
- Model
- Multiplier
- NonAutonomous
- NonFixed
- NotImplemented
- OCPInit
- OptimalControlModel
- OptimalControlSolution
- ParsingError
- Poisson
- PrintCallback
- State
- StateConstraint
- States
- StopCallback
- Time
- TimeDependence
- Times
- TimesDisc
- UnauthorizedCall
- Variable
- VariableConstraint
- VariableDependence
- VectorField
- add
- constraint
- constraint!
- constraint_type
- constraints_labels
- control!
- ctNumber
- ctVector
- ct_repl
- ctgradient
- ctindices
- ctinterpolate
- ctjacobian
- ctupperscripts
- @def
- dynamics!
- getFullDescription
- get_priority_print_callbacks
- get_priority_stop_callbacks
- is_max
- is_min
- is_time_dependent
- is_time_independent
- is_variable_dependent
- is_variable_independent
- nlp_constraints
- objective!
- plot
- plot!
- remove_constraint!
- replace_call
- state!
- time!
- variable!
- ∂ₜ
- ⋅
CTBase.Control — TypeType alias for a control.
CTBase.Costate — TypeType alias for an costate.
CTBase.DCostate — TypeType alias for a tangent vector to the costate space.
CTBase.DState — TypeType alias for a tangent vector to the state space.
CTBase.State — TypeType alias for a state.
CTBase.TimesDisc — TypeType alias for a grid of times.
CTBase.Variable — TypeType alias for a variable.
CTBase.ctVector — TypeType alias for a vector of real numbers.
CTBase.AbstractHamiltonian — Typeabstract type AbstractHamiltonian{time_dependence, variable_dependence}Abstract type for hamiltonians.
CTBase.AmbiguousDescription — Typestruct AmbiguousDescription <: CTExceptionException thrown when the description is ambiguous / incorrect.
Fields
- var::Tuple{Vararg{Symbol}}
CTBase.Autonomous — Typeabstract type Autonomous <: TimeDependenceCTBase.BoundaryConstraint — Typestruct BoundaryConstraint{variable_dependence}Fields
- f::Function
The default value for variable_dependence is Fixed.
Constructor
The constructor BoundaryConstraint returns a BoundaryConstraint of a function. The function must take 2 or 3 arguments (x0, xf) or (x0, xf, v), if the function is variable, it must be specified.  Dependencies are specified with a boolean, variable, false by default or with a DataType, NonFixed/Fixed, Fixed by default.
Examples
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B = BoundaryConstraint((x0, xf, v) -> [v[3]+xf[2]-x0[1], v[1]-v[2]+2xf[1]+x0[2]^2], variable=true)
julia> B = BoundaryConstraint((x0, xf, v) -> [v[3]+xf[2]-x0[1], v[1]-v[2]+2xf[1]+x0[2]^2], NonFixed)When the state is of dimension 1, consider x0 and xf as a scalar. When the constraint is dimension 1, return a scalar.
Call
The call returns the evaluation of the BoundaryConstraint for given values. If a variable is given for a non variable dependent boundary constraint, it will be ignored.
Examples
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B([0, 0], [1, 1])
[1, 2]
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B([0, 0], [1, 1],Real[])
[1, 2]
julia> B = BoundaryConstraint((x0, xf, v) -> [v[3]+xf[2]-x0[1], v[1]-v[2]+2xf[1]+x0[2]^2], variable=true)
julia> B([0, 0], [1, 1], [1, 2, 3])
[4, 1]CTBase.BoundaryConstraint — MethodBoundaryConstraint(
    f::Function,
    dependencies::DataType...
) -> BoundaryConstraint{Fixed}
Return a BoundaryConstraint of a function. Dependencies are specified with a DataType, NonFixed/Fixed, Fixed by default.
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B = BoundaryConstraint((x0, xf, v) -> [v[3]+xf[2]-x0[1], v[1]-v[2]+2xf[1]+x0[2]^2], NonFixed)CTBase.BoundaryConstraint — MethodBoundaryConstraint(
    f::Function;
    variable
) -> BoundaryConstraint{Fixed}
Return a BoundaryConstraint of a function. Dependencies are specified with a boolean, variable, false by default.
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B = BoundaryConstraint((x0, xf, v) -> [v[3]+xf[2]-x0[1], v[1]-v[2]+2xf[1]+x0[2]^2], variable=true)CTBase.BoundaryConstraint — MethodReturn the evaluation of the BoundaryConstraint.
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B([0, 0], [1, 1])
[1, 2]
julia> B = BoundaryConstraint((x0, xf) -> [xf[2]-x0[1], 2xf[1]+x0[2]^2])
julia> B([0, 0], [1, 1],Real[])
[1, 2]
julia> B = BoundaryConstraint((x0, xf, v) -> [v[3]+xf[2]-x0[1], v[1]-v[2]+2xf[1]+x0[2]^2], variable=true)
julia> B([0, 0], [1, 1], [1, 2, 3])
[4, 1]CTBase.CTCallback — Typeabstract type CTCallbackAbstract type for callbacks.
CTBase.CTCallbacks — TypeTuple of callbacks
CTBase.CTException — Typeabstract type CTException <: ExceptionAbstract type for exceptions.
CTBase.ControlConstraint — Typestruct ControlConstraint{time_dependence, variable_dependence}Fields
- f::Function
Similar to VectorField in the usage, but the dimension of the output of the function f is arbitrary.
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor ControlConstraint returns a ControlConstraint of a function. The function must take 1 to 3 arguments, u to (t, u, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> IncorrectArgument ControlConstraint(u -> [u[1]^2, 2u[2]], Int64)
julia> IncorrectArgument ControlConstraint(u -> [u[1]^2, 2u[2]], Int64)
julia> C = ControlConstraint(u -> [u[1]^2, 2u[2]], Autonomous, Fixed)
julia> C = ControlConstraint((u, v) -> [u[1]^2, 2u[2]+v[3]], Autonomous, NonFixed)
julia> C = ControlConstraint((t, u) -> [t+u[1]^2, 2u[2]], NonAutonomous, Fixed)
julia> C = ControlConstraint((t, u, v) -> [t+u[1]^2, 2u[2]+v[3]], NonAutonomous, NonFixed)
julia> C = ControlConstraint(u -> [u[1]^2, 2u[2]], autonomous=true, variable=false)
julia> C = ControlConstraint((u, v) -> [u[1]^2, 2u[2]+v[3]], autonomous=true, variable=true)
julia> C = ControlConstraint((t, u) -> [t+u[1]^2, 2u[2]], autonomous=false, variable=false)
julia> C = ControlConstraint((t, u, v) -> [t+u[1]^2, 2u[2]+v[3]], autonomous=false, variable=true)When the control is of dimension 1, consider u as a scalar.
Call
The call returns the evaluation of the ControlConstraint for given values.
Examples
julia> C = ControlConstraint(u -> [u[1]^2, 2u[2]], autonomous=true, variable=false)
julia> C([1, -1])
[1, -2]
julia> t = 1
julia> v = Real[]
julia> C(t, [1, -1], v)
[1, -2]
julia> C = ControlConstraint((u, v) -> [u[1]^2, 2u[2]+v[3]], autonomous=true, variable=true)
julia> C([1, -1], [1, 2, 3])
[1, 1]
julia> C(t, [1, -1], [1, 2, 3])
[1, 1]
julia> C = ControlConstraint((t, u) -> [t+u[1]^2, 2u[2]], autonomous=false, variable=false)
julia> C(1, [1, -1])
[2, -2]
julia> C(1, [1, -1], v)
[2, -2]
julia> C = ControlConstraint((t, u, v) -> [t+u[1]^2, 2u[2]+v[3]], autonomous=false, variable=true)
julia> C(1, [1, -1], [1, 2, 3])
[2, 1]CTBase.ControlConstraint — MethodControlConstraint(
    f::Function,
    dependencies::DataType...
) -> ControlConstraint{Autonomous, Fixed}
Return the StateConstraint of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> IncorrectArgument ControlConstraint(u -> [u[1]^2, 2u[2]], Int64)
julia> IncorrectArgument ControlConstraint(u -> [u[1]^2, 2u[2]], Int64)
julia> C = ControlConstraint(u -> [u[1]^2, 2u[2]], Autonomous, Fixed)
julia> C = ControlConstraint((u, v) -> [u[1]^2, 2u[2]+v[3]], Autonomous, NonFixed)
julia> C = ControlConstraint((t, u) -> [t+u[1]^2, 2u[2]], NonAutonomous, Fixed)
julia> C = ControlConstraint((t, u, v) -> [t+u[1]^2, 2u[2]+v[3]], NonAutonomous, NonFixed)CTBase.ControlConstraint — MethodControlConstraint(
    f::Function;
    autonomous,
    variable
) -> ControlConstraint{Autonomous, Fixed}
Return the ControlConstraint of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> C = ControlConstraint(u -> [u[1]^2, 2u[2]], autonomous=true, variable=false)
julia> C = ControlConstraint((u, v) -> [u[1]^2, 2u[2]+v[3]], autonomous=true, variable=true)
julia> C = ControlConstraint((t, u) -> [t+u[1]^2, 2u[2]], autonomous=false, variable=false)
julia> C = ControlConstraint((t, u, v) -> [t+u[1]^2, 2u[2]+v[3]], autonomous=false, variable=true)CTBase.ControlConstraint — MethodReturn the value of the ControlConstraint function.
julia> IncorrectArgument ControlConstraint(u -> [u[1]^2, 2u[2]], Int64)
julia> IncorrectArgument ControlConstraint(u -> [u[1]^2, 2u[2]], Int64)
julia> C = ControlConstraint(u -> [u[1]^2, 2u[2]], autonomous=true, variable=false)
julia> C([1, -1])
[1, -2]
julia> t = 1
julia> v = Real[]
julia> C(t, [1, -1], v)
[1, -2]
julia> C = ControlConstraint((u, v) -> [u[1]^2, 2u[2]+v[3]], autonomous=true, variable=true)
julia> C([1, -1], [1, 2, 3])
[1, 1]
julia> C(t, [1, -1], [1, 2, 3])
[1, 1]
julia> C = ControlConstraint((t, u) -> [t+u[1]^2, 2u[2]], autonomous=false, variable=false)
julia> C(1, [1, -1])
[2, -2]
julia> C(1, [1, -1], v)
[2, -2]
julia> C = ControlConstraint((t, u, v) -> [t+u[1]^2, 2u[2]+v[3]], autonomous=false, variable=true)
julia> C(1, [1, -1], [1, 2, 3])
[2, 1]CTBase.ControlLaw — Typestruct ControlLaw{time_dependence, variable_dependence}Fields
- f::Function
Similar to Hamiltonian in the usage, but the dimension of the output of the function f is arbitrary.
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor ControlLaw returns a ControlLaw of a function. The function must take 2 to 4 arguments, (x, p) to (t, x, p, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> ControlLaw((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> ControlLaw((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> u = ControlLaw((x, p) -> x[1]^2+2p[2], Autonomous, Fixed)
julia> u = ControlLaw((x, p, v) -> x[1]^2+2p[2]+v[3], Autonomous, NonFixed)
julia> u = ControlLaw((t, x, p) -> t+x[1]^2+2p[2], NonAutonomous, Fixed)
julia> u = ControlLaw((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], NonAutonomous, NonFixed)
julia> u = ControlLaw((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> u = ControlLaw((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> u = ControlLaw((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> u = ControlLaw((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)When the state and costate are of dimension 1, consider x and p as scalars.
Call
The call returns the evaluation of the ControlLaw for given values.
Examples
julia> u = ControlLaw((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> u([1, 0], [0, 1])
3
julia> t = 1
julia> v = Real[]
julia> u(t, [1, 0], [0, 1])
MethodError
julia> u([1, 0], [0, 1], v)
MethodError
julia> u(t, [1, 0], [0, 1], v)
3
julia> u = ControlLaw((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> u([1, 0], [0, 1], [1, 2, 3])
6
julia> u(t, [1, 0], [0, 1], [1, 2, 3])
6
julia> u = ControlLaw((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> u(1, [1, 0], [0, 1])
4
julia> u(1, [1, 0], [0, 1], v)
4
julia> u = ControlLaw((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)
julia> u(1, [1, 0], [0, 1], [1, 2, 3])
7CTBase.ControlLaw — MethodControlLaw(
    f::Function,
    dependencies::DataType...
) -> ControlLaw{Autonomous, Fixed}
Return the ControlLaw of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> ControlLaw((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> ControlLaw((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> u = ControlLaw((x, p) -> x[1]^2+2p[2], Autonomous, Fixed)
julia> u = ControlLaw((x, p, v) -> x[1]^2+2p[2]+v[3], Autonomous, NonFixed)
julia> u = ControlLaw((t, x, p) -> t+x[1]^2+2p[2], NonAutonomous, Fixed)
julia> u = ControlLaw((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], NonAutonomous, NonFixed)CTBase.ControlLaw — MethodControlLaw(
    f::Function;
    autonomous,
    variable
) -> ControlLaw{Autonomous, Fixed}
Return the ControlLaw of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> u = ControlLaw((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> u = ControlLaw((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> u = ControlLaw((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> u = ControlLaw((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)CTBase.ControlLaw — MethodReturn the value of the ControlLaw function.
julia> ControlLaw((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> ControlLaw((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> u = ControlLaw((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> u([1, 0], [0, 1])
3
julia> t = 1
julia> v = Real[]
julia> u(t, [1, 0], [0, 1])
MethodError
julia> u([1, 0], [0, 1], v)
MethodError
julia> u(t, [1, 0], [0, 1], v)
3
julia> u = ControlLaw((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> u([1, 0], [0, 1], [1, 2, 3])
6
julia> u(t, [1, 0], [0, 1], [1, 2, 3])
6
julia> u = ControlLaw((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> u(1, [1, 0], [0, 1])
4
julia> u(1, [1, 0], [0, 1], v)
4
julia> u = ControlLaw((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)
julia> u(1, [1, 0], [0, 1], [1, 2, 3])
7CTBase.Controls — TypeType alias for a vector of controls.
CTBase.Costates — TypeType alias for a vector of costates.
CTBase.Description — TypeA description is a tuple of symbols, that is a Tuple{Vararg{Symbol}}.CTBase.Dimension — TypeType alias for a dimension.
CTBase.Dynamics — Typestruct Dynamics{time_dependence, variable_dependence}Fields
- f::Function
The default value for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor Dynamics returns a Dynamics of a function. The function must take 2 to 4 arguments, (x, u) to (t, x, u, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> Dynamics((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> Dynamics((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> D = Dynamics((x, u) -> [2x[2]-u^2, x[1]], Autonomous, Fixed)
julia> D = Dynamics((x, u, v) -> [2x[2]-u^2+v[3], x[1]], Autonomous, NonFixed)
julia> D = Dynamics((t, x, u) -> [t+2x[2]-u^2, x[1]], NonAutonomous, Fixed)
julia> D = Dynamics((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], NonAutonomous, NonFixed)
julia> D = Dynamics((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> D = Dynamics((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> D = Dynamics((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> D = Dynamics((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)When the state is of dimension 1, consider x as a scalar. Same for the control.
Call
The call returns the evaluation of the Dynamics for given values.
Examples
julia> D = Dynamics((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> D([1, 0], 1)
[-1, 1]
julia> t = 1
julia> v = Real[]
julia> D(t, [1, 0], 1, v)
[-1, 1]
julia> D = Dynamics((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> D([1, 0], 1, [1, 2, 3])
[2, 1]
julia> D(t, [1, 0], 1, [1, 2, 3])
[2, 1]
julia> D = Dynamics((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> D(1, [1, 0], 1)
[0, 1]
julia> D(1, [1, 0], 1, v)
[0, 1]
julia> D = Dynamics((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)
julia> D(1, [1, 0], 1, [1, 2, 3])
[3, 1]CTBase.Dynamics — MethodDynamics(
    f::Function,
    dependencies::DataType...
) -> Dynamics{Autonomous, Fixed}
Return the Dynamics of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> Dynamics((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> Dynamics((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> D = Dynamics((x, u) -> [2x[2]-u^2, x[1]], Autonomous, Fixed)
julia> D = Dynamics((x, u, v) -> [2x[2]-u^2+v[3], x[1]], Autonomous, NonFixed)
julia> D = Dynamics((t, x, u) -> [t+2x[2]-u^2, x[1]], NonAutonomous, Fixed)
julia> D = Dynamics((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], NonAutonomous, NonFixed)CTBase.Dynamics — MethodDynamics(
    f::Function;
    autonomous,
    variable
) -> Dynamics{Autonomous, Fixed}
Return the Dynamics of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> D = Dynamics((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> D = Dynamics((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> D = Dynamics((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> D = Dynamics((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)CTBase.Dynamics — MethodReturn the value of the Dynamics function.
julia> D = Dynamics((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> D([1, 0], 1)
[-1, 1]
julia> t = 1
julia> v = Real[]
julia> D(t, [1, 0], 1, v)
[-1, 1]
julia> D = Dynamics((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> D([1, 0], 1, [1, 2, 3])
[2, 1]
julia> D(t, [1, 0], 1, [1, 2, 3])
[2, 1]
julia> D = Dynamics((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> D(1, [1, 0], 1)
[0, 1]
julia> D(1, [1, 0], 1, v)
[0, 1]
julia> D = Dynamics((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)
julia> D(1, [1, 0], 1, [1, 2, 3])
[3, 1]CTBase.FeedbackControl — Typestruct FeedbackControl{time_dependence, variable_dependence}Fields
- f::Function
Similar to VectorField in the usage, but the dimension of the output of the function f is arbitrary.
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor FeedbackControl returns a FeedbackControl of a function. The function must take 1 to 3 arguments, x to (t, x, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> FeedbackControl(x -> x[1]^2+2x[2], Int64)
IncorrectArgument
julia> FeedbackControl(x -> x[1]^2+2x[2], Int64)
IncorrectArgument
julia> u = FeedbackControl(x -> x[1]^2+2x[2], Autonomous, Fixed)
julia> u = FeedbackControl((x, v) -> x[1]^2+2x[2]+v[3], Autonomous, NonFixed)
julia> u = FeedbackControl((t, x) -> t+x[1]^2+2x[2], NonAutonomous, Fixed)
julia> u = FeedbackControl((t, x, v) -> t+x[1]^2+2x[2]+v[3], NonAutonomous, NonFixed)
julia> u = FeedbackControl(x -> x[1]^2+2x[2], autonomous=true, variable=false)
julia> u = FeedbackControl((x, v) -> x[1]^2+2x[2]+v[3], autonomous=true, variable=true)
julia> u = FeedbackControl((t, x) -> t+x[1]^2+2x[2], autonomous=false, variable=false)
julia> u = FeedbackControl((t, x, v) -> t+x[1]^2+2x[2]+v[3], autonomous=false, variable=true)When the state is of dimension 1, consider x as a scalar.
Call
The call returns the evaluation of the FeedbackControl for given values.
Examples
julia> u = FeedbackControl(x -> x[1]^2+2x[2], autonomous=true, variable=false)
julia> u([1, 0])
1
julia> t = 1
julia> v = Real[]
julia> u(t, [1, 0])
MethodError
julia> u([1, 0], v)
MethodError
julia> u(t, [1, 0], v)
1
julia> u = FeedbackControl((x, v) -> x[1]^2+2x[2]+v[3], autonomous=true, variable=true)
julia> u([1, 0], [1, 2, 3])
4
julia> u(t, [1, 0], [1, 2, 3])
4
julia> u = FeedbackControl((t, x) -> t+x[1]^2+2x[2], autonomous=false, variable=false)
julia> u(1, [1, 0])
2
julia> u(1, [1, 0], v)
2
julia> u = FeedbackControl((t, x, v) -> t+x[1]^2+2x[2]+v[3], autonomous=false, variable=true)
julia> u(1, [1, 0], [1, 2, 3])
5CTBase.FeedbackControl — MethodFeedbackControl(
    f::Function,
    dependencies::DataType...
) -> FeedbackControl{Autonomous, Fixed}
Return the FeedbackControl of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> FeedbackControl(x -> x[1]^2+2x[2], Int64)
IncorrectArgument
julia> FeedbackControl(x -> x[1]^2+2x[2], Int64)
IncorrectArgument
julia> u = FeedbackControl(x -> x[1]^2+2x[2], Autonomous, Fixed)
julia> u = FeedbackControl((x, v) -> x[1]^2+2x[2]+v[3], Autonomous, NonFixed)
julia> u = FeedbackControl((t, x) -> t+x[1]^2+2x[2], NonAutonomous, Fixed)
julia> u = FeedbackControl((t, x, v) -> t+x[1]^2+2x[2]+v[3], NonAutonomous, NonFixed)CTBase.FeedbackControl — MethodFeedbackControl(
    f::Function;
    autonomous,
    variable
) -> FeedbackControl{Autonomous, Fixed}
Return the FeedbackControl of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> u = FeedbackControl(x -> x[1]^2+2x[2], autonomous=true, variable=false)
julia> u = FeedbackControl((x, v) -> x[1]^2+2x[2]+v[3], autonomous=true, variable=true)
julia> u = FeedbackControl((t, x) -> t+x[1]^2+2x[2], autonomous=false, variable=false)
julia> u = FeedbackControl((t, x, v) -> t+x[1]^2+2x[2]+v[3], autonomous=false, variable=true)CTBase.FeedbackControl — MethodReturn the value of the FeedbackControl function.
julia> FeedbackControl(x -> x[1]^2+2x[2], Int64)
IncorrectArgument
julia> FeedbackControl(x -> x[1]^2+2x[2], Int64)
IncorrectArgument
julia> u = FeedbackControl(x -> x[1]^2+2x[2], autonomous=true, variable=false)
julia> u([1, 0])
1
julia> t = 1
julia> v = Real[]
julia> u(t, [1, 0])
MethodError
julia> u([1, 0], v)
MethodError
julia> u(t, [1, 0], v)
1
julia> u = FeedbackControl((x, v) -> x[1]^2+2x[2]+v[3], autonomous=true, variable=true)
julia> u([1, 0], [1, 2, 3])
4
julia> u(t, [1, 0], [1, 2, 3])
4
julia> u = FeedbackControl((t, x) -> t+x[1]^2+2x[2], autonomous=false, variable=false)
julia> u(1, [1, 0])
2
julia> u(1, [1, 0], v)
2
julia> u = FeedbackControl((t, x, v) -> t+x[1]^2+2x[2]+v[3], autonomous=false, variable=true)
julia> u(1, [1, 0], [1, 2, 3])
5CTBase.Fixed — Typeabstract type Fixed <: VariableDependenceCTBase.Hamiltonian — Typestruct Hamiltonian{time_dependence, variable_dependence} <: AbstractHamiltonian{time_dependence, variable_dependence}Fields
- f::Function
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor Hamiltonian returns a Hamiltonian of a function. The function must take 2 to 4 arguments, (x, p) to (t, x, p, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> Hamiltonian((x, p) -> x + p, Int64)
IncorrectArgument 
julia> Hamiltonian((x, p) -> x + p, Int64)
IncorrectArgument
julia> H = Hamiltonian((x, p) -> x[1]^2+2p[2])
julia> H = Hamiltonian((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3]], autonomous=false, variable=true)
julia> H = Hamiltonian((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3]], NonAutonomous, NonFixed)When the state and costate are of dimension 1, consider x and p as scalars.
Call
The call returns the evaluation of the Hamiltonian for given values.
Examples
julia> H = Hamiltonian((x, p) -> [x[1]^2+2p[2]]) # autonomous=true, variable=false
julia> H([1, 0], [0, 1])
MethodError # H must return a scalar
julia> H = Hamiltonian((x, p) -> x[1]^2+2p[2])
julia> H([1, 0], [0, 1])
3
julia> t = 1
julia> v = Real[]
julia> H(t, [1, 0], [0, 1])
MethodError
julia> H([1, 0], [0, 1], v)
MethodError 
julia> H(t, [1, 0], [0, 1], v)
3
julia> H = Hamiltonian((x, p, v) -> x[1]^2+2p[2]+v[3], variable=true)
julia> H([1, 0], [0, 1], [1, 2, 3])
6
julia> H(t, [1, 0], [0, 1], [1, 2, 3])
6
julia> H = Hamiltonian((t, x, p) -> t+x[1]^2+2p[2], autonomous=false)
julia> H(1, [1, 0], [0, 1])
4
julia> H(1, [1, 0], [0, 1], v)
4
julia> H = Hamiltonian((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)
julia> H(1, [1, 0], [0, 1], [1, 2, 3])
7CTBase.Hamiltonian — MethodHamiltonian(
    f::Function,
    dependencies::DataType...
) -> Hamiltonian{Autonomous, Fixed}
Return an Hamiltonian of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> H = Hamiltonian((x, p) -> x[1]^2+2p[2])
julia> H = Hamiltonian((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3]], NonAutonomous, NonFixed)CTBase.Hamiltonian — MethodHamiltonian(
    f::Function;
    autonomous,
    variable
) -> Hamiltonian{Autonomous, Fixed}
Return an Hamiltonian of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> H = Hamiltonian((x, p) -> x[1]^2+2p[2])
julia> H = Hamiltonian((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3]], autonomous=false, variable=true)CTBase.Hamiltonian — MethodReturn the value of the Hamiltonian.
julia> Hamiltonian((x, p) -> x + p, Int64)
IncorrectArgument 
julia> Hamiltonian((x, p) -> x + p, Int64)
IncorrectArgument
julia> H = Hamiltonian((x, p) -> [x[1]^2+2p[2]]) # autonomous=true, variable=false
julia> H([1, 0], [0, 1])
MethodError # H must return a scalar
julia> H = Hamiltonian((x, p) -> x[1]^2+2p[2])
julia> H([1, 0], [0, 1])
3
julia> t = 1
julia> v = Real[]
julia> H(t, [1, 0], [0, 1])
MethodError
julia> H([1, 0], [0, 1], v)
MethodError 
julia> H(t, [1, 0], [0, 1], v)
3
julia> H = Hamiltonian((x, p, v) -> x[1]^2+2p[2]+v[3], variable=true)
julia> H([1, 0], [0, 1], [1, 2, 3])
6
julia> H(t, [1, 0], [0, 1], [1, 2, 3])
6
julia> H = Hamiltonian((t, x, p) -> t+x[1]^2+2p[2], autonomous=false)
julia> H(1, [1, 0], [0, 1])
4
julia> H(1, [1, 0], [0, 1], v)
4
julia> H = Hamiltonian((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)
julia> H(1, [1, 0], [0, 1], [1, 2, 3])
7CTBase.HamiltonianLift — Typestruct HamiltonianLift{time_dependence, variable_dependence} <: AbstractHamiltonian{time_dependence, variable_dependence}Lifts
- X::VectorField
The values for time_dependence and variable_dependence are deternimed by the values of those for the VectorField.
Constructor
The constructor HamiltonianLift returns a HamiltonianLift of a VectorField.
Examples
julia> H = HamiltonianLift(VectorField(x -> [x[1]^2, 2x[2]]))
julia> H = HamiltonianLift(VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true))
julia> H = HamiltonianLift(VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false))
julia> H = HamiltonianLift(VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true))
julia> H = HamiltonianLift(VectorField(x -> [x[1]^2, 2x[2]]))
julia> H = HamiltonianLift(VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], NonFixed))
julia> H = HamiltonianLift(VectorField((t, x) -> [t+x[1]^2, 2x[2]], NonAutonomous))
julia> H = HamiltonianLift(VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], NonAutonomous, NonFixed))When the state and costate are of dimension 1, consider x and p as scalars.
Call
The call returns the evaluation of the HamiltonianLift for given values.
Examples
julia> H = HamiltonianLift(VectorField(x -> [x[1]^2, 2x[2]]))
julia> H([1, 2], [1, 1])
5
julia> t = 1
julia> v = Real[]
julia> H(t, [1, 0], [0, 1])
MethodError
julia> H([1, 0], [0, 1], v)
MethodError 
julia> H(t, [1, 0], [0, 1], v)
5
julia> H = HamiltonianLift(VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true))
julia> H([1, 0], [0, 1], [1, 2, 3])
3
julia> H(t, [1, 0], [0, 1], [1, 2, 3])
3
julia> H = HamiltonianLift(VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false))
julia> H(1, [1, 2], [1, 1])
6
julia> H(1, [1, 0], [0, 1], v)
6
julia> H = HamiltonianLift(VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true))
julia> H(1, [1, 0], [0, 1], [1, 2, 3])
3Alternatively, it is possible to construct the HamiltonianLift from a Function being the VectorField.
julia> HL1 = HamiltonianLift((x, v) -> [x[1]^2,x[2]^2+v], autonomous=true, variable=true)
julia> HL2 = HamiltonianLift(VectorField((x, v) -> [x[1]^2,x[2]^2+v], autonomous=true, variable=true))
julia> HL1([1, 0], [0, 1], 1) == HL2([1, 0], [0, 1], 1)
trueCTBase.HamiltonianLift — MethodHamiltonianLift(
    f::Function,
    dependences::DataType...
) -> HamiltonianLift
Return an HamiltonianLift of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> HamiltonianLift(HamiltonianLift(VectorField(x -> [x[1]^2, 2x[2]], Int64))
IncorrectArgument 
julia> HL = HamiltonianLift(x -> [x[1]^2,x[2]^2], Autonomous, Fixed)
julia> HL = HamiltonianLift((x, v) -> [x[1]^2,x[2]^2+v], Autonomous, NonFixed)
julia> HL = HamiltonianLift((t, x) -> [t+x[1]^2,x[2]^2], NonAutonomous, Fixed)
julia> HL = HamiltonianLift((t, x, v) -> [t+x[1]^2,x[2]^2+v], NonAutonomous, NonFixed)CTBase.HamiltonianLift — MethodHamiltonianLift(
    f::Function;
    autonomous,
    variable
) -> HamiltonianLift
Return an HamiltonianLift of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> HL = HamiltonianLift(x -> [x[1]^2,x[2]^2], autonomous=true, variable=false)
julia> HL = HamiltonianLift((x, v) -> [x[1]^2,x[2]^2+v], autonomous=true, variable=true)
julia> HL = HamiltonianLift((t, x) -> [t+x[1]^2,x[2]^2], autonomous=false, variable=false)
julia> HL = HamiltonianLift((t, x, v) -> [t+x[1]^2,x[2]^2+v], autonomous=false, variable=true)CTBase.HamiltonianLift — MethodReturn the value of the HamiltonianLift.
Examples
julia> HamiltonianLift(HamiltonianLift(VectorField(x -> [x[1]^2, 2x[2]], Int64))
IncorrectArgument 
julia> H = HamiltonianLift(VectorField(x -> [x[1]^2, 2x[2]]))
julia> H([1, 2], [1, 1])
5
julia> t = 1
julia> v = Real[]
julia> H(t, [1, 0], [0, 1])
MethodError
julia> H([1, 0], [0, 1], v)
MethodError 
julia> H(t, [1, 0], [0, 1], v)
5
julia> H = HamiltonianLift(VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true))
julia> H([1, 0], [0, 1], [1, 2, 3])
3
julia> H(t, [1, 0], [0, 1], [1, 2, 3])
3
julia> H = HamiltonianLift(VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false))
julia> H(1, [1, 2], [1, 1])
6
julia> H(1, [1, 0], [0, 1], v)
6
julia> H = HamiltonianLift(VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true))
julia> H(1, [1, 0], [0, 1], [1, 2, 3])
3CTBase.HamiltonianVectorField — Typestruct HamiltonianVectorField{time_dependence, variable_dependence} <: CTBase.AbstractVectorField{time_dependence, variable_dependence}Fields
- f::Function
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor HamiltonianVectorField returns a HamiltonianVectorField of a function. The function must take 2 to 4 arguments, (x, p) to (t, x, p, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2], Int64)
IncorrectArgument
julia> HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2], Int64)
IncorrectArgument
julia> Hv = HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2]) # autonomous=true, variable=false
julia> Hv = HamiltonianVectorField((x, p, v) -> [x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], variable=true)
julia> Hv = HamiltonianVectorField((t, x, p) -> [t+x[1]^2+2p[2], x[2]-3p[2]^2], autonomous=false)
julia> Hv = HamiltonianVectorField((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], autonomous=false, variable=true)
julia> Hv = HamiltonianVectorField((x, p, v) -> [x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], NonFixed)
julia> Hv = HamiltonianVectorField((t, x, p) -> [t+x[1]^2+2p[2], x[2]-3p[2]^2], NonAutonomous)
julia> Hv = HamiltonianVectorField((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], NonAutonomous, NonFixed)When the state and costate are of dimension 1, consider x and p as scalars.
Call
The call returns the evaluation of the HamiltonianVectorField for given values.
Examples
julia> Hv = HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2]) # autonomous=true, variable=false
julia> Hv([1, 0], [0, 1])
[3, -3]
julia> t = 1
julia> v = Real[]
julia> Hv(t, [1, 0], [0, 1])
MethodError
julia> Hv([1, 0], [0, 1], v)
MethodError
julia> Hv(t, [1, 0], [0, 1], v)
[3, -3]
julia> Hv = HamiltonianVectorField((x, p, v) -> [x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], variable=true)
julia> Hv([1, 0], [0, 1], [1, 2, 3, 4])
[6, -3]
julia> Hv(t, [1, 0], [0, 1], [1, 2, 3, 4])
[6, -3]
julia> Hv = HamiltonianVectorField((t, x, p) -> [t+x[1]^2+2p[2], x[2]-3p[2]^2], autonomous=false)
julia> Hv(1, [1, 0], [0, 1])
[4, -3]
julia> Hv(1, [1, 0], [0, 1], v)
[4, -3]
julia> Hv = HamiltonianVectorField((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], autonomous=false, variable=true)
julia> Hv(1, [1, 0], [0, 1], [1, 2, 3, 4])
[7, -3]CTBase.HamiltonianVectorField — MethodHamiltonianVectorField(
    f::Function,
    dependencies::DataType...
) -> HamiltonianVectorField{Autonomous, Fixed}
Return an HamiltonianVectorField of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2], Int64)
IncorrectArgument
julia> HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2], Int64)
IncorrectArgument
julia> Hv = HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2]) # autonomous=true, variable=false
julia> Hv = HamiltonianVectorField((x, p, v) -> [x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], NonFixed)
julia> Hv = HamiltonianVectorField((t, x, p) -> [t+x[1]^2+2p[2], x[2]-3p[2]^2], NonAutonomous)
julia> Hv = HamiltonianVectorField((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], NonAutonomous, NonFixed)CTBase.HamiltonianVectorField — MethodHamiltonianVectorField(
    f::Function;
    autonomous,
    variable
) -> HamiltonianVectorField{Autonomous, Fixed}
Return an HamiltonianVectorField of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> Hv = HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2]) # autonomous=true, variable=false
julia> Hv = HamiltonianVectorField((x, p, v) -> [x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], variable=true)
julia> Hv = HamiltonianVectorField((t, x, p) -> [t+x[1]^2+2p[2], x[2]-3p[2]^2], autonomous=false)
julia> Hv = HamiltonianVectorField((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], autonomous=false, variable=true)CTBase.HamiltonianVectorField — MethodReturn the value of the HamiltonianVectorField.
Examples
julia> HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2], Int64)
IncorrectArgument
julia> HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2], Int64)
IncorrectArgument
julia> Hv = HamiltonianVectorField((x, p) -> [x[1]^2+2p[2], x[2]-3p[2]^2]) # autonomous=true, variable=false
julia> Hv([1, 0], [0, 1])
[3, -3]
julia> t = 1
julia> v = Real[]
julia> Hv(t, [1, 0], [0, 1])
MethodError
julia> Hv([1, 0], [0, 1], v)
MethodError
julia> Hv(t, [1, 0], [0, 1], v)
[3, -3]
julia> Hv = HamiltonianVectorField((x, p, v) -> [x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], variable=true)
julia> Hv([1, 0], [0, 1], [1, 2, 3, 4])
[6, -3]
julia> Hv(t, [1, 0], [0, 1], [1, 2, 3, 4])
[6, -3]
julia> Hv = HamiltonianVectorField((t, x, p) -> [t+x[1]^2+2p[2], x[2]-3p[2]^2], autonomous=false)
julia> Hv(1, [1, 0], [0, 1])
[4, -3]
julia> Hv(1, [1, 0], [0, 1], v)
[4, -3]
julia> Hv = HamiltonianVectorField((t, x, p, v) -> [t+x[1]^2+2p[2]+v[3], x[2]-3p[2]^2+v[4]], autonomous=false, variable=true)
julia> Hv(1, [1, 0], [0, 1], [1, 2, 3, 4])
[7, -3]CTBase.IncorrectArgument — Typestruct IncorrectArgument <: CTExceptionException thrown when an argument is inconsistent.
Fields
- var::String
CTBase.IncorrectMethod — Typestruct IncorrectMethod <: CTExceptionException thrown when a method is incorrect.
Fields
- var::Symbol
CTBase.IncorrectOutput — Typestruct IncorrectOutput <: CTExceptionException thrown when the output is incorrect.
Fields
- var::String
CTBase.Index — Typemutable struct IndexFields
- val::Integer
CTBase.Lagrange — Typestruct Lagrange{time_dependence, variable_dependence}Fields
- f::Function
The default value for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor Lagrange returns a Lagrange cost of a function. The function must take 2 to 4 arguments, (x, u) to (t, x, u, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> Lagrange((x, u) -> 2x[2]-u[1]^2, Int64)
IncorrectArgument
julia> Lagrange((x, u) -> 2x[2]-u[1]^2, Int64)
IncorrectArgument
julia> L = Lagrange((x, u) -> [2x[2]-u[1]^2], autonomous=true, variable=false)
julia> L = Lagrange((x, u) -> 2x[2]-u[1]^2, autonomous=true, variable=false)
julia> L = Lagrange((x, u, v) -> 2x[2]-u[1]^2+v[3], autonomous=true, variable=true)
julia> L = Lagrange((t, x, u) -> t+2x[2]-u[1]^2, autonomous=false, variable=false)
julia> L = Lagrange((t, x, u, v) -> t+2x[2]-u[1]^2+v[3], autonomous=false, variable=true)
julia> L = Lagrange((x, u) -> [2x[2]-u[1]^2], Autonomous, Fixed)
julia> L = Lagrange((x, u) -> 2x[2]-u[1]^2, Autonomous, Fixed)
julia> L = Lagrange((x, u, v) -> 2x[2]-u[1]^2+v[3], Autonomous, NonFixed)
julia> L = Lagrange((t, x, u) -> t+2x[2]-u[1]^2, autonomous=false, Fixed)
julia> L = Lagrange((t, x, u, v) -> t+2x[2]-u[1]^2+v[3], autonomous=false, NonFixed)When the state is of dimension 1, consider x as a scalar. Same for the control.
Call
The call returns the evaluation of the Lagrange cost for given values.
Examples
julia> L = Lagrange((x, u) -> [2x[2]-u[1]^2], autonomous=true, variable=false)
julia> L([1, 0], [1])
MethodError
julia> L = Lagrange((x, u) -> 2x[2]-u[1]^2, autonomous=true, variable=false)
julia> L([1, 0], [1])
-1
julia> t = 1
julia> v = Real[]
julia> L(t, [1, 0], [1])
MethodError
julia> L([1, 0], [1], v)
MethodError
julia> L(t, [1, 0], [1], v)
-1
julia> L = Lagrange((x, u, v) -> 2x[2]-u[1]^2+v[3], autonomous=true, variable=true)
julia> L([1, 0], [1], [1, 2, 3])
2
julia> L(t, [1, 0], [1], [1, 2, 3])
2
julia> L = Lagrange((t, x, u) -> t+2x[2]-u[1]^2, autonomous=false, variable=false)
julia> L(1, [1, 0], [1])
0
julia> L(1, [1, 0], [1], v)
0
julia> L = Lagrange((t, x, u, v) -> t+2x[2]-u[1]^2+v[3], autonomous=false, variable=true)
julia> L(1, [1, 0], [1], [1, 2, 3])
3CTBase.Lagrange — MethodLagrange(
    f::Function,
    dependencies::DataType...
) -> Lagrange{Autonomous, Fixed}
Return a Lagrange cost of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> Lagrange((x, u) -> 2x[2]-u[1]^2, Int64)
IncorrectArgument
julia> Lagrange((x, u) -> 2x[2]-u[1]^2, Int64)
IncorrectArgument
julia> L = Lagrange((x, u) -> [2x[2]-u[1]^2], autonomous=true, variable=false)
julia> L = Lagrange((x, u) -> 2x[2]-u[1]^2, autonomous=true, variable=false)
julia> L = Lagrange((x, u, v) -> 2x[2]-u[1]^2+v[3], autonomous=true, variable=true)
julia> L = Lagrange((t, x, u) -> t+2x[2]-u[1]^2, autonomous=false, variable=false)
julia> L = Lagrange((t, x, u, v) -> t+2x[2]-u[1]^2+v[3], autonomous=false, variable=true)
CTBase.Lagrange — MethodLagrange(
    f::Function;
    autonomous,
    variable
) -> Lagrange{Autonomous, Fixed}
Return a Lagrange cost of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> L = Lagrange((x, u) -> [2x[2]-u[1]^2], autonomous=true, variable=false)
julia> L = Lagrange((x, u) -> 2x[2]-u[1]^2, autonomous=true, variable=false)
julia> L = Lagrange((x, u, v) -> 2x[2]-u[1]^2+v[3], autonomous=true, variable=true)
julia> L = Lagrange((t, x, u) -> t+2x[2]-u[1]^2, autonomous=false, variable=false)
julia> L = Lagrange((t, x, u, v) -> t+2x[2]-u[1]^2+v[3], autonomous=false, variable=true)
CTBase.Lagrange — MethodReturn the value of the Lagrange function.
Examples
julia> Lagrange((x, u) -> 2x[2]-u[1]^2, Int64)
IncorrectArgument
julia> Lagrange((x, u) -> 2x[2]-u[1]^2, Int64)
IncorrectArgument
julia> L = Lagrange((x, u) -> [2x[2]-u[1]^2], autonomous=true, variable=false)
julia> L([1, 0], [1])
MethodError
julia> L = Lagrange((x, u) -> 2x[2]-u[1]^2, autonomous=true, variable=false)
julia> L([1, 0], [1])
-1
julia> t = 1
julia> v = Real[]
julia> L(t, [1, 0], [1])
MethodError
julia> L([1, 0], [1], v)
MethodError
julia> L(t, [1, 0], [1], v)
-1
julia> L = Lagrange((x, u, v) -> 2x[2]-u[1]^2+v[3], autonomous=true, variable=true)
julia> L([1, 0], [1], [1, 2, 3])
2
julia> L(t, [1, 0], [1], [1, 2, 3])
2
julia> L = Lagrange((t, x, u) -> t+2x[2]-u[1]^2, autonomous=false, variable=false)
julia> L(1, [1, 0], [1])
0
julia> L(1, [1, 0], [1], v)
0
julia> L = Lagrange((t, x, u, v) -> t+2x[2]-u[1]^2+v[3], autonomous=false, variable=true)
julia> L(1, [1, 0], [1], [1, 2, 3])
3CTBase.Mayer — Typestruct Mayer{variable_dependence}Fields
- f::Function
The default value for variable_dependence is Fixed.
Constructor
The constructor Mayer returns a Mayer cost of a function. The function must take 2 or 3 arguments (x0, xf) or (x0, xf, v), if the function is variable, it must be specified.  Dependencies are specified with a boolean, variable, false by default or with a DataType, NonFixed/Fixed, Fixed by default.
Examples
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G = Mayer((x0, xf, v) -> v[3]+xf[2]-x0[1], variable=true)
julia> G = Mayer((x0, xf, v) -> v[3]+xf[2]-x0[1], NonFixed)When the state is of dimension 1, consider x0 and xf as a scalar.
Call
The call returns the evaluation of the Mayer cost for given values. If a variable is given for a non variable dependent Mayer cost, it will be ignored.
Examples
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G([0, 0], [1, 1])
1
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G([0, 0], [1, 1],Real[])
1
julia> G = Mayer((x0, xf, v) -> v[3]+xf[2]-x0[1], variable=true)
julia> G([0, 0], [1, 1], [1, 2, 3])
4CTBase.Mayer — MethodMayer(
    f::Function,
    dependencies::DataType...
) -> Mayer{Fixed}
Return a Mayer cost of a function. Dependencies are specified with a DataType, NonFixed/Fixed, Fixed by default.
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G = Mayer((x0, xf, v) -> v[3]+xf[2]-x0[1], NonFixed)CTBase.Mayer — MethodMayer(f::Function; variable) -> Mayer{Fixed}
Return a Mayer cost of a function. Dependencies are specified with a boolean, variable, false by default.
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G = Mayer((x0, xf, v) -> v[3]+xf[2]-x0[1], variable=true)CTBase.Mayer — MethodReturn the evaluation of the Mayer cost.
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G([0, 0], [1, 1])
1
julia> G = Mayer((x0, xf) -> xf[2]-x0[1])
julia> G([0, 0], [1, 1], Real[])
1
julia> G = Mayer((x0, xf, v) -> v[3]+xf[2]-x0[1], variable=true)
julia> G([0, 0], [1, 1], [1, 2, 3])
4CTBase.MixedConstraint — Typestruct MixedConstraint{time_dependence, variable_dependence}Fields
- f::Function
Similar to Lagrange in the usage, but the dimension of the output of the function f is arbitrary.
The default value for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor MixedConstraint returns a MixedConstraint of a function. The function must take 2 to 4 arguments, (x, u) to (t, x, u, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> M = MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Autonomous, Fixed)
julia> M = MixedConstraint((x, u, v) -> [2x[2]-u^2+v[3], x[1]], Autonomous, NonFixed)
julia> M = MixedConstraint((t, x, u) -> [t+2x[2]-u^2, x[1]], NonAutonomous, Fixed)
julia> M = MixedConstraint((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], NonAutonomous, NonFixed)
julia> M = MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> M = MixedConstraint((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> M = MixedConstraint((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> M = MixedConstraint((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)When the state is of dimension 1, consider x as a scalar. Same for the control.
Call
The call returns the evaluation of the MixedConstraint for given values.
Examples
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> M = MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> M([1, 0], 1)
[-1, 1]
julia> t = 1
julia> v = Real[]
julia> MethodError M(t, [1, 0], 1)
julia> MethodError M([1, 0], 1, v)
julia> M(t, [1, 0], 1, v)
[-1, 1]
julia> M = MixedConstraint((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> M([1, 0], 1, [1, 2, 3])
[2, 1]
julia> M(t, [1, 0], 1, [1, 2, 3])
[2, 1]
julia> M = MixedConstraint((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> M(1, [1, 0], 1)
[0, 1]
julia> M(1, [1, 0], 1, v)
[0, 1]
julia> M = MixedConstraint((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)
julia> M(1, [1, 0], 1, [1, 2, 3])
[3, 1]CTBase.MixedConstraint — MethodMixedConstraint(
    f::Function,
    dependencies::DataType...
) -> MixedConstraint{Autonomous, Fixed}
Return the MixedConstraint of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> M = MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Autonomous, Fixed)
julia> M = MixedConstraint((x, u, v) -> [2x[2]-u^2+v[3], x[1]], Autonomous, NonFixed)
julia> M = MixedConstraint((t, x, u) -> [t+2x[2]-u^2, x[1]], NonAutonomous, Fixed)
julia> M = MixedConstraint((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], NonAutonomous, NonFixed)CTBase.MixedConstraint — MethodMixedConstraint(
    f::Function;
    autonomous,
    variable
) -> MixedConstraint{Autonomous, Fixed}
Return the MixedConstraint of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> M = MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> M = MixedConstraint((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> M = MixedConstraint((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> M = MixedConstraint((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)CTBase.MixedConstraint — MethodReturn the value of the MixedConstraint function.
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], Int64)
IncorrectArgument
julia> M = MixedConstraint((x, u) -> [2x[2]-u^2, x[1]], autonomous=true, variable=false)
julia> M([1, 0], 1)
[-1, 1]
julia> t = 1
julia> v = Real[]
julia> MethodError M(t, [1, 0], 1)
julia> MethodError M([1, 0], 1, v)
julia> M(t, [1, 0], 1, v)
[-1, 1]
julia> M = MixedConstraint((x, u, v) -> [2x[2]-u^2+v[3], x[1]], autonomous=true, variable=true)
julia> M([1, 0], 1, [1, 2, 3])
[2, 1]
julia> M(t, [1, 0], 1, [1, 2, 3])
[2, 1]
julia> M = MixedConstraint((t, x, u) -> [t+2x[2]-u^2, x[1]], autonomous=false, variable=false)
julia> M(1, [1, 0], 1)
[0, 1]
julia> M(1, [1, 0], 1, v)
[0, 1]
julia> M = MixedConstraint((t, x, u, v) -> [t+2x[2]-u^2+v[3], x[1]], autonomous=false, variable=true)
julia> M(1, [1, 0], 1, [1, 2, 3])
[3, 1]CTBase.Multiplier — Typestruct Multiplier{time_dependence, variable_dependence}Fields
- f::Function
Similar to ControlLaw in the usage.
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor Multiplier returns a Multiplier of a function. The function must take 2 to 4 arguments, (x, p) to (t, x, p, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> Multiplier((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> Multiplier((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> μ = Multiplier((x, p) -> x[1]^2+2p[2], Autonomous, Fixed)
julia> μ = Multiplier((x, p, v) -> x[1]^2+2p[2]+v[3], Autonomous, NonFixed)
julia> μ = Multiplier((t, x, p) -> t+x[1]^2+2p[2], NonAutonomous, Fixed)
julia> μ = Multiplier((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], NonAutonomous, NonFixed)
julia> μ = Multiplier((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> μ = Multiplier((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> μ = Multiplier((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> μ = Multiplier((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)When the state and costate are of dimension 1, consider x and p as scalars.
Call
The call returns the evaluation of the Multiplier for given values.
Examples
julia> μ = Multiplier((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> μ([1, 0], [0, 1])
3
julia> t = 1
julia> v = Real[]
julia> μ(t, [1, 0], [0, 1])
MethodError
julia> μ([1, 0], [0, 1], v)
MethodError
julia> μ(t, [1, 0], [0, 1], v)
3
julia> μ = Multiplier((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> μ([1, 0], [0, 1], [1, 2, 3])
6
julia> μ(t, [1, 0], [0, 1], [1, 2, 3])
6
julia> μ = Multiplier((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> μ(1, [1, 0], [0, 1])
4
julia> μ(1, [1, 0], [0, 1], v)
4
julia> μ = Multiplier((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)
julia> μ(1, [1, 0], [0, 1], [1, 2, 3])
7CTBase.Multiplier — MethodMultiplier(
    f::Function,
    dependencies::DataType...
) -> Multiplier{Autonomous, Fixed}
Return the Multiplier of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> Multiplier((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> Multiplier((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> μ = Multiplier((x, p) -> x[1]^2+2p[2], Autonomous, Fixed)
julia> μ = Multiplier((x, p, v) -> x[1]^2+2p[2]+v[3], Autonomous, NonFixed)
julia> μ = Multiplier((t, x, p) -> t+x[1]^2+2p[2], NonAutonomous, Fixed)
julia> μ = Multiplier((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], NonAutonomous, NonFixed)CTBase.Multiplier — MethodMultiplier(
    f::Function;
    autonomous,
    variable
) -> Multiplier{Autonomous, Fixed}
Return the Multiplier of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> μ = Multiplier((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> μ = Multiplier((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> μ = Multiplier((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> μ = Multiplier((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)CTBase.Multiplier — MethodReturn the value of the Multiplier function.
julia> Multiplier((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> Multiplier((x, p) -> x[1]^2+2p[2], Int64)
IncorrectArgument
julia> μ = Multiplier((x, p) -> x[1]^2+2p[2], autonomous=true, variable=false)
julia> μ([1, 0], [0, 1])
3
julia> t = 1
julia> v = Real[]
julia> μ(t, [1, 0], [0, 1])
MethodError
julia> μ([1, 0], [0, 1], v)
MethodError
julia> μ(t, [1, 0], [0, 1], v)
3
julia> μ = Multiplier((x, p, v) -> x[1]^2+2p[2]+v[3], autonomous=true, variable=true)
julia> μ([1, 0], [0, 1], [1, 2, 3])
6
julia> μ(t, [1, 0], [0, 1], [1, 2, 3])
6
julia> μ = Multiplier((t, x, p) -> t+x[1]^2+2p[2], autonomous=false, variable=false)
julia> μ(1, [1, 0], [0, 1])
4
julia> μ(1, [1, 0], [0, 1], v)
4
julia> μ = Multiplier((t, x, p, v) -> t+x[1]^2+2p[2]+v[3], autonomous=false, variable=true)
julia> μ(1, [1, 0], [0, 1], [1, 2, 3])
7CTBase.NonAutonomous — Typeabstract type NonAutonomous <: TimeDependenceCTBase.NonFixed — Typeabstract type NonFixed <: VariableDependenceCTBase.NotImplemented — Typestruct NotImplemented <: CTExceptionException thrown when a method is not implemented.
Fields
- var::String
CTBase.OCPInit — TypeInitialization of the OCP solution that can be used when solving the discretized problem DOCP.
Constructors:
- OCPInit(): default initialization
- OCPInit(x_init, u_init, v_init): constant vector and/or function handles
- OCPInit(sol): from existing solution
Examples
julia> init = OCPInit()
julia> init = OCPInit(x_init=[0.1, 0.2], u_init=0.3)
julia> init = OCPInit(x_init=[0.1, 0.2], u_init=0.3, v_init=0.5)
julia> init = OCPInit(x_init=[0.1, 0.2], u_init=t->sin(t), v_init=0.5)
julia> init = OCPInit(sol)CTBase.OptimalControlModel — Typemutable struct OptimalControlModel{time_dependence<:TimeDependence, variable_dependence<:VariableDependence} <: CTBase.AbstractOptimalControlModelFields
- model_expression::Union{Nothing, Expr}: Default: nothing
- initial_time::Union{Nothing, Index, Real}: Default: nothing
- initial_time_name::Union{Nothing, String}: Default: nothing
- final_time::Union{Nothing, Index, Real}: Default: nothing
- final_time_name::Union{Nothing, String}: Default: nothing
- time_name::Union{Nothing, String}: Default: nothing
- control_dimension::Union{Nothing, Integer}: Default: nothing
- control_components_names::Union{Nothing, Vector{String}}: Default: nothing
- control_name::Union{Nothing, String}: Default: nothing
- state_dimension::Union{Nothing, Integer}: Default: nothing
- state_components_names::Union{Nothing, Vector{String}}: Default: nothing
- state_name::Union{Nothing, String}: Default: nothing
- variable_dimension::Union{Nothing, Integer}: Default: nothing
- variable_components_names::Union{Nothing, Vector{String}}: Default: nothing
- variable_name::Union{Nothing, String}: Default: nothing
- lagrange::Union{Nothing, Lagrange}: Default: nothing
- mayer::Union{Nothing, Mayer}: Default: nothing
- criterion::Union{Nothing, Symbol}: Default: nothing
- dynamics::Union{Nothing, Dynamics}: Default: nothing
- constraints::Dict{Symbol, Tuple}: Default: Dict{Symbol, Tuple{Vararg{Any}}}()
CTBase.OptimalControlSolution — Typemutable struct OptimalControlSolution <: CTBase.AbstractOptimalControlSolutionType of an optimal control solution.
Fields
- times::Union{Nothing, StepRangeLen, AbstractVector{<:Real}}: Default: nothing
- initial_time_name::Union{Nothing, String}: Default: nothing
- final_time_name::Union{Nothing, String}: Default: nothing
- time_name::Union{Nothing, String}: Default: nothing
- control_dimension::Union{Nothing, Integer}: Default: nothing
- control_components_names::Union{Nothing, Vector{String}}: Default: nothing
- control_name::Union{Nothing, String}: Default: nothing
- control::Union{Nothing, Function}: Default: nothing
- state_dimension::Union{Nothing, Integer}: Default: nothing
- state_components_names::Union{Nothing, Vector{String}}: Default: nothing
- state_name::Union{Nothing, String}: Default: nothing
- state::Union{Nothing, Function}: Default: nothing
- variable_dimension::Union{Nothing, Integer}: Default: nothing
- variable_components_names::Union{Nothing, Vector{String}}: Default: nothing
- variable_name::Union{Nothing, String}: Default: nothing
- variable::Union{Nothing, Real, AbstractVector{<:Real}}: Default: nothing
- costate::Union{Nothing, Function}: Default: nothing
- objective::Union{Nothing, Real}: Default: nothing
- iterations::Union{Nothing, Integer}: Default: nothing
- stopping::Union{Nothing, Symbol}: Default: nothing
- message::Union{Nothing, String}: Default: nothing
- success::Union{Nothing, Bool}: Default: nothing
- infos::Dict{Symbol, Any}: Default: Dict{Symbol, Any}()
CTBase.ParsingError — Typestruct ParsingError <: CTExceptionException thrown for syntax error during abstract parsing.
Fields
- var::String
CTBase.PrintCallback — Typemutable struct PrintCallback <: CTCallbackCallback for printing.
CTBase.PrintCallback — MethodCall the callback.
CTBase.StateConstraint — Typestruct StateConstraint{time_dependence, variable_dependence}Fields
- f::Function
Similar to VectorField in the usage, but the dimension of the output of the function f is arbitrary.
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor StateConstraint returns a StateConstraint of a function. The function must take 1 to 3 arguments, x to (t, x, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> S = StateConstraint(x -> [x[1]^2, 2x[2]], Autonomous, Fixed)
julia> S = StateConstraint((x, v) -> [x[1]^2, 2x[2]+v[3]], Autonomous, NonFixed)
julia> S = StateConstraint((t, x) -> [t+x[1]^2, 2x[2]], NonAutonomous, Fixed)
julia> S = StateConstraint((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], NonAutonomous, NonFixed)
julia> S = StateConstraint(x -> [x[1]^2, 2x[2]], autonomous=true, variable=false)
julia> S = StateConstraint((x, v) -> [x[1]^2, 2x[2]+v[3]], autonomous=true, variable=true)
julia> S = StateConstraint((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false, variable=false)
julia> S = StateConstraint((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)When the state is of dimension 1, consider x as a scalar.
Call
The call returns the evaluation of the StateConstraint for given values.
Examples
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> S = StateConstraint(x -> [x[1]^2, 2x[2]], autonomous=true, variable=false)
julia> S([1, -1])
[1, -2]
julia> t = 1
julia> v = Real[]
julia> S(t, [1, -1], v)
[1, -2]
julia> S = StateConstraint((x, v) -> [x[1]^2, 2x[2]+v[3]], autonomous=true, variable=true)
julia> S([1, -1], [1, 2, 3])
[1, 1]
julia> S(t, [1, -1], [1, 2, 3])
[1, 1]
julia> S = StateConstraint((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false, variable=false)
julia>  S(1, [1, -1])
[2, -2]
julia>  S(1, [1, -1], v)
[2, -2]
julia> S = StateConstraint((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)
julia>  S(1, [1, -1], [1, 2, 3])
[2, 1]CTBase.StateConstraint — MethodStateConstraint(
    f::Function,
    dependencies::DataType...
) -> StateConstraint{Autonomous, Fixed}
Return the StateConstraint of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> S = StateConstraint(x -> [x[1]^2, 2x[2]], Autonomous, Fixed)
julia> S = StateConstraint((x, v) -> [x[1]^2, 2x[2]+v[3]], Autonomous, NonFixed)
julia> S = StateConstraint((t, x) -> [t+x[1]^2, 2x[2]], NonAutonomous, Fixed)
julia> S = StateConstraint((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], NonAutonomous, NonFixed)CTBase.StateConstraint — MethodStateConstraint(
    f::Function;
    autonomous,
    variable
) -> StateConstraint{Autonomous, Fixed}
Return the StateConstraint of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> S = StateConstraint(x -> [x[1]^2, 2x[2]], autonomous=true, variable=false)
julia> S = StateConstraint((x, v) -> [x[1]^2, 2x[2]+v[3]], autonomous=true, variable=true)
julia> S = StateConstraint((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false, variable=false)
julia> S = StateConstraint((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)CTBase.StateConstraint — MethodReturn the value of the StateConstraint function.
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> StateConstraint(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> S = StateConstraint(x -> [x[1]^2, 2x[2]], autonomous=true, variable=false)
julia> S([1, -1])
[1, -2]
julia> t = 1
julia> v = Real[]
julia> S(t, [1, -1], v)
[1, -2]
julia> S = StateConstraint((x, v) -> [x[1]^2, 2x[2]+v[3]], autonomous=true, variable=true)
julia> S([1, -1], [1, 2, 3])
[1, 1]
julia> S(t, [1, -1], [1, 2, 3])
[1, 1]
julia> S = StateConstraint((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false, variable=false)
julia>  S(1, [1, -1])
[2, -2]
julia>  S(1, [1, -1], v)
[2, -2]
julia> S = StateConstraint((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)
julia>  S(1, [1, -1], [1, 2, 3])
[2, 1]CTBase.States — TypeType alias for a vector of states.
CTBase.StopCallback — TypeStopping callback.
CTBase.StopCallback — MethodCall the callback.
CTBase.Time — TypeType alias for a time.
CTBase.TimeDependence — Typeabstract type TimeDependenceCTBase.Times — TypeType alias for a vector of times.
CTBase.UnauthorizedCall — Typestruct UnauthorizedCall <: CTExceptionException thrown when a call to a function is not authorized.
Fields
- var::String
CTBase.VariableConstraint — Typestruct VariableConstraintFields
- f::Function
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor VariableConstraint returns a VariableConstraint of a function. The function must take 1 argument, v.
Examples
julia> V = VariableConstraint(v -> [v[1]^2, 2v[2]])When the variable is of dimension 1, consider v as a scalar.
Call
The call returns the evaluation of the VariableConstraint for given values.
Examples
julia> V = VariableConstraint(v -> [v[1]^2, 2v[2]])
julia> V([1, -1])
[1, -2]CTBase.VariableConstraint — MethodReturn the value of the VariableConstraint function.
julia> V = VariableConstraint(v -> [v[1]^2, 2v[2]])
julia> V([1, -1])
[1, -2]CTBase.VariableDependence — Typeabstract type VariableDependenceCTBase.VectorField — Typestruct VectorField{time_dependence, variable_dependence} <: CTBase.AbstractVectorField{time_dependence, variable_dependence}Fields
- f::Function
The default values for time_dependence and variable_dependence are Autonomous and Fixed respectively.
Constructor
The constructor VectorField returns a VectorField of a function. The function must take 1 to 3 arguments, x to (t, x, v), if the function is variable or non autonomous, it must be specified.  Dependencies are specified either with :
- booleans, autonomousandvariable, respectivelytrueandfalseby default
- DataType,- Autonomous/- NonAutonomousand- NonFixed/- Fixed, respectively- Autonomousand- Fixedby default.
Examples
julia> VectorField(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> VectorField(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> V = VectorField(x -> [x[1]^2, 2x[2]]) # autonomous=true, variable=false
julia> V = VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true)
julia> V = VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false)
julia> V = VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)
julia> V = VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], NonFixed)
julia> V = VectorField((t, x) -> [t+x[1]^2, 2x[2]], NonAutonomous)
julia> V = VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], NonAutonomous, NonFixed)When the state is of dimension 1, consider x as a scalar.
Call
The call returns the evaluation of the VectorField for given values.
Examples
julia> V = VectorField(x -> [x[1]^2, 2x[2]]) # autonomous=true, variable=false
julia> V([1, -1])
[1, -2]
julia> t = 1
julia> v = Real[]
julia> V(t, [1, -1])
MethodError
julia> V([1, -1], v)
MethodError
julia> V(t, [1, -1], v)
[1, -2]
julia> V = VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true)
julia> V([1, -1], [1, 2, 3])
[1, 1]
julia> V(t, [1, -1], [1, 2, 3])
[1, 1]
julia> V = VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false)
julia> V(1, [1, -1])
[2, -2]
julia> V(1, [1, -1], v)
[2, -2]
julia> V = VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)
julia> V(1, [1, -1], [1, 2, 3])
[2, 1]CTBase.VectorField — MethodVectorField(
    f::Function,
    dependencies::DataType...
) -> VectorField{Autonomous, Fixed}
Return a VectorField of a function. Dependencies are specified with DataType, Autonomous, NonAutonomous and Fixed, NonFixed.
julia> VectorField(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> VectorField(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> V = VectorField(x -> [x[1]^2, 2x[2]]) # autonomous=true, variable=false
julia> V = VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], NonFixed)
julia> V = VectorField((t, x) -> [t+x[1]^2, 2x[2]], NonAutonomous)
julia> V = VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], NonAutonomous, NonFixed)CTBase.VectorField — MethodVectorField(
    f::Function;
    autonomous,
    variable
) -> VectorField{Autonomous, Fixed}
Return a VectorField of a function. Dependencies are specified with a boolean, variable, false by default, autonomous, true by default.
julia> V = VectorField(x -> [x[1]^2, 2x[2]]) # autonomous=true, variable=false
julia> V = VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true)
julia> V = VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false)
julia> V = VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)CTBase.VectorField — MethodReturn the value of the VectorField.
Examples
julia> VectorField(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> VectorField(x -> [x[1]^2, 2x[2]], Int64)
IncorrectArgument
julia> V = VectorField(x -> [x[1]^2, 2x[2]]) # autonomous=true, variable=false
julia> V([1, -1])
[1, -2]
julia> t = 1
julia> v = Real[]
julia> V(t, [1, -1])
MethodError
julia> V([1, -1], v)
MethodError
julia> V(t, [1, -1], v)
[1, -2]
julia> V = VectorField((x, v) -> [x[1]^2, 2x[2]+v[3]], variable=true)
julia> V([1, -1], [1, 2, 3])
[1, 1]
julia> V(t, [1, -1], [1, 2, 3])
[1, 1]
julia> V = VectorField((t, x) -> [t+x[1]^2, 2x[2]], autonomous=false)
julia> V(1, [1, -1])
[2, -2]
julia> V(1, [1, -1], v)
[2, -2]
julia> V = VectorField((t, x, v) -> [t+x[1]^2, 2x[2]+v[3]], autonomous=false, variable=true)
julia> V(1, [1, -1], [1, 2, 3])
[2, 1]CTBase.ctNumber — TypeType alias for a real number.
CTBase.:⋅ — Method⋅(X::Function, f::Function) -> Function
Lie derivative of a scalar function along a function. In this case both functions will be considered autonomous and non-variable.
Example
julia> φ = x -> [x[2], -x[1]]
julia> f = x -> x[1]^2 + x[2]^2
julia> (φ⋅f)([1, 2])
0
julia> φ = (t, x, v) -> [t + x[2] + v[1], -x[1] + v[2]]
julia> f = (t, x, v) -> t + x[1]^2 + x[2]^2
julia> (φ⋅f)(1, [1, 2], [2, 1])
MethodErrorCTBase.:⋅ — Method⋅(
    X::VectorField{Autonomous, <:VariableDependence},
    f::Function
) -> CTBase.var"#106#108"{VectorField{Autonomous, var"#s97"}, <:Function} where var"#s97"<:VariableDependence
Lie derivative of a scalar function along a vector field : L_X(f) = X⋅f, in autonomous case
Example
julia> φ = x -> [x[2], -x[1]]
julia> X = VectorField(φ)
julia> f = x -> x[1]^2 + x[2]^2
julia> (X⋅f)([1, 2])
0CTBase.:⋅ — Method⋅(
    X::VectorField{NonAutonomous, <:VariableDependence},
    f::Function
) -> CTBase.var"#110#112"{VectorField{NonAutonomous, var"#s97"}, <:Function} where var"#s97"<:VariableDependence
Lie derivative of a scalar function along a vector field : L_X(f) = X⋅f, in nonautonomous case
Example
julia> φ = (t, x, v) -> [t + x[2] + v[1], -x[1] + v[2]]
julia> X = VectorField(φ, NonAutonomous, NonFixed)
julia> f = (t, x, v) -> t + x[1]^2 + x[2]^2
julia> (X⋅f)(1, [1, 2], [2, 1])
10CTBase.Lie — MethodLie(
    X::Function,
    f::Function,
    dependences::DataType...
) -> Function
Lie derivative of a scalar function along a vector field or a function. Dependencies are specified with DataType : Autonomous, NonAutonomous and Fixed, NonFixed.
Example
julia> φ = x -> [x[2], -x[1]]
julia> f = x -> x[1]^2 + x[2]^2
julia> Lie(φ,f)([1, 2])
0
julia> φ = (t, x, v) -> [t + x[2] + v[1], -x[1] + v[2]]
julia> f = (t, x, v) -> t + x[1]^2 + x[2]^2
julia> Lie(φ, f, NonAutonomous, NonFixed)(1, [1, 2], [2, 1])
10CTBase.Lie — MethodLie(
    X::Function,
    f::Function;
    autonomous,
    variable
) -> Function
Lie derivative of a scalar function along a function. Dependencies are specified with boolean : autonomous and variable.
Example
julia> φ = x -> [x[2], -x[1]]
julia> f = x -> x[1]^2 + x[2]^2
julia> Lie(φ,f)([1, 2])
0
julia> φ = (t, x, v) -> [t + x[2] + v[1], -x[1] + v[2]]
julia> f = (t, x, v) -> t + x[1]^2 + x[2]^2
julia> Lie(φ, f, autonomous=false, variable=true)(1, [1, 2], [2, 1])
10CTBase.Lie — MethodLie(X::VectorField, f::Function) -> Function
Lie derivative of a scalar function along a vector field.
Example
julia> φ = x -> [x[2], -x[1]]
julia> X = VectorField(φ)
julia> f = x -> x[1]^2 + x[2]^2
julia> Lie(X,f)([1, 2])
0
julia> φ = (t, x, v) -> [t + x[2] + v[1], -x[1] + v[2]]
julia> X = VectorField(φ, NonAutonomous, NonFixed)
julia> f = (t, x, v) -> t + x[1]^2 + x[2]^2
julia> Lie(X, f)(1, [1, 2], [2, 1])
10CTBase.Lie — MethodLie(
    X::VectorField{Autonomous, V<:VariableDependence},
    Y::VectorField{Autonomous, V<:VariableDependence}
) -> VectorField
Lie bracket of two vector fields: [X, Y] = Lie(X, Y), autonomous case
Example
julia> f = x -> [x[2], 2x[1]]
julia> g = x -> [3x[2], -x[1]]
julia> X = VectorField(f)
julia> Y = VectorField(g)
julia> Lie(X, Y)([1, 2])
[7, -14]CTBase.Lie — MethodLie(
    X::VectorField{NonAutonomous, V<:VariableDependence},
    Y::VectorField{NonAutonomous, V<:VariableDependence}
) -> VectorField{NonAutonomous}
Lie bracket of two vector fields: [X, Y] = Lie(X, Y), nonautonomous case
Example
julia> f = (t, x, v) -> [t + x[2] + v, -2x[1] - v]
julia> g = (t, x, v) -> [t + 3x[2] + v, -x[1] - v]
julia> X = VectorField(f, NonAutonomous, NonFixed)
julia> Y = VectorField(g, NonAutonomous, NonFixed)
julia> Lie(X, Y)(1, [1, 2], 1)
[-7,12]CTBase.Lift — MethodLift(
    X::Function,
    dependences::DataType...
) -> HamiltonianLift
Return the HamiltonianLift of a VectorField or a function. Dependencies are specified with DataType : Autonomous, NonAutonomous and Fixed, NonFixed.
Example
julia> H = Lift(x -> 2x)
julia> H(1, 1)
2
julia> H = Lift((t, x, v) -> 2x + t - v, NonAutonomous, NonFixed)
julia> H(1, 1, 1, 1)
2CTBase.Lift — MethodLift(X::Function; autonomous, variable) -> HamiltonianLift
Return the HamiltonianLift of a function. Dependencies are specified with boolean : autonomous and variable.
Example
julia> H = Lift(x -> 2x)
julia> H(1, 1)
2
julia> H = Lift((t, x, v) -> 2x + t - v, autonomous=false, variable=true)
julia> H(1, 1, 1, 1)
2CTBase.Lift — MethodLift(X::VectorField) -> HamiltonianLift
Return the HamiltonianLift of a VectorField.
Example
julia> HL = Lift(VectorField(x -> [x[1]^2,x[2]^2], autonomous=true, variable=false))
julia> HL([1, 0], [0, 1])
0
julia> HL = Lift(VectorField((t, x, v) -> [t+x[1]^2,x[2]^2+v], autonomous=false, variable=true))
julia> HL(1, [1, 0], [0, 1], 1)
1
julia> H = Lift(x -> 2x)
julia> H(1, 1)
2
julia> H = Lift((t, x, v) -> 2x + t - v, autonomous=false, variable=true)
julia> H(1, 1, 1, 1)
2
julia> H = Lift((t, x, v) -> 2x + t - v, NonAutonomous, NonFixed)
julia> H(1, 1, 1, 1)
2CTBase.Model — MethodModel(
    dependencies::DataType...
) -> OptimalControlModel{Autonomous, Fixed}
Return a new OptimalControlModel instance, that is a model of an optimal control problem.
The model is defined by the following argument:
- dependencies: either- Autonomousor- NonAutonomous. Default is- Autonomous. And either- NonFixedor- Fixed. Default is- Fixed.
Examples
julia> ocp = Model()
julia> ocp = Model(NonAutonomous)
julia> ocp = Model(Autonomous, NonFixed)- If the time dependence of the model is defined as nonautonomous, then, the dynamics function, the lagrange cost and the path constraints must be defined as functions of time and state, and possibly control. If the model is defined as autonomous, then, the dynamics function, the lagrange cost and the path constraints must be defined as functions of state, and possibly control.
CTBase.Model — MethodModel(
;
    autonomous,
    variable
) -> OptimalControlModel{Autonomous, Fixed}
Return a new OptimalControlModel instance, that is a model of an optimal control problem.
The model is defined by the following optional keyword argument:
- autonomous: either- trueor- false. Default is- true.
- variable: either- trueor- false. Default is- false.
Examples
julia> ocp = Model()
julia> ocp = Model(autonomous=false)
julia> ocp = Model(autonomous=false, variable=true)- If the time dependence of the model is defined as nonautonomous, then, the dynamics function, the lagrange cost and the path constraints must be defined as functions of time and state, and possibly control. If the model is defined as autonomous, then, the dynamics function, the lagrange cost and the path constraints must be defined as functions of state, and possibly control.
CTBase.Poisson — MethodPoisson(
    f::Function,
    g::Function,
    dependences::DataType...
) -> Hamiltonian
Poisson bracket of two functions : {f, g} = Poisson(f, g) Dependencies are specified with DataType : Autonomous, NonAutonomous and Fixed, NonFixed.
Example
julia> f = (x, p) -> x[2]^2 + 2x[1]^2 + p[1]^2
julia> g = (x, p) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1]
julia> Poisson(f, g)([1, 2], [2, 1])
-20            
julia> f = (t, x, p, v) -> t*v[1]*x[2]^2 + 2x[1]^2 + p[1]^2 + v[2]
julia> g = (t, x, p, v) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1] + t - v[2]
julia> Poisson(f, g, NonAutonomous, NonFixed)(2, [1, 2], [2, 1], [4, 4])
-76CTBase.Poisson — MethodPoisson(
    f::Function,
    g::Function;
    autonomous,
    variable
) -> Hamiltonian
Poisson bracket of two functions : {f, g} = Poisson(f, g) Dependencies are specified with boolean : autonomous and variable.
Example
julia> f = (x, p) -> x[2]^2 + 2x[1]^2 + p[1]^2
julia> g = (x, p) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1]
julia> Poisson(f, g)([1, 2], [2, 1])
-20            
julia> f = (t, x, p, v) -> t*v[1]*x[2]^2 + 2x[1]^2 + p[1]^2 + v[2]
julia> g = (t, x, p, v) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1] + t - v[2]
julia> Poisson(f, g, autonomous=false, variable=true)(2, [1, 2], [2, 1], [4, 4])
-76CTBase.Poisson — MethodPoisson(
    f::AbstractHamiltonian{Autonomous, V<:VariableDependence},
    g::AbstractHamiltonian{Autonomous, V<:VariableDependence}
) -> HamiltonianLift
Poisson bracket of two Hamiltonian functions (subtype of AbstractHamiltonian) : {f, g} = Poisson(f, g), autonomous case
Example
julia> f = (x, p) -> x[2]^2 + 2x[1]^2 + p[1]^2
julia> g = (x, p) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1]
julia> F = Hamiltonian(f)
julia> G = Hamiltonian(g)
julia> Poisson(f, g)([1, 2], [2, 1])
-20            
julia> Poisson(f, G)([1, 2], [2, 1])
-20
julia> Poisson(F, g)([1, 2], [2, 1])
-20CTBase.Poisson — MethodPoisson(
    f::AbstractHamiltonian{NonAutonomous, V<:VariableDependence},
    g::AbstractHamiltonian{NonAutonomous, V<:VariableDependence}
) -> HamiltonianLift
Poisson bracket of two Hamiltonian functions (subtype of AbstractHamiltonian) : {f, g} = Poisson(f, g), non autonomous case
Example
julia> f = (t, x, p, v) -> t*v[1]*x[2]^2 + 2x[1]^2 + p[1]^2 + v[2]
julia> g = (t, x, p, v) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1] + t - v[2]
julia> F = Hamiltonian(f, autonomous=false, variable=true)
julia> G = Hamiltonian(g, autonomous=false, variable=true)
julia> Poisson(F, G)(2, [1, 2], [2, 1], [4, 4])
-76
julia> Poisson(f, g, NonAutonomous, NonFixed)(2, [1, 2], [2, 1], [4, 4])
-76CTBase.Poisson — MethodPoisson(
    f::AbstractHamiltonian{T<:TimeDependence, V<:VariableDependence},
    g::Function
) -> Hamiltonian
Poisson bracket of an Hamiltonian function (subtype of AbstractHamiltonian) and a function : {f, g} = Poisson(f, g), autonomous case
Example
julia> f = (x, p) -> x[2]^2 + 2x[1]^2 + p[1]^2
julia> g = (x, p) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1]
julia> F = Hamiltonian(f)
julia> Poisson(F, g)([1, 2], [2, 1])
-20
julia> f = (t, x, p, v) -> t*v[1]*x[2]^2 + 2x[1]^2 + p[1]^2 + v[2]
julia> g = (t, x, p, v) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1] + t - v[2]
julia> F = Hamiltonian(f, autonomous=false, variable=true)
julia> Poisson(F, g)(2, [1, 2], [2, 1], [4, 4])
-76CTBase.Poisson — MethodPoisson(
    f::Function,
    g::AbstractHamiltonian{T<:TimeDependence, V<:VariableDependence}
) -> Hamiltonian
Poisson bracket of a function and an Hamiltonian function (subtype of AbstractHamiltonian) : {f, g} = Poisson(f, g)
Example
julia> f = (x, p) -> x[2]^2 + 2x[1]^2 + p[1]^2
julia> g = (x, p) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1]
julia> G = Hamiltonian(g)          
julia> Poisson(f, G)([1, 2], [2, 1])
-20
julia> f = (t, x, p, v) -> t*v[1]*x[2]^2 + 2x[1]^2 + p[1]^2 + v[2]
julia> g = (t, x, p, v) -> 3x[2]^2 + -x[1]^2 + p[2]^2 + p[1] + t - v[2]
julia> G = Hamiltonian(g, autonomous=false, variable=true)
julia> Poisson(f, G)(2, [1, 2], [2, 1], [4, 4])
-76CTBase.Poisson — MethodPoisson(
    f::HamiltonianLift{T<:TimeDependence, V<:VariableDependence},
    g::HamiltonianLift{T<:TimeDependence, V<:VariableDependence}
) -> HamiltonianLift
Poisson bracket of two HamiltonianLift functions : {f, g} = Poisson(f, g)
Example
julia> f = x -> [x[1]^2+x[2]^2, 2x[1]^2]
julia> g = x -> [3x[2]^2, x[2]-x[1]^2]
julia> F = Lift(f)
julia> G = Lift(g)
julia> Poisson(F, G)([1, 2], [2, 1])
-64
julia> f = (t, x, v) -> [t*v[1]*x[2]^2, 2x[1]^2 + + v[2]]
julia> g = (t, x, v) -> [3x[2]^2 + -x[1]^2, t - v[2]]
julia> F = Lift(f, NonAutonomous, NonFixed)
julia> G = Lift(g, NonAutonomous, NonFixed)
julia> Poisson(F, G)(2, [1, 2], [2, 1], [4, 4])
100CTBase.add — Methodadd(
    x::Tuple{Vararg{Tuple{Vararg{Symbol}}}},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Tuple{Vararg{Symbol}}}
Concatenate the description y at the tuple of descriptions x if it is not already in the tuple x.
Example
julia> descriptions = ()
julia> descriptions = add(descriptions, (:a,))
((:a,),)
julia> descriptions = add(descriptions, (:b,))
((:a,), (:b,))CTBase.add — Methodadd(
    x::Tuple{},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Tuple{Vararg{Symbol}}}
Return a tuple containing only the description y.
Example
julia> descriptions = ()
julia> descriptions = add(descriptions, (:a,))
((:a,),)
julia> descriptions[1]
(:a,)CTBase.constraint! — Functionconstraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    lb::Union{Real, AbstractVector{<:Real}},
    ub::Union{Real, AbstractVector{<:Real}}
)
constraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    lb::Union{Real, AbstractVector{<:Real}},
    ub::Union{Real, AbstractVector{<:Real}},
    label::Symbol
)
Add an :initial, :final, :control, :state or :variable box constraint (whole range).
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Examples
julia> constraint!(ocp, :initial, [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :final, [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :control, [ 0, 0 ], [ 2, 3 ])
julia> constraint!(ocp, :state, [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :variable, 0, 1) # the variable here is of dimension 1CTBase.constraint! — Functionconstraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    f::Function,
    val::Union{Real, AbstractVector{<:Real}}
)
constraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    f::Function,
    val::Union{Real, AbstractVector{<:Real}},
    label::Symbol
)
Add a :boundary, :control, :state, :mixed or :variable value functional constraint.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Examples
# variable independent ocp
julia> constraint!(ocp, :boundary, (x0, xf) -> x0[3]+xf[2], 0)
# variable dependent ocp
julia> constraint!(ocp, :boundary, (x0, xf, v) -> x0[3]+xf[2]*v[1], 0)
# time independent and variable independent ocp
julia> constraint!(ocp, :control, u -> 2u, 1)
julia> constraint!(ocp, :state, x -> x-1, [ 0, 0, 0 ])
julia> constraint!(ocp, :mixed, (x, u) -> x[1]-u, 0)
# time dependent and variable independent ocp
julia> constraint!(ocp, :control, (t, u) -> 2u, 1)
julia> constraint!(ocp, :state, (t, x) -> x-t, [ 0, 0, 0 ])
julia> constraint!(ocp, :mixed, (t, x, u) -> x[1]-u, 0)
# time independent and variable dependent ocp
julia> constraint!(ocp, :control, (u, v) -> 2u*v[1], 1)
julia> constraint!(ocp, :state, (x, v) -> x-v[2], [ 0, 0, 0 ])
julia> constraint!(ocp, :mixed, (x, u) -> x[1]-u+v[1], 0)
# time dependent and variable dependent ocp
julia> constraint!(ocp, :control, (t, u, v) -> 2u-t*v[2], 1)
julia> constraint!(ocp, :state, (t, x, v) -> x-t+v[1], [ 0, 0, 0 ])
julia> constraint!(ocp, :mixed, (t, x, u, v) -> x[1]-u*v[1], 0)CTBase.constraint! — Functionconstraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    rg::Union{Index, OrdinalRange{<:Integer}},
    val::Union{Real, AbstractVector{<:Real}}
)
constraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    rg::Union{Index, OrdinalRange{<:Integer}},
    val::Union{Real, AbstractVector{<:Real}},
    label::Symbol
)
Add an :initial or :final value constraint on a range of the state, or a value constraint on a range of the :variable.
- The range of the constraint must be contained in 1:n if the constraint is on the state, or 1:q if the constraint is on the variable.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
Examples
julia> constraint!(ocp, :initial, 1:2:5, [ 0, 0, 0 ])
julia> constraint!(ocp, :initial, 2:3, [ 0, 0 ])
julia> constraint!(ocp, :final, Index(2), 0)
julia> constraint!(ocp, :variable, 2:3, [ 0, 3 ])CTBase.constraint! — Functionconstraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    val::Union{Real, AbstractVector{<:Real}}
)
constraint!(
    ocp::OptimalControlModel,
    type::Symbol,
    val::Union{Real, AbstractVector{<:Real}},
    label::Symbol
)
Add an :initial or :final value constraint on the state, or a :variable value. Can also be used with :state and :control.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Examples
julia> constraint!(ocp, :initial, [ 0, 0 ])
julia> constraint!(ocp, :final, 2) # if the state is of dimension 1
julia> constraint!(ocp, :variable, [ 3, 0, 1 ])CTBase.constraint! — Methodconstraint!(
    ocp::OptimalControlModel,
    type::Symbol;
    rg,
    f,
    val,
    lb,
    ub,
    label
)
Add an :initial, :final, :control, :state or :variable box constraint on a range.
- The range of the constraint must be contained in 1:n if the constraint is on the state, or 1:m if the constraint is on the control, or 1:q if the constraint is on the variable.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
Examples
julia> constraint!(ocp, :initial, rg=2:3, lb=[ 0, 0 ], ub=[ 1, 2 ])
julia> constraint!(ocp, :final, val=Index(1), lb=0, ub=2)
julia> constraint!(ocp, :control, val=Index(1), lb=0, ub=2)
julia> constraint!(ocp, :state, rg=2:3, lb=[ 0, 0 ], ub=[ 1, 2 ])
julia> constraint!(ocp, :initial, rg=1:2:5, lb=[ 0, 0, 0 ], ub=[ 1, 2, 1 ])
julia> constraint!(ocp, :variable, rg=1:2, lb=[ 0, 0 ], ub=[ 1, 2 ])CTBase.constraint! — Methodconstraint!(
    ocp::OptimalControlModel{<:TimeDependence, V<:VariableDependence},
    type::Symbol,
    rg::Union{Index, OrdinalRange{<:Integer}},
    lb::Union{Real, AbstractVector{<:Real}},
    ub::Union{Real, AbstractVector{<:Real}}
)
constraint!(
    ocp::OptimalControlModel{<:TimeDependence, V<:VariableDependence},
    type::Symbol,
    rg::Union{Index, OrdinalRange{<:Integer}},
    lb::Union{Real, AbstractVector{<:Real}},
    ub::Union{Real, AbstractVector{<:Real}},
    label::Symbol
)
Add an :initial, :final, :control, :state or :variable box constraint on a range.
- The range of the constraint must be contained in 1:n if the constraint is on the state, or 1:m if the constraint is on the control, or 1:q if the constraint is on the variable.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
Examples
julia> constraint!(ocp, :initial, 2:3, [ 0, 0 ], [ 1, 2 ])
julia> constraint!(ocp, :final, Index(1), 0, 2)
julia> constraint!(ocp, :control, Index(1), 0, 2)
julia> constraint!(ocp, :state, 2:3, [ 0, 0 ], [ 1, 2 ])
julia> constraint!(ocp, :initial, 1:2:5, [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :variable, 1:2, [ 0, 0 ], [ 1, 2 ])CTBase.constraint! — Methodconstraint!(
    ocp::OptimalControlModel{T, V},
    type::Symbol,
    f::Function,
    lb::Union{Real, AbstractVector{<:Real}},
    ub::Union{Real, AbstractVector{<:Real}}
)
constraint!(
    ocp::OptimalControlModel{T, V},
    type::Symbol,
    f::Function,
    lb::Union{Real, AbstractVector{<:Real}},
    ub::Union{Real, AbstractVector{<:Real}},
    label::Symbol
)
Add a :boundary, :control, :state, :mixed or :variable box functional constraint.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Examples
# variable independent ocp
julia> constraint!(ocp, :boundary, (x0, xf) -> x0[3]+xf[2], 0, 1)
# variable dependent ocp
julia> constraint!(ocp, :boundary, (x0, xf, v) -> x0[3]+xf[2]*v[1], 0, 1)
# time independent and variable independent ocp
julia> constraint!(ocp, :control, u -> 2u, 0, 1)
julia> constraint!(ocp, :state, x -> x-1, [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :mixed, (x, u) -> x[1]-u, 0, 1)
# time dependent and variable independent ocp
julia> constraint!(ocp, :control, (t, u) -> 2u, 0, 1)
julia> constraint!(ocp, :state, (t, x) -> x-t, [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :mixed, (t, x, u) -> x[1]-u, 0, 1)
# time independent and variable dependent ocp
julia> constraint!(ocp, :control, (u, v) -> 2u*v[1], 0, 1)
julia> constraint!(ocp, :state, (x, v) -> x-v[1], [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :mixed, (x, u, v) -> x[1]-v[2]*u, 0, 1)
# time dependent and variable dependent ocp
julia> constraint!(ocp, :control, (t, u, v) -> 2u+v[2], 0, 1)
julia> constraint!(ocp, :state, (t, x, v) -> x-t*v[1], [ 0, 0, 0 ], [ 1, 2, 1 ])
julia> constraint!(ocp, :mixed, (t, x, u, v) -> x[1]*v[2]-u, 0, 1)CTBase.constraint — Methodconstraint(
    ocp::OptimalControlModel{T<:TimeDependence, V<:VariableDependence},
    label::Symbol
) -> Any
Retrieve a labeled constraint. The result is a function associated with the constraint computation (not taking into account provided value / bounds).
Example
julia> constraint!(ocp, :initial, 0, :c0)
julia> c = constraint(ocp, :c0)
julia> c(1)
1CTBase.constraint_type — Methodconstraint_type(
    e,
    t,
    t0,
    tf,
    x,
    u,
    v
) -> Union{Symbol, Tuple{Symbol, Any}}
Return the type constraint among :initial, :final, :boundary, :control_range, :control_fun, :state_range, :state_fun, :mixed, :variable_range, :variable_fun (:other otherwise), together with the appropriate value (range, updated expression...)
Example
julia> t = :t; t0 = 0; tf = :tf; x = :x; u = :u; v = :v
julia> constraint_type(:( ẏ(t) ), t, t0, tf, x, u, v)
:other
julia> constraint_type(:( ẋ(s) ), t, t0, tf, x, u, v)
:other
julia> constraint_type(:( x(0)' ), t, t0, tf, x, u, v)
:boundary
julia> constraint_type(:( x(t)' ), t, t0, tf, x, u, v)
:state_fun
julia> constraint_type(:( x(0) ), t, t0, tf, x, u, v)
(:initial, nothing)
julia> constraint_type(:( x[1:2:5](0) ), t, t0, tf, x, u, v)
(:initial, 1:2:5)
julia> constraint_type(:( x[1:2](0) ), t, t0, tf, x, u, v)
(:initial, 1:2)
julia> constraint_type(:( x[1](0) ), t, t0, tf, x, u, v)
(:initial, Index(1))
julia> constraint_type(:( 2x[1](0)^2 ), t, t0, tf, x, u, v)
:boundary
julia> constraint_type(:( x(tf) ), t, t0, tf, x, u, v)
(:final, nothing)
j
julia> constraint_type(:( x[1:2:5](tf) ), t, t0, tf, x, u, v)
(:final, 1:2:5)
julia> constraint_type(:( x[1:2](tf) ), t, t0, tf, x, u, v)
(:final, 1:2)
julia> constraint_type(:( x[1](tf) ), t, t0, tf, x, u, v)
(:final, Index(1))
julia> constraint_type(:( 2x[1](tf)^2 ), t, t0, tf, x, u, v)
:boundary
julia> constraint_type(:( x[1](tf) - x[2](0) ), t, t0, tf, x, u, v)
:boundary
julia> constraint_type(:( u[1:2:5](t) ), t, t0, tf, x, u, v)
(:control_range, 1:2:5)
julia> constraint_type(:( u[1:2](t) ), t, t0, tf, x, u, v)
(:control_range, 1:2)
julia> constraint_type(:( u[1](t) ), t, t0, tf, x, u, v)
(:control_range, Index(1))
julia> constraint_type(:( u(t) ), t, t0, tf, x, u, v)
(:control_range, nothing)
julia> constraint_type(:( 2u[1](t)^2 ), t, t0, tf, x, u, v)
:control_fun
julia> constraint_type(:( x[1:2:5](t) ), t, t0, tf, x, u, v)
(:state_range, 1:2:5)
julia> constraint_type(:( x[1:2](t) ), t, t0, tf, x, u, v)
(:state_range, 1:2)
julia> constraint_type(:( x[1](t) ), t, t0, tf, x, u, v)
(:state_range, Index(1))
julia> constraint_type(:( x(t) ), t, t0, tf, x, u, v)
(:state_range, nothing)
julia> constraint_type(:( 2x[1](t)^2 ), t, t0, tf, x, u, v)
:state_fun
julia> constraint_type(:( 2u[1](t)^2 * x(t) ), t, t0, tf, x, u, v)
:mixed
julia> constraint_type(:( 2u[1](0)^2 * x(t) ), t, t0, tf, x, u, v)
:other
julia> constraint_type(:( 2u[1](0)^2 * x(t) ), t, t0, tf, x, u, v)
:other
julia> constraint_type(:( 2u[1](t)^2 * x(t) + v ), t, t0, tf, x, u, v)
:mixed
julia> constraint_type(:( v[1:2:10] ), t, t0, tf, x, u, v)
(:variable_range, 1:2:9)
julia> constraint_type(:( v[1:10] ), t, t0, tf, x, u, v)
(:variable_range, 1:10)
julia> constraint_type(:( v[2] ), t, t0, tf, x, u, v)
(:variable_range, Index(2))
julia> constraint_type(:( v ), t, t0, tf, x, u, v)
(:variable_range, nothing)
julia> constraint_type(:( v^2  + 1 ), t, t0, tf, x, u, v)
(:variable_fun, :(v ^ 2 + 1))
julia> constraint_type(:( v[2]^2 + 1 ), t, t0, tf, x, u, v)
(:variable_fun, :(v[2] ^ 2 + 1))CTBase.constraints_labels — Methodconstraints_labels(
    ocp::OptimalControlModel
) -> Base.KeySet{Symbol, Dict{Symbol, Tuple}}
Return the labels of the constraints as a Base.keys.
Example
julia> constraints_labels(ocp)CTBase.control! — Functioncontrol!(ocp::OptimalControlModel, m::Integer)
control!(ocp::OptimalControlModel, m::Integer, name::String)
control!(
    ocp::OptimalControlModel,
    m::Integer,
    name::String,
    components_names::Vector{String}
)
Define the control dimension and possibly the names of each coordinate.
You must use control! only once to set the control dimension.
Examples
julia> control!(ocp, 1)
julia> ocp.control_dimension
1
julia> ocp.control_components_names
["u"]
julia> control!(ocp, 1, "v")
julia> ocp.control_dimension
1
julia> ocp.control_components_names
["v"]
julia> control!(ocp, 2)
julia> ocp.control_dimension
2
julia> ocp.control_components_names
["u₁", "u₂"]
julia> control!(ocp, 2, :v)
julia> ocp.control_dimension
2
julia> ocp.control_components_names
["v₁", "v₂"]
julia> control!(ocp, 2, "v")
julia> ocp.control_dimension
2
julia> ocp.control_components_names
["v₁", "v₂"]CTBase.ct_repl — Methodct_repl(; debug, demo, verbose) -> Any
Create a ct REPL.
CTBase.ctgradient — Methodctgradient(f::Function, x) -> Any
Return the gradient of f at x.
CTBase.ctgradient — Methodctgradient(f::Function, x::Real) -> Any
Return the gradient of f at x.
CTBase.ctgradient — Methodctgradient(X::VectorField, x) -> Any
Return the gradient of X at x.
CTBase.ctindices — Methodctindices(i::Integer) -> String
Return i > 0 as a subscript.
CTBase.ctinterpolate — Methodctinterpolate(x, f) -> Any
Return the interpolation of f at x.
CTBase.ctjacobian — Methodctjacobian(f::Function, x) -> Any
Return the Jacobian of f at x.
CTBase.ctjacobian — Methodctjacobian(f::Function, x::Real) -> Any
Return the Jacobian of f at x.
CTBase.ctjacobian — Methodctjacobian(X::VectorField, x) -> Any
Return the Jacobian of X at x.
CTBase.ctupperscripts — Methodctupperscripts(i::Integer) -> String
Return i > 0 as an upperscript.
CTBase.dynamics! — Methoddynamics!(
    ocp::OptimalControlModel{T<:TimeDependence, V<:VariableDependence},
    f::Function
)
Set the dynamics.
You can use dynamics! only once to define the dynamics.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Example
julia> dynamics!(ocp, f)CTBase.getFullDescription — MethodgetFullDescription(
    desc::Tuple{Vararg{Symbol}},
    desc_list::Tuple{Vararg{Tuple{Vararg{Symbol}}}}
) -> Tuple{Vararg{Symbol}}
Return a complete description from an incomplete description desc and  a list of complete descriptions desc_list. If several complete descriptions are possible,  then the first one is returned.
Example
julia> desc_list = ((:a, :b), (:b, :c), (:a, :c))
((:a, :b), (:b, :c), (:a, :c))
julia> getFullDescription((:a,), desc_list)
(:a, :b)CTBase.get_priority_print_callbacks — Methodget_priority_print_callbacks(
    cbs::Tuple{Vararg{CTCallback}}
) -> Tuple{Vararg{CTCallback}}
Get the highest priority print callbacks.
CTBase.get_priority_stop_callbacks — Methodget_priority_stop_callbacks(
    cbs::Tuple{Vararg{CTCallback}}
) -> Tuple{Vararg{CTCallback}}
Get the highest priority stop callbacks.
CTBase.is_max — Methodis_max(ocp::OptimalControlModel) -> Bool
Return true if the criterion type of ocp is :max.
CTBase.is_min — Methodis_min(ocp::OptimalControlModel) -> Bool
Return true if the criterion type of ocp is :min.
CTBase.is_time_dependent — Methodis_time_dependent(
    ocp::OptimalControlModel{NonAutonomous}
) -> Bool
Return true if the model has been defined as time dependent.
CTBase.is_time_independent — Methodis_time_independent(ocp::OptimalControlModel) -> Bool
Return true if the model has been defined as time independent.
CTBase.is_variable_dependent — Methodis_variable_dependent(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed}
) -> Bool
Return true if the model has been defined as variable dependent.
CTBase.is_variable_independent — Methodis_variable_independent(ocp::OptimalControlModel) -> Bool
Return true if the model has been defined as variable independent.
CTBase.nlp_constraints — Methodnlp_constraints(
    ocp::OptimalControlModel
) -> Tuple{Tuple{Vector{Real}, CTBase.var"#ξ#100", Vector{Real}}, Tuple{Vector{Real}, CTBase.var"#η#101", Vector{Real}}, Tuple{Vector{Real}, CTBase.var"#ψ#102", Vector{Real}}, Tuple{Vector{Real}, CTBase.var"#ϕ#103", Vector{Real}}, Tuple{Vector{Real}, CTBase.var"#θ#104", Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}}
Return a 6-tuple of tuples:
- (ξl, ξ, ξu)are control constraints
- (ηl, η, ηu)are state constraints
- (ψl, ψ, ψu)are mixed constraints
- (ϕl, ϕ, ϕu)are boundary constraints
- (θl, θ, θu)are variable constraints
- (ul, uind, uu)are control linear constraints of a subset of indices
- (xl, xind, xu)are state linear constraints of a subset of indices
- (vl, vind, vu)are variable linear constraints of a subset of indices
- The dimensions of the state and control must be set before calling nlp_constraints.
Example
julia> (ξl, ξ, ξu), (ηl, η, ηu), (ψl, ψ, ψu), (ϕl, ϕ, ϕu), (θl, θ, θu),
    (ul, uind, uu), (xl, xind, xu), (vl, vind, vu) = nlp_constraints(ocp)CTBase.objective! — Methodobjective!(
    ocp::OptimalControlModel{T<:TimeDependence, V<:VariableDependence},
    type::Symbol,
    g::Function,
    f⁰::Function
)
objective!(
    ocp::OptimalControlModel{T<:TimeDependence, V<:VariableDependence},
    type::Symbol,
    g::Function,
    f⁰::Function,
    criterion::Symbol
)
Set the criterion to the function g and f⁰. Type can be :bolza. Criterion is :min or :max.
You can use objective! only once to define the objective.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Example
julia> objective!(ocp, :bolza, (x0, xf) -> x0[1] + xf[2], (x, u) -> x[1]^2 + u^2) # the control is of dimension 1CTBase.objective! — Methodobjective!(
    ocp::OptimalControlModel{T<:TimeDependence, V<:VariableDependence},
    type::Symbol,
    f::Function
)
objective!(
    ocp::OptimalControlModel{T<:TimeDependence, V<:VariableDependence},
    type::Symbol,
    f::Function,
    criterion::Symbol
)
Set the criterion to the function f. Type can be :mayer or :lagrange. Criterion is :min or :max.
You can use objective! only once to define the objective.
- The state, control and variable dimensions must be set before. Use state!, control! and variable!.
- The times must be set before. Use time!.
- When an element is of dimension 1, consider it as a scalar.
Examples
julia> objective!(ocp, :mayer, (x0, xf) -> x0[1] + xf[2])
julia> objective!(ocp, :lagrange, (x, u) -> x[1]^2 + u^2) # the control is of dimension 1If you set twice the objective, only the last one will be taken into account.
CTBase.remove_constraint! — Methodremove_constraint!(ocp::OptimalControlModel, label::Symbol)
Remove a labeled constraint.
Example
julia> remove_constraint!(ocp, :con)CTBase.replace_call — Methodreplace_call(e, x::Symbol, t, y) -> Any
Replace calls in e of the form (...x...)(t) by (...y...).
Example
julia> t = :t; t0 = 0; tf = :tf; x = :x; u = :u;
julia> e = :( x[1](0) * 2x(tf) - x[2](tf) * 2x(0) )
:((x[1])(0) * (2 * x(tf)) - (x[2])(tf) * (2 * x(0)))
julia> x0 = Symbol(x, 0); e = replace_call(e, x, t0, x0)
:(x0[1] * (2 * x(tf)) - (x[2])(tf) * (2x0))
julia> xf = Symbol(x, "f"); replace_call(ans, x, tf, xf)
:(x0[1] * (2xf) - xf[2] * (2x0))
julia> e = :( A*x(t) + B*u(t) ); replace_call(replace_call(e, x, t, x), u, t, u)
:(A * x + B * u)
julia> e = :( F0(x(t)) + u(t)*F1(x(t)) ); replace_call(replace_call(e, x, t, x), u, t, u)
:(F0(x) + u * F1(x))
julia> e = :( 0.5u(t)^2 ); replace_call(e, u, t, u)
:(0.5 * u ^ 2)CTBase.replace_call — Methodreplace_call(e, x::Vector{Symbol}, t, y) -> Any
Replace calls in e of the form (...x1...x2...)(t) by (...y1...y2...) for all symbols x1, x2... in the vector x.
Example
julia> t = :t; t0 = 0; tf = :tf; x = :x; u = :u;
julia> e = :( (x^2 + u[1])(t) ); replace_call(e, [ x, u ], t , [ :xx, :uu ])
:(xx ^ 2 + uu[1])
julia> e = :( ((x^2)(t) + u[1])(t) ); replace_call(e, [ x, u ], t , [ :xx, :uu ])
:(xx ^ 2 + uu[1])
julia> e = :( ((x^2)(t0) + u[1])(t) ); replace_call(e, [ x, u ], t , [ :xx, :uu ])
:((xx ^ 2)(t0) + uu[1])CTBase.state! — Functionstate!(ocp::OptimalControlModel, n::Integer)
state!(ocp::OptimalControlModel, n::Integer, name::String)
state!(
    ocp::OptimalControlModel,
    n::Integer,
    name::String,
    components_names::Vector{String}
)
Define the state dimension and possibly the names of each component.
You must use state! only once to set the state dimension.
Examples
julia> state!(ocp, 1)
julia> ocp.state_dimension
1
julia> ocp.state_components_names
["x"]
julia> state!(ocp, 1, "y")
julia> ocp.state_dimension
1
julia> ocp.state_components_names
["y"]
julia> state!(ocp, 2)
julia> ocp.state_dimension
2
julia> ocp.state_components_names
["x₁", "x₂"]
julia> state!(ocp, 2, :y)
julia> ocp.state_dimension
2
julia> ocp.state_components_names
["y₁", "y₂"]
julia> state!(ocp, 2, "y")
julia> ocp.state_dimension
2
julia> ocp.state_components_names
["y₁", "y₂"]CTBase.time! — Functiontime!(ocp::OptimalControlModel, t0::Real, tf::Real)
time!(
    ocp::OptimalControlModel,
    t0::Real,
    tf::Real,
    name::String
)
Fix initial and final times to times[1] and times[2], respectively.
Examples
julia> time!(ocp, 0, 1)
julia> ocp.initial_time
0
julia> ocp.final_time
1
julia> ocp.time_name
"t"
julia> time!(ocp, 0, 1, "s")
julia> ocp.initial_time
0
julia> ocp.final_time
1
julia> ocp.time_name
"s"
julia> time!(ocp, 0, 1, :s)
julia> ocp.initial_time
0
julia> ocp.final_time
1
julia> ocp.time_name
"s"CTBase.time! — Functiontime!(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed},
    t0::Real,
    indf::Index
)
time!(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed},
    t0::Real,
    indf::Index,
    name::String
)
Fix initial time, final time is free and given by the variable at the provided index.
You must use time! only once to set either the initial or the final time, or both.
Examples
julia> time!(ocp, 0, Index(2), "t")CTBase.time! — Functiontime!(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed},
    ind0::Index,
    tf::Real
)
time!(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed},
    ind0::Index,
    tf::Real,
    name::String
)
Fix final time, initial time is free and given by the variable at the provided index.
Examples
julia> time!(ocp, Index(2), 1, "t")CTBase.time! — Functiontime!(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed},
    ind0::Index,
    indf::Index
)
time!(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed},
    ind0::Index,
    indf::Index,
    name::String
)
Initial and final times are free and given by the variable at the provided indices.
Examples
julia> time!(ocp, Index(2), Index(3), "t")CTBase.time! — Functiontime!(
    ocp::OptimalControlModel,
    times::AbstractVector{<:Real}
) -> Any
time!(
    ocp::OptimalControlModel,
    times::AbstractVector{<:Real},
    name::String
) -> Any
Fix initial and final times to times[1] and times[2], respectively.
Examples
julia> time!(ocp, [ 0, 1 ])
julia> ocp.initial_time
0
julia> ocp.final_time
1
julia> ocp.time_name
"t"
julia> time!(ocp, [ 0, 1 ], "s")
julia> ocp.initial_time
0
julia> ocp.final_time
1
julia> ocp.time_name
"s"
julia> time!(ocp, [ 0, 1 ], :s)
julia> ocp.initial_time
0
julia> ocp.final_time
1
julia> ocp.time_name
"s"CTBase.variable! — Functionvariable!(ocp::OptimalControlModel, q::Integer)
variable!(
    ocp::OptimalControlModel,
    q::Integer,
    name::String
)
variable!(
    ocp::OptimalControlModel,
    q::Integer,
    name::String,
    components_names::Vector{String}
)
Define the variable dimension and possibly the names of each component.
You can use variable! once to set the variable dimension when the model is NonFixed.
Examples
julia> variable!(ocp, 1, "v")
julia> variable!(ocp, 2, "v", [ "v₁", "v₂" ])CTBase.∂ₜ — Method∂ₜ(f) -> CTBase.var"#115#117"
Partial derivative wrt time of a function.
Example
julia> ∂ₜ((t,x) -> t*x)(0,8)
8RecipesBase.plot! — Methodplot!(
    p::Plots.Plot,
    sol::OptimalControlSolution;
    layout,
    control,
    time,
    state_style,
    control_style,
    costate_style,
    kwargs...
) -> Plots.Plot
Plot the optimal control solution sol using the layout layout.
Notes.
- The argument layoutcan be:groupor:split(default).
- controlcan be- :components,- :normor- :all.
- timecan be- :defaultor- :normalized.
- The keyword arguments state_style,control_styleandcostate_styleare passed to theplotfunction of thePlotspackage. Thestate_styleis passed to the plot of the state, thecontrol_styleis passed to the plot of the control and thecostate_styleis passed to the plot of the costate.
RecipesBase.plot — Methodplot(
    sol::OptimalControlSolution;
    layout,
    control,
    time,
    state_style,
    control_style,
    costate_style,
    kwargs...
) -> Any
Plot the optimal control solution sol using the layout layout.
Notes.
- The argument layoutcan be:groupor:split(default).
- The keyword arguments state_style,control_styleandcostate_styleare passed to theplotfunction of thePlotspackage. Thestate_styleis passed to the plot of the state, thecontrol_styleis passed to the plot of the control and thecostate_styleis passed to the plot of the costate.
CTBase.@Lie — MacroMacros for Lie and Poisson brackets
Example
julia> F0 = VectorField(x -> [x[1], x[2], (1-x[3])])
julia> F1 = VectorField(x -> [0, -x[3], x[2]])
julia> @Lie [F0, F1]([1, 2, 3])
[0, 5, 4]
julia> H0 = Hamiltonian((x, p) -> 0.5*(2x[1]^2+x[2]^2+p[1]^2))
julia> H1 = Hamiltonian((x, p) -> 0.5*(3x[1]^2+x[2]^2+p[2]^2))
julia> @Lie {H0, H1}([1, 2, 3], [1,0,7])
3.0CTBase.@def — MacroDefine an optimal control problem. One pass parsing of the definition.
Example
@def ocp begin
    tf ∈ R, variable
    t ∈ [ 0, tf ], time
    x ∈ R², state
    u ∈ R, control
    tf ≥ 0
    -1 ≤ u(t) ≤ 1
    q = x₁
    v = x₂
    q(0) == 1
    v(0) == 2
    q(tf) == 0
    v(tf) == 0
    0 ≤ q(t) ≤ 5,       (1)
    -2 ≤ v(t) ≤ 3,      (2)
    ẋ(t) == [ v(t), u(t) ]
    tf → min
end