Skip to content

Commit

Permalink
more paradox compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Jan 14, 2024
1 parent 16a9145 commit 7906f47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion R/AcqFunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
16 changes: 13 additions & 3 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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'"
}

Expand Down

0 comments on commit 7906f47

Please sign in to comment.