CTModels.jl
The CTModels.jl package is part of the control-toolbox ecosystem.
Index
CTModels.AbstractConstraintsModel
CTModels.AbstractControlModel
CTModels.AbstractDualModel
CTModels.AbstractModel
CTModels.AbstractObjectiveModel
CTModels.AbstractSolution
CTModels.AbstractSolverInfos
CTModels.AbstractStateModel
CTModels.AbstractTimeGridModel
CTModels.AbstractTimeModel
CTModels.AbstractTimesModel
CTModels.AbstractVariableModel
CTModels.BolzaObjectiveModel
CTModels.ConstraintsModel
CTModels.ControlModel
CTModels.ControlModelSolution
CTModels.DualModel
CTModels.EmptyTimeGridModel
CTModels.EmptyVariableModel
CTModels.FixedTimeModel
CTModels.FreeTimeModel
CTModels.Init
CTModels.LagrangeObjectiveModel
CTModels.MayerObjectiveModel
CTModels.Model
CTModels.PreModel
CTModels.Solution
CTModels.SolverInfos
CTModels.StateModel
CTModels.StateModelSolution
CTModels.TimeGridModel
CTModels.TimesModel
CTModels.VariableModel
CTModels.VariableModelSolution
CTModels.__constraint!
CTModels.__constraint_label
CTModels.__control_components
CTModels.__control_name
CTModels.__criterion_type
CTModels.__is_consistent
CTModels.__is_control_set
CTModels.__is_control_set
CTModels.__is_definition_set
CTModels.__is_definition_set
CTModels.__is_dynamics_set
CTModels.__is_dynamics_set
CTModels.__is_empty
CTModels.__is_objective_set
CTModels.__is_objective_set
CTModels.__is_state_set
CTModels.__is_state_set
CTModels.__is_times_set
CTModels.__is_times_set
CTModels.__is_variable_set
CTModels.__is_variable_set
CTModels.__state_components
CTModels.__state_name
CTModels.__time_name
CTModels.__variable_components
CTModels.__variable_name
CTModels.boundary_constraints
CTModels.boundary_constraints_dual
CTModels.boundary_constraints_nl
CTModels.boundary_constraints_nl
CTModels.buildFunctionalInit
CTModels.buildFunctionalInit
CTModels.buildFunctionalInit
CTModels.buildFunctionalInit
CTModels.buildVectorInit
CTModels.build_constraints
CTModels.build_model
CTModels.build_solution
CTModels.checkDim
CTModels.components
CTModels.components
CTModels.components
CTModels.components
CTModels.components
CTModels.components
CTModels.components
CTModels.constraint
CTModels.constraint!
CTModels.constraints
CTModels.constraints_violation
CTModels.control
CTModels.control
CTModels.control!
CTModels.control_components
CTModels.control_components
CTModels.control_constraints_box
CTModels.control_constraints_box
CTModels.control_constraints_lb_dual
CTModels.control_constraints_ub_dual
CTModels.control_dimension
CTModels.control_dimension
CTModels.control_discretized
CTModels.control_name
CTModels.control_name
CTModels.costate
CTModels.costate_discretized
CTModels.criterion
CTModels.criterion
CTModels.criterion
CTModels.criterion
CTModels.ctinterpolate
CTModels.definition
CTModels.definition
CTModels.definition!
CTModels.dim_boundary_constraints_nl
CTModels.dim_boundary_constraints_nl
CTModels.dim_control_constraints_box
CTModels.dim_control_constraints_box
CTModels.dim_path_constraints_nl
CTModels.dim_path_constraints_nl
CTModels.dim_state_constraints_box
CTModels.dim_state_constraints_box
CTModels.dim_variable_constraints_box
CTModels.dim_variable_constraints_box
CTModels.dimension
CTModels.dimension
CTModels.dimension
CTModels.dimension
CTModels.dimension
CTModels.dimension
CTModels.dimension
CTModels.dynamics
CTModels.dynamics!
CTModels.final
CTModels.final_time
CTModels.final_time
CTModels.final_time
CTModels.final_time
CTModels.final_time_name
CTModels.final_time_name
CTModels.final_time_name
CTModels.formatData
CTModels.formatTimeGrid
CTModels.has_fixed_final_time
CTModels.has_fixed_final_time
CTModels.has_fixed_final_time
CTModels.has_fixed_initial_time
CTModels.has_fixed_initial_time
CTModels.has_fixed_initial_time
CTModels.has_free_final_time
CTModels.has_free_final_time
CTModels.has_free_initial_time
CTModels.has_free_initial_time
CTModels.has_lagrange_cost
CTModels.has_lagrange_cost
CTModels.has_lagrange_cost
CTModels.has_lagrange_cost
CTModels.has_mayer_cost
CTModels.has_mayer_cost
CTModels.has_mayer_cost
CTModels.has_mayer_cost
CTModels.index
CTModels.infos
CTModels.initial
CTModels.initial_time
CTModels.initial_time
CTModels.initial_time
CTModels.initial_time
CTModels.initial_time_name
CTModels.initial_time_name
CTModels.initial_time_name
CTModels.is_empty_time_grid
CTModels.isaVectVect
CTModels.isempty_constraints
CTModels.iterations
CTModels.lagrange
CTModels.lagrange
CTModels.lagrange
CTModels.lagrange
CTModels.matrix2vec
CTModels.mayer
CTModels.mayer
CTModels.mayer
CTModels.mayer
CTModels.message
CTModels.name
CTModels.name
CTModels.name
CTModels.name
CTModels.name
CTModels.name
CTModels.name
CTModels.name
CTModels.name
CTModels.objective
CTModels.objective
CTModels.objective!
CTModels.path_constraints
CTModels.path_constraints_dual
CTModels.path_constraints_nl
CTModels.path_constraints_nl
CTModels.state
CTModels.state
CTModels.state!
CTModels.state_components
CTModels.state_components
CTModels.state_constraints_box
CTModels.state_constraints_box
CTModels.state_constraints_lb_dual
CTModels.state_constraints_ub_dual
CTModels.state_dimension
CTModels.state_dimension
CTModels.state_discretized
CTModels.state_name
CTModels.state_name
CTModels.stopping
CTModels.success
CTModels.time
CTModels.time
CTModels.time!
CTModels.time_grid
CTModels.time_name
CTModels.time_name
CTModels.time_name
CTModels.times
CTModels.value
CTModels.value
CTModels.value
CTModels.variable
CTModels.variable
CTModels.variable!
CTModels.variable_components
CTModels.variable_components
CTModels.variable_constraints_box
CTModels.variable_constraints_box
CTModels.variable_constraints_lb_dual
CTModels.variable_constraints_ub_dual
CTModels.variable_dimension
CTModels.variable_dimension
CTModels.variable_name
CTModels.variable_name
Documentation
Public
Private
CTModels.AbstractConstraintsModel
— Typeabstract type AbstractConstraintsModel
CTModels.AbstractControlModel
— Typeabstract type AbstractControlModel
CTModels.AbstractDualModel
— Typeabstract type AbstractDualModel
CTModels.AbstractModel
— Typeabstract type AbstractModel
CTModels.AbstractObjectiveModel
— Typeabstract type AbstractObjectiveModel
CTModels.AbstractSolution
— Typeabstract type AbstractSolution
CTModels.AbstractSolverInfos
— Typeabstract type AbstractSolverInfos
CTModels.AbstractStateModel
— Typeabstract type AbstractStateModel
CTModels.AbstractTimeGridModel
— Typeabstract type AbstractTimeGridModel
CTModels.AbstractTimeModel
— Typeabstract type AbstractTimeModel
CTModels.AbstractTimesModel
— Typeabstract type AbstractTimesModel
CTModels.AbstractVariableModel
— Typeabstract type AbstractVariableModel
CTModels.BolzaObjectiveModel
— Typestruct BolzaObjectiveModel{TM<:Function, TL<:Function} <: CTModels.AbstractObjectiveModel
Fields
mayer::Function
lagrange::Function
criterion::Symbol
CTModels.ConstraintsModel
— Typestruct ConstraintsModel{TP<:Tuple, TB<:Tuple, TS<:Tuple, TC<:Tuple, TV<:Tuple, TC_ALL<:Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}}} <: CTModels.AbstractConstraintsModel
Fields
path_nl::Tuple
boundary_nl::Tuple
state_box::Tuple
control_box::Tuple
variable_box::Tuple
dict::Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}}
CTModels.ControlModel
— Typestruct ControlModel <: CTModels.AbstractControlModel
Fields
name::String
components::Vector{String}
CTModels.ControlModelSolution
— Typestruct ControlModelSolution{TS<:Function} <: CTModels.AbstractControlModel
Fields
name::String
components::Vector{String}
value::Function
CTModels.DualModel
— Typestruct DualModel{PC<:Function, PC_Dual<:Function, BC<:(AbstractVector{<:Real}), BC_Dual<:(AbstractVector{<:Real}), SC_LB_Dual<:Function, SC_UB_Dual<:Function, CC_LB_Dual<:Function, CC_UB_Dual<:Function, VC_LB_Dual<:(AbstractVector{<:Real}), VC_UB_Dual<:(AbstractVector{<:Real})} <: CTModels.AbstractDualModel
Fields
path_constraints::Function
path_constraints_dual::Function
boundary_constraints::AbstractVector{<:Real}
boundary_constraints_dual::AbstractVector{<:Real}
state_constraints_lb_dual::Function
state_constraints_ub_dual::Function
control_constraints_lb_dual::Function
control_constraints_ub_dual::Function
variable_constraints_lb_dual::AbstractVector{<:Real}
variable_constraints_ub_dual::AbstractVector{<:Real}
CTModels.EmptyTimeGridModel
— Typestruct EmptyTimeGridModel <: CTModels.AbstractTimeGridModel
Fields
CTModels.EmptyVariableModel
— Typestruct EmptyVariableModel <: CTModels.AbstractVariableModel
Fields
CTModels.FixedTimeModel
— Typestruct FixedTimeModel{T<:Real} <: CTModels.AbstractTimeModel
Fields
time::Real
name::String
CTModels.FreeTimeModel
— Typestruct FreeTimeModel <: CTModels.AbstractTimeModel
Fields
index::Int64
name::String
CTModels.Init
— TypeInitial guess for OCP, contains
- functions of time for the state and control variables
- vector for optimization variables
Initialization data for each field can be left to default or:
- vector for optimization variables
- constant / vector / function for state and control
- existing solution ('warm start') for all fields
Constructors:
Init()
: default initializationInit(state, control, variable, time)
: constant vector, function handles and / or matrices / vectors interpolated along given time gridInit(sol)
: from existing solution
Examples
julia> init = Init()
julia> init = Init(state=[0.1, 0.2], control=0.3)
julia> init = Init(state=[0.1, 0.2], control=0.3, variable=0.5)
julia> init = Init(state=[0.1, 0.2], controlt=t->sin(t), variable=0.5)
julia> init = Init(state=[[0, 0], [1, 2], [5, -1]], time=[0, .3, 1.], controlt=t->sin(t))
julia> init = Init(sol)
CTModels.LagrangeObjectiveModel
— Typestruct LagrangeObjectiveModel{TL<:Function} <: CTModels.AbstractObjectiveModel
Fields
lagrange::Function
criterion::Symbol
CTModels.MayerObjectiveModel
— Typestruct MayerObjectiveModel{TM<:Function} <: CTModels.AbstractObjectiveModel
Fields
mayer::Function
criterion::Symbol
CTModels.Model
— Typestruct Model{TimesModelType<:CTModels.AbstractTimesModel, StateModelType<:CTModels.AbstractStateModel, ControlModelType<:CTModels.AbstractControlModel, VariableModelType<:CTModels.AbstractVariableModel, DynamicsModelType<:Function, ObjectiveModelType<:CTModels.AbstractObjectiveModel, ConstraintsModelType<:CTModels.AbstractConstraintsModel} <: CTModels.AbstractModel
Fields
times::CTModels.AbstractTimesModel
state::CTModels.AbstractStateModel
control::CTModels.AbstractControlModel
variable::CTModels.AbstractVariableModel
dynamics::Function
objective::CTModels.AbstractObjectiveModel
constraints::CTModels.AbstractConstraintsModel
definition::Expr
CTModels.PreModel
— Typemutable struct PreModel <: CTModels.AbstractModel
Fields
times::Union{Nothing, CTModels.AbstractTimesModel}
: Default: nothingstate::Union{Nothing, CTModels.AbstractStateModel}
: Default: nothingcontrol::Union{Nothing, CTModels.AbstractControlModel}
: Default: nothingvariable::CTModels.AbstractVariableModel
: Default: EmptyVariableModel()dynamics::Union{Nothing, Function}
: Default: nothingobjective::Union{Nothing, CTModels.AbstractObjectiveModel}
: Default: nothingconstraints::Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}}
: Default: ConstraintsDictType()definition::Union{Nothing, Expr}
: Default: nothing
CTModels.Solution
— Typestruct Solution{TimeGridModelType<:CTModels.AbstractTimeGridModel, TimesModelType<:CTModels.AbstractTimesModel, StateModelType<:CTModels.AbstractStateModel, ControlModelType<:CTModels.AbstractControlModel, VariableModelType<:CTModels.AbstractVariableModel, CostateModelType<:Function, ObjectiveValueType<:Real, DualModelType<:CTModels.AbstractDualModel, SolverInfosType<:CTModels.AbstractSolverInfos} <: CTModels.AbstractSolution
Fields
time_grid::CTModels.AbstractTimeGridModel
times::CTModels.AbstractTimesModel
state::CTModels.AbstractStateModel
control::CTModels.AbstractControlModel
variable::CTModels.AbstractVariableModel
costate::Function
objective::Real
dual::CTModels.AbstractDualModel
solver_infos::CTModels.AbstractSolverInfos
CTModels.SolverInfos
— Typestruct SolverInfos{TI<:Dict{Symbol, Any}} <: CTModels.AbstractSolverInfos
Fields
iterations::Int64
stopping::Symbol
message::String
success::Bool
constraints_violation::Float64
infos::Dict{Symbol, Any}
CTModels.StateModel
— Typestruct StateModel <: CTModels.AbstractStateModel
Fields
name::String
components::Vector{String}
CTModels.StateModelSolution
— Typestruct StateModelSolution{TS<:Function} <: CTModels.AbstractStateModel
Fields
name::String
components::Vector{String}
value::Function
CTModels.TimeGridModel
— Typestruct TimeGridModel{T<:Union{StepRangeLen, AbstractVector{<:Real}}} <: CTModels.AbstractTimeGridModel
Fields
value::Union{StepRangeLen, AbstractVector{<:Real}}
CTModels.TimesModel
— Typestruct TimesModel{TI<:CTModels.AbstractTimeModel, TF<:CTModels.AbstractTimeModel} <: CTModels.AbstractTimesModel
Fields
initial::CTModels.AbstractTimeModel
final::CTModels.AbstractTimeModel
time_name::String
CTModels.VariableModel
— Typestruct VariableModel <: CTModels.AbstractVariableModel
Fields
name::String
components::Vector{String}
CTModels.VariableModelSolution
— Typestruct VariableModelSolution{TS<:Union{Real, AbstractVector{<:Real}}} <: CTModels.AbstractVariableModel
Fields
name::String
components::Vector{String}
value::Union{Real, AbstractVector{<:Real}}
Base.isempty
— Methodisempty(model::CTModels.ConstraintsModel) -> Bool
Return if the constraints model is not empty.
Base.show
— Methodshow(
io::IO,
_::MIME{Symbol("text/plain")},
ocp::CTModels.PreModel
)
Print the optimal control problem.
Base.show
— Methodshow(
io::IO,
_::MIME{Symbol("text/plain")},
sol::CTModels.Solution
)
Prints the solution.
Base.show
— Methodshow(io::IO, _::MIME{Symbol("text/plain")}, ocp::Model)
Print the optimal control problem.
CTModels.__constraint!
— Method__constraint!(
ocp_constraints::Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}},
type::Symbol,
n::Int64,
m::Int64,
q::Int64;
rg,
f,
lb,
ub,
label
)
Add a constraint to a dictionary of constraints.
CTModels.__constraint_label
— Method__constraint_label() -> Symbol
Used to set the default value of the label of a constraint. A unique value is given to each constraint using the gensym
function and prefixing by :unamed
.
CTModels.__control_components
— Method__control_components(
m::Int64,
name::String
) -> Vector{String}
Used to set the default value of the names of the controls. The default value is ["u"]
for a one dimensional control, and ["u₁", "u₂", ...]
for a multi dimensional control.
CTModels.__control_name
— Method__control_name() -> String
Used to set the default value of the names of the control. The default value is "u"
.
CTModels.__criterion_type
— Method__criterion_type() -> Symbol
Used to set the default value of the type of criterion. Either :min or :max. The default value is :min
. The other possible criterion type is :max
.
CTModels.__is_consistent
— Method__is_consistent(ocp::CTModels.PreModel) -> Bool
CTModels.__is_control_set
— Method__is_control_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_control_set
— Method__is_control_set(ocp::Model) -> Bool
CTModels.__is_definition_set
— Method__is_definition_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_definition_set
— Method__is_definition_set(ocp::Model) -> Bool
CTModels.__is_dynamics_set
— Method__is_dynamics_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_dynamics_set
— Method__is_dynamics_set(ocp::Model) -> Bool
CTModels.__is_empty
— Method__is_empty(ocp::CTModels.PreModel) -> Bool
CTModels.__is_objective_set
— Method__is_objective_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_objective_set
— Method__is_objective_set(ocp::Model) -> Bool
CTModels.__is_state_set
— Method__is_state_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_state_set
— Method__is_state_set(ocp::Model) -> Bool
CTModels.__is_times_set
— Method__is_times_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_times_set
— Method__is_times_set(ocp::Model) -> Bool
CTModels.__is_variable_set
— Method__is_variable_set(ocp::CTModels.PreModel) -> Bool
CTModels.__is_variable_set
— Method__is_variable_set(ocp::Model) -> Bool
CTModels.__state_components
— Method__state_components(n::Int64, name::String) -> Vector{String}
Used to set the default value of the names of the states. The default value is ["x"]
for a one dimensional state, and ["x₁", "x₂", ...]
for a multi dimensional state.
CTModels.__state_name
— Method__state_name() -> String
Used to set the default value of the name of the state. The default value is "x"
.
CTModels.__time_name
— Method__time_name() -> String
Used to set the default value of the name of the time. The default value is t
.
CTModels.__variable_components
— Method__variable_components(
q::Int64,
name::String
) -> Vector{String}
Used to set the default value of the names of the variables. The default value is ["v"]
for a one dimensional variable, and ["v₁", "v₂", ...]
for a multi dimensional variable.
CTModels.__variable_name
— Method__variable_name(q::Int64) -> String
Used to set the default value of the names of the variables. The default value is "v"
.
CTModels.boundary_constraints
— Methodboundary_constraints(
sol::CTModels.Solution
) -> AbstractVector{<:Real}
Return the boundary constraints of the optimal control solution.
CTModels.boundary_constraints_dual
— Methodboundary_constraints_dual(
sol::CTModels.Solution
) -> AbstractVector{<:Real}
Return the dual of the boundary constraints of the optimal control solution.
CTModels.boundary_constraints_nl
— Methodboundary_constraints_nl(
model::CTModels.ConstraintsModel{<:Tuple, TB}
) -> Any
Get the nonlinear boundary constraints from the model.
CTModels.boundary_constraints_nl
— Methodboundary_constraints_nl(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, TB<:Tuple}}
) -> Any
Get the nonlinear boundary constraints from the model.
CTModels.buildFunctionalInit
— MethodbuildFunctionalInit(data, time, dim) -> CTModels.var"#14#15"
Build functional initialization: general interpolation case
CTModels.buildFunctionalInit
— MethodbuildFunctionalInit(
data::Function,
time,
dim
) -> CTModels.var"#16#17"{<:Function}
Build functional initialization: function case
CTModels.buildFunctionalInit
— MethodbuildFunctionalInit(
data::Nothing,
time,
dim
) -> CTModels.var"#14#15"
Build functional initialization: default case
CTModels.buildFunctionalInit
— MethodbuildFunctionalInit(
data::Union{Real, AbstractVector{<:Real}},
time,
dim
) -> Union{CTModels.var"#18#20", CTModels.var"#19#21"}
Build functional initialization: constant / 1D interpolation
CTModels.buildVectorInit
— MethodbuildVectorInit(data, dim) -> Any
Build vector initialization: default / vector case
CTModels.build_constraints
— Methodbuild_constraints(
constraints::Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}}
) -> CTModels.ConstraintsModel{TP, TB, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}}} where {TP<:Tuple{Vector{Real}, Any, Vector{Real}}, TB<:Tuple{Vector{Real}, Any, Vector{Real}}}
Build a concrete type constraints model from a dictionary of constraints.
CTModels.build_model
— Methodbuild_model(
pre_ocp::CTModels.PreModel
) -> Model{TimesModelType, StateModelType, ControlModelType, VariableModelType, DynamicsModelType, ObjectiveModelType, ConstraintsModelType} where {TimesModelType<:CTModels.AbstractTimesModel, StateModelType<:CTModels.AbstractStateModel, ControlModelType<:CTModels.AbstractControlModel, VariableModelType<:CTModels.AbstractVariableModel, DynamicsModelType<:Function, ObjectiveModelType<:CTModels.AbstractObjectiveModel, ConstraintsModelType<:(CTModels.ConstraintsModel{TP, TB, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Tuple{Vector{Real}, Vector{Int64}, Vector{Real}}, Dict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}}} where {TP<:Tuple{Vector{Real}, Any, Vector{Real}}, TB<:Tuple{Vector{Real}, Any, Vector{Real}}})}
Build a concrete type model from a pre-model.
CTModels.build_solution
— Methodbuild_solution(
ocp::Model,
T::Vector{Float64},
X::Union{Function, Matrix{Float64}},
U::Union{Function, Matrix{Float64}},
v::Vector{Float64},
P::Union{Function, Matrix{Float64}};
objective,
iterations,
constraints_violation,
message,
stopping,
success,
path_constraints,
path_constraints_dual,
boundary_constraints,
boundary_constraints_dual,
state_constraints_lb_dual,
state_constraints_ub_dual,
control_constraints_lb_dual,
control_constraints_ub_dual,
variable_constraints_lb_dual,
variable_constraints_ub_dual
)
Build a solution from the optimal control problem, the time grid, the state, control, variable, and dual variables.
Arguments
ocp::Model
: the optimal control problem.T::Vector{Float64}
: the time grid.X::Matrix{Float64}
: the state trajectory.U::Matrix{Float64}
: the control trajectory.v::Vector{Float64}
: the variable trajectory.P::Matrix{Float64}
: the costate trajectory.objective::Float64
: the objective value.iterations::Int
: the number of iterations.constraints_violation::Float64
: the constraints violation.message::String
: the message associated to the stopping criterion.stopping::Symbol
: the stopping criterion.success::Bool
: the success status.path_constraints::Matrix{Float64}
: the path constraints.path_constraints_dual::Matrix{Float64}
: the dual of the path constraints.boundary_constraints::Vector{Float64}
: the boundary constraints.boundary_constraints_dual::Vector{Float64}
: the dual of the boundary constraints.state_constraints_lb_dual::Matrix{Float64}
: the lower bound dual of the state constraints.state_constraints_ub_dual::Matrix{Float64}
: the upper bound dual of the state constraints.control_constraints_lb_dual::Matrix{Float64}
: the lower bound dual of the control constraints.control_constraints_ub_dual::Matrix{Float64}
: the upper bound dual of the control constraints.variable_constraints_lb_dual::Vector{Float64}
: the lower bound dual of the variable constraints.variable_constraints_ub_dual::Vector{Float64}
: the upper bound dual of the variable constraints.
Returns
sol::Solution
: the optimal control solution.
CTModels.checkDim
— MethodcheckDim(actual_dim, target_dim)
Check if actual dimension is equal to target dimension, error otherwise
CTModels.components
— Methodcomponents(
model::CTModels.ControlModelSolution
) -> Vector{String}
Get the components names of the control from the model solution.
CTModels.components
— Methodcomponents(model::CTModels.ControlModel) -> Vector{String}
Get the components names of the control from the model.
CTModels.components
— Methodcomponents(_::CTModels.EmptyVariableModel) -> Vector{String}
Get the components names of the variable from the empty variable model. Return an empty vector.
CTModels.components
— Methodcomponents(
model::CTModels.StateModelSolution
) -> Vector{String}
Get the components names of the state from the state model solution.
CTModels.components
— Methodcomponents(model::CTModels.StateModel) -> Vector{String}
Get the components names of the state from the state model.
CTModels.components
— Methodcomponents(
model::CTModels.VariableModelSolution
) -> Vector{String}
Get the components names of the variable from the variable model solution.
CTModels.components
— Methodcomponents(model::CTModels.VariableModel) -> Vector{String}
Get the components names of the variable from the variable model.
CTModels.constraint!
— Methodconstraint!(
ocp::CTModels.PreModel,
type::Symbol;
rg,
f,
lb,
ub,
label
)
Add a constraint to a pre-model.
CTModels.constraint
— Methodconstraint(ocp::Model, label::Symbol) -> Tuple
Get a labelled constraint from the model.
CTModels.constraints
— Methodconstraints(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, C<:CTModels.AbstractConstraintsModel}
) -> CTModels.AbstractConstraintsModel
Get the constraints from the model.
CTModels.constraints_violation
— Methodconstraints_violation(sol::CTModels.Solution) -> Float64
Return the constraints violation of the optimal control solution.
CTModels.control!
— Methodcontrol!(ocp::CTModels.PreModel, m::Int64)
control!(
ocp::CTModels.PreModel,
m::Int64,
name::Union{String, Symbol}
)
control!(
ocp::CTModels.PreModel,
m::Int64,
name::Union{String, Symbol},
components_names::Array{T2<:Union{String, Symbol}, 1}
)
Define the control dimension and possibly the names of each coordinate.
You must use control! only once to set the control dimension.
Examples
julia> control!(ocp, 1)
julia> control_dimension(ocp)
1
julia> control_components(ocp)
["u"]
julia> control!(ocp, 1, "v")
julia> control_dimension(ocp)
1
julia> control_components(ocp)
["v"]
julia> control!(ocp, 2)
julia> control_dimension(ocp)
2
julia> control_components(ocp)
["u₁", "u₂"]
julia> control!(ocp, 2, :v)
julia> control_dimension(ocp)
2
julia> control_components(ocp)
["v₁", "v₂"]
julia> control!(ocp, 2, "v")
julia> control_dimension(ocp)
2
julia> control_components(ocp)
["v₁", "v₂"]
julia> control!(ocp, 2, "v", ["a", "b"])
julia> control_dimension(ocp)
2
julia> control_components(ocp)
["a", "b"]
julia> control!(ocp, 2, "v", [:a, :b])
julia> control_dimension(ocp)
2
julia> control_components(ocp)
["a", "b"]
CTModels.control
— Methodcontrol(
sol::CTModels.Solution{<:CTModels.AbstractTimeGridModel, <:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.ControlModelSolution{TS<:Function}}
) -> Function
Return the control (function of time) of the optimal control solution.
julia> t0 = time_grid(sol)[1]
julia> u = control(sol)
julia> u0 = u(t0) # control at initial time
CTModels.control
— Methodcontrol(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, T<:CTModels.AbstractControlModel}
) -> CTModels.AbstractControlModel
Get the control from the model.
CTModels.control_components
— Methodcontrol_components(sol::CTModels.Solution) -> Vector{String}
Return the names of the components of the control of the optimal control solution.
CTModels.control_components
— Methodcontrol_components(ocp::Model) -> Vector{String}
Get the components names of the control from the model.
CTModels.control_constraints_box
— Methodcontrol_constraints_box(
model::CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, TC}
) -> Any
Get the control box constraints from the model.
CTModels.control_constraints_box
— Methodcontrol_constraints_box(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, TC<:Tuple}}
) -> Any
Get the box constraints on control from the model.
CTModels.control_constraints_lb_dual
— Methodcontrol_constraints_lb_dual(
sol::CTModels.Solution
) -> Function
Return the lower bound dual of the control constraints of the optimal control solution.
CTModels.control_constraints_ub_dual
— Methodcontrol_constraints_ub_dual(
sol::CTModels.Solution
) -> Function
Return the upper bound dual of the control constraints of the optimal control solution.
CTModels.control_dimension
— Methodcontrol_dimension(sol::CTModels.Solution) -> Int64
Return the dimension of the control of the optimal control solution.
CTModels.control_dimension
— Methodcontrol_dimension(ocp::Model) -> Int64
Get the control dimension from the model.
CTModels.control_discretized
— Methodcontrol_discretized(sol::CTModels.Solution) -> Any
Return the control values at times time_grid(sol)
of the optimal control solution or nothing
.
julia> u = control_discretized(sol)
julia> u0 = u[1] # control at initial time
CTModels.control_name
— Methodcontrol_name(sol::CTModels.Solution) -> String
Return the name of the control of the optimal control solution.
CTModels.control_name
— Methodcontrol_name(ocp::Model) -> String
Get the name of the control from the model.
CTModels.costate
— Methodcostate(
sol::CTModels.Solution{<:CTModels.AbstractTimeGridModel, <:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, Co<:Function}
) -> Function
Return the costate of the optimal control solution.
julia> t0 = time_grid(sol)[1]
julia> p = costate(sol)
julia> p0 = p(t0)
CTModels.costate_discretized
— Methodcostate_discretized(sol::CTModels.Solution) -> Any
Return the costate values at times time_grid(sol)
of the optimal control solution or nothing
.
julia> p = costate_discretized(sol)
julia> p0 = p[1] # costate at initial time
CTModels.criterion
— Methodcriterion(model::CTModels.BolzaObjectiveModel) -> Symbol
Get the criterion (:min or :max) of the Bolza objective model.
CTModels.criterion
— Methodcriterion(model::CTModels.LagrangeObjectiveModel) -> Symbol
Get the criterion (:min or :max) of the Lagrange objective model.
CTModels.criterion
— Methodcriterion(model::CTModels.MayerObjectiveModel) -> Symbol
Get the criterion (:min or :max) of the Mayer objective model.
CTModels.criterion
— Methodcriterion(ocp::Model) -> Symbol
Get the type of criterion (:min or :max) from the model.
CTModels.ctinterpolate
— Methodctinterpolate(x, f) -> Any
Return the interpolation of f
at x
.
CTModels.definition!
— Methoddefinition!(ocp::CTModels.PreModel, definition::Expr)
Set the model definition of the optimal control problem.
CTModels.definition
— Methoddefinition(ocp::CTModels.PreModel) -> Union{Nothing, Expr}
Return the model definition of the optimal control problem or nothing
.
CTModels.definition
— Methoddefinition(ocp::Model) -> Expr
Return the model definition of the optimal control problem.
CTModels.dim_boundary_constraints_nl
— Methoddim_boundary_constraints_nl(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of nonlinear boundary constraints.
CTModels.dim_boundary_constraints_nl
— Methoddim_boundary_constraints_nl(ocp::Model) -> Int64
Return the dimension of the boundary constraints.
CTModels.dim_control_constraints_box
— Methoddim_control_constraints_box(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of control box constraints.
CTModels.dim_control_constraints_box
— Methoddim_control_constraints_box(ocp::Model) -> Int64
Return the dimension of box constraints on control.
CTModels.dim_path_constraints_nl
— Methoddim_path_constraints_nl(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of nonlinear path constraints.
CTModels.dim_path_constraints_nl
— Methoddim_path_constraints_nl(ocp::Model) -> Int64
Return the dimension of nonlinear path constraints.
CTModels.dim_state_constraints_box
— Methoddim_state_constraints_box(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of state box constraints.
CTModels.dim_state_constraints_box
— Methoddim_state_constraints_box(ocp::Model) -> Int64
Return the dimension of box constraints on state.
CTModels.dim_variable_constraints_box
— Methoddim_variable_constraints_box(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of variable box constraints.
CTModels.dim_variable_constraints_box
— Methoddim_variable_constraints_box(ocp::Model) -> Int64
Return the dimension of box constraints on variable.
CTModels.dimension
— Methoddimension(model::CTModels.ControlModelSolution) -> Int64
Get the control dimension from the model solution.
CTModels.dimension
— Methoddimension(model::CTModels.ControlModel) -> Int64
Get the control dimension from the model.
CTModels.dimension
— Methoddimension(_::CTModels.EmptyVariableModel) -> Int64
Get the variable dimension from the empty variable model. Return 0.
CTModels.dimension
— Methoddimension(model::CTModels.StateModelSolution) -> Int64
Get the dimension of the state from the state model solution.
CTModels.dimension
— Methoddimension(model::CTModels.StateModel) -> Int64
Get the dimension of the state from the state model.
CTModels.dimension
— Methoddimension(model::CTModels.VariableModelSolution) -> Int64
Get the variable dimension from the variable model solution.
CTModels.dimension
— Methoddimension(model::CTModels.VariableModel) -> Int64
Get the variable dimension from the variable model.
CTModels.dynamics!
— Methoddynamics!(ocp::CTModels.PreModel, f::Function)
Set the dynamics of the optimal control problem, in a pre-model.
CTModels.dynamics
— Methoddynamics(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, D<:Function}
) -> Function
Get the dynamics from the model.
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(
ocp::Model{<:CTModels.TimesModel{<:CTModels.AbstractTimeModel, CTModels.FixedTimeModel{T<:Real}}}
) -> Real
Get the final time from the model, for a fixed final time.
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
— Methodfinal_time(
ocp::Model{<:CTModels.TimesModel{<:CTModels.AbstractTimeModel, CTModels.FreeTimeModel}},
variable::AbstractArray{T<:Real, 1}
) -> Any
Get the final time from the model, for a free final time.
CTModels.final_time_name
— Methodfinal_time_name(sol::CTModels.Solution) -> String
Return the name of the final time of the optimal control solution.
CTModels.final_time_name
— Methodfinal_time_name(model::CTModels.TimesModel) -> String
Get the name of the final time from the times model.
CTModels.final_time_name
— Methodfinal_time_name(ocp::Model) -> String
Get the name of the final time from the model.
CTModels.formatData
— MethodformatData(data) -> Any
Convert matrix to vector of vectors (could be expanded)
CTModels.formatTimeGrid
— MethodformatTimeGrid(time) -> Any
Convert matrix time-grid to vector
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(ocp::Model) -> Bool
Check if the final time is fixed.
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(ocp::Model) -> Bool
Check if the initial time is fixed.
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_final_time
— Methodhas_free_final_time(ocp::Model) -> 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.has_free_initial_time
— Methodhas_free_initial_time(ocp::Model) -> Bool
Check if the initial time is free.
CTModels.has_lagrange_cost
— Methodhas_lagrange_cost(
model::CTModels.BolzaObjectiveModel
) -> Bool
Check if the Bolza objective model has a Lagrange function. Return true.
CTModels.has_lagrange_cost
— Methodhas_lagrange_cost(
model::CTModels.LagrangeObjectiveModel
) -> Bool
Check if the Lagrange objective model has a Lagrange function. Return true.
CTModels.has_lagrange_cost
— Methodhas_lagrange_cost(
model::CTModels.MayerObjectiveModel
) -> Bool
Check if the Mayer objective model has a Lagrange function. Return false.
CTModels.has_lagrange_cost
— Methodhas_lagrange_cost(ocp::Model) -> Bool
Check if the model has a Lagrange cost.
CTModels.has_mayer_cost
— Methodhas_mayer_cost(model::CTModels.BolzaObjectiveModel) -> Bool
Check if the Bolza objective model has a Mayer function. Return true.
CTModels.has_mayer_cost
— Methodhas_mayer_cost(
model::CTModels.LagrangeObjectiveModel
) -> Bool
Check if the Lagrange objective model has a Mayer function. Return false.
CTModels.has_mayer_cost
— Methodhas_mayer_cost(model::CTModels.MayerObjectiveModel) -> Bool
Check if the Mayer objective model has a Mayer function. Return true.
CTModels.has_mayer_cost
— Methodhas_mayer_cost(ocp::Model) -> Bool
Check if the model has a Mayer cost.
CTModels.index
— Methodindex(model::CTModels.FreeTimeModel) -> Int64
Get the index of the time variable from the free time model.
CTModels.infos
— Methodinfos(sol::CTModels.Solution) -> Dict{Symbol, Any}
Return a dictionary of additional infos depending on the solver or nothing
.
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(
ocp::Model{<:CTModels.TimesModel{CTModels.FixedTimeModel{T<:Real}}}
) -> Real
Get the initial time from the model, for a fixed initial time.
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
— Methodinitial_time(
ocp::Model{<:CTModels.TimesModel{CTModels.FreeTimeModel}},
variable::AbstractArray{T<:Real, 1}
) -> Any
Get the initial time from the model, for a free initial time.
CTModels.initial_time_name
— Methodinitial_time_name(sol::CTModels.Solution) -> String
Return the name of the initial time of the optimal control solution.
CTModels.initial_time_name
— Methodinitial_time_name(model::CTModels.TimesModel) -> String
Get the name of the initial time from the times model.
CTModels.initial_time_name
— Methodinitial_time_name(ocp::Model) -> String
Get the name of the initial time from the model.
CTModels.is_empty_time_grid
— Methodis_empty_time_grid(sol::CTModels.Solution) -> Bool
Check if the time grid is empty from the solution.
CTModels.isaVectVect
— MethodisaVectVect(data) -> Bool
Return true if argument is a vector of vectors
CTModels.isempty_constraints
— Methodisempty_constraints(ocp::Model) -> Bool
Return if the constraints from the model are not empty.
CTModels.iterations
— Methoditerations(sol::CTModels.Solution) -> Int64
Return the number of iterations (if solved by an iterative method) of the optimal control solution.
CTModels.lagrange
— Methodlagrange(
model::CTModels.BolzaObjectiveModel{<:Function, L<:Function}
) -> Function
Get the Lagrange function of the Bolza objective model.
CTModels.lagrange
— Methodlagrange(
model::CTModels.LagrangeObjectiveModel{L<:Function}
) -> Function
Get the Lagrange function of the Lagrange objective model.
CTModels.lagrange
— Methodlagrange(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.BolzaObjectiveModel{<:Function, L<:Function}}
) -> Any
Get the Lagrange cost from the model.
CTModels.lagrange
— Methodlagrange(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, CTModels.LagrangeObjectiveModel{L<:Function}}
) -> Function
Get the Lagrange cost from the model.
CTModels.matrix2vec
— Functionmatrix2vec(x::Matrix{<:Real}) -> Vector{<:Vector{<:Real}}
matrix2vec(
x::Matrix{<:Real},
dim::Int64
) -> Vector{<:Vector{<:Real}}
Transforms x
to a Vector{<:Vector{<:ctNumber}}.
Note. dim
∈ {1, 2} is the dimension along which the matrix is transformed.
CTModels.mayer
— Methodmayer(
model::CTModels.BolzaObjectiveModel{M<:Function}
) -> Function
Get the Mayer function of the Bolza objective model.
CTModels.mayer
— Methodmayer(
model::CTModels.MayerObjectiveModel{M<:Function}
) -> Function
Get the Mayer function of the Mayer objective model.
CTModels.mayer
— Methodmayer(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.BolzaObjectiveModel{M<:Function}}
) -> Any
Get the Mayer cost from the model.
CTModels.mayer
— Methodmayer(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.MayerObjectiveModel{M<:Function}}
) -> Any
Get the Mayer cost from the model.
CTModels.message
— Methodmessage(sol::CTModels.Solution) -> String
Return the message associated to the stopping criterion of the optimal control solution.
CTModels.name
— Methodname(model::CTModels.ControlModelSolution) -> String
Get the name of the control from the model solution.
CTModels.name
— Methodname(model::CTModels.ControlModel) -> String
Get the name of the control from the model.
CTModels.name
— Methodname(_::CTModels.EmptyVariableModel) -> String
Get the variable name from the empty variable model. Return an empty string.
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.name
— Methodname(model::CTModels.StateModelSolution) -> String
Get the name of the state from the state model solution.
CTModels.name
— Methodname(model::CTModels.StateModel) -> String
Get the name of the state from the state model.
CTModels.name
— Methodname(model::CTModels.VariableModelSolution) -> String
Get the variable name from the variable model solution.
CTModels.name
— Methodname(model::CTModels.VariableModel) -> String
Get the variable name from the variable model.
CTModels.objective!
— Functionobjective!(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.
- 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
```@example julia> function mayer(x0, xf, v) return x0[1] + xf[1] + v[1] end juila> function lagrange(t, x, u, v) return x[1] + u[1] + v[1] end julia> objective!(ocp, :min, mayer=mayer, lagrange=lagrange)
CTModels.objective
— Methodobjective(
sol::CTModels.Solution{<:CTModels.AbstractTimeGridModel, <:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, O<:Real}
) -> Real
Return the objective value of the optimal control solution.
CTModels.objective
— Methodobjective(
ocp::Model{<:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, O<:CTModels.AbstractObjectiveModel}
) -> CTModels.AbstractObjectiveModel
Get the objective from the model.
CTModels.path_constraints
— Methodpath_constraints(sol::CTModels.Solution) -> Function
Return the path constraints of the optimal control solution.
CTModels.path_constraints_dual
— Methodpath_constraints_dual(sol::CTModels.Solution) -> Function
Return the dual of the path constraints of the optimal control solution.
CTModels.path_constraints_nl
— Methodpath_constraints_nl(
model::CTModels.ConstraintsModel{TP}
) -> Any
Get the nonlinear path constraints from the model.
CTModels.path_constraints_nl
— Methodpath_constraints_nl(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{TP<:Tuple}}
) -> Any
Get the nonlinear path constraints from the model.
CTModels.state!
— Methodstate!(ocp::CTModels.PreModel, n::Int64)
state!(
ocp::CTModels.PreModel,
n::Int64,
name::Union{String, Symbol}
)
state!(
ocp::CTModels.PreModel,
n::Int64,
name::Union{String, Symbol},
components_names::Array{T2<:Union{String, Symbol}, 1}
)
Define the state dimension and possibly the names of each component.
You must use state! only once to set the state dimension.
Examples
julia> state!(ocp, 1)
julia> state_dimension(ocp)
1
julia> state_components(ocp)
["x"]
julia> state!(ocp, 1, "y")
julia> state_dimension(ocp)
1
julia> state_components(ocp)
["y"]
julia> state!(ocp, 2)
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["x₁", "x₂"]
julia> state!(ocp, 2, :y)
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["y₁", "y₂"]
julia> state!(ocp, 2, "y")
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["y₁", "y₂"]
julia> state!(ocp, 2, "y", ["u", "v"])
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["u", "v"]
julia> state!(ocp, 2, "y", [:u, :v])
julia> state_dimension(ocp)
2
julia> state_components(ocp)
["u", "v"]
CTModels.state
— Methodstate(
sol::CTModels.Solution{<:CTModels.AbstractTimeGridModel, <:CTModels.AbstractTimesModel, <:CTModels.StateModelSolution{TS<:Function}}
) -> Function
Return the state (function of time) of the optimal control solution.
julia> t0 = time_grid(sol)[1]
julia> x = state(sol)
julia> x0 = x(t0)
CTModels.state
— Methodstate(
ocp::Model{<:CTModels.TimesModel, T<:CTModels.AbstractStateModel}
) -> CTModels.AbstractStateModel
Get the state from the model.
CTModels.state_components
— Methodstate_components(sol::CTModels.Solution) -> Vector{String}
Return the names of the components of the state of the optimal control solution.
CTModels.state_components
— Methodstate_components(ocp::Model) -> Vector{String}
Get the components names of the state from the model.
CTModels.state_constraints_box
— Methodstate_constraints_box(
model::CTModels.ConstraintsModel{<:Tuple, <:Tuple, TS}
) -> Any
Get the state box constraints from the model.
CTModels.state_constraints_box
— Methodstate_constraints_box(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, <:Tuple, TS<:Tuple}}
) -> Any
Get the box constraints on state from the model.
CTModels.state_constraints_lb_dual
— Methodstate_constraints_lb_dual(
sol::CTModels.Solution
) -> Function
Return the lower bound dual of the state constraints of the optimal control solution.
CTModels.state_constraints_ub_dual
— Methodstate_constraints_ub_dual(
sol::CTModels.Solution
) -> Function
Return the upper bound dual of the state constraints of the optimal control solution.
CTModels.state_dimension
— Methodstate_dimension(sol::CTModels.Solution) -> Int64
Return the dimension of the state of the optimal control solution.
CTModels.state_dimension
— Methodstate_dimension(ocp::Model) -> Int64
Get the state dimension from the model.
CTModels.state_discretized
— Methodstate_discretized(sol::CTModels.Solution) -> Any
Return the state values at times time_grid(sol)
of the optimal control solution or nothing
.
julia> x = state_discretized(sol)
julia> x0 = x[1] # state at initial time
CTModels.state_name
— Methodstate_name(sol::CTModels.Solution) -> String
Return the name of the state of the optimal control solution.
CTModels.state_name
— Methodstate_name(ocp::Model) -> String
Get the name of the state from the model.
CTModels.stopping
— Methodstopping(sol::CTModels.Solution) -> Symbol
Return the stopping criterion (a Symbol) of the optimal control solution.
CTModels.success
— Methodsuccess(sol::CTModels.Solution) -> Bool
Return the success status of the optimal control solution.
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.
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, name="s") # name is a String
# or
julia> time!(ocp, t0=0, tf=1, name=:s ) # 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_grid
— Methodtime_grid(
sol::CTModels.Solution{<:CTModels.TimeGridModel{T<:Union{StepRangeLen, AbstractVector{<:Real}}}}
) -> Union{StepRangeLen, AbstractVector{<:Real}}
Return the time grid of the optimal control solution.
CTModels.time_name
— Methodtime_name(sol::CTModels.Solution) -> String
Return the name of the time component of the optimal control solution.
CTModels.time_name
— Methodtime_name(model::CTModels.TimesModel) -> String
Get the name of the time variable from the times model.
CTModels.time_name
— Methodtime_name(ocp::Model) -> String
Get the name of the time from the model.
CTModels.times
— Methodtimes(
ocp::Model{T<:CTModels.TimesModel}
) -> CTModels.TimesModel
Get the times from the model.
CTModels.value
— Methodvalue(
model::CTModels.ControlModelSolution{TS<:Function}
) -> Function
Get the control function value from the model solution.
CTModels.value
— Methodvalue(
model::CTModels.StateModelSolution{TS<:Function}
) -> Function
Get the state function from the state model solution.
CTModels.value
— Methodvalue(
model::CTModels.VariableModelSolution{TS<:Union{Real, AbstractVector{<:Real}}}
) -> Union{Real, AbstractVector{<:Real}}
Get the variable from the variable model solution.
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 the variable dimension and possibly the names of each component.
You can use variable! once to set the variable dimension.
Examples
julia> variable!(ocp, 1, "v")
julia> variable!(ocp, 2, "v", [ "v₁", "v₂" ])
CTModels.variable
— Methodvariable(
sol::CTModels.Solution{<:CTModels.AbstractTimeGridModel, <:CTModels.AbstractTimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.VariableModelSolution{TS<:Union{Real, AbstractVector{<:Real}}}}
) -> Union{Real, AbstractVector{<:Real}}
Return the variable of the optimal control solution or nothing
.
julia> v = variable(sol)
CTModels.variable
— Methodvariable(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, T<:CTModels.AbstractVariableModel}
) -> CTModels.AbstractVariableModel
Get the variable from the model.
CTModels.variable_components
— Methodvariable_components(
sol::CTModels.Solution
) -> Vector{String}
Return the names of the components of the variable of the optimal control solution.
CTModels.variable_components
— Methodvariable_components(ocp::Model) -> Vector{String}
Get the components names of the variable from the model.
CTModels.variable_constraints_box
— Methodvariable_constraints_box(
model::CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, <:Tuple, TV}
) -> Any
Get the variable box constraints from the model.
CTModels.variable_constraints_box
— Methodvariable_constraints_box(
ocp::Model{<:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, <:Tuple, TV<:Tuple}}
) -> Any
Get the box constraints on variable from the model.
CTModels.variable_constraints_lb_dual
— Methodvariable_constraints_lb_dual(
sol::CTModels.Solution
) -> AbstractVector{<:Real}
Return the lower bound dual of the variable constraints of the optimal control solution.
CTModels.variable_constraints_ub_dual
— Methodvariable_constraints_ub_dual(
sol::CTModels.Solution
) -> AbstractVector{<:Real}
Return the upper bound dual of the variable constraints of the optimal control solution.
CTModels.variable_dimension
— Methodvariable_dimension(sol::CTModels.Solution) -> Int64
Return the dimension of the variable of the optimal control solution.
CTModels.variable_dimension
— Methodvariable_dimension(ocp::Model) -> Int64
Get the variable dimension from the model.
CTModels.variable_name
— Methodvariable_name(sol::CTModels.Solution) -> String
Return the name of the variable of the optimal control solution.
CTModels.variable_name
— Methodvariable_name(ocp::Model) -> String
Get the name of the variable from the model.