Extends an MBO control object with infill criteria and infill optimizer options.

setMBOControlTermination(
control,
iters = NULL,
time.budget = NULL,
exec.time.budget = NULL,
target.fun.value = NULL,
max.evals = NULL,
more.termination.conds = list(),
use.for.adaptive.infill = NULL
)

Arguments

control [MBOControl] Control object for mbo. [integer(1)] Number of sequential optimization steps. [numeric(1) | NULL] Running time budget in seconds. Note that the actual mbo run can take more time since the condition is checked after each iteration. The default NULL means: There is no time budget. [numeric(1) | NULL] Execution time (time spent executing the function passed to mbo) budget in seconds. Note that the actual mbo run can take more time since the condition is checked after each iteration. The default NULL means: There is no execution time budget. [numeric(1)] | NULL] Termination criterion for single-objective optimization: Stop if a function evaluation is better than this given target.value. The default NULL means: The function value won't be taken into account for termination. [integer(1) | NULL] Maximal number of function evaluations. The default NULL means: The total number of evaluations won't be taken into account for termination. [list] Optional list of termination conditions. Each condition needs to be a function of a single argument opt.state of type OptState and should return a list with the following elements: term [logical(1)]Logical value indicating whether the termination condition is met. message [character(1)]Termination message. At the moment we just allow term.custom. [character(1)|NULL] Which termination criterion should determine the progress that is used for adaptive infill criteria like [makeMBOInfillCritAdaCB]. The default is NULL which means, that the first supplied argument is taken, following the order of the function signature. Other values can be "iters", "time.budget", etc. If you want to to use it together with a criterion you supplied in more.termination.conds, more.termination.conds has to be a named list and the function further has to return a list element progress with values between 0 and 1.

Value

[MBOControl].

See also

Other MBOControl: makeMBOControl(), setMBOControlInfill(), setMBOControlMultiObj(), setMBOControlMultiPoint()

Examples

fn = smoof::makeSphereFunction(1L)
ctrl = makeMBOControl()

# custom termination condition (stop if target function value reached)
# We neglect the optimization direction (min/max) in this example.
yTargetValueTerminator = function(y.val) {
force(y.val)
function(opt.state) {
opt.path = opt.state$opt.path current.best = getOptPathEl(opt.path, getOptPathBestIndex((opt.path)))$y
term = (current.best <= y.val)
message = if (!term) NA_character_ else sprintf("Target function value %f reached.", y.val)
return(list(term = term, message = message))
}
}

# assign custom termination condition
ctrl = setMBOControlTermination(ctrl, more.termination.conds = list(yTargetValueTerminator(0.05)))
res = mbo(fn, control = ctrl)
#> Computing y column(s) for design. Not provided.#> [mbo] 0: x=-3.7 : y = 13.7 : 0.0 secs : initdesign#> [mbo] 0: x=2.08 : y = 4.33 : 0.0 secs : initdesign#> [mbo] 0: x=-2.49 : y = 6.22 : 0.0 secs : initdesign#> [mbo] 0: x=2.63 : y = 6.91 : 0.0 secs : initdesign#> [mbo] 1: x=1.82 : y = 3.3 : 0.0 secs : infill_cb#> [mbo] 2: x=0.955 : y = 0.912 : 0.0 secs : infill_cb#> [mbo] 3: x=-0.385 : y = 0.148 : 0.0 secs : infill_cb#> [mbo] 4: x=0.144 : y = 0.0206 : 0.0 secs : infill_cbprint(res)
#> Recommended parameters:
#> x=0.144
#> Objective: y = 0.021
#>
#> Optimization path
#> 4 + 4 entries in total, displaying last 10 (or less):
#>            x           y dob eol error.message exec.time         cb error.model
#> 1 -3.6953594 13.65568112   0  NA          <NA>     0.000         NA        <NA>
#> 2  2.0814326  4.33236157   0  NA          <NA>     0.001         NA        <NA>
#> 3 -2.4934847  6.21746596   0  NA          <NA>     0.000         NA        <NA>
#> 4  2.6296002  6.91479717   0  NA          <NA>     0.000         NA        <NA>
#> 5  1.8167531  3.30059200   1  NA          <NA>     0.000  2.9284423        <NA>
#> 6  0.9548314  0.91170306   2  NA          <NA>     0.000  1.1170946        <NA>
#> 7 -0.3845713  0.14789507   3  NA          <NA>     0.001 -1.7860681        <NA>
#> 8  0.1436811  0.02064425   4  NA          <NA>     0.000 -0.4403414        <NA>
#>   train.time  prop.type propose.time        se       mean lambda
#> 1         NA initdesign           NA        NA         NA     NA
#> 2         NA initdesign           NA        NA         NA     NA
#> 3         NA initdesign           NA        NA         NA     NA
#> 4         NA initdesign           NA        NA         NA     NA
#> 5      0.040  infill_cb        0.217 2.4141499 5.34259219      1
#> 6      0.042  infill_cb        0.216 2.9398519 4.05694646      1
#> 7      0.072  infill_cb        0.223 2.0162487 0.23018064      1
#> 8      0.053  infill_cb        0.226 0.4823983 0.04205684      1