Variable
Index
CTModels.components
CTModels.components
CTModels.components
CTModels.dimension
CTModels.dimension
CTModels.dimension
CTModels.name
CTModels.name
CTModels.name
CTModels.value
CTModels.variable!
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 error
must 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(_::CTModels.EmptyVariableModel) -> Vector{String}
Return an empty vector since there are no variable components defined.
CTModels.components
— Methodcomponents(
model::CTModels.VariableModelSolution
) -> Vector{String}
Return the names of the components from the variable solution.
CTModels.components
— Methodcomponents(model::CTModels.VariableModel) -> Vector{String}
Return the names of the components of the variable.
CTModels.dimension
— Methoddimension(_::CTModels.EmptyVariableModel) -> Int64
Return 0
since no variable is defined.
CTModels.dimension
— Methoddimension(model::CTModels.VariableModelSolution) -> Int64
Return the number of components in the variable solution.
CTModels.dimension
— Methoddimension(model::CTModels.VariableModel) -> Int64
Return the dimension (number of components) of the variable.
CTModels.name
— Methodname(_::CTModels.EmptyVariableModel) -> String
Return an empty string, since no variable is defined.
CTModels.name
— Methodname(model::CTModels.VariableModelSolution) -> String
Return the name of the variable stored in the model solution.
CTModels.name
— Methodname(model::CTModels.VariableModel) -> String
Return the name of the variable stored in the model.
CTModels.value
— Methodvalue(
model::CTModels.VariableModelSolution{TS<:Union{Real, AbstractVector{<:Real}}}
) -> Union{Real, AbstractVector{<:Real}}
Return the value stored in the variable solution model.
CTModels.variable!
— Methodvariable!(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
: ThePreModel
where 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₂"])