qpmadr
provides R-bindings to the quadratic programming-solver qpmad
, written by Alexander Sherikov.
install.packages("qpmadr")
[ s.t. _{i}{x_i} = n ]
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)
n = 100
H = crossprod(matrix(rnorm(n*n), n))
# constraint specification for qpmadr
lb = -2
ub = 2
A = matrix(1, 1, n)
Alb = n
Aub = n
# constraint specification for quadprog
At = cbind(rep_len(1, n), diag(1, n, n), diag(-1, n, n))
b = c(n, rep_len(-2, 2*n))
bm = microbenchmark(
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
)
knitr::kable(summary(bm, "relative"), digits=1)
Timings are relative.
The solver is a c++ header-only library and can be used in other packages via the LinkingTo: field
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4