The following example solves exmaple 36 from the Hock-Schittkowski-Collection
.
minimize \ -x_1 x_2 x_3
subject \ to: \ x_1 + 2 x_2 + x_3 ≤q 72
0 ≤q x_1 ≤q 20, \ 0 ≤q x_2 ≤q 11, \ 0 ≤q x_3 ≤q 42
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(ROI)
hs036_obj <- function(x) {
-x[1] * x[2] * x[3]
}
hs036_con <- function(x) {
x[1] + 2 * x[2] + 2 * x[3]
}
x <- OP( objective = F_objective(hs036_obj, n = 3L),
constraints = F_constraint(hs036_con, "<=", 72),
bounds = V_bound(ub = c(20, 11, 42)) )
nlp <- ROI_solve(x, solver = "alabama", start = c(10, 10, 10))
nlp
## Optimal solution found.
## The objective value is: -3.300000e+03
solution(nlp, "objval")
## [1] -3300
solution(nlp)
## [1] 20 11 15
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.