search for: fitness_fn

Displaying 2 results from an estimated 2 matches for "fitness_fn".

2025 May 07
1
How to get the same result for GA optimization?
...thm* to maximize some function which use data. > > I use GA package in R for this ( > https://cran.r-project.org/web/packages/GA/index.html) > > Below is my code > > library(GA) > set.seed(1) > Dat = data.frame(rnorm(1000), matrix(rnorm(1000 * 30), nc = 30)) > > Fitness_Fn = function(x) { > return(cor(Dat[, 1], as.matrix(Dat[, -1]) %*% matrix(x, nc = 1))[1,1]) > } > > ga(type = 'real-valued', fitness = Fitness_Fn, seed = 1, lower = > rep(0, 30), upper = rep(1, 30), elitism = 10, popSize = 200, maxiter = > 1, pcrossover = 0.9, pmutation...
2025 May 07
1
How to get the same result for GA optimization?
I am using *Genetic Algorithm* to maximize some function which use data. I use GA package in R for this ( https://cran.r-project.org/web/packages/GA/index.html) Below is my code library(GA) set.seed(1) Dat = data.frame(rnorm(1000), matrix(rnorm(1000 * 30), nc = 30)) Fitness_Fn = function(x) { return(cor(Dat[, 1], as.matrix(Dat[, -1]) %*% matrix(x, nc = 1))[1,1]) } ga(type = 'real-valued', fitness = Fitness_Fn, seed = 1, lower = rep(0, 30), upper = rep(1, 30), elitism = 10, popSize = 200, maxiter = 1, pcrossover = 0.9, pmutation = 0.9, run = 1) However now I...