-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The domain assertion does not take the parameter transformation into account #165
Comments
I would argue that the objective = ObjectiveRFun$new(
fun = fun,
domain = domain,
codomain = codomain,
properties = "deterministic",
check_values = FALSE
)
instance = OptimInstanceSingleCrit$new(
objective = objective,
terminator = terminator,
search_space = param_set,
check_values = TRUE # TRUE by default but just highlighting this
)
design = generate_design_lhs(instance$search_space, 10L)$data
instance$eval_batch(design)
Via this setup, the actual sampled instance$archive$data[, c("x1", "x2"), with = FALSE] # sampled x
instance$archive$data$x_domain # actually evaluated x based on the trafo
If your use case is something like that you want to frequently switch between I also believe that the separation of |
Thanks for the quick response! (There was a copy pasta error in my example but you got it anyway I think) nontheless here the corrected reprex. However, now that I understand the issue better I think I agree with you! Also the solution with setting library(paradox)
library(bbotk)
# define objective function
fun = function(xs) {
c(y = - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}
param_set = ps(
x1 = p_dbl(-10, 10, trafo = function(x) x^2),
x2 = p_dbl(-5, 5, trafo = function(x) x^2)
)
# set codomain
codomain = ps(
y = p_dbl(tags = "maximize")
)
# create Objective object
objective = ObjectiveRFun$new(
fun = fun,
domain = param_set,
codomain = codomain,
properties = "deterministic"
)
# Define termination criterion
terminator = trm("evals", n_evals = 100000)
# create optimization instance
instance = OptimInstanceSingleCrit$new(
objective = objective,
terminator = terminator
)
design = generate_design_lhs(param_set, 100)$data
instance$eval_batch(design)
#> INFO [21:31:44.689] [bbotk] Evaluating 100 configuration(s)
#> Error in FUN(X[[i]], ...): Assertion on 'X[[i]]' failed: x1: Element 1 is not <= 10. Created on 2022-01-05 by the reprex package (v2.0.1) |
When evaluating an initial design, generated from a parameter set that uses a
trafo
, the methodeval_batch
causes an error because the domain assertion does not take the parameter transformation into account. This can be circumvented by settingobjective$check_values = FALSE
but I assume the behaviour below is unintented? (This is also a problem for using data transformations in mlr3mbo @sumny )Created on 2022-01-05 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: