Skip to content

Private API ​

This page lists non-exported (internal) symbols of OptimalControlProblems.Catalogue, OptimalControlProblems, OptimalControlProblems.Metadata, OptimalControlProblems.References, OptimalControlModels, ModelingToolkitModels, JuMPModels, OptimalControlProblems.Modelings, OptimalControlProblems.Problems.


From OptimalControlProblems.Catalogue ​

_fingerprint [Function] ​

OptimalControlProblems.Catalogue._fingerprint Function

Fingerprint of problem (#314): the SHA-256 of the files that define it (metadata, description, model files), recorded with each result and compared by the documentation to tell whether a result is up to date. The same on every platform: paths are relative to the package and written with /, and line endings are read as ``.

source

From OptimalControlProblems.Metadata ​

MODELING_TOOLKIT_GRID_SIZE [Constant] ​

OptimalControlProblems.Metadata.MODELING_TOOLKIT_GRID_SIZE Constant

The default number of steps of a ModelingToolkit problem: it is solved by direct shooting (Corleone), one integration per control interval, which needs a coarser grid than a collocation (#435). At most the grid of the problem.

source

From OptimalControlProblems.References ​

_default_scheme [Function] ​

OptimalControlProblems.References._default_scheme Function

The default discretization of a solve in the modeling of a backend, the one of its references: the trapezoidal rule, but for ModelingToolkit, solved by single shooting.

source

_relative_gap [Function] ​

OptimalControlProblems.References._relative_gap Function

Relative gap of a to b (absolute when b is zero).

source

From JuMPModels ​

ButcherTableau [Struct] ​

JuMPModels.ButcherTableau Type
julia
struct ButcherTableau

A Runge–Kutta scheme given by its Butcher tableau (A, b, c), with s stages.

source

Component [Struct] ​

JuMPModels.Component Type
julia
struct Component

A component of the state, the control or the variable: its name (also the name of the JuMP container) and bounds. A bound is a number, or for the state and the control a vector over the nodes 0:N; nothing leaves it unset. The start values come from the initial guess of the problem (#377), not from the components.

source

ProblemData [Struct] ​

JuMPModels.ProblemData Type
julia
struct ProblemData

The data of an optimal control problem, written once for every scheme.

The functions receive, at one node, the vectors x (state), u (control), v (variable) of JuMP variables and the time t; x0, xf are the state at the first and last nodes.

  • times(v): the initial and final times, numbers or expressions of v.

  • dynamics(x, u, v, t): the vector ẋ.

  • lagrange(x, u, v, t): the integrand of the cost, or nothing.

  • cost(I, x0, xf, v): the objective, given the discretized integral I of the Lagrange cost (0 without one).

  • path: (lower, f, upper) with f(x, u, v, t), imposed at every node.

  • boundary: (lower, f, upper) with f(x0, xf, v).

source

_costate_times [Function] ​

JuMPModels._costate_times Function
julia
_costate_times(T) -> Any

Return the time stamps of the dynamics multipliers: the multiplier of a step approximates the costate at the middle of the step (the discrete adjoint of the scheme, CTDirect.jl#640), so the values are stamped at the midpoints t_i + h_i/2 of the steps, not at the nodes.

Evaluations outside [τ_1, τ_N] return the first / last value (ctinterpolate extrapolates flat), i.e. the multiplier of the first / last step.

Arguments

  • T: The node time grid t_0, …, t_N (length(T) == N + 1).

Returns

  • Vector{Float64}: The N step midpoints (T[i] + T[i + 1]) / 2.
source

_interpolate_costate [Function] ​

JuMPModels._interpolate_costate Function
julia
_interpolate_costate(
    T,
    P,
    dim_x::Int64
) -> Union{JuMPModels.var"#_interpolate_costate##2#_interpolate_costate##3", JuMPModels.var"#_interpolate_costate##4#_interpolate_costate##5"}

Interpolate the costate matrix P (sampled at step midpoints _costate_times(T)) into a function of continuous time, coercing to scalar when dim_x == 1.

Arguments

  • T: The node time grid t_0, …, t_N.

  • P: The N × dim_x matrix of step multipliers.

  • dim_x::Int: The state dimension.

Returns

  • Function: A function of continuous time returning the interpolated costate (scalar when dim_x == 1, vector otherwise).
source

_multiplier [Function] ​

JuMPModels._multiplier Function
julia
_multiplier(ref) -> Any

Return the signed multiplier y = μU - μL of the constraint ref in the convention of rules/signs.md (ct-conventions, SGN1, SGN3): the multiplier y of a row c(x) ∈ S satisfies ∇F_min + Jᵀy = 0, with F_min the objective of the equivalent minimization (F for a minimization, -F for a maximization).

JuMP.dual returns the MOI ConstraintDual, a convention fixed by MathOptInterface, independent of the solver and of the objective sense — it is the one of the equivalent minimization, ∇F_min - Jᵀy_MOI = 0. The signed multiplier is hence -JuMP.dual, for a Min and a Max model alike (SGN1: min f and max -f have the same multipliers).

See https://jump.dev/MathOptInterface.jl/stable/background/duality/.

Arguments

  • ref: A JuMP constraint reference.

Returns

  • Float64: The signed multiplier -JuMP.dual(ref).
source

_stage_values [Function] ​

JuMPModels._stage_values Function
julia
_stage_values(
    _::JuMPModels.FirstSameAsLast,
    g,
    tab,
    θ,
    x,
    u,
    v,
    t,
    Δt
) -> Any

Values of g(x, u, v, t) at the stages of every step: G[i + 1][j] for stage j of step i. With FSAL, the stages are nodes and g is evaluated once per node.

source

_start! [Function] ​

JuMPModels._start! Function

Set the start values from the initial guess init ((state=…, control=…, variable=…), any of them may be missing), as CTDirect does: the state at the N+1 nodes, the control at the nodes of its M values, the variable once; the time grid is the one of the initial guess of the variable when the final time is free.

source

build [Function] ​

JuMPModels.build Function
julia
build(
    data::JuMPModels.ProblemData,
    grid_size::Int64,
    scheme::Symbol,
    ordering::Symbol,
    args...;
    init,
    kwargs...
) -> Model

Build the JuMP model of data discretized on grid_size steps by scheme (:trapeze, :euler, :euler_implicit or :midpoint), with the variables and constraints in the order ordering (:interleaved or :blocks), with the start values of the initial guess init (see _start!). args and kwargs are passed to JuMP.Model.

Throws

  • CTBase.Exceptions.IncorrectArgument: If scheme or ordering is not one of them.
source

control_at_node [Function] ​

JuMPModels.control_at_node Function
julia
control_at_node(
    tab::JuMPModels.ButcherTableau,
    k::Int64,
    N::Int64
) -> Int64

The control (0-based) used at the node k of a grid of N steps, by the path constraints. At the nodes for a tableau with final control; otherwise the control of the step that starts at the node, the last node taking the last one, except when the only stage is at the end of the step (implicit Euler): the control of the step that ends at the node, the first node taking the first one (CTDirect's conventions).

source

control_at_stage [Function] ​

JuMPModels.control_at_stage Function

The control (0-based) of stage j of step i (0-based).

source

control_count [Function] ​

JuMPModels.control_count Function

Number of controls on a grid of N steps.

source

costate_components [Function] ​

JuMPModels.costate_components Function
julia
costate_components(model::GenericModel) -> Any

Return the list of costate component names stored in a JuMP model.

Arguments

  • model::JuMP.GenericModel: A JuMP model that contains the key :costate_components.

Returns

  • Vector{String}: The names of the costate components.

Example

julia
julia> costate_components(model)
["∂x", "∂v", "∂θ", "∂ω"]
source

has_explicit_first_stage [Function] ​

JuMPModels.has_explicit_first_stage Function

First row of A zero and c_1 = 0: the first stage is the node X_i.

source

has_final_control [Function] ​

JuMPModels.has_final_control Function

The controls of a FSAL tableau live at the nodes, shared by neighbouring steps: one more control than steps (CTDirect's _final_control).

source

is_explicit [Function] ​

JuMPModels.is_explicit Function

A strictly lower triangular: each stage depends on the previous ones only.

source

is_fsal [Function] ​

JuMPModels.is_fsal Function

First Same As Last: the last stage of a step is the first stage of the next one.

source

is_stiffly_accurate [Function] ​

JuMPModels.is_stiffly_accurate Function

Last row of A equal to b and c_s = 1: the last stage is the next node X_{i+1}.

source

stage_positions [Function] ​

JuMPModels.stage_positions Function
julia
stage_positions(
    tab::JuMPModels.ButcherTableau
) -> Vector{Float64}

The position θ_j of each stage in the step, Z_j = X_i + θ_j (X_{i+1} - X_i).

Throws

  • CTBase.Exceptions.NotImplemented: If a stage is not of this form (an interior stage of a tableau of several stages): it needs stage unknowns, which the JuMP models do not have.
source

tableau [Function] ​

JuMPModels.tableau Function
julia
tableau(scheme::Symbol) -> JuMPModels.ButcherTableau

The tableau of scheme, one of the keys of TABLEAUX.

Throws

  • CTBase.Exceptions.IncorrectArgument: If scheme is not one of them.
source