Private API
This page lists non-exported (internal) symbols of CTModels.
From CTModels
__constraint!
CTModels.__constraint! — Function
__constraint!(
ocp_constraints::OrderedCollections.OrderedDict{Symbol, Tuple{Symbol, Union{Function, OrdinalRange{<:Int64}}, AbstractVector{<:Real}, AbstractVector{<:Real}}},
type::Symbol,
n::Int64,
m::Int64,
q::Int64;
rg,
f,
lb,
ub,
label,
codim_f
)
Add a constraint to a dictionary of constraints.
Arguments
ocp_constraints: The dictionary of constraints to which the constraint will be added.type: The type of the constraint. It can be:state,:control,:variable,:boundary, or:path.n: The dimension of the state.m: The dimension of the control.q: The dimension of the variable.rg: The range of the constraint. It can be an integer or a range of integers.f: The function that defines the constraint. It must return a vector of the same dimension as the constraint.lb: The lower bound of the constraint. It can be a number or a vector.ub: The upper bound of the constraint. It can be a number or a vector.label: The label of the constraint. It must be unique in the dictionary of constraints.
Requirements
- The constraint must not be set before.
- The lower bound
lband the upper boundubcannot be bothnothing. - The lower bound
lband the upper boundubmust have the same length, if both provided.
If rg and f are not provided then,
typemust be:state,:control, or:variable.lbandubmust be of dimensionn,m, orqrespectively, when provided.
If rg is provided, then:
fmust not be provided.typemust be:state,:control, or:variable.rgmust be a range of integers, and must be contained in1:n,1:m, or1:qrespectively.
If f is provided, then:
rgmust not be provided.typemust be:boundaryor:path.fmust be a function that returns a vector of the same dimension as the constraint.lbandubmust be of the same dimension as the output off, when provided.
Example
# Example of adding a state constraint
julia> ocp_constraints = Dict()
julia> __constraint!(ocp_constraints, :state, 3, 2, 1, lb=[0.0], ub=[1.0], label=:my_constraint)as_range
CTModels.as_range — Function
as_range(::Nothing) -> NothingReturn nothing unchanged.
as_range(r::Int) -> UnitRange{Int}Convert a scalar integer to a single-element range r:r.
as_range(r::OrdinalRange{Int}) -> OrdinalRange{Int}Return an ordinal range unchanged.
as_vector
CTModels.as_vector — Function
as_vector(::Nothing) -> NothingReturn nothing unchanged.
as_vector(x::T) -> Vector{T} where {T<:ctNumber}Wrap a scalar number into a single-element vector.
as_vector(x::Vector{T}) -> Vector{T} where {T<:ctNumber}Return a vector unchanged.
boundary_constraints_nl
CTModels.boundary_constraints_nl — Function
boundary_constraints_nl(
model::CTModels.ConstraintsModel{<:Tuple, TB}
) -> Any
Get the nonlinear boundary constraints from the model.
Arguments
model: The constraints model from which to retrieve the boundary constraints.
Returns
- The nonlinear boundary constraints.
Example
# Example of retrieving nonlinear boundary constraints
julia> model = ConstraintsModel(...)
julia> boundary_constraints = boundary_constraints_nl(model)boundary_constraints_nl(
ocp::CTModels.Model{<:CTModels.TimeDependence, <:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, TB<:Tuple}}
) -> Any
Return the nonlinear boundary constraints.
constraint
CTModels.constraint — Function
constraint(
model::CTModels.Model,
label::Symbol
) -> Tuple{Symbol, Any, Any, Any}
Get a labelled constraint from the model. Returns a tuple of the form (type, f, lb, ub) where type is the type of the constraint, f is the function, lb is the lower bound and ub is the upper bound.
The function returns an exception if the label is not found in the model.
Arguments
model: The model from which to retrieve the constraint.label: The label of the constraint to retrieve.
Returns
Tuple: A tuple containing the type, function, lower bound, and upper bound of the constraint.
constraint!
CTModels.constraint! — Function
constraint!(
ocp::CTModels.PreModel,
type::Symbol;
rg,
f,
lb,
ub,
label,
codim_f
)
Add a constraint to a pre-model. See __constraint! for more details.
Arguments
ocp: The pre-model to which the constraint will be added.type: The type of the constraint. It can be:state,:control,:variable,:boundary, or:path.rg: The range of the constraint. It can be an integer or a range of integers.f: The function that defines the constraint. It must return a vector of the same dimension as the constraint.lb: The lower bound of the constraint. It can be a number or a vector.ub: The upper bound of the constraint. It can be a number or a vector.label: The label of the constraint. It must be unique in the pre-model.
Example
# Example of adding a control constraint to a pre-model
julia> ocp = PreModel()
julia> constraint!(ocp, :control, rg=1:2, lb=[0.0], ub=[1.0], label=:control_constraint)control_constraints_box
CTModels.control_constraints_box — Function
control_constraints_box(
model::CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, TC}
) -> Any
Get the control box constraints from the model.
Arguments
model: The constraints model from which to retrieve the control box constraints.
Returns
- The control box constraints.
Example
# Example of retrieving control box constraints
julia> model = ConstraintsModel(...)
julia> control_constraints = control_constraints_box(model)control_constraints_box(
ocp::CTModels.Model{<:CTModels.TimeDependence, <:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, TC<:Tuple}}
) -> Any
Return the box constraints on control.
dim_boundary_constraints_nl
CTModels.dim_boundary_constraints_nl — Function
dim_boundary_constraints_nl(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of nonlinear boundary constraints.
Arguments
model: The constraints model from which to retrieve the dimension of boundary constraints.
Returns
Dimension: The dimension of the nonlinear boundary constraints.
Example
# Example of getting the dimension of nonlinear boundary constraints
julia> model = ConstraintsModel(...)
julia> dim_boundary = dim_boundary_constraints_nl(model)dim_boundary_constraints_nl(ocp::CTModels.Model) -> Int64
Return the dimension of the boundary constraints.
dim_control_constraints_box
CTModels.dim_control_constraints_box — Function
dim_control_constraints_box(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of control box constraints.
Arguments
model: The constraints model from which to retrieve the dimension of control box constraints.
Returns
Dimension: The dimension of the control box constraints.
Example
julia> # Example of getting the dimension of control box constraints
julia> model = ConstraintsModel(...)
julia> dim_control = dim_control_constraints_box(model)dim_control_constraints_box(ocp::CTModels.Model) -> Int64
Return the dimension of box constraints on control.
dim_path_constraints_nl
CTModels.dim_path_constraints_nl — Function
dim_path_constraints_nl(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of nonlinear path constraints.
Arguments
model: The constraints model from which to retrieve the dimension of path constraints.
Returns
Dimension: The dimension of the nonlinear path constraints.
Example
# Example of getting the dimension of nonlinear path constraints
julia> model = ConstraintsModel(...)
julia> dim_path = dim_path_constraints_nl(model)dim_path_constraints_nl(ocp::CTModels.Model) -> Int64
Return the dimension of nonlinear path constraints.
dim_state_constraints_box
CTModels.dim_state_constraints_box — Function
dim_state_constraints_box(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of state box constraints.
Arguments
model: The constraints model from which to retrieve the dimension of state box constraints.
Returns
Dimension: The dimension of the state box constraints.
Example
julia> # Example of getting the dimension of state box constraints
julia> model = ConstraintsModel(...)
julia> dim_state = dim_state_constraints_box(model)dim_state_constraints_box(ocp::CTModels.Model) -> Int64
Return the dimension of box constraints on state.
dim_variable_constraints_box
CTModels.dim_variable_constraints_box — Function
dim_variable_constraints_box(
model::CTModels.ConstraintsModel
) -> Int64
Return the dimension of variable box constraints.
Arguments
model: The constraints model from which to retrieve the dimension of variable box constraints.
Returns
Dimension: The dimension of the variable box constraints.
Example
julia> # Example of getting the dimension of variable box constraints
julia> model = ConstraintsModel(...)
julia> dim_variable = dim_variable_constraints_box(model)dim_variable_constraints_box(ocp::CTModels.Model) -> Int64
Return the dimension of box constraints on variable.
discretize
CTModels.discretize — Function
discretize(constraint::Function, grid::Vector{T}) -> Vector where {T<:ctNumber}Discretise a constraint function over a time grid.
discretize(::Nothing, grid::Vector{T}) -> Nothing where {T<:ctNumber}Return nothing when discretising a missing constraint.
path_constraints_nl
CTModels.path_constraints_nl — Function
path_constraints_nl(
model::CTModels.ConstraintsModel{TP}
) -> Any
Get the nonlinear path constraints from the model.
Arguments
model: The constraints model from which to retrieve the path constraints.
Returns
- The nonlinear path constraints.
Example
# Example of retrieving nonlinear path constraints
julia> model = ConstraintsModel(...)
julia> path_constraints = path_constraints_nl(model)path_constraints_nl(
ocp::CTModels.Model{<:CTModels.TimeDependence, <:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{TP<:Tuple}}
) -> Any
Return the nonlinear path constraints.
state_constraints_box
CTModels.state_constraints_box — Function
state_constraints_box(
model::CTModels.ConstraintsModel{<:Tuple, <:Tuple, TS}
) -> Any
Get the state box constraints from the model.
Arguments
model: The constraints model from which to retrieve the state box constraints.
Returns
- The state box constraints.
Example
# Example of retrieving state box constraints
julia> model = ConstraintsModel(...)
julia> state_constraints = state_constraints_box(model)state_constraints_box(
ocp::CTModels.Model{<:CTModels.TimeDependence, <:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, <:Tuple, TS<:Tuple}}
) -> Any
Return the box constraints on state.
variable_constraints_box
CTModels.variable_constraints_box — Function
variable_constraints_box(
model::CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, <:Tuple, TV}
) -> Any
Get the variable box constraints from the model.
Arguments
model: The constraints model from which to retrieve the variable box constraints.
Returns
- The variable box constraints.
Example
# Example of retrieving variable box constraints
julia> model = ConstraintsModel(...)
julia> variable_constraints = variable_constraints_box(model)variable_constraints_box(
ocp::CTModels.Model{<:CTModels.TimeDependence, <:CTModels.TimesModel, <:CTModels.AbstractStateModel, <:CTModels.AbstractControlModel, <:CTModels.AbstractVariableModel, <:Function, <:CTModels.AbstractObjectiveModel, <:CTModels.ConstraintsModel{<:Tuple, <:Tuple, <:Tuple, <:Tuple, TV<:Tuple}}
) -> Any
Return the box constraints on variable.