## example, adapted from PIQP documentation
library(piqp)
library(Matrix)
P <- Matrix(c(6., 0.,
0., 4.), 2, 2, sparse = TRUE)
c <- c(-1., -4.)
A <- Matrix(c(1., -2.), 1, 2, sparse = TRUE)
b <- c(1.)
G <- Matrix(c(1., 2., -1., 0.), 2, 2, sparse = TRUE)
h <- c(0.2, -1.)
x_lb <- c(-1., -Inf)
x_ub <- c(1., Inf)
settings <- list(verbose = TRUE)
model <- piqp(P, c, A, b, G, h, x_lb, x_ub, settings)
# Solve
res <- model$solve()
res$x
# Define new data
A_new <- Matrix(c(1., -3.), 1, 2, sparse = TRUE)
h_new <- c(2., 1.)
# Update model and solve again
model$update(A = A_new, h = h_new)
res <- model$solve()
res$x
Run the code above in your browser using DataLab