mlr-org / bbotk

Black-box optimization framework for R.
https://bbotk.mlr-org.com
GNU Lesser General Public License v3.0
21 stars 9 forks source link

deep cloning of archive #153

Closed sumny closed 3 years ago

sumny commented 3 years ago

Seems like deep cloning of archives does not fully work:

library(bbotk)
library(paradox)
library(data.table)

search_space = domain = ps(x = p_dbl(lower = -1, upper = 1))
codomain = ps(y = p_dbl(tags = "minimize"))
objective_function = function(xs) {
  list(y = as.numeric(xs)^2)
}
objective = ObjectiveRFun$new(
 fun = objective_function,
 domain = domain,
 codomain = codomain)
instance = OptimInstanceSingleCrit$new(
 objective = objective,
 search_space = search_space,
 terminator = trm("evals", n_evals = 10)
)
optimizer = opt("random_search")
optimizer$optimize(instance)

archive1 = instance$archive
archive2 = instance$archive$clone(deep = TRUE)
address(archive1) != address(archive2)
address(archive1$data) != address(archive2$data)
archive1$data[, x := 0]
archive1
archive2
be-marc commented 3 years ago

Thanks! Fixed by 3aa2e29ba4efbc5bd2c800b872b3fc45c8f5feae