r - GA-Algorithm returning "non-numeric argument to binary operator" when parallel computing -


for reason ga algorithm returns "non-numeric argument binary operator" when use option parallel = true. optimization algorithm seems works without option or when setting parallel = false. have installed neccessary packages , date. r version work 3.3.2 on 64bit machine.

i calling function within function try optimize. code below simple example of general structure of problem returns same error code.

fun_in <- function(a, b, c, d, e) {   return(a + b + c + d + e) }  fun_out <- function(a, b, c, d, e, f, g) {  x <- f +g  y <- fun_in(a = a, b = b, c = c, d = d, e = e)  z <- x + y  return(z) }  library('ga')  <- 1 b <- 1 c <- 1 d <- 1 e <- 1 f <- 1 g <- 1  fitness <- function(x) -fun_out(a, b, c, d, e, f, g) lower_bound <- c(1,1,1,1,1,1,1) upper_bound <- c(5,5,5,5,5,5,5) coef_names <- c('a', 'b', 'b', 'd', 'e', 'f', 'g')  ga <- ga(type = "real-valued",           fitness = fitness,           min = lower_bound,           max = upper_bound,          popsize = 100,          maxiter = 1000,          pmutation = 0.8,          pcrossover = 0.8,          maxfitness = 1e-5,          names = coef_names,          parallel = true ) 

thank help.

simple fix argument name in fitness()

 --- fitness <- function(x) -fun_out(a, b, c, d, e, f, g)  +++ fitness <- function(x) -fun_out(x[1], x[2], x[3], x[4], x[5], x[6], x[7]) 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -