# API Manual

DynamicNLPModels.DenseLQDynamicBlocksType

Struct containing block matrices used for creating and resetting the DenseLQDynamicModel. A and B matrices are given in part by Jerez, Kerrigan, and Constantinides in section 4 of "A sparse and condensed QP formulation for predictive control of LTI systems" (doi:10.1016/j.automatica.2012.03.010). States are eliminated by the equation $x = Ax_0 + Bu + \hat{A}w$ where $x = [x_0^T, x_1^T, ..., x_N^T]$ and $u = [u_0^T, u_1^T, ..., u_{N-1}^T]$

• A : block A matrix given by Jerez et al. with $n_s(N + 1)$ rows and ns columns
• B : block B matrix given by Jerez et al. with $n_s(N)$ rows and nu columns
• Aw : length $n_s(N + 1)$ vector corresponding to the linear term of the dynamic constraints
• h : $n_u(N) \times n_s$ matrix for building the linear term of the objective function. Just needs to be

multiplied by s0.

• h01: ns x ns matrix for building the constant term fo the objective function. This can be found by

taking $s_0^T$ h01 $s_0$

• h02: similar to h01, but one side is multiplied by Aw rather than by As0. This will just

be multiplied by s0 once

• h_constant : linear term in the objective function that arises from Aw. Not a function of s0
• h0_constant: constant term in the objective function that arises from Aw. Not a function of s0
• d : length $n_c(N)$ term for the constraint bounds corresponding to E and F. Must be multiplied by s0 and

subtracted from gl and gu. Equal to the blocks (E + FK) A (see Jerez et al.)

• dw : length $n_c(N)$ term for the constraint bounds that arises from w. Equal to the blocks (E + FK) Aw
• KA : size $n_u(N)$ x ns matrix. Needs to be multiplied by s0 and subtracted from ul and uu to update

the algebraic constraints corresponding to the input bounds

• KAw: similar to KA, but it is multiplied by Aw rather than A

See also reset_s0!

DynamicNLPModels.DenseLQDynamicModelMethod
DenseLQDynamicModel(dnlp::LQDynamicData; implicit = false)    -> DenseLQDynamicModel
DenseLQDynamicModel(s0, A, B, Q, R, N; implicit = false ...) -> DenseLQDynamicModel

A constructor for building a DenseLQDynamicModel <: QuadraticModels.AbstractQuadraticModel

Input data is for the problem of the form

\begin{aligned} \min \frac{1}{2} &\; \sum_{i = 0}^{N - 1}(s_i^T Q s_i + 2 u_i^T S^T x_i + u_i^T R u_i) + \frac{1}{2} s_N^T Q_f s_N \\ \textrm{s.t.} &\; s_{i+1} = A s_i + B u_i + w_i \quad \forall i=0, 1, ..., N-1 \\ &\; u_i = Kx_i + v_i \quad \forall i = 0, 1, ..., N - 1 \\ &\; gl \le E s_i + F u_i \le gu \quad \forall i = 0, 1, ..., N-1\\ &\; sl \le s \le su \\ &\; ul \le u \le uu \\ &\; s_0 = s0 \end{aligned}

Data is converted to the form

\begin{aligned} \min &\; \frac{1}{2} z^T H z \\ \textrm{s.t.} &\; \textrm{lcon} \le Jz \le \textrm{ucon}\\ &\; \textrm{lvar} \le z \le \textrm{uvar} \end{aligned}

Resulting H, J, h, and h0 matrices are stored within QuadraticModels.QPData as H, A, c, and c0 attributes respectively

If K is defined, then u variables are replaced by v variables. The bounds on u are transformed into algebraic constraints, and u can be queried by get_u and get_s within DynamicNLPModels.jl

Keyword argument implicit = false determines how the Jacobian is stored within the QPData. If implicit = false, the full, dense Jacobian matrix is stored. If implicit = true, only the first nu columns of the Jacobian are stored with the Linear Operator LQJacobianOperator.

DynamicNLPModels.LQDynamicDataType
LQDynamicData{T,V,M,MK} <: AbstractLQDynData{T,V}

A struct to represent the features of the optimization problem

\begin{aligned} \min \frac{1}{2} &\; \sum_{i = 0}^{N - 1}(s_i^T Q s_i + 2 u_i^T S^T x_i + u_i^T R u_i) + \frac{1}{2} s_N^T Q_f s_N \\ \textrm{s.t.} &\; s_{i+1} = A s_i + B u_i + w_i \quad \forall i=0, 1, ..., N-1 \\ &\; u_i = Kx_i + v_i \quad \forall i = 0, 1, ..., N - 1 \\ &\; g^l \le E s_i + F u_i \le g^u \quad \forall i = 0, 1, ..., N-1\\ &\; s^l \le s \le s^u \\ &\; u^l \le u \le u^u \\ &\; s_0 = s0 \end{aligned}

Attributes include:

• s0: initial state of system
• A : constraint matrix for system states
• B : constraint matrix for system inputs
• Q : objective function matrix for system states from 0:(N-1)
• R : objective function matrix for system inputs from 0:(N-1)
• N : number of time steps
• Qf: objective function matrix for system state at time N
• S : objective function matrix for system states and inputs
• ns: number of state variables
• nu: number of input varaibles
• E : constraint matrix for state variables
• F : constraint matrix for input variables
• K : feedback gain matrix
• 'w' : constant term for dynamic constraints
• sl: vector of lower bounds on state variables
• su: vector of upper bounds on state variables
• ul: vector of lower bounds on input variables
• uu: vector of upper bounds on input variables
• gl: vector of lower bounds on constraints
• gu: vector of upper bounds on constraints

see also LQDynamicData(s0, A, B, Q, R, N; ...)

DynamicNLPModels.LQDynamicDataMethod
LQDynamicData(s0, A, B, Q, R, N; ...) -> LQDynamicData{T, V, M, MK}

A constructor for building an object of type LQDynamicData for the optimization problem

\begin{aligned} \min \frac{1}{2} &\; \sum_{i = 0}^{N - 1}(s_i^T Q s_i + 2 u_i^T S^T x_i + u_i^T R u_i) + \frac{1}{2} s_N^T Q_f s_N \\ \textrm{s.t.} &\; s_{i+1} = A s_i + B u_i + w_i \quad \forall i=0, 1, ..., N-1 \\ &\; u_i = Kx_i + v_i \quad \forall i = 0, 1, ..., N - 1 \\ &\; gl \le E s_i + F u_i \le gu \quad \forall i = 0, 1, ..., N-1\\ &\; sl \le s \le su \\ &\; ul \le u \le uu \\ &\; s_0 = s0 \end{aligned}
• s0: initial state of system
• A : constraint matrix for system states
• B : constraint matrix for system inputs
• Q : objective function matrix for system states from 0:(N-1)
• R : objective function matrix for system inputs from 0:(N-1)
• N : number of time steps

The following attributes of the LQDynamicData type are detected automatically from the length of s0 and size of R

• ns: number of state variables
• nu: number of input varaibles

The following keyward arguments are also accepted

• Qf = Q: objective function matrix for system state at time N; dimensions must be ns x ns
• S = nothing: objective function matrix for system state and inputs
• E = zeros(eltype(Q), 0, ns) : constraint matrix for state variables
• F = zeros(eltype(Q), 0, nu) : constraint matrix for input variables
• K = nothing : feedback gain matrix
• w = zeros(eltype(Q), ns * N) : constant term for dynamic constraints
• sl = fill(-Inf, ns): vector of lower bounds on state variables
• su = fill(Inf, ns) : vector of upper bounds on state variables
• ul = fill(-Inf, nu): vector of lower bounds on input variables
• uu = fill(Inf, nu) : vector of upper bounds on input variables
• gl = fill(-Inf, size(E, 1)) : vector of lower bounds on constraints
• gu = fill(Inf, size(E, 1)) : vector of upper bounds on constraints
DynamicNLPModels.LQJacobianOperatorType
LQJacobianOperator{T, V, M}

