solveqp function

Quadratic Programming

Quadratic Programming

Solves [REMOVE_ME]argmin0.5xHx+hx[REMOVEME2] argmin 0.5 x' H x + h' x [REMOVE_ME_2]

s.t. [REMOVE_ME]lbixiubilbixiubi[REMOVEME2] lb_i \leq x_i \leq ub_ilb_i \le x_i \le ub_i [REMOVE_ME_2]

[REMOVE_ME]Albi(Ax)iAubiAlbi(Ax)iAubi[REMOVEME2] Alb_i \leq (A x)_i \leq Aub_iAlb_i \le (A x)_i \le Aub_i [REMOVE_ME_2]

solveqp( H, h = NULL, lb = NULL, ub = NULL, A = NULL, Alb = NULL, Aub = NULL, pars = list() )

Arguments

  • H: Symmetric positive definite matrix, n*n. Can also be a (inverse) Cholesky factor cf. qpmadParameters.
  • h: Optional, vector of length n.
  • lb, ub: Optional, lower/upper bounds of x. Will be repeated n times if length is one.
  • A: Optional, constraints matrix of dimension p*n, where each row corresponds to a constraint. For equality constraints let corresponding elements in Alb equal those in Aub
  • Alb, Aub: Optional, lower/upper bounds for AxAx.
  • pars: Optional, qpmad-solver parameters, conveniently set with qpmadParameters

Returns

At least one of lb, ub or A must be specified. If A has been specified then also at least one of Alb or Aub. Returns a list with elements solution (the solution vector), status (a status code) and message (a human readable message). If status = 0 the algorithm has converged. Possible status codes:

  • 0: Ok
  • -1: Numerical issue, matrix (probably) not positive definite
  • 1: Inconsistent
  • 2: Infeasible equality
  • 3: Infeasible inequality
  • 4: Maximal number of iterations

Description

Solves

argmin0.5xHx+hx argmin 0.5 x' H x + h' x

s.t.

lbixiubilbixiubi lb_i \leq x_i \leq ub_ilb_i \le x_i \le ub_i Albi(Ax)iAubiAlbi(Ax)iAubi Alb_i \leq (A x)_i \leq Aub_iAlb_i \le (A x)_i \le Aub_i

Examples

## Assume we want to minimize: -(0 5 0) %*% b + 1/2 b^T b ## under the constraints: A^T b >= b0 ## with b0 = (-8,2,0)^T ## and (-4 2 0) ## A = (-3 1 -2) ## ( 0 0 1) ## we can use solveqp as follows: ## Dmat <- diag(3) dvec <- c(0,-5,0) Amat <- t(matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)) bvec <- c(-8,2,0) solveqp(Dmat,dvec,A=Amat,Alb=bvec)

See Also

qpmadParameters

  • Maintainer: Eric Anderson
  • License: GPL (>= 3)
  • Last published: 2021-06-23