Description Usage Arguments Value Author(s) Examples
Optimization problem constructor
1 2 3 |
objective |
an object inheriting from class |
constraints |
an object inheriting from class |
types |
a character vector giving the types of the objective
variables, with |
bounds |
|
maximum |
a logical giving the direction of the
optimization. |
x |
an R object. |
an object of class "OP"
.
Stefan Theussl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Simple linear program.
## maximize: 2 x_1 + 4 x_2 + 3 x_3
## subject to: 3 x_1 + 4 x_2 + 2 x_3 <= 60
## 2 x_1 + x_2 + x_3 <= 40
## x_1 + 3 x_2 + 2 x_3 <= 80
## x_1, x_2, x_3 are non-negative real numbers
LP <- OP( c(2, 4, 3),
L_constraint(L = matrix(c(3, 2, 1, 4, 1, 3, 2, 2, 2), nrow = 3),
dir = c("<=", "<=", "<="),
rhs = c(60, 40, 80)),
max = TRUE )
LP
## Simple quadratic program.
## minimize: - 5 x_2 + 1/2 (x_1^2 + x_2^2 + x_3^2)
## subject to: -4 x_1 - 3 x_2 >= -8
## 2 x_1 + x_2 >= 2
## - 2 x_2 + x_3 >= 0
QP <- OP( Q_objective (Q = diag(1, 3), L = c(0, -5, 0)),
L_constraint(L = matrix(c(-4,-3,0,2,1,0,0,-2,1),
ncol = 3, byrow = TRUE),
dir = rep(">=", 3),
rhs = c(-8,2,0)) )
QP
|
ROI.plugin.glpk: R Optimization Infrastructure
Registered solver plugins: nlminb, glpk.
Default solver: auto.
ROI Optimization Problem:
Maximize a linear objective function of length 3 with
- 3 continuous objective variables,
subject to
- 3 constraints of type linear.
ROI Optimization Problem:
Minimize a quadratic objective function of length 3 with
- 3 continuous objective variables,
subject to
- 3 constraints of type linear.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.