A second-order cone program (SOCP) is an optimization problem of the form
where is the optimization variable and , , , , , , and are problem data.
An example of an SOCP is the robust linear program
where the problem data are known within an -norm ball of radius one. The robust linear program can be rewritten as the SOCP
When we solve a SOCP, in addition to a solution , we obtain a dual solution corresponding to each second-order cone constraint. A non-zero indicates that the constraint holds with equality for and suggests that changing would change the optimal value.
Example
In the following code, we solve a SOCP with CVXR. The second-order cone constraint is expressed as norm2(A %*% x + b) <= t in CVXR.
## Problem dimensionsset.seed(2)m <-3# number of SOC constraintsn <-10# number of variablesp <-5# number of equality constraintsn_i <-5# rows per SOC constraint## A feasible point used to construct the problem datax0 <-rnorm(n)f <-rnorm(n)## Generate random data for each SOC constraintsoc_data <-lapply(1:m, function(i) { Ai <-matrix(rnorm(n_i * n), nrow = n_i) bi <-rnorm(n_i) ci <-rnorm(n)## Choose d_i so that x0 is feasible: ||A_i x0 + b_i||_2 <= c_i'x0 + d_i di <-norm(Ai %*% x0 + bi, type ="2") -sum(ci * x0)list(A = Ai, b = bi, c = ci, d = di)})## Equality constraint: F x = g with g = F x0 so x0 is feasibleF_mat <-matrix(rnorm(p * n), nrow = p)g <- F_mat %*% x0## Define and solve the CVXR problemx <-Variable(n)soc_constraints <-lapply(soc_data, function(s) {norm2(s$A %*% x + s$b) <=sum(s$c * x) + s$d})
Warning: `norm2()` is deprecated. Use `p_norm(x, 2)` instead.
This warning is displayed once per session.
## Print resultcat(sprintf("The optimal value is %f\n", result))cat("A solution x is\n")print(value(x))for (i in1:m) {cat(sprintf("SOC constraint %d dual variable solution\n", i))print(dual_value(soc_constraints[[i]]))}
The optimal value is -120.464973
A solution x is
[,1]
[1,] -31.037523
[2,] 28.606756
[3,] -22.197659
[4,] 2.210524
[5,] -30.300881
[6,] 2.724953
[7,] 10.617886
[8,] 82.395792
[9,] -87.680423
[10,] -11.980917
SOC constraint 1 dual variable solution
[1] 2.90497
SOC constraint 2 dual variable solution
[1] 11.61755
SOC constraint 3 dual variable solution
[1] 2.153939e-09