# NOT RUN {
n = 5 # Size of population
m = 2 # Number of variable
lb = c(-5.12, -5.12) # Lower bounds of sample data
ub = c(5.12, 5.12) # Upper bounds of sample data
hgaparams = list(method="L-BFGS-B",
poptim=0.05, pressel=0.5,
lower=lb, upper=ub,
control=list(maxit=100))
genpop = initval(n, m, lb=lb, ub=ub) # Sample population
fitfunc = function(x, ...) 2*(x[1]-1)^2 + 5*(x[2]-2)^2 + 10
fitvals = evaluate(fitfunc, genpop[,1:m])
genpop[,"fitval"]=fitvals
genpop
genpop = hgaroi(genpop, fitfunc, hgaparams,
hgaftype="r", hgans=3)
genpop
# }
Run the code above in your browser using DataLab