CTBase.jl private functions

Index

Documentation

CTBase.DescVarArgConstant

DescVarArg is a Vararg of symbols. DescVarArg is a type alias for a Vararg of symbols.

julia> const DescVarArg = Vararg{Symbol}

See also: Description.

source
Base.showMethod
show(
    io::IO,
    _::MIME{Symbol("text/plain")},
    ocp::OptimalControlModel
)

Print the optimal control problem.

source
Base.showMethod
show(
    io::IO,
    _::MIME{Symbol("text/plain")},
    sol::OptimalControlSolution
)

Prints the solution.

source
Base.showMethod
show(
    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)
source
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]
source
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]
source
CTBase.__OptimalControlSolutionMethod
__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.

source
CTBase.__callbacksMethod
__callbacks() -> Tuple{}

Used to set the default value of the callbacks argument. The default value is (), which means that no additional callback is given.

source
CTBase.__check_all_setMethod
__check_all_set(
    ocp::OptimalControlModel
) -> Union{Nothing, Bool}

Check if the parameters of an ocp are set.

source
CTBase.__check_control_setMethod
__check_control_set(ocp::OptimalControlModel) -> Bool

Throw UnauthorizedCall exception if the control of an ocp is not set.

source
CTBase.__check_dependenciesMethod
__check_dependencies(
    dependencies::Tuple{Vararg{DataType}}
) -> Bool

Throw IncorrectArgument exception if dependencies arguments are incorrect.

source
CTBase.__check_is_time_setMethod
__check_is_time_set(ocp::OptimalControlModel) -> Bool

Throw UnauthorizedCall exception if the time of an ocp is not set.

source
CTBase.__check_state_setMethod
__check_state_set(ocp::OptimalControlModel) -> Bool

Throw UnauthorizedCall exception if the state of an ocp is not set.

source
CTBase.__check_variable_setMethod
__check_variable_set(
    ocp::OptimalControlModel{<:TimeDependence, NonFixed}
) -> Bool

Throw UnauthorizedCall exception if the variable of an ocp is not set.

source
CTBase.__constraint_labelMethod
__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.

source
CTBase.__control_components_namesMethod
__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.

source
CTBase.__control_nameMethod
__control_name() -> String

Used to set the default value of the names of the control. The default value is "u".

source
CTBase.__criterion_typeMethod
__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.

source
CTBase.__displayMethod
__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.

source
CTBase.__fun_time_dependenceMethod
__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.

source
CTBase.__fun_variable_dependenceMethod
__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.

source
CTBase.__get_AD_backendMethod
__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.

source
CTBase.__init_interpolationMethod
__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.

source
CTBase.__ocp_initMethod
__ocp_init()

Used to set the default initial guess. The default value is nothing.

source
CTBase.__ocp_time_dependenceMethod
__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.

source
CTBase.__ocp_variable_dependenceMethod
__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.

source
CTBase.__state_components_namesMethod
__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.

source
CTBase.__state_nameMethod
__state_name() -> String

Used to set the default value of the name of the state. The default value is "x".

source
CTBase.__time_nameMethod
__time_name() -> String

Used to set the default value of the name of the time. The default value is t.

source
CTBase.__variable_components_namesMethod
__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.

source
CTBase.__variable_nameMethod
__variable_name() -> String

Used to set the default value of the names of the variables. The default value is "v".

source
CTBase.buildFunctionalInitMethod
buildFunctionalInit(data, time, dim) -> CTBase.var"#211#212"

Build functional initialization: general interpolation case

source
CTBase.buildFunctionalInitMethod
buildFunctionalInit(
    data::Function,
    time,
    dim
) -> CTBase.var"#213#214"{<:Function}

Build functional initialization: function case

source
CTBase.buildFunctionalInitMethod
buildFunctionalInit(
    data::Nothing,
    time,
    dim
) -> CTBase.var"#211#212"

Build functional initialization: default case

source
CTBase.buildFunctionalInitMethod
buildFunctionalInit(
    data::Union{Real, AbstractVector{<:Real}},
    time,
    dim
) -> Any

Build functional initialization: constant / 1D interpolation

source
CTBase.checkDimMethod
checkDim(actual_dim, target_dim)

Check if actual dimension is equal to target dimension, error otherwise

source
CTBase.expandMethod
expand(x::Matrix{<:Real}) -> Vector{<:Real}

Return expand(matrix2vec(x, 1))

source
CTBase.expandMethod
expand(x::Vector{<:Vector{<:Real}}) -> Vector{<:Real}

Equivalent to vec2vec(x)

source
CTBase.expr_itMethod
expr_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)
source
CTBase.hasMethod
has(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
source
CTBase.hasMethod
has(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
source
CTBase.matrix2vecFunction
matrix2vec(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.

source
CTBase.parse!Method
parse!(p, ocp, e; log) -> Union{Expr, LineNumberNode}

Parse the expression e and update the ParsingInfo structure p.

Example

parse!(p, :ocp, :(v ∈ R, variable))
source
CTBase.subsMethod
subs(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)))
source
CTBase.vec2vecMethod
vec2vec(
    x::Vector{<:Real},
    n::Integer
) -> Vector{<:Vector{<:Real}}

Transforms x to a Vector{<:Vector{<:ctNumber}}.

source
CTBase.vec2vecMethod
vec2vec(x::Vector{<:Vector{<:Real}}) -> Vector{<:Real}

Transforms x to a Vector{<:ctNumber}.

source