Closed sumny closed 3 years ago
ObjectiveRFunDt with trafo and deps fails to evaluate a batch larger than 1 ;
ObjectiveRFunDt
1
library(bbotk) # bbotk_0.3.2.9000 library(paradox) # paradox_0.7.1 library(data.table) domain = ParamSet$new( list( ParamDbl$new("x1", lower = log(1), upper = log(10)), ParamFct$new("x2", levels = c("a", "b")), ParamInt$new("x3", lower = -5, upper = 5) ) ) domain$add_dep("x3", on = "x2", cond = CondEqual$new("b")) f = ObjectiveRFunDt$new( fun = function(xdt) { data.table(y = if (xdt[["x2"]] == "a") xdt[["x1"]] ^ 2 else sqrt(xdt[["x1"]]) - xdt[["x3"]]) }, domain = domain ) search_space = domain$clone(deep = TRUE) search_space$params$x1$lower = 1 search_space$params$x1$upper = 10 search_space$trafo = function(x, param_set) { x[["x1"]] = log(x[["x1"]]) x } ins = OptimInstanceSingleCrit$new( objective = f, search_space = search_space, terminator = trm("evals", n_evals = 100L) ) set.seed(1) opt("random_search", batch_size = 1L)$optimize(ins) # works
ins = OptimInstanceSingleCrit$new( objective = f, search_space = search_space, terminator = trm("evals", n_evals = 100L) ) set.seed(1) opt("random_search", batch_size = 100L)$optimize(ins) # fails
Error in rbindlist(xss) : Item 2 has 2 columns, inconsistent with item 1 which has 3 columns. To fill missing columns use fill=TRUE.
In your example search_space is not used. Still it fails successfully.
search_space
Thanks.. fixed it in the example :)
ObjectiveRFunDt
with trafo and deps fails to evaluate a batch larger than1
;