hgaoptim | R Documentation |
This function allows GA to hybridize with methods in the optim general-purpose optimization function for n-variable problems in R's basic stats package (R Core Team, 2021).
hgaoptim(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
R Core Team. (2021). R: A language and environmental for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
hgaoptimx
,
hgaroi
hgaparams = list(method="Nelder-Mead", poptim=0.05, pressel=0.5, control = list(fnscale=1, maxit=100)) n = 5 # Size of population m = 2 # Number of variables lb = c(-5.12, -5.12) # Lower bounds for sample data ub = c(5.12, 5.12) # Upper bounds for sample data 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 newpop = hgaoptim(genpop, fitfunc, hgaparams, hgaftype="r", hgans=3) newpop
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.