# NOT RUN {
##################################
## Optimizing the schewefel's problem 1.2 function
# define schewefel's problem 1.2 function as objective function
schewefels1.2 <- function(x){
dim <- length(x)
result <- 0
for(i in 1:dim){
result <- result + sum(x[1:i])^2
}
return(result)
}
## Define parameter
numVar <- 5
rangeVar <- matrix(c(-10,10), nrow=2)
## calculate the optimum solution using dragonfly algorithm
resultDA <- DA(schewefels1.2, optimType="MIN", numVar, numPopulation=20,
maxIter=100, rangeVar)
## calculate the optimum value using schewefel's problem 1.2 function
optimum.value <- schewefels1.2(resultDA)
# }
Run the code above in your browser using DataLab