Private API
This page lists non-exported (internal) symbols of CTModels.
From CTModels
components
CTModels.components — Function
components(model::CTModels.StateModel) -> Vector{String}
Get the components names of the state from the state model.
components(
model::CTModels.StateModelSolution
) -> Vector{String}
Get the components names of the state from the state model solution.
components(model::CTModels.ControlModel) -> Vector{String}
Get the names of the control components.
Arguments
model::ControlModel: The control model.
Returns
Vector{String}: A list of control component names.
Example
julia> components(controlmodel)
["u₁", "u₂"]components(
model::CTModels.ControlModelSolution
) -> Vector{String}
Get the names of the control components from the solution.
Arguments
model::ControlModelSolution: The control model solution.
Returns
Vector{String}: A list of control component names.
components(model::CTModels.VariableModel) -> Vector{String}
Return the names of the components of the variable.
components(
model::CTModels.VariableModelSolution
) -> Vector{String}
Return the names of the components from the variable solution.
components(_::CTModels.EmptyVariableModel) -> Vector{String}
Return an empty vector since there are no variable components defined.
control!
CTModels.control! — Function
control!(ocp::CTModels.PreModel, m::Int64)
control!(
ocp::CTModels.PreModel,
m::Int64,
name::Union{String, Symbol}
)
control!(
ocp::CTModels.PreModel,
m::Int64,
name::Union{String, Symbol},
components_names::Array{T2<:Union{String, Symbol}, 1}
)
Define the control input for a given optimal control problem model.
This function sets the control dimension and optionally allows specifying the control name and the names of its components.
Arguments
ocp::PreModel: The model to which the control will be added.m::Dimension: The control input dimension (must be greater than 0).name::Union{String,Symbol}(optional): The name of the control variable (default:"u").components_names::Vector{<:Union{String,Symbol}}(optional): Names of the control components (default: automatically generated).
Examples
julia> control!(ocp, 1)
julia> control_dimension(ocp)
1
julia> control_components(ocp)
["u"]
julia> control!(ocp, 1, "v")
julia> control_components(ocp)
["v"]
julia> control!(ocp, 2)
julia> control_components(ocp)
["u₁", "u₂"]
julia> control!(ocp, 2, :v)
julia> control_components(ocp)
["v₁", "v₂"]
julia> control!(ocp, 2, "v", ["a", "b"])
julia> control_components(ocp)
["a", "b"]dimension
CTModels.dimension — Function
dimension(model::CTModels.StateModel) -> Int64
Get the dimension of the state from the state model.
dimension(model::CTModels.StateModelSolution) -> Int64
Get the dimension of the state from the state model solution.
dimension(model::CTModels.ControlModel) -> Int64
Get the control input dimension.
Arguments
model::ControlModel: The control model.
Returns
Dimension: The number of control components.
dimension(model::CTModels.ControlModelSolution) -> Int64
Get the control input dimension from the solution.
Arguments
model::ControlModelSolution: The control model solution.
Returns
Dimension: The number of control components.
dimension(model::CTModels.VariableModel) -> Int64
Return the dimension (number of components) of the variable.
dimension(model::CTModels.VariableModelSolution) -> Int64
Return the number of components in the variable solution.
dimension(_::CTModels.EmptyVariableModel) -> Int64
Return 0 since no variable is defined.
name
CTModels.name — Function
name(model::CTModels.StateModel) -> String
Get the name of the state from the state model.
name(model::CTModels.StateModelSolution) -> String
Get the name of the state from the state model solution.
name(model::CTModels.ControlModel) -> String
Get the name of the control variable.
Arguments
model::ControlModel: The control model.
Returns
String: The name of the control.
Example
julia> name(controlmodel)
"u"name(model::CTModels.ControlModelSolution) -> String
Get the name of the control variable from the solution.
Arguments
model::ControlModelSolution: The control model solution.
Returns
String: The name of the control.
name(model::CTModels.VariableModel) -> String
Return the name of the variable stored in the model.
name(model::CTModels.VariableModelSolution) -> String
Return the name of the variable stored in the model solution.
name(_::CTModels.EmptyVariableModel) -> String
Return an empty string, since no variable is defined.
name(model::CTModels.FixedTimeModel) -> String
Get the name of the time from the fixed time model.
name(model::CTModels.FreeTimeModel) -> String
Get the name of the time from the free time model.
state!
CTModels.state! — Function
state!(ocp::CTModels.PreModel, n::Int64)
state!(
ocp::CTModels.PreModel,
n::Int64,
name::Union{String, Symbol}
)
state!(
ocp::CTModels.PreModel,
n::Int64,
name::Union{String, Symbol},
components_names::Array{T2<:Union{String, Symbol}, 1}
)
Define the state dimension and possibly the names of each component.
Examples
julia> state!(ocp, 1)
julia> state_dimension(ocp)
1
julia> state_components(ocp)
["x"]
julia> state!(ocp, 1, "y")
julia> state_dimension(ocp)
1
julia> state_components(ocp)
["y"]
julia> state!(ocp, 2)
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["x₁", "x₂"]
julia> state!(ocp, 2, :y)
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["y₁", "y₂"]
julia> state!(ocp, 2, "y")
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["y₁", "y₂"]
julia> state!(ocp, 2, "y", ["u", "v"])
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["u", "v"]
julia> state!(ocp, 2, "y", [:u, :v])
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["u", "v"]value
CTModels.value — Function
value(
model::CTModels.StateModelSolution{TS<:Function}
) -> Function
Get the state function from the state model solution.
value(
model::CTModels.ControlModelSolution{TS<:Function}
) -> Function
Get the control function associated with the solution.
Arguments
model::ControlModelSolution{TS}: The control model solution.
Returns
TS: A function giving the control value at a given time or state.
value(
model::CTModels.VariableModelSolution{TS<:Union{Real, AbstractVector{<:Real}}}
) -> Union{Real, AbstractVector{<:Real}}
Return the value stored in the variable solution model.
variable!
CTModels.variable! — Function
variable!(ocp::CTModels.PreModel, q::Int64)
variable!(
ocp::CTModels.PreModel,
q::Int64,
name::Union{String, Symbol}
)
variable!(
ocp::CTModels.PreModel,
q::Int64,
name::Union{String, Symbol},
components_names::Array{T2<:Union{String, Symbol}, 1}
)
Define a new variable in the optimal control problem ocp with dimension q.
This function registers a named variable (e.g. "state", "control", or other) to be used in the problem definition. You may optionally specify a name and individual component names.
Arguments
ocp: ThePreModelwhere the variable is registered.q: The dimension of the variable (number of components).name: A name for the variable (default: auto-generated fromq).components_names: A vector of strings or symbols for each component (default:["v₁", "v₂", ...]).
Examples
julia> variable!(ocp, 1, "v")
julia> variable!(ocp, 2, "v", ["v₁", "v₂"])