Example_01: Quadratic Problem 1

Description Examples

Description

maximize \ \ x_1^2 + x_2^2 + x_3^2 - 5 x_2

subject \ to:

-4 x_1 - 3 x_2 + ≥q -8

2 x_1 + x_2 + ≥q 2

- 2 x_2 + x_3 ≥q 0

x_1, x_2, x_3 ≥q 0

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
require("ROI")
require("ROI.plugin.osqp")

A <- cbind(c(-4, -3, 0), 
           c( 2,  1, 0), 
           c( 0, -2, 1))
x <- OP(Q_objective(diag(3), L =  c(0, -5, 0)),
        L_constraint(L = t(A),
                     dir = rep(">=", 3),
                     rhs = c(-8, 2, 0)))

opt <- ROI_solve(x, solver = "osqp", abs_tol = 1e-8, rel_tol = 1e-8)
opt
## Optimal solution found.
## The objective value is: -2.380952e+00
solution(opt)
## [1] 0.4761905 1.0476191 2.0952381

ROI.plugin.osqp documentation built on Sept. 14, 2020, 5:06 p.m.