hgaoptimx | R Documentation |
This function allows GA to hybridize with methods in the optimx package (Nash & Varadhan, 2011; Nash, 2014).
hgaoptimx(genpop, fitfunc, hgaparams, hgaftype, hgans, ...)
genpop |
A matrix of individuals in the current population and their fitness values. |
fitfunc |
Fitness function |
hgaparams |
A list of parameters defined for use by the Optim function. |
hgaftype |
Types of fitness to transfer.
|
hgans |
Number of individuals to be transferred to the Optim. |
... |
Further arguments passed to or from other methods. |
A matrix containing the updated population.
Zeynel Cebeci & Erkut Tekeli
Nash, J.C. and Varadhan, R. (2011). Unified optimization algorithms to aid software system users: optimx for R. Journal of Statistical Software, 43(9), 1-14. URL http://www.jstatsoft.org/v43/i09. Nash, J.C. (2014). On best practice optimization methods in R. Journal of Statistical Software, 60(2), 1-14. URL http://www.jstatsoft.org/v60/i02.
hgaoptim
,
hgaroi
n = 5 # Size of population m = 2 # Number of Variables 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(maximize=FALSE, 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 = hgaoptimx(genpop, fitfunc, hgaparams, hgaftype="r", hgans=3) genpop
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.