`qpmadr`

provides R-bindings to the quadratic
programming-solver `qpmad`

, written by Alexander Sherikov.

You can install the released version of qpmadr from CRAN with:

`install.packages("qpmadr")`

This is an example which shows you how to solve a simple problem:

[ _{}{ x’H x} ]

[ s.t. _{i}{x_i} = n ]

[ -2 x_i ]

where (H) is a random positive definite matrix of size (n n), and (x) is a (column) vector of size (n).

The code below will run a benchmark against the quadprog solver for n=100, checking that both give the same results.

```
library(qpmadr)
library(quadprog)
library(microbenchmark)
set.seed(42)
= 100
n
= crossprod(matrix(rnorm(n*n), n))
H
# constraint specification for qpmadr
= -2
lb = 2
ub = matrix(1, 1, n)
A = n
Alb = n
Aub
# constraint specification for quadprog
= cbind(rep_len(1, n), diag(1, n, n), diag(-1, n, n))
At = c(n, rep_len(-2, 2*n))
b
= microbenchmark(
bm check = "equal",
qpmadr = qpmadr::solveqp(H, lb=lb, ub=ub, A=A, Alb=Alb, Aub=Aub)$solution,
quadprog = quadprog::solve.QP(H, numeric(n), At, b, meq=1)$solution
)
::kable(summary(bm, "relative"), digits=1) knitr
```

expr | min | lq | mean | median | uq | max | neval |
---|---|---|---|---|---|---|---|

qpmadr | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 100 |

quadprog | 2.7 | 2.5 | 2.5 | 2.8 | 2.4 | 2.5 | 100 |

Timings are relative.

The solver is a c++ header-only library and can be used in other packages via the LinkingTo: field