library(osqp)
## example, adapted from OSQP documentation
library(Matrix)
P <- Matrix(c(11., 0.,
0., 0.), 2, 2, sparse = TRUE)
q <- c(3., 4.)
A <- Matrix(c(-1., 0., -1., 2., 3.,
0., -1., -3., 5., 4.)
, 5, 2, sparse = TRUE)
u <- c(0., 0., -15., 100., 80)
l <- rep_len(-Inf, 5)
settings <- osqpSettings(verbose = TRUE)
# Solve with OSQP
res <- solve_osqp(P, q, A, l, u, settings)
res$x
Run the code above in your browser using DataLab