## Purpose

This vignette gives a short example of the usage of the adaptive infill criteria in mlrMBO.

An adaptive infill criterion can change its behaviour based on the progress of the optimization. The progress has to be supplied by the termination criterion. All integrated termination criteria support this feature.

## Exemplary Usage of the Adaptive CB

To specify which infill criterion should be used, the MBOControl object has to be extended by calling setMBOControlInfill(). In addition to the criterion you can also set the parameters of the infill criterion optimization. The criterion itself is created with makeMBOInfillCrit*(). The most common infill criteria are predefined like crit.ei and crit.cb2. See ?MBOInfillCrit for details.

ctrl = makeMBOControl()
ctrl = setMBOControlTermination(ctrl, iters = 10L)
ctrl = setMBOControlInfill(ctrl, crit = makeMBOInfillCritAdaCB(cb.lambda.start = 4, cb.lambda.end = 0.1))

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).

test.fun = makeSingleObjectiveFunction(
fn = function(x) x[1]^2 * sin(3 * x[2]),
par.set = makeNumericParamSet(lower = 0, upper = 1, len = 2L)
)

You can now start the optimization like usual:

res = mbo(test.fun, control = ctrl)

If we look at the OptPath we can see the different progress values and the resulting different values of lambda.

tail(as.data.frame(res\$opt.path))
##              x1           x2            y dob eol error.message exec.time
## 13 1.709222e-01 3.315767e-05 2.906045e-06   5  NA          <NA>     0.000
## 14 1.295025e-01 8.443279e-01 9.588378e-03   6  NA          <NA>     0.000
## 15 9.034855e-07 3.963116e-01 7.574909e-13   7  NA          <NA>     0.000
## 16 1.780031e-05 1.426885e-01 1.315285e-10   8  NA          <NA>     0.000
## 17 1.456652e-05 8.941830e-01 9.401662e-11   9  NA          <NA>     0.000
## 18 7.865404e-02 5.394556e-06 1.001196e-07  10  NA          <NA>     0.001
##          adacb error.model train.time    prop.type propose.time         se
## 13 -0.07941555        <NA>      0.072 infill_adacb        0.351 0.05191568
## 14 -0.05742526        <NA>      0.096 infill_adacb        0.342 0.03896670
## 15 -0.03561018        <NA>      0.075 infill_adacb        0.395 0.05122843
## 16 -0.02551347        <NA>      0.062 infill_adacb        0.308 0.02848987
## 17 -0.01516411        <NA>      0.084 infill_adacb        0.335 0.01835809
## 18 -0.01357802        <NA>      0.075 infill_adacb        0.342 0.02391981
##            mean lambda
## 13 -0.014520950   1.25
## 14 -0.014561893   1.10
## 15  0.013056827   0.95
## 16 -0.002721574   0.80
## 17 -0.003231352   0.65
## 18 -0.001618116   0.50