Quadratic models with linear constraints

The quadratic model with linear constraints is another specific case where the objective function is quadratic and the constraints are linear.

\[\begin{aligned} \min \quad & x^TQx + c^Tx + c_0 \\ & c_A \leq Ax \leq l_A, \\ & \ell \leq x \leq u. \end{aligned}\]

This problem is convex whenever the matrix Q is positive semi-definite. A key aspect here is the modeling of the matrices Q and A. The main data structure available in Julia are: LinearAlgebra.Matrix, SparseArrays.sparse, SparseMatricesCOO.sparse, LinearOperators.LinearOperator.

In JuliaSmoothOptimizers, the package QuadraticModels.jl can be used to access the NLPModel API for such instance.

The function minimize with the following sets of arguments will automatically build a QuadraticModel and choose the adequate solver.

  stats = minimize(c, H, c0 = c0, x0 = x0, name = name; kwargs...)
  stats = minimize(c, H, lvar, uvar, c0 = c0, x0 = x0, name = name; kwargs...)
  stats = minimize(c, H, A, lcon, ucon, c0 = c0, x0 = x0, name = name; kwargs...)
  stats = minimize(c, H, lvar, uvar, A, lcon, ucon, c0 = c0, x0 = x0, name = name; kwargs...)

Examples

  using SparseArrays
  n = 50
  c = zeros(n)
  H = spdiagm(0 => 1.0:n)
  H[n, 1] = 1.0
  A = ones(1, n)
  lcon = [1.0]
  ucon = [1.0]
1-element Vector{Float64}:
 1.0

The quadratic model can then be solved using minimize.

using JSOSuite
  stats = minimize(c, H, A, lcon, ucon, name = "eqconqp_QP")
"Execution stats: first-order stationary"

This is equivalent to building a QuadraticModel and then minimize.

using QuadraticModels, JSOSuite
  qp_model = QuadraticModel(c, H, A, lcon, ucon, name = "eqconqp_QP")
  stats = minimize(qp_model)
"Execution stats: first-order stationary"

As usual, it is also possible to select manually the solver to be used.

  using RipQP
  stats = minimize("RipQP", c, H, A, lcon, ucon, name = "eqconqp_QP")
"Execution stats: first-order stationary"