Skip to content

Commit

Permalink
Merge branch 'master' of github.com:berndbischl/mlrMBO
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg committed Mar 9, 2017
2 parents fc4fe3f + 16e5137 commit fb19114
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 39 deletions.
4 changes: 2 additions & 2 deletions R/exampleRun.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ exampleRun = function(fun, design = NULL, learner = NULL, control,
messagef("Performing MBO on function.")
if (is.null(design))
messagef("Initial design: %i. Sequential iterations: %i.", control$init.design.points, control$iters)
messagef("Learner: %s. Settings:\n%s", learner$id, mlr:::getHyperParsString(learner, show.missing.values = FALSE))
messagef("Learner: %s. Settings:\n%s", learner$id, getHyperParsString2(learner, show.missing.values = FALSE))
}

# run optimizer now
Expand Down Expand Up @@ -142,7 +142,7 @@ print.MBOExampleRun = function(x, ...) {
catf("True points per dim. : %s", collapse(x$points.per.dim))
print(x$control)
catf("Learner : %s", x$learner$id)
catf("Learner settings:\n%s", mlr:::getHyperParsString(x$learner, show.missing.values = FALSE))
catf("Learner settings:\n%s", getHyperParsString2(x$learner, show.missing.values = FALSE))
mr = x$mbo.res
op = mr$opt.path
catf("Recommended parameters:")
Expand Down
4 changes: 2 additions & 2 deletions R/exampleRunMultiObj.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ exampleRunMultiObj= function(fun, design = NULL, learner, control, points.per.di

showInfo(show.info, "Performing MBO on function.")
showInfo(show.info, "Initial design: %i. Sequential iterations: %i.", control$init.design.points, control$iters)
showInfo(show.info, "Learner: %s. Settings:\n%s", learner$id, mlr:::getHyperParsString(learner, show.missing.values = FALSE))
showInfo(show.info, "Learner: %s. Settings:\n%s", learner$id, getHyperParsString2(learner, show.missing.values = FALSE))

# run optimizer now
res = mbo(fun, design, learner = learner, control = control, show.info = show.info)
Expand Down Expand Up @@ -151,7 +151,7 @@ print.MBOExampleRunMultiObj = function(x, ...) {
catf("Parameter types : %s", collapse(x$par.types))
print(x$control)
catf("Learner : %s", x$learner$id)
catf("Learner settings:\n%s", mlr:::getHyperParsString(x$learner, show.missing.values = FALSE))
catf("Learner settings:\n%s", getHyperParsString2(x$learner, show.missing.values = FALSE))
catf("Hypervolume : %.4e", x$mbo.hypervolume)
catf("NSGA2 Hypervolume (6000 FEs) : %.4e", x$nsga2.hypervolume)
}
10 changes: 9 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ measureTime = function(expr, ee = parent.frame()) {
# FIXME: remove as soon as this is in ParamHelper
isSimpleNumeric = function(par) {
isNumeric(par, include.int = TRUE) && !hasRequires(par)
}
}

getHyperParsString2 = function(learner, show.missing.values = TRUE) {
hps = getHyperPars(learner)
ns = names(hps)
pars = getParamSet(learner)$pars[ns]
s = mapply(paramValueToString, pars, hps, MoreArgs = list(show.missing.values = show.missing.values))
paste(ns, s, sep = "=", collapse = ",")
}
4 changes: 2 additions & 2 deletions inst/examples/ex_1d_noisy_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ ctrl = makeMBOControl(
)
ctrl = setMBOControlTermination(ctrl, iters = 5L)

ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(), opt = "focussearch",
opt.focussearch.points = 500L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(),
opt = "focussearch", opt.focussearch.points = 500L)

lrn = makeMBOLearner(ctrl, obj.fun)

Expand Down
4 changes: 2 additions & 2 deletions inst/examples/ex_1d_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ obj.fun = makeSingleObjectiveFunction(

ctrl = makeMBOControl(propose.points = 1)
ctrl = setMBOControlTermination(ctrl, iters = 10L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(), opt = "focussearch",
opt.focussearch.points = 500L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(),
opt = "focussearch", opt.focussearch.points = 500L)

lrn = makeMBOLearner(ctrl, obj.fun)

Expand Down
4 changes: 2 additions & 2 deletions inst/examples/ex_2d_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ obj.fun = makeBraninFunction()

ctrl = makeMBOControl(propose.points = 1L)
ctrl = setMBOControlTermination(ctrl, iters = 10L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(), opt = "focussearch",
opt.focussearch.points = 2000L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(),
opt = "focussearch", opt.focussearch.points = 2000L)

lrn = makeMBOLearner(ctrl, obj.fun)
design = generateDesign(10L, getParamSet(obj.fun), fun = lhs::maximinLHS)
Expand Down
4 changes: 2 additions & 2 deletions inst/examples/ex_mixed.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ obj.fun = makeSingleObjectiveFunction(

ctrl = makeMBOControl(propose.points = 1L)
ctrl = setMBOControlTermination(ctrl, iters = 10L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(), opt = "focussearch",
opt.focussearch.points = 500L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritEI(),
opt = "focussearch", opt.focussearch.points = 500L)

lrn = makeMBOLearner(ctrl, obj.fun)

Expand Down
16 changes: 8 additions & 8 deletions man/mlrMBO_examples.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions tests/run-examples.R

This file was deleted.

6 changes: 3 additions & 3 deletions vignettes/parallelization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ctrl = setMBOControlInfill(ctrl, crit = crit.cb)
ctrl = setMBOControlMultiPoint(ctrl, method = "cb")
ctrl = setMBOControlTermination(ctrl, iters = 5)
design = generateDesign(n = 5*8, par.set = getParamSet(obj.fun))
# library(parallelMap)
library(parallelMap)
# parallelStartMulticore(cpus = 2, show.info = FALSE)
res = mbo(obj.fun, control = ctrl, design = design, show.info = FALSE)
# parallelStop()
Expand Down Expand Up @@ -178,7 +178,7 @@ autoplot(obj.fun.single, render.levels = TRUE) + general.scale
Now let's create an objective function that uses parallelization internally by using the function `parallelMap()` of the equally named package.

```{r custom_noisy_parallel}
# parallelRegisterLevels(levels = "objective")
parallelRegisterLevels(levels = "objective")
obj.fun.parallel = makeSingleObjectiveFunction(
name = "noisy_example",
fn = function(x) {
Expand All @@ -204,7 +204,7 @@ library(mlr)
ctrl = makeMBOControl(final.method = "best.predicted")
ctrl = setMBOControlTermination(ctrl, iters = 5L)
ctrl = setMBOControlInfill(ctrl, crit = crit.aei)
# parallelStartMulticore(cpus = 4L, show.info = TRUE, level = "custom.objective")
# parallelStartMulticore(cpus = 2L, show.info = TRUE, level = "custom.objective")
res.parallel = mbo(obj.fun.parallel, control = ctrl, show.info = FALSE)
# parallelStop()
res.parallel
Expand Down

0 comments on commit fb19114

Please sign in to comment.