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

Error message when cols are missing in eval_batch should be more informative #132

Closed mb706 closed 3 years ago

mb706 commented 3 years ago
objective <- ObjectiveRFun$new(
  fun = function(xs) list(obj = xs$x + 10),
  domain = ps(x = p_lgl(), y = p_dbl(-2, 4)),
  codomain = ps(obj = p_dbl(tags = "maximize"))
)
oi <- OptimInstanceSingleCrit$new(objective, terminator = trm("none"))

oi$eval_batch(data.table(x = FALSE))

gives error

Error in `[.data.table`(xdt, , search_space$ids(), with = FALSE) : 
  column(s) not found: y

This error message looks like an internal bug and not like the user did something wrong. This is especially confusing when the search space has dependencies and y is not feasible (but the call still needs the y column to contain an NA). It would be nicer if the error message were something like error in eval_batch: colnames(xdt) must include {'x', 'y'} etc.; I believe assert_names does that.

be-marc commented 3 years ago

Closed by d08af38827373b98352a64943f54b443a430a2c3.