Control
Index
CTModels.componentsCTModels.componentsCTModels.control!CTModels.dimensionCTModels.dimensionCTModels.nameCTModels.nameCTModels.value
In the examples in the documentation below, the methods are not prefixed by the module name even if they are private.
julia> using CTModels
julia> x = 1
julia> private_fun(x) # throw an errormust be replaced by
julia> using CTModels
julia> x = 1
julia> CTModels.private_fun(x)However, if the method is reexported by another package, then, there is no need of prefixing.
julia> module OptimalControl
import CTModels: private_fun
export private_fun
end
julia> using OptimalControl
julia> x = 1
julia> private_fun(x)Documentation
CTModels.components — Methodcomponents(
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.
CTModels.components — Methodcomponents(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₂"]CTModels.control! — Methodcontrol!(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"]CTModels.dimension — Methoddimension(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.
CTModels.dimension — Methoddimension(model::CTModels.ControlModel) -> Int64
Get the control input dimension.
Arguments
model::ControlModel: The control model.
Returns
Dimension: The number of control components.
CTModels.name — Methodname(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.
CTModels.name — Methodname(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"CTModels.value — Methodvalue(
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.