| piqp | R Documentation |
PIQP Solver object
piqp(
P = NULL,
c = NULL,
A = NULL,
b = NULL,
G = NULL,
h_l = NULL,
h_u = NULL,
x_l = NULL,
x_u = NULL,
settings = list(),
backend = c("auto", "sparse", "dense")
)
P |
dense or sparse matrix of class dgCMatrix or coercible into such, must be positive semidefinite |
c |
numeric vector |
A |
dense or sparse matrix of class dgCMatrix or coercible into such |
b |
numeric vector |
G |
dense or sparse matrix of class dgCMatrix or coercible into such |
h_l |
numeric vector of lower inequality bounds, default |
h_u |
numeric vector of upper inequality bounds, default |
x_l |
a numeric vector of lower variable bounds, default |
x_u |
a numeric vector of upper variable bounds, default |
settings |
list with optimization parameters, empty by default; see |
backend |
which backend to use, if auto and P, A or G are sparse then sparse backend is used ( |
Allows one to solve a parametric
problem with for example warm starts between updates of the parameter, c.f. the examples.
The object returned by piqp contains several methods which can be used to either update/get details of the
problem, modify the optimization settings or attempt to solve the problem.
An S7 object of class "piqp_model" with methods
solve(), update(), get_settings(), get_dims(), update_settings()
which can be used to solve the problem with updated settings / parameters.
model = piqp(P = NULL, c = NULL, A = NULL, b = NULL, G = NULL,
h_l = NULL, h_u = NULL, x_l = NULL, x_u = NULL,
settings = piqp_settings(),
backend = c("auto", "sparse", "dense"))
solve(model)
update(model, P = NULL, c = NULL, A = NULL, b = NULL, G = NULL,
h_l = NULL, h_u = NULL, x_l = NULL, x_u = NULL)
get_settings(model)
get_dims(model)
update_settings(model, new_settings = piqp_settings())
solve_piqp(), piqp_settings()
## 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_u <- c(0.2, -1.)
x_l <- c(-1., -Inf)
x_u <- c(1., Inf)
settings <- list(verbose = TRUE)
model <- piqp(P, c, A, b, G, h_u = h_u, x_l = x_l, x_u = x_u, settings = settings)
# Solve
res <- solve(model)
res$x
# Define new data
A_new <- Matrix(c(1., -3.), 1, 2, sparse = TRUE)
h_u_new <- c(2., 1.)
# Update model and solve again
update(model, A = A_new, h_u = h_u_new)
res <- solve(model)
res$x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.