Times
Index
CTModels.final
CTModels.final_time
CTModels.final_time
CTModels.final_time_name
CTModels.has_fixed_final_time
CTModels.has_fixed_final_time
CTModels.has_fixed_initial_time
CTModels.has_fixed_initial_time
CTModels.has_free_final_time
CTModels.has_free_initial_time
CTModels.index
CTModels.initial
CTModels.initial_time
CTModels.initial_time
CTModels.initial_time_name
CTModels.name
CTModels.name
CTModels.time
CTModels.time
CTModels.time!
CTModels.time_name
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.final
— Methodfinal(
model::CTModels.TimesModel{<:CTModels.AbstractTimeModel, TF<:CTModels.AbstractTimeModel}
) -> CTModels.AbstractTimeModel
Get the final time from the times model.
CTModels.final_time
— Methodfinal_time(
model::CTModels.TimesModel{<:CTModels.AbstractTimeModel, <:CTModels.FixedTimeModel{T<:Real}}
) -> Real
Get the final time from the times model, from a fixed final time model.
CTModels.final_time
— Methodfinal_time(
model::CTModels.TimesModel{<:CTModels.AbstractTimeModel, CTModels.FreeTimeModel},
variable::AbstractArray{T<:Real, 1}
) -> Any
Get the final time from the times model, from a free final time model.
CTModels.final_time_name
— Methodfinal_time_name(model::CTModels.TimesModel) -> String
Get the name of the final time from the times model.
CTModels.has_fixed_final_time
— Methodhas_fixed_final_time(
times::CTModels.TimesModel{<:CTModels.AbstractTimeModel, CTModels.FreeTimeModel}
) -> Bool
Check if the final time is free. Return false.
CTModels.has_fixed_final_time
— Methodhas_fixed_final_time(
times::CTModels.TimesModel{<:CTModels.AbstractTimeModel, <:CTModels.FixedTimeModel{T<:Real}}
) -> Bool
Check if the final time is fixed. Return true.
CTModels.has_fixed_initial_time
— Methodhas_fixed_initial_time(
times::CTModels.TimesModel{CTModels.FreeTimeModel}
) -> Bool
Check if the initial time is free. Return false.
CTModels.has_fixed_initial_time
— Methodhas_fixed_initial_time(
times::CTModels.TimesModel{<:CTModels.FixedTimeModel{T<:Real}}
) -> Bool
Check if the initial time is fixed. Return true.
CTModels.has_free_final_time
— Methodhas_free_final_time(times::CTModels.TimesModel) -> Bool
Check if the final time is free.
CTModels.has_free_initial_time
— Methodhas_free_initial_time(times::CTModels.TimesModel) -> Bool
Check if the final time is free.
CTModels.index
— Methodindex(model::CTModels.FreeTimeModel) -> Int64
Get the index of the time variable from the free time model.
CTModels.initial
— Methodinitial(
model::CTModels.TimesModel{TI<:CTModels.AbstractTimeModel}
) -> CTModels.AbstractTimeModel
Get the initial time from the times model.
CTModels.initial_time
— Methodinitial_time(
model::CTModels.TimesModel{<:CTModels.FixedTimeModel{T<:Real}}
) -> Real
Get the initial time from the times model, from a fixed initial time model.
CTModels.initial_time
— Methodinitial_time(
model::CTModels.TimesModel{CTModels.FreeTimeModel},
variable::AbstractArray{T<:Real, 1}
) -> Any
Get the initial time from the times model, from a free initial time model.
CTModels.initial_time_name
— Methodinitial_time_name(model::CTModels.TimesModel) -> String
Get the name of the initial time from the times model.
CTModels.name
— Methodname(model::CTModels.FixedTimeModel) -> String
Get the name of the time from the fixed time model.
CTModels.name
— Methodname(model::CTModels.FreeTimeModel) -> String
Get the name of the time from the free time model.
CTModels.time!
— Methodtime!(ocp::CTModels.PreModel; t0, tf, ind0, indf, time_name)
Set the initial and final times. We denote by t0 the initial time and tf the final time. The optimal control problem is denoted ocp. When a time is free, then, one must provide the corresponding index of the ocp variable.
Examples
julia> time!(ocp, t0=0, tf=1 ) # Fixed t0 and fixed tf
julia> time!(ocp, t0=0, indf=2) # Fixed t0 and free tf
julia> time!(ocp, ind0=2, tf=1 ) # Free t0 and fixed tf
julia> time!(ocp, ind0=2, indf=3) # Free t0 and free tf
When you plot a solution of an optimal control problem, the name of the time variable appears. By default, the name is "t". Consider you want to set the name of the time variable to "s".
julia> time!(ocp, t0=0, tf=1, time_name="s") # time_name is a String
# or
julia> time!(ocp, t0=0, tf=1, time_name=:s ) # time_name is a Symbol
CTModels.time
— Methodtime(model::CTModels.FixedTimeModel{T<:Real}) -> Real
Get the time from the fixed time model.
CTModels.time
— Methodtime(
model::CTModels.FreeTimeModel,
variable::AbstractArray{T<:Real, 1}
) -> Any
Get the time from the free time model.
Exceptions
- If the index of the time variable is not in [1, length(variable)], throw an error.
CTModels.time_name
— Methodtime_name(model::CTModels.TimesModel) -> String
Get the name of the time variable from the times model.