Skip to content
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

Objective function cares what you call its argument!? #441

Open
zkurtz opened this issue Sep 16, 2018 · 1 comment
Open

Objective function cares what you call its argument!? #441

zkurtz opened this issue Sep 16, 2018 · 1 comment

Comments

@zkurtz
Copy link

zkurtz commented Sep 16, 2018

Can anyone replicate this?

library(mlrMBO)

# Copied straight from `makeSingleObjectiveFunction` examples
fn.mixed = makeSingleObjectiveFunction(
  name = "Mixed 2D",
  fn = function(x) x$num1^2 + as.integer(as.character(x$disc1) == "a"),
  has.simple.signature = FALSE,
  par.set = makeParamSet(
    makeNumericParam("num1", lower = -5, upper = 5),
    makeDiscreteParam("disc1", values = c("a", "b"))
  ),
  global.opt.params = list(num1 = 0, disc1 = "b")
)

# Same as above, but replacing "x" with "z" in the objective
fn.mixed.z = makeSingleObjectiveFunction(
  name = "Mixed 2D",
  fn = function(z) z$num1^2 + as.integer(as.character(z$disc1) == "a"),
  has.simple.signature = FALSE,
  par.set = makeParamSet(
    makeNumericParam("num1", lower = -5, upper = 5),
    makeDiscreteParam("disc1", values = c("a", "b"))
  ),
  global.opt.params = list(num1 = 0, disc1 = "b")
)

# Works as expected
mlrMBO::mbo(fn.mixed,
    control = mlrMBO::makeMBOControl(),
    show.info = FALSE)

# Crashes:
mlrMBO::mbo(fn.mixed.z,
    control = mlrMBO::makeMBOControl(),
    show.info = FALSE)

The error:

Error in (function (z)  : 
  unused argument (x = list(0.753873288049363, "b"))

Is this desired behavior? If so, maybe the error could be made more descriptive?

Details:
OSX 10.13.6
R 3.5.1
mlrMBO version 1.1.2

@jakob-r
Copy link
Sponsor Member

jakob-r commented Sep 16, 2018

Let me ping @jakobbossek to see what is his opinion. How is it supposed to be in smoof?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants