Times

Index

Warning

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.finalMethod
final(
    model::CTModels.TimesModel{<:CTModels.AbstractTimeModel, TF<:CTModels.AbstractTimeModel}
) -> CTModels.AbstractTimeModel

Get the final time from the times model.

CTModels.final_timeMethod
final_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_timeMethod
final_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_nameMethod
final_time_name(model::CTModels.TimesModel) -> String

Get the name of the final time from the times model.

CTModels.has_fixed_final_timeMethod
has_fixed_final_time(
    times::CTModels.TimesModel{<:CTModels.AbstractTimeModel, CTModels.FreeTimeModel}
) -> Bool

Check if the final time is free. Return false.

CTModels.has_fixed_final_timeMethod
has_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_timeMethod
has_fixed_initial_time(
    times::CTModels.TimesModel{CTModels.FreeTimeModel}
) -> Bool

Check if the initial time is free. Return false.

CTModels.has_fixed_initial_timeMethod
has_fixed_initial_time(
    times::CTModels.TimesModel{<:CTModels.FixedTimeModel{T<:Real}}
) -> Bool

Check if the initial time is fixed. Return true.

CTModels.indexMethod
index(model::CTModels.FreeTimeModel) -> Int64

Get the index of the time variable from the free time model.

CTModels.initialMethod
initial(
    model::CTModels.TimesModel{TI<:CTModels.AbstractTimeModel}
) -> CTModels.AbstractTimeModel

Get the initial time from the times model.

CTModels.initial_timeMethod
initial_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_timeMethod
initial_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_nameMethod
initial_time_name(model::CTModels.TimesModel) -> String

Get the name of the initial time from the times model.

CTModels.nameMethod
name(model::CTModels.FixedTimeModel) -> String

Get the name of the time from the fixed time model.

CTModels.nameMethod
name(model::CTModels.FreeTimeModel) -> String

Get the name of the time from the free time model.

CTModels.time!Method
time!(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.

Note

You must use time! only once to set either the initial or the final time, or both.

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.timeMethod
time(model::CTModels.FixedTimeModel{T<:Real}) -> Real

Get the time from the fixed time model.

CTModels.timeMethod
time(
    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_nameMethod
time_name(model::CTModels.TimesModel) -> String

Get the name of the time variable from the times model.