| cross | R Documentation |
It is a wrapper function that calls crossover operators from a single function.
cross(crossfunc, matpool, cxon, cxpc, gatype, ...)
crossfunc |
The name of the crossover operator |
matpool |
A matrix. Mating pool containing selected individuals. |
cxon |
Number of offspring to be generated as a result of crossover |
cxpc |
Crossover Ratio. Default value is 0.95 |
gatype |
Indicates the GA type. "gga" is assigned for generational refresh, and "ssga" for steady-state refresh. |
... |
Further arguments passed to or from other methods. |
A matrix containing the generated offsprings.
Zeynel Cebeci & Erkut Tekeli
Cebeci, Z. (2021). R ile Genetik Algoritmalar ve Optimizasyon Uygulamalari, 535 p. Ankara:Nobel Akademik Yayincilik.
px1,
kpx,
sc,
rsc,
hux,
ux,
ux2,
mx,
rrc,
disc,
atc,
cpc,
eclc,
raoc,
dc,
ax,
hc,
sax,
wax,
lax,
bx,
ebx,
blxa,
blxab,
lapx,
elx,
geomx,
spherex,
pmx,
mpmx,
upmx,
ox,
ox2,
mpx,
erx,
pbx,
pbx2,
cx,
icx,
smc
genpop = initbin(12,8) #Initial population m = ncol(genpop)-2 #Number of Gene sumx = function(x, ...) (sum(x)) #Fitness Function fitvals = evaluate(fitfunc=sumx, genpop[,1:m]) #Fitness Values genpop[,"fitval"] = fitvals selidx = select(selfunc=selrws, fitvals) #Selection of Parents matpool = genpop[selidx,] #Mating Pool offsprings = cross(crossfunc=px1, matpool=matpool, #Crossing cxon=2, cxpc=0.8, gatype="gga") offsprings offsprings = cross(crossfunc=kpx, matpool=matpool, cxon=2, cxpc=0.8, gatype="ssga", cxps=0.5, cxk=2) offsprings
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.