|
| 1 | +--- |
| 2 | +title: "Adaptive Infill Criteria" |
| 3 | +vignette: > |
| 4 | + %\VignetteIndexEntry{Infill criteria} |
| 5 | + %\VignetteEngine{knitr::rmarkdown} |
| 6 | + %\VignetteEncoding{UTF-8} |
| 7 | +--- |
| 8 | + |
| 9 | +```{r setup, include=FALSE} |
| 10 | +library(mlrMBO) |
| 11 | +library(rgenoud) |
| 12 | +set.seed(1) |
| 13 | +knitr::opts_chunk$set(cache = TRUE, collapse = FALSE) |
| 14 | +knitr::knit_hooks$set(document = function(x){ |
| 15 | + gsub("```\n*```r*\n*", "", x) |
| 16 | +}) |
| 17 | +``` |
| 18 | + |
| 19 | +## Purpose |
| 20 | + |
| 21 | +This vignette gives a short example of the usage of the adaptive infill criteria in `mlrMBO`. |
| 22 | + |
| 23 | +## Adaptive Infill Criteria |
| 24 | + |
| 25 | +An adaptive infill criterion can change its behaviour based on the progress of the optimization. |
| 26 | +The progress has to be supplied by the termination criterion. |
| 27 | +All integrated termination criteria support this feature. |
| 28 | + |
| 29 | +## Exemplary Usage of the Adaptive CB |
| 30 | + |
| 31 | +To specify which infill criterion should be used, the `MBOControl` object has to be extended by calling `setMBOControlInfill()`. |
| 32 | +In addition to the criterion you can also set the parameters of the infill criterion optimization. |
| 33 | +The criterion itself is created with `makeMBOInfillCrit*()`. |
| 34 | +The most common infill criteria are predefined like `crit.ei` and `crit.cb2`. See `?MBOInfillCrit` for details. |
| 35 | + |
| 36 | +```{r control} |
| 37 | +ctrl = makeMBOControl() |
| 38 | +ctrl = setMBOControlTermination(ctrl, iters = 10L) |
| 39 | +ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritAdaCB(cb.lambda.start = 4, cb.lambda.end = 0.1)) |
| 40 | +``` |
| 41 | + |
| 42 | +This will lead to an CB infill criterion ($CB(x) = \hat{\mu}(x) \pm \lambda * \hat{s}(x)$) that will focus on uncertain regions in the beginning (`cb.lambda.start = 4`) and towards the end will have a stronger focus on areas close to the global minimum of the surrogate (`cb.lambda.end = 0.1`). |
| 43 | + |
| 44 | +```{r fun} |
| 45 | +test.fun = makeSingleObjectiveFunction( |
| 46 | + fn = function(x) x[1]^2 * sin(3 * x[2]), |
| 47 | + par.set = makeNumericParamSet(lower = 0, upper = 1, len = 2L) |
| 48 | +) |
| 49 | +``` |
| 50 | + |
| 51 | +You can now start the optimization like usual: |
| 52 | + |
| 53 | +```{r example, results = "hide", message = FALSE, warning = FALSE} |
| 54 | +res = mbo(test.fun, control = ctrl) |
| 55 | +``` |
| 56 | + |
| 57 | +If we look at the OptPath we can see the different progress values and the resulting different values of lambda. |
| 58 | + |
| 59 | +```{r res} |
| 60 | +tail(as.data.frame(res$opt.path)) |
| 61 | +``` |
0 commit comments