Objective

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.criterionMethod
criterion(model::CTModels.BolzaObjectiveModel) -> Symbol

Return the criterion (:min or :max).

CTModels.criterionMethod
criterion(model::CTModels.LagrangeObjectiveModel) -> Symbol

Return the criterion (:min or :max).

CTModels.criterionMethod
criterion(model::CTModels.MayerObjectiveModel) -> Symbol

Return the criterion (:min or :max).

CTModels.lagrangeMethod
lagrange(
    model::CTModels.BolzaObjectiveModel{<:Function, L<:Function}
) -> Function

Return the Lagrange function.

CTModels.lagrangeMethod
lagrange(
    model::CTModels.LagrangeObjectiveModel{L<:Function}
) -> Function

Return the Lagrange function.

CTModels.mayerMethod
mayer(
    model::CTModels.BolzaObjectiveModel{M<:Function}
) -> Function

Return the Mayer function.

CTModels.mayerMethod
mayer(
    model::CTModels.MayerObjectiveModel{M<:Function}
) -> Function

Return the Mayer function.

CTModels.objective!Function
objective!(ocp::CTModels.PreModel; ...)
objective!(
    ocp::CTModels.PreModel,
    criterion::Symbol;
    mayer,
    lagrange
)

Set the objective of the optimal control problem.

Arguments

  • ocp::PreModel: the optimal control problem.
  • criterion::Symbol: the type of criterion. Either :min or :max. Default is :min.
  • mayer::Union{Function, Nothing}: the Mayer function (inplace). Default is nothing.
  • lagrange::Union{Function, Nothing}: the Lagrange function (inplace). Default is nothing.
Note
  • The state, control and variable must be set before the objective.
  • The objective must not be set before.
  • At least one of the two functions must be given. Please provide a Mayer or a Lagrange function.

Examples

julia> function mayer(x0, xf, v)
           return x0[1] + xf[1] + v[1]
       end
julia> function lagrange(t, x, u, v)
           return x[1] + u[1] + v[1]
       end
julia> objective!(ocp, :min, mayer=mayer, lagrange=lagrange)