# NOT RUN {
# Required package forega
require("forega")
set.seed(12345)
# This function has the global minimum at x_1 = pi and x_2 = exp(1)
f <- function (x){
return( (x[1]-pi)^2 + (x[2]-2.71828)^2 )
}
# Performing a floating-point genetic algorithm search with forecast probability of 0.10
res <- forecasting_ga(evalFunc=f, chsize=2, minv=rep(-10.0,2),
maxv=rep(10.0,2), crossprob=0.80, mutationprob=0.01,
popsize=100, maxiter=1000, MinimumForecastLength=20,
ForecastFunction=ForecastArima, elitism=2, forecastprob=0.01)
# Show the first chromosome of the returned population matrix
print(res[1,])
# }
Run the code above in your browser using DataLab