Version: | 1.1-2 |
Title: | 'SCS' Plug-in for the 'R' Optimization Infrastructure |
Description: | Enhances the 'R' Optimization Infrastructure ('ROI') package with the 'SCS' solver for solving convex cone problems. |
Imports: | stats, methods, slam, ROI (≥ 1.0-0), scs (≥ 3.2-4) |
License: | GPL-3 |
URL: | https://roigrp.gitlab.io, https://gitlab.com/roigrp/solver/ROI.plugin.scs |
NeedsCompilation: | no |
Packaged: | 2023-07-07 11:03:25 UTC; f |
Author: | Florian Schwendinger [aut, cre] |
Maintainer: | Florian Schwendinger <FlorianSchwendinger@gmx.at> |
Repository: | CRAN |
Date/Publication: | 2023-07-07 12:40:02 UTC |
SOCP 1
Description
maximize \ \ x + y
subject \ to \ \ x^2 + y^2 \leq 1
x \geq 0, y \geq 0
Examples
Sys.setenv("ROI_LOAD_PLUGINS" = FALSE)
library(ROI)
library(ROI.plugin.scs)
obj <- L_objective(c(1, 1))
## NOTE: chol(diag(2)) == diag(2)
con <- C_constraint(L = rbind(0, -diag(2)), cones = K_soc(3), rhs = c(1, 0, 0))
op <- OP(obj, con, maximum = TRUE)
x <- ROI_solve(op, solver = "scs")
x
## Optimal solution found.
## The objective value is: 1.414214e+00
solution(x)
## [1] 0.7071068 0.7071068
SOCP 2
Description
The following example is also known as Problem 10
from the
Hock-Schittkowski-Collection Hock and Schittkowski (1981)
.
minimize \ \ x - y \\
subject \ to \ \ -3 x^2 + 2 x y + 1 \geq 0
References
W. Hock, K. Schittkowski (1981): Test Examples for Nonlinear Programming Codes, Lecture Notes in Economics and Mathematical Systems, Vol. 187, Springer
Examples
Sys.setenv("ROI_LOAD_PLUGINS" = FALSE)
library(ROI)
library(ROI.plugin.scs)
obj <- L_objective(c(1, -1))
L <- chol(rbind(c(3, -1), c(-1, 1)))
con <- C_constraint(L = rbind(0, -L), cones = K_soc(3), rhs = c(1, 0, 0))
op <- OP(objective = obj, constraints = con,
bounds = V_bound(li = 1:2, lb = rep(-Inf, 2)))
x <- ROI_solve(op, solver="scs")
x
## Optimal solution found.
## The objective value is: -1.000000e+00
solution(x)
## [1] 1.996387e-10 1.000000e+00
SOCP 3
Description
The following example is originally from the CVXOPT
(http://cvxopt.org/userguide/coneprog.html) homepage.
minimize \ \ -2x_1 + x_2 + 5 x_3
subject to
\left\|
\begin{array}{c}
-13 x_1 + 3 x_2 + 5 x_3 - 3 \\
-12 x_1 + 12 x_2 - 6 x_3 - 2
\end{array}
\right\|_2 \leq -12 x_1 - 6 x_2 + 5 x_3 - 12
\left\|
\begin{array}{c}
-3 x_1 + 6 x_2 + 2 x_3 \\
x_1 + 9 x_2 + 2 x_3 + 3 \\
- x_1 - 19 x_2 + 3 x_3 - 42
\end{array}
\right\|_2 \leq -3 x_1 + 6 x_2 - 10 x_3 + 27
References
Andersen, Martin S and Dahl, Joachim and Vandenberghe, Lieven (2016) CVXOPT: A Python package for convex optimization, version 1.1.8, http://cvxopt.org/
Examples
Sys.setenv("ROI_LOAD_PLUGINS" = FALSE)
library(ROI)
library(ROI.plugin.scs)
lo <- L_objective(c(-2, 1, 5))
lc1 <- rbind(c(12, 6, -5), c(13, -3, -5), c(12, -12, 6))
lc2 <- rbind(c(3, -6, 10), c(3, -6, -2), c(-1, -9, -2), c(1, 19, -3))
lc <- C_constraint(L = rbind(lc1, lc2),
cones = K_soc(c(3, 4)),
rhs = c(c(-12, -3, -2), c(27, 0, 3, -42)))
vb <- V_bound(li = 1:3, lb = rep(-Inf, 3))
op <- OP(objective = lo, constraints = lc, bounds = vb)
x <- ROI_solve(op, solver="scs")
x
## Optimal solution found.
## The objective value is: -3.834637e+01
solution(x)
## [1] -5.014767 -5.766924 -8.521796