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

add OptimizerIrace #149

Merged
merged 4 commits into from
Jul 13, 2021
Merged

add OptimizerIrace #149

merged 4 commits into from
Jul 13, 2021

Conversation

be-marc
Copy link
Member

@be-marc be-marc commented Jul 7, 2021

What's new?

  • adds OptimizerIrace
  • instances are passed via the already implemented constants field / parameters
  • the user implements an objective function with xs and instances (see example)
  • all Objective subclasses are usable
  • race and step are recorded in archive
  • improved documentation

Example

library(data.table)

search_space = domain = ps(
  x1 = p_dbl(-5, 10),
  x2 = p_dbl(0, 15)
)

codomain = ps(y = p_dbl(tags = "minimize"))

# branin function with noise 
# the noise generates different instances of the branin function
# the noise values are passed via the `instances` parameter
fun = function(xdt, instances) {
  a = 1
  b = 5.1 / (4 * (pi ^ 2))
  c = 5 / pi
  r = 6
  s = 10
  t = 1 / (8 * pi)

  data.table(y = (
    a * ((xdt[["x2"]] - 
    b * (xdt[["x1"]] ^ 2L) + 
    c * xdt[["x1"]] - r) ^ 2) + 
    ((s * (1 - t)) * cos(xdt[["x1"]])) + 
    unlist(instances)))
}

objective = ObjectiveRFunDt$new(fun = fun, domain = domain,  codomain = codomain)

instance = OptimInstanceSingleCrit$new(
  objective = objective,
  search_space = search_space,
  terminator = trm("evals", n_evals = 1000))

# sample noise values to create instances of branin function
instances = rnorm(10, mean = 0, sd = 0.1)

# load optimizer irace and set branin instances
optimizer = opt("irace", instances = instances)

# modifies the instance by reference
optimizer$optimize(instance)

# best scoring configuration
instance$result

# all evaluations
as.data.table(instance$archive)

@be-marc be-marc mentioned this pull request Jul 7, 2021
@be-marc be-marc merged commit cae75ab into main Jul 13, 2021
@be-marc be-marc deleted the optimizer_irace branch July 13, 2021 11:45
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

Successfully merging this pull request may close these issues.

None yet

1 participant