Struct for storing the implicit Jacobian matrix. All data for the Jacobian can be stored in the first nu columns of J. This struct contains the needed data and storage arrays for calculating $Jx$, $J^T x$, and $J^T \Sigma J$. $Jx$ and $J^T x$ are performed through extensions to LinearAlgebra.mul!().

Attributes

• truncated_jac1: Matrix of first nu columns of the Jacobian corresponding to Ax + Bu constraints
• truncated_jac2: Matrix of first nu columns of the Jacobian corresponding to state variable bounds
• truncated_jac3: Matrix of first nu columns of the Jacobian corresponding to input variable bounds
• N : number of time steps
• nu : number of inputs
• nc : number of algebraic constraints of the form gl <= Es + Fu <= gu
• nsc: number of bounded state variables
• nuc: number of bounded input variables (if K is defined)
• SJ1: placeholder for storing data when calculating ΣJ
• SJ2: placeholder for storing data when calculating ΣJ
• SJ3: placeholder for storing data when calculating ΣJ
• H_sub_block: placeholder for storing data when adding J^T ΣJ to the Hessian
DynamicNLPModels.SparseLQDynamicModelMethod

SparseLQDynamicModel(dnlp::LQDynamicData) -> SparseLQDynamicModel SparseLQDynamicModel(s0, A, B, Q, R, N; ...) -> SparseLQDynamicModel A constructor for building a SparseLQDynamicModel <: QuadraticModels.AbstractQuadraticModel Input data is for the problem of the form

\begin{aligned} \min \frac{1}{2} &\; \sum_{i = 0}^{N - 1}(s_i^T Q s_i + 2 u_i^T S^T x_i + u_i^T R u_i) + \frac{1}{2} s_N^T Q_f s_N \\ \textrm{s.t.} &\; s_{i+1} = A s_i + B u_i + w_i \quad \forall i=0, 1, ..., N-1 \\ &\; u_i = Kx_i + v_i \quad \forall i = 0, 1, ..., N - 1 \\ &\; gl \le E s_i + F u_i \le gu \quad \forall i = 0, 1, ..., N-1\\ &\; sl \le s \le su \\ &\; ul \le u \le uu \\ &\; s_0 = s0 \end{aligned}

Data is converted to the form

\begin{aligned} \min &\; \frac{1}{2} z^T H z \\ \textrm{s.t.} &\; \textrm{lcon} \le Jz \le \textrm{ucon}\\ &\; \textrm{lvar} \le z \le \textrm{uvar} \end{aligned}

Resulting H and J matrices are stored as QuadraticModels.QPData within the SparseLQDynamicModel struct and variable and constraint limits are stored within NLPModels.NLPModelMeta

If K is defined, then u variables are replaced by v variables, and u can be queried by get_u and get_s within DynamicNLPModels.jl

DynamicNLPModels.add_jtsj!Method
add_jtsj!(H::M, Jac::LQJacobianOperator{T, V, M}, Σ::V, alpha::Number = 1, beta::Number = 1)

Generates Jac' Σ Jac and adds it to the matrix H.

alpha and beta are scalar multipliers such beta H + alpha Jac' Σ Jac is stored in H, overwriting the existing value of H

DynamicNLPModels.get_AMethod
get_A(LQDynamicData)
get_A(SparseLQDynamicModel)
get_A(DenseLQDynamicModel)

Return the value of A from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_BMethod
get_B(LQDynamicData)
get_B(SparseLQDynamicModel)
get_B(DenseLQDynamicModel)

Return the value of B from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_EMethod
get_E(LQDynamicData)
get_E(SparseLQDynamicModel)
get_E(DenseLQDynamicModel)

Return the value of E from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_FMethod
get_F(LQDynamicData)
get_F(SparseLQDynamicModel)
get_F(DenseLQDynamicModel)

Return the value of F from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_KMethod
get_K(LQDynamicData)
get_K(SparseLQDynamicModel)
get_K(DenseLQDynamicModel)

Return the value of K from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_NMethod
get_N(LQDynamicData)
get_N(SparseLQDynamicModel)
get_N(DenseLQDynamicModel)

Return the value of N from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_QMethod
get_Q(LQDynamicData)
get_Q(SparseLQDynamicModel)
get_Q(DenseLQDynamicModel)

Return the value of Q from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_QfMethod
get_Qf(LQDynamicData)
get_Qf(SparseLQDynamicModel)
get_Qf(DenseLQDynamicModel)

Return the value of Qf from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_RMethod
get_R(LQDynamicData)
get_R(SparseLQDynamicModel)
get_R(DenseLQDynamicModel)

Return the value of R from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_SMethod
get_S(LQDynamicData)
get_S(SparseLQDynamicModel)
get_S(DenseLQDynamicModel)

Return the value of S from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_glMethod
get_gl(LQDynamicData)
get_gl(SparseLQDynamicModel)
get_gl(DenseLQDynamicModel)

Return the value of gl from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_guMethod
get_gu(LQDynamicData)
get_gu(SparseLQDynamicModel)
get_gu(DenseLQDynamicModel)

Return the value of gu from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_jacobianMethod
get_jacobian(lqdm::DenseLQDynamicModel) -> LQJacobianOperator
get_jacobian(Jac::AdjointLinearOpeartor{T, LQJacobianOperator}) -> LQJacobianOperator

Gets the LQJacobianOperator from DenseLQDynamicModel (if the QPdata contains a LQJacobian Operator) or returns the LQJacobian Operator from the adjoint of the LQJacobianOperator

DynamicNLPModels.get_nsMethod
get_ns(LQDynamicData)
get_ns(SparseLQDynamicModel)
get_ns(DenseLQDynamicModel)

Return the value of ns from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_nuMethod
get_nu(LQDynamicData)
get_nu(SparseLQDynamicModel)
get_nu(DenseLQDynamicModel)

Return the value of nu from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_sMethod

gets(solutionref, lqdm::SparseLQDynamicModel) -> s <: vector gets(solutionref, lqdm::DenseLQDynamicModel) -> s <: vector

Query the solution s from the solver. If lqdm <: SparseLQDynamicModel, the solution is queried directly from solution_ref.solution If lqdm <: DenseLQDynamicModel, then solution_ref.solution returns u (if K = nothing) or v (if K <: AbstactMatrix), and s is found form transforming u or v into s using A, B, and K matrices.

DynamicNLPModels.get_s0Method
get_s0(LQDynamicData)
get_s0(SparseLQDynamicModel)
get_s0(DenseLQDynamicModel)

Return the value of s0 from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_slMethod
get_sl(LQDynamicData)
get_sl(SparseLQDynamicModel)
get_sl(DenseLQDynamicModel)

Return the value of sl from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_suMethod
get_su(LQDynamicData)
get_su(SparseLQDynamicModel)
get_su(DenseLQDynamicModel)

Return the value of su from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_uMethod

getu(solutionref, lqdm::SparseLQDynamicModel) -> u <: vector getu(solutionref, lqdm::DenseLQDynamicModel) -> u <: vector

Query the solution u from the solver. If K = nothing, the solution for u is queried from solution_ref.solution

If K <: AbstractMatrix, solution_ref.solution returns v, and get_u solves for u using the K matrix (and the A and B matrices if lqdm <: DenseLQDynamicModel)

DynamicNLPModels.get_ulMethod
get_ul(LQDynamicData)
get_ul(SparseLQDynamicModel)
get_ul(DenseLQDynamicModel)

Return the value of ul from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_uuMethod
get_uu(LQDynamicData)
get_uu(SparseLQDynamicModel)
get_uu(DenseLQDynamicModel)

Return the value of uu from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.get_wMethod
get_w(LQDynamicData)
get_w(SparseLQDynamicModel)
get_w(DenseLQDynamicModel)

Return the value of w from LQDynamicData or SparseLQDynamicModel.dynamic_data or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.reset_s0!Method
reset_s0!(lqdm::SparseLQDynamicModel, s0)
reset_s0!(lqdm::DenseLQDynamicModel, s0)

Resets s0 within lqdm.dynamic_data. For a SparseLQDynamicModel, this updates the variable bounds which fix the value of s0. For a DenseLQDynamicModel, also resets the constraint bounds on the Jacobian and resets the linear and constant terms within the objective function (i.e., lqdm.data.c and lqdm.data.c0). This provides a way to update the model after each sample period.

DynamicNLPModels.set_A!Method
set_A!(LQDynamicData, row, col, val)
set_A!(SparseLQDynamicModel, row, col, val)
set_A!(DenseLQDynamicModel, row, col, val)

Set the value of entry A[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_B!Method
set_B!(LQDynamicData, row, col, val)
set_B!(SparseLQDynamicModel, row, col, val)
set_B!(DenseLQDynamicModel, row, col, val)

Set the value of entry B[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_E!Method
set_E!(LQDynamicData, row, col, val)
set_E!(SparseLQDynamicModel, row, col, val)
set_E!(DenseLQDynamicModel, row, col, val)

Set the value of entry E[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_F!Method
set_F!(LQDynamicData, row, col, val)
set_F!(SparseLQDynamicModel, row, col, val)
set_F!(DenseLQDynamicModel, row, col, val)

Set the value of entry F[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_K!Method
set_K!(LQDynamicData, row, col, val)
set_K!(SparseLQDynamicModel, row, col, val)
set_K!(DenseLQDynamicModel, row, col, val)

Set the value of entry K[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_Q!Method
set_Q!(LQDynamicData, row, col, val)
set_Q!(SparseLQDynamicModel, row, col, val)
set_Q!(DenseLQDynamicModel, row, col, val)

Set the value of entry Q[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_Qf!Method
set_Qf!(LQDynamicData, row, col, val)
set_Qf!(SparseLQDynamicModel, row, col, val)
set_Qf!(DenseLQDynamicModel, row, col, val)

Set the value of entry Qf[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_R!Method
set_R!(LQDynamicData, row, col, val)
set_R!(SparseLQDynamicModel, row, col, val)
set_R!(DenseLQDynamicModel, row, col, val)

Set the value of entry R[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_S!Method
set_S!(LQDynamicData, row, col, val)
set_S!(SparseLQDynamicModel, row, col, val)
set_S!(DenseLQDynamicModel, row, col, val)

Set the value of entry S[row, col] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_gl!Method
set_gl!(LQDynamicData, index, val)
set_gl!(SparseLQDynamicModel, index, val)
set_gl!(DenseLQDynamicModel, index, val)

Set the value of entry gl[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_gu!Method
set_gu!(LQDynamicData, index, val)
set_gu!(SparseLQDynamicModel, index, val)
set_gu!(DenseLQDynamicModel, index, val)

Set the value of entry gu[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_s0!Method
set_s0!(LQDynamicData, index, val)
set_s0!(SparseLQDynamicModel, index, val)
set_s0!(DenseLQDynamicModel, index, val)

Set the value of entry s0[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_sl!Method
set_sl!(LQDynamicData, index, val)
set_sl!(SparseLQDynamicModel, index, val)
set_sl!(DenseLQDynamicModel, index, val)

Set the value of entry sl[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_su!Method
set_su!(LQDynamicData, index, val)
set_su!(SparseLQDynamicModel, index, val)
set_su!(DenseLQDynamicModel, index, val)

Set the value of entry su[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_ul!Method
set_ul!(LQDynamicData, index, val)
set_ul!(SparseLQDynamicModel, index, val)
set_ul!(DenseLQDynamicModel, index, val)

Set the value of entry ul[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

DynamicNLPModels.set_uu!Method
set_uu!(LQDynamicData, index, val)
set_uu!(SparseLQDynamicModel, index, val)
set_uu!(DenseLQDynamicModel, index, val)

Set the value of entry uu[index] to val for LQDynamicData, SparseLQDynamicModel.dynamic_data, or DenseLQDynamicModel.dynamic_data

LinearOperators.reset!Method
LinearOperators.reset!(Jac::LQJacobianOperator{T, V, M})

Resets the values of attributes SJ1, SJ2, and SJ3 to zero