f <- function(x){
return(-sum( (x-5)^2 ) )
}
myga <- ga(type="real-valued", fitness = f, popSize = 100, maxiter = 100,
min = rep(-50,5), max = rep(50,5), crossover = linear_crossover)
print(myga@solution)
Run the code above in your browser using DataLab