Example_02: Hock-Schittkowski-Collection Problem 16

Description Examples

Description

The following example solves problem 16 from the Hock-Schittkowski-Collection.

minimize \ f(x) = 100 (x_2 - x_1^2)^2 + (1 - x_1)^2

subject \ to: \ \ x_1 + x_2^2 ≥q 0 \ \ \ x_1^2 + x_2 ≥q 0

-2 ≥q x_1 ≥q 0.5 \ \ \ x_2 ≥q 1

Solution: c(0.5, 0.25)

Examples

 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
Sys.setenv(ROI_LOAD_PLUGINS = FALSE)
library(ROI)
library(ROI.plugin.deoptim)

f <- function(x) {
    return( 100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2 )
}

f.gradient <- function(x) {
    return( c( -400 * x[1] * (x[2] - x[1] * x[1]) - 2 * (1 - x[1]),
               200 * (x[2] - x[1] * x[1])) )
}

x <- OP( objective = F_objective(f, n=2L, G=f.gradient), 
         constraints = c(F_constraint(F=function(x) x[1] + x[2]^2, ">=", 0,
                                      J=function(x) c(1, 2*x[2])),
                         F_constraint(F=function(x) x[1]^2 + x[2], ">=", 0,
                                      J=function(x) c(2*x[1], x[2]))),
         bounds = V_bound(li=1:2, ui=1:2, lb=c(-2, -Inf), ub=c(0.5,  1)) )

nlp <- ROI_solve(x, solver="deoptimr", start=c(0.4, 0.3))
nlp
## Optimal solution found.
## The objective value is: 2.499999e-01
solution(nlp)
## [1] 0.5000001 0.2499994

ROI.plugin.deoptim documentation built on Aug. 30, 2020, 3:01 a.m.