# NOT RUN {
fnR <- function (x, gs=100.0)
{
n <- length(x)
x1 <- x[2:n]
x2 <- x[1:(n - 1)]
sum(gs * (x1 - x2^2)^2 + (1 - x2)^2)
}
grR <- function (x, gs=100.0)
{
n <- length(x)
g <- rep(NA, n)
g[1] <- 2 * (x[1] - 1) + 4*gs * x[1] * (x[1]^2 - x[2])
if (n > 2) {
ii <- 2:(n - 1)
g[ii] <- 2 * (x[ii] - 1) + 4 * gs * x[ii] * (x[ii]^2 - x[ii +
1]) + 2 * gs * (x[ii] - x[ii - 1]^2)
}
g[n] <- 2 * gs * (x[n] - x[n - 1]^2)
g
}
x0 <- rep(pi, 4)
mc <- data.frame(method=c("Nelder-Mead","Rvmmin"), maxit=c(1000, 100), maxfeval= c(1000, 1000))
ans <- polyopt(x0, fnR, grR, methcontrol=mc, control=list(trace=0))
ans
mc <- data.frame(method=c("Nelder-Mead","Rvmmin"), maxit=c(100, 100), maxfeval= c(100, 1000))
ans <- polyopt(x0, fnR, grR, methcontrol=mc, control=list(trace=0))
ans
mc <- data.frame(method=c("Nelder-Mead","Rvmmin"), maxit=c(10, 100), maxfeval= c(10, 1000))
ans <- polyopt(x0, fnR, grR, methcontrol=mc, control=list(trace=0))
ans
# }
Run the code above in your browser using DataLab