Skip to content

Commit

Permalink
new paradox
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Jan 14, 2024
1 parent 2a747bd commit a5f4947
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions R/helper.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
task_to_domain = function(task) {
ParamSet$new(map(task$feature_names, function(s) ParamLgl$new(id = s)))
params = rep(list(p_lgl()), length(task$feature_names))
names(params) = task$feature_names
do.call(ps, params)
}

measures_to_codomain = function(measures) {
Codomain$new(map(as_measures(measures), function(s) {
ParamDbl$new(id = s$id, tags = ifelse(s$minimize, "minimize", "maximize"))
}))
measures = as_measures(measures)
domains = map(measures, function(s) {
if ("set_id" %in% names(ps())) {
# old paradox
get("ParamDbl")$new(id = s$id, tags = ifelse(s$minimize, "minimize", "maximize"))
} else {
p_dbl(tags = ifelse(s$minimize, "minimize", "maximize"))
}
})
names(domains) = ids(measures)
Codomain$new(domains)
}

0 comments on commit a5f4947

Please sign in to comment.