Time dependence
Index
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.is_autonomous
— Methodis_autonomous(
ocp::CTModels.PreModel
) -> Union{Nothing, Bool}
Check whether the system is autonomous.
Arguments
ocp::PreModel
: The optimal control problem.
Returns
Bool
:true
if the system is autonomous (i.e., does not explicitly depend on time),false
otherwise.
Example
julia> is_autonomous(ocp) # returns true or false
CTModels.time_dependence!
— Methodtime_dependence!(ocp::CTModels.PreModel; autonomous)
Set the time dependence of the optimal control problem ocp
.
Arguments
ocp::PreModel
: The optimal control problem being defined.autonomous::Bool
: Indicates whether the system is autonomous (true
) or time-dependent (false
).
Preconditions
- The time dependence must not have been set previously.
Behavior
This function sets the autonomous
field of the model to indicate whether the system's dynamics explicitly depend on time. It can only be called once.
Errors
Throws CTBase.UnauthorizedCall
if the time dependence has already been set.
Example
julia> ocp = PreModel(...)
julia> time_dependence!(ocp; autonomous=true)