CTBase.jl private functions
Index
CTBase.DescVarArg
CTBase.AbstractCTFunction
CTBase.AbstractOptimalControlModel
CTBase.AbstractOptimalControlSolution
CTBase.AbstractVectorField
CTBase.ParsingInfo
CTBase.RangeConstraint
CTBase.:⅋
CTBase.:⅋
CTBase.__OptimalControlSolution
CTBase.__callbacks
CTBase.__check_all_set
CTBase.__check_control_set
CTBase.__check_dependencies
CTBase.__check_is_time_set
CTBase.__check_state_set
CTBase.__check_variable_set
CTBase.__check_variable_set
CTBase.__constraint_label
CTBase.__control_components_names
CTBase.__control_name
CTBase.__criterion_type
CTBase.__display
CTBase.__fun_time_dependence
CTBase.__fun_variable_dependence
CTBase.__get_AD_backend
CTBase.__init_interpolation
CTBase.__is_complete
CTBase.__is_control_not_set
CTBase.__is_control_set
CTBase.__is_criterion_valid
CTBase.__is_dynamics_not_set
CTBase.__is_dynamics_set
CTBase.__is_empty
CTBase.__is_final_time_free
CTBase.__is_incomplete
CTBase.__is_initial_time_free
CTBase.__is_objective_not_set
CTBase.__is_objective_set
CTBase.__is_state_not_set
CTBase.__is_state_set
CTBase.__is_time_not_set
CTBase.__is_time_set
CTBase.__is_variable_not_set
CTBase.__is_variable_set
CTBase.__matrix_dimension_stock
CTBase.__ocp_init
CTBase.__ocp_time_dependence
CTBase.__ocp_variable_dependence
CTBase.__state_components_names
CTBase.__state_name
CTBase.__time_name
CTBase.__variable_components_names
CTBase.__variable_name
CTBase.buildFunctionalInit
CTBase.buildFunctionalInit
CTBase.buildFunctionalInit
CTBase.buildFunctionalInit
CTBase.buildVectorInit
CTBase.checkDim
CTBase.ctindice
CTBase.ctupperscript
CTBase.expand
CTBase.expand
CTBase.expand
CTBase.expr_it
CTBase.formatData
CTBase.formatTimeGrid
CTBase.has
CTBase.has
CTBase.isaVectVect
CTBase.matrix2vec
CTBase.parse!
CTBase.subs
CTBase.vec2vec
CTBase.vec2vec
Documentation
CTBase.DescVarArg
— ConstantDescVarArg is a Vararg of symbols. DescVarArg
is a type alias for a Vararg of symbols.
julia> const DescVarArg = Vararg{Symbol}
See also: Description
.
CTBase.RangeConstraint
— TypeType alias for an index or range.
CTBase.AbstractCTFunction
— Typeabstract type AbstractCTFunction <: Function
Abstract type for functions.
CTBase.AbstractOptimalControlModel
— Typeabstract type AbstractOptimalControlModel
CTBase.AbstractOptimalControlSolution
— Typeabstract type AbstractOptimalControlSolution
Abstract type for optimal control solutions.
CTBase.AbstractVectorField
— Typeabstract type AbstractVectorField{time_dependence, variable_dependence}
Abstract type for vectorfields.
CTBase.ParsingInfo
— Typemutable struct ParsingInfo
Fields
Base.show
— Methodshow(
io::IO,
_::MIME{Symbol("text/plain")},
ocp::OptimalControlModel
)
Print the optimal control problem.
Base.show
— Methodshow(
io::IO,
_::MIME{Symbol("text/plain")},
sol::OptimalControlSolution
)
Prints the solution.
Base.show
— Methodshow(
io::IO,
_::MIME{Symbol("text/plain")},
descriptions::Tuple{Vararg{Tuple{Vararg{Symbol}}}}
)
Print a tuple of descriptions.
Example
julia> display( ( (:a, :b), (:b, :c) ) )
(:a, :b)
(:b, :c)
Base.showerror
— Methodshowerror(io::IO, e::AmbiguousDescription)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::ExtensionError)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::IncorrectArgument)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::IncorrectMethod)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::IncorrectOutput)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::NotImplemented)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::ParsingError)
Print the exception.
Base.showerror
— Methodshowerror(io::IO, e::UnauthorizedCall)
Print the exception.
CTBase.:⅋
— Method⅋(
X::VectorField{Autonomous, V<:VariableDependence},
Y::VectorField{Autonomous, V<:VariableDependence}
) -> VectorField
"Directional derivative" of a vector field: internal and only used to compute efficiently the Lie bracket of two vector fields, autonomous case
Example
julia> X = VectorField(x -> [x[2], -x[1]])
julia> Y = VectorField(x -> [x[1], x[2]])
julia> CTBase.:(⅋)(X, Y)([1, 2])
[2, -1]
CTBase.:⅋
— Method⅋(
X::VectorField{NonAutonomous, V<:VariableDependence},
Y::VectorField{NonAutonomous, V<:VariableDependence}
) -> VectorField{NonAutonomous}
"Directional derivative" of a vector field: internal and only used to compute efficiently the Lie bracket of two vector fields, nonautonomous case
Example
julia> X = VectorField((t, x, v) -> [t + v[1] + v[2] + x[2], -x[1]], NonFixed, NonAutonomous)
julia> Y = VectorField((t, x, v) -> [v[1] + v[2] + x[1], x[2]], NonFixed, NonAutonomous)
julia> CTBase.:(⅋)(X, Y)(1, [1, 2], [2, 3])
[8, -1]
CTBase.__OptimalControlSolution
— Method__OptimalControlSolution(
ocp::OptimalControlModel;
state,
control,
objective,
costate,
time_grid,
variable,
iterations,
stopping,
message,
success,
infos,
boundary_constraints,
mult_boundary_constraints,
variable_constraints,
mult_variable_constraints,
mult_variable_box_lower,
mult_variable_box_upper,
control_constraints,
mult_control_constraints,
state_constraints,
mult_state_constraints,
mixed_constraints,
mult_mixed_constraints,
mult_state_box_lower,
mult_state_box_upper,
mult_control_box_lower,
mult_control_box_upper
) -> OptimalControlSolution
Constructor from an optimal control problem. Internal.
CTBase.__callbacks
— Method__callbacks() -> Tuple{}
Used to set the default value of the callbacks argument. The default value is ()
, which means that no additional callback is given.
CTBase.__check_all_set
— Method__check_all_set(
ocp::OptimalControlModel
) -> Union{Nothing, Bool}
Check if the parameters of an ocp are set.
CTBase.__check_control_set
— Method__check_control_set(ocp::OptimalControlModel) -> Bool
Throw UnauthorizedCall
exception if the control of an ocp is not set.
CTBase.__check_dependencies
— Method__check_dependencies(
dependencies::Tuple{Vararg{DataType}}
) -> Bool
Throw IncorrectArgument
exception if dependencies arguments are incorrect.
CTBase.__check_is_time_set
— Method__check_is_time_set(ocp::OptimalControlModel) -> Bool
Throw UnauthorizedCall
exception if the time of an ocp is not set.
CTBase.__check_state_set
— Method__check_state_set(ocp::OptimalControlModel) -> Bool
Throw UnauthorizedCall
exception if the state of an ocp is not set.
CTBase.__check_variable_set
— Method__check_variable_set(
ocp::OptimalControlModel{<:TimeDependence, Fixed}
)
Do nothing, no variable for fixed ocp.
CTBase.__check_variable_set
— Method__check_variable_set(
ocp::OptimalControlModel{<:TimeDependence, NonFixed}
) -> Bool
Throw UnauthorizedCall
exception if the variable of an ocp is not set.
CTBase.__constraint_label
— Method__constraint_label() -> Symbol
Used to set the default value of the label of a constraint. A unique value is given to each constraint using the gensym
function and prefixing by :unamed
.
CTBase.__control_components_names
— Method__control_components_names(m::Integer, name::String) -> Any
Used to set the default value of the names of the controls. The default value is ["u"]
for a one dimensional control, and ["u₁", "u₂", ...]
for a multi dimensional control.
CTBase.__control_name
— Method__control_name() -> String
Used to set the default value of the names of the control. The default value is "u"
.
CTBase.__criterion_type
— Method__criterion_type() -> Symbol
Used to set the default value of the type of criterion. Either :min or :max. The default value is :min
. The other possible criterion type is :max
.
CTBase.__display
— Method__display() -> Bool
Used to set the default value of the display argument. The default value is true
, which means that the output is printed during resolution.
CTBase.__fun_time_dependence
— Method__fun_time_dependence() -> Type{Autonomous}
Used to set the default value of the time dependence of the functions.
The default value is Autonomous
, which means that the functions are considered time independent. The other possible time dependence is NonAutonomous
, which means that the functions are considered time dependent.
CTBase.__fun_variable_dependence
— Method__fun_variable_dependence() -> Type{Fixed}
Used to set the default value of the variable dependence of the functions.
The default value is Fixed
, which means that the functions are considered variable independent. The other possible variable dependence is NonFixed
, which means that the functions are considered variable dependent.
CTBase.__get_AD_backend
— Method__get_AD_backend(
) -> ADTypes.AutoForwardDiff{nothing, Nothing}
Used to set the default value of Automatic Differentiation backend.
The default value is AutoForwardDiff()
, that is the ForwardDiff
package is used by default.
CTBase.__init_interpolation
— Method__init_interpolation() -> CTBase.var"#7#8"
Used to set the default interpolation function used for initialisation. The default value is Interpolations.linear_interpolation
, which means that the initial guess is linearly interpolated.
CTBase.__is_complete
— Method__is_complete(ocp) -> Bool
CTBase.__is_control_not_set
— Method__is_control_not_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_control_set
— Method__is_control_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_criterion_valid
— Method__is_criterion_valid(criterion::Symbol) -> Bool
CTBase.__is_dynamics_not_set
— Method__is_dynamics_not_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_dynamics_set
— Method__is_dynamics_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_empty
— Method__is_empty(ocp::OptimalControlModel) -> Bool
CTBase.__is_final_time_free
— Method__is_final_time_free(ocp) -> Bool
CTBase.__is_incomplete
— Method__is_incomplete(ocp) -> Bool
CTBase.__is_initial_time_free
— Method__is_initial_time_free(ocp) -> Bool
CTBase.__is_objective_not_set
— Method__is_objective_not_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_objective_set
— Method__is_objective_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_state_not_set
— Method__is_state_not_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_state_set
— Method__is_state_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_time_not_set
— Method__is_time_not_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_time_set
— Method__is_time_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_variable_not_set
— Method__is_variable_not_set(ocp::OptimalControlModel) -> Bool
CTBase.__is_variable_set
— Method__is_variable_set(ocp::OptimalControlModel) -> Bool
CTBase.__matrix_dimension_stock
— Method__matrix_dimension_stock() -> Int64
Used to set the default value of the stockage of elements in a matrix. The default value is 1
.
CTBase.__ocp_init
— Method__ocp_init()
Used to set the default initial guess. The default value is nothing
.
CTBase.__ocp_time_dependence
— Method__ocp_time_dependence() -> Type{Autonomous}
Used to set the default value of the time dependence of the Optimal Control Problem. The default value is Autonomous
, which means that the Optimal Control Problem is considered time independent. The other possible time dependence is NonAutonomous
, which means that all the functions used to define the Optimal Control Problem are considered time dependent.
CTBase.__ocp_variable_dependence
— Method__ocp_variable_dependence() -> Type{Fixed}
Used to set the default value of the variable dependence of the Optimal Control Problem. The default value is Fixed
, which means that the Optimal Control Problem is considered variable independent. The other possible variable dependence is NonFixed
, which means that all the functions used to define the Optimal Control Problem are considered variable dependent.
CTBase.__state_components_names
— Method__state_components_names(n::Integer, name::String) -> Any
Used to set the default value of the names of the states. The default value is ["x"]
for a one dimensional state, and ["x₁", "x₂", ...]
for a multi dimensional state.
CTBase.__state_name
— Method__state_name() -> String
Used to set the default value of the name of the state. The default value is "x"
.
CTBase.__time_name
— Method__time_name() -> String
Used to set the default value of the name of the time. The default value is t
.
CTBase.__variable_components_names
— Method__variable_components_names(q::Integer, name::String) -> Any
Used to set the default value of the names of the variables. The default value is ["v"]
for a one dimensional variable, and ["v₁", "v₂", ...]
for a multi dimensional variable.
CTBase.__variable_name
— Method__variable_name() -> String
Used to set the default value of the names of the variables. The default value is "v"
.
CTBase.buildFunctionalInit
— MethodbuildFunctionalInit(data, time, dim) -> CTBase.var"#211#212"
Build functional initialization: general interpolation case
CTBase.buildFunctionalInit
— MethodbuildFunctionalInit(
data::Function,
time,
dim
) -> CTBase.var"#213#214"{<:Function}
Build functional initialization: function case
CTBase.buildFunctionalInit
— MethodbuildFunctionalInit(
data::Nothing,
time,
dim
) -> CTBase.var"#211#212"
Build functional initialization: default case
CTBase.buildFunctionalInit
— MethodbuildFunctionalInit(
data::Union{Real, AbstractVector{<:Real}},
time,
dim
) -> Union{CTBase.var"#215#217", CTBase.var"#216#218"}
Build functional initialization: constant / 1D interpolation
CTBase.buildVectorInit
— MethodbuildVectorInit(data, dim) -> Any
Build vector initialization: default / vector case
CTBase.checkDim
— MethodcheckDim(actual_dim, target_dim)
Check if actual dimension is equal to target dimension, error otherwise
CTBase.ctindice
— Methodctindice(i::Integer) -> Char
Return i
∈ [0, 9] as a subscript.
CTBase.ctupperscript
— Methodctupperscript(i::Integer) -> Char
Return i
∈ [0, 9] as an upperscript.
CTBase.expand
— Methodexpand(x::Matrix{<:Real}) -> Vector{<:Real}
Return expand(matrix2vec(x, 1))
CTBase.expand
— Methodexpand(x::Vector{<:Real}) -> Vector{<:Real}
Return x
.
CTBase.expand
— Methodexpand(x::Vector{<:Vector{<:Real}}) -> Vector{<:Real}
Equivalent to vec2vec(x)
CTBase.expr_it
— Methodexpr_it(e, _Expr, f) -> Any
Expr iterator: apply _Expr
to nodes and f
to leaves of the AST.
Example
julia> id(e) = expr_it(e, Expr, x -> x)
CTBase.formatData
— MethodformatData(data) -> Any
Convert matrix to vector of vectors (could be expanded)
CTBase.formatTimeGrid
— MethodformatTimeGrid(time) -> Any
Convert matrix time-grid to vector
CTBase.has
— Methodhas(e, x, t) -> Union{Missing, Bool}
Return true if e contains a (...x...)(t)
call.
Example
julia> e = :( ∫( x[1](t)^2 + 2*u(t) ) → min )
:(∫((x[1])(t) ^ 2 + 2 * u(t)) → min)
julia> has(e, :x, :t)
true
julia> has(e, :u, :t)
true
CTBase.has
— Methodhas(e, e1) -> Union{Missing, Bool}
Return true if e contains e1.
Example
julia> e = :( ∫( x[1](t)^2 + 2*u(t) ) → min )
:(∫((x[1])(t) ^ 2 + 2 * u(t)) → min)
julia> has(e, 2)
true
julia> has(e, :x)
true
julia> has(e, :min)
true
julia> has(e, :( x[1](t)^2 ))
true
julia> !has(e, :( x[1](t)^3 ))
true
julia> !has(e, 3)
true
julia> !has(e, :max)
true
julia> has(:x, :x)
true
julia> !has(:x, 2)
true
julia> !has(:x, :y)
true
CTBase.isaVectVect
— MethodisaVectVect(data) -> Bool
Return true if argument is a vector of vectors
CTBase.matrix2vec
— Functionmatrix2vec(x::Matrix{<:Real}) -> Vector{<:Vector{<:Real}}
matrix2vec(
x::Matrix{<:Real},
dim::Integer
) -> Vector{<:Vector{<:Real}}
Transforms x
to a Vector{<:Vector{<:ctNumber}}.
Note. dim
∈ {1, 2} is the dimension along which the matrix is transformed.
CTBase.parse!
— Methodparse!(p, ocp, e; log) -> Union{Expr, LineNumberNode}
Parse the expression e
and update the ParsingInfo
structure p
.
Example
parse!(p, :ocp, :(v ∈ R, variable))
CTBase.subs
— Methodsubs(e, e1::Union{Real, Symbol}, e2) -> Any
Substitute expression e1
by expression e2
in expression e
.
Examples
julia> e = :( ∫( r(t)^2 + 2u₁(t)) → min )
:(∫(r(t) ^ 2 + 2 * u₁(t)) → min)
julia> subs(e, :r, :( x[1] ))
:(∫((x[1])(t) ^ 2 + 2 * u₁(t)) → min)
julia> e = :( ∫( u₁(t)^2 + 2u₂(t)) → min )
:(∫(u₁(t) ^ 2 + 2 * u₂(t)) → min)
julia> for i ∈ 1:2
e = subs(e, Symbol(:u, Char(8320+i)), :( u[$i] ))
end; e
:(∫((u[1])(t) ^ 2 + 2 * (u[2])(t)) → min)
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); subs(e, :( $x[1]($(t0)) ), :( $x0[1] ))
:(x0[1] * (2 * x(tf)) - (x[2])(tf) * (2 * x(0)))
CTBase.vec2vec
— Methodvec2vec(
x::Vector{<:Real},
n::Integer
) -> Vector{<:Vector{<:Real}}
Transforms x
to a Vector{<:Vector{<:ctNumber}}.
CTBase.vec2vec
— Methodvec2vec(x::Vector{<:Vector{<:Real}}) -> Vector{<:Real}
Transforms x
to a Vector{<:ctNumber}.