# NOT RUN {
##################################
## Optimizing the schewefel's problem 2.22 function
# define schewefel's problem 2.22 function as objective function
schewefels2.22 <- function(x){
return(sum(abs(x)+prod(abs(x))))
}
## Define parameter
numVar <- 5
rangeVar <- matrix(c(-10,10), nrow=2)
## calculate the optimum solution using Gravitational Based Search
resultGBS <- GBS(schewefels2.22, optimType="MIN", numVar, numPopulation=20,
maxIter=100, rangeVar)
## calculate the optimum value using schewefel's problem 2.22 function
optimum.value <- schewefels2.22(resultGBS)
# }
Run the code above in your browser using DataLab