From 7906f47f44594120814f096ad51a0df9db22cfd1 Mon Sep 17 00:00:00 2001 From: mb706 Date: Sun, 14 Jan 2024 16:45:38 +0100 Subject: [PATCH] more paradox compatibility --- R/AcqFunction.R | 3 ++- R/helper.R | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/R/AcqFunction.R b/R/AcqFunction.R index d7045f91..03c62ba0 100644 --- a/R/AcqFunction.R +++ b/R/AcqFunction.R @@ -180,7 +180,8 @@ AcqFunction = R6Class("AcqFunction", codomain = generate_acq_codomain(rhs, id = self$id, direction = self$direction) self$surrogate_max_to_min = surrogate_mult_max_to_min(rhs) domain = generate_acq_domain(rhs) - self$codomain = Codomain$new(codomain$params) # lazy initialization requires this + # lazy initialization requires this: + self$codomain = Codomain$new(get0("domains", codomain, ifnotfound = codomain$params)) # get0 for old paradox self$domain = domain } }, diff --git a/R/helper.R b/R/helper.R index b80b3f84..7dc307cd 100644 --- a/R/helper.R +++ b/R/helper.R @@ -16,8 +16,18 @@ generate_acq_codomain = function(surrogate, id, direction = "same") { generate_acq_domain = function(surrogate) { assert_r6(surrogate$archive, classes = "Archive") - domain = surrogate$archive$search_space$clone(deep = TRUE)$subset(surrogate$cols_x) - domain$trafo = NULL + if ("set_id" %in% names(domain)) { + # old paradox + domain = surrogate$archive$search_space$clone(deep = TRUE)$subset(surrogate$cols_x) + domain$trafo = NULL + } else { + # get "domain" objects, set their .trafo-entry to NULL individually + dms = lapply(surrogate$archive$search_space$domains[surrogate$cols_x], function(x) { + x$.trafo[1] = list(NULL) + x + }) + domain = do.call(ps, dms) + } domain } @@ -127,7 +137,7 @@ check_learner_surrogate = function(learner) { return(TRUE) } } - + "Must inherit from class 'Learner' or be a list of elements inheriting from class 'Learner'" }