# NOT RUN {
##################################
## Optimizing the step function
# define step function as objective function
step <- function(x){
result <- sum(abs((x+0.5))^2)
return(result)
}
## Define parameter
numVar <- 5
rangeVar <- matrix(c(-100,100), nrow=2)
## calculate the optimum solution using differential evolution
resultDE <- DE(step, optimType="MIN", numVar, numPopulation=20,
maxIter=100, rangeVar)
## calculate the optimum value using step function
optimum.value <- step(resultDE)
# }
Run the code above in your browser using DataLab