OptimizerIrace class that implements iterated racing. Calls irace::irace() from package irace.

Source

Lopez-Ibanez M, Dubois-Lacoste J, Caceres LP, Birattari M, Stuetzle T (2016). “The irace package: Iterated racing for automatic algorithm configuration.” Operations Research Perspectives, 3, 43--58. doi: 10.1016/j.orp.2016.09.002 .

Parameters

instances

list()
A list of instances where the configurations executed on.

targetRunnerParallel

function()
A function that executes the objective function with a specific parameter configuration and instance. A default function is provided, see section "Target Runner and Instances".

For the meaning of all other parameters, see irace::defaultScenario(). Note that we have removed all control parameters which refer to the termination of the algorithm. Use TerminatorEvals instead. Other terminators do not work with OptimizerIrace.

Target Runner and Instances

The irace package uses a targetRunner script or R function to evaluate a configuration on a particular instance. Usually it is not necessary to specify a targetRunner function when using OptimizerIrace. A default function is used that forwards several configurations and instances to the user defined objective function. As usually, the user defined function has a xs, xss or xdt parameter depending on the used Objective class. For irace, the function needs an additional instances parameter.

fun = function(xs, instances) {
 # function to evaluate configuration in `xs` on instance `instances`
}

Archive

The Archive holds the following additional columns:

  • "race" (integer(1))
    Race iteration.

  • "step" (integer(1))
    Step number of race.

  • "instance" (integer(1))
    Identifies instances across races and steps.

  • "configuration" (integer(1))
    Identifies configurations across races and steps.

Result

The optimization result (instance$result) is the best performing elite of the final race. The reported performance is the average performance estimated on all used instances.

Dictionary

This Optimizer can be instantiated via the dictionary mlr_optimizers or with the associated sugar function opt():

mlr_optimizers$get("irace")
opt("irace")

Progress Bars

$optimize() supports progress bars via the package progressr combined with a Terminator. Simply wrap the function in progressr::with_progress() to enable them. We recommend to use package progress as backend; enable with progressr::handlers("progress").

Super class

bbotk::Optimizer -> OptimizerIrace

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage

OptimizerIrace$new()


Method clone()

The objects of this class are cloneable with this method.

Usage

OptimizerIrace$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

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)) # 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)
#> # 2021-09-17 04:11:54 UTC: Initialization #> # Elitist race #> # Elitist new instances: 1 #> # Elitist limit: 2 #> # nbIterations: 3 #> # minNbSurvival: 3 #> # nbParameters: 2 #> # seed: 1861043051 #> # confidence level: 0.95 #> # budget: 1000 #> # mu: 5 #> # deterministic: FALSE #> #> # 2021-09-17 04:11:54 UTC: Iteration 1 of 3 #> # experimentsUsedSoFar: 0 #> # remainingBudget: 1000 #> # currentBudget: 333 #> # nbConfigurations: 55 #> # Markers: #> x No test is performed. #> c Configurations are discarded only due to capping. #> - The test is performed and some configurations are discarded. #> = The test is performed but no configuration is discarded. #> ! The test is performed and configurations could be discarded but elite configurations are preserved. #> . All alive configurations are elite and nothing is discarded #> #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> |x| 1| 55| 25| -9.417354508| 55|00:00:00| NA| NA| NA| #> |x| 2| 55| 25| -9.374418161| 110|00:00:00|+1.00|1.00|0.0000| #> |x| 3| 55| 25| -9.341785995| 165|00:00:00|+1.00|1.00|0.0000| #> |x| 4| 55| 25| -9.342761030| 220|00:00:00|+1.00|1.00|0.0000| #> |-| 5| 1| 25| -9.344356526| 275|00:00:00| NA| NA| NA| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> Best-so-far configuration: 25 mean value: -9.344356526 #> Description of the best-so-far configuration: #> .ID. x1 x2 .PARENT. #> 25 25 2.9398 2.4074 NA #> #> # 2021-09-17 04:11:55 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks): #> x1 x2 #> 25 2.9398 2.4074 #> # 2021-09-17 04:11:55 UTC: Iteration 2 of 3 #> # experimentsUsedSoFar: 275 #> # remainingBudget: 725 #> # currentBudget: 362 #> # nbConfigurations: 52 #> # Markers: #> x No test is performed. #> c Configurations are discarded only due to capping. #> - The test is performed and some configurations are discarded. #> = The test is performed but no configuration is discarded. #> ! The test is performed and configurations could be discarded but elite configurations are preserved. #> . All alive configurations are elite and nothing is discarded #> #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> |x| 6| 52| 25| -9.389142769| 52|00:00:00| NA| NA| NA| #> |x| 5| 52| 25| -9.369940638| 103|00:00:00|+1.00|1.00|0.0000| #> |x| 1| 52| 25| -9.385745261| 154|00:00:00|+1.00|1.00|0.0000| #> |x| 2| 52| 25| -9.372179399| 205|00:00:00|+1.00|1.00|0.0000| #> |-| 3| 1| 25| -9.353047852| 256|00:00:00| NA| NA| NA| #> |.| 4| 1| 25| -9.351820900| 256|00:00:00| NA| NA| NA| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> Best-so-far configuration: 25 mean value: -9.351820900 #> Description of the best-so-far configuration: #> .ID. x1 x2 .PARENT. #> 25 25 2.9398 2.4074 NA #> #> # 2021-09-17 04:11:55 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks): #> x1 x2 #> 25 2.9398 2.4074 #> # 2021-09-17 04:11:55 UTC: Iteration 3 of 3 #> # experimentsUsedSoFar: 531 #> # remainingBudget: 469 #> # currentBudget: 469 #> # nbConfigurations: 59 #> # Markers: #> x No test is performed. #> c Configurations are discarded only due to capping. #> - The test is performed and some configurations are discarded. #> = The test is performed but no configuration is discarded. #> ! The test is performed and configurations could be discarded but elite configurations are preserved. #> . All alive configurations are elite and nothing is discarded #> #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> |x| 7| 59| 157| -9.409114006| 59|00:00:00| NA| NA| NA| #> |x| 4| 59| 157| -9.474993771| 117|00:00:00|+1.00|1.00|0.0000| #> |x| 3| 59| 157| -9.473898869| 175|00:00:00|+1.00|1.00|0.0000| #> |x| 1| 59| 157| -9.508559629| 233|00:00:00|+1.00|1.00|0.0000| #> |-| 2| 2| 157| -9.512181546| 291|00:00:00|+1.00|1.00|0.0000| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> Best-so-far configuration: 25 mean value: -9.332121715 #> Description of the best-so-far configuration: #> .ID. x1 x2 .PARENT. #> 25 25 2.9398 2.4074 NA #> #> # 2021-09-17 04:11:56 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks): #> x1 x2 #> 25 2.9398 2.4074 #> 157 3.1322 2.2942 #> # 2021-09-17 04:11:56 UTC: Iteration 4 of 4 #> # experimentsUsedSoFar: 822 #> # remainingBudget: 178 #> # currentBudget: 178 #> # nbConfigurations: 21 #> # Markers: #> x No test is performed. #> c Configurations are discarded only due to capping. #> - The test is performed and some configurations are discarded. #> = The test is performed but no configuration is discarded. #> ! The test is performed and configurations could be discarded but elite configurations are preserved. #> . All alive configurations are elite and nothing is discarded #> #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> |x| 8| 21| 157| -9.656374067| 21|00:00:00| NA| NA| NA| #> |x| 7| 21| 157| -9.532744037| 40|00:00:00|+1.00|1.00|0.0000| #> |x| 2| 21| 157| -9.530719096| 59|00:00:00|+1.00|1.00|0.0000| #> |x| 5| 21| 157| -9.534520799| 79|00:00:00|+1.00|1.00|0.0000| #> |-| 3| 2| 157| -9.521958452| 98|00:00:00|+1.00|1.00|0.0000| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> Best-so-far configuration: 25 mean value: -9.348254834 #> Description of the best-so-far configuration: #> .ID. x1 x2 .PARENT. #> 25 25 2.9398 2.4074 NA #> #> # 2021-09-17 04:11:56 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks): #> x1 x2 #> 25 2.9398 2.4074 #> 157 3.1322 2.2942 #> # 2021-09-17 04:11:56 UTC: Iteration 5 of 5 #> # experimentsUsedSoFar: 920 #> # remainingBudget: 80 #> # currentBudget: 80 #> # nbConfigurations: 9 #> # Markers: #> x No test is performed. #> c Configurations are discarded only due to capping. #> - The test is performed and some configurations are discarded. #> = The test is performed but no configuration is discarded. #> ! The test is performed and configurations could be discarded but elite configurations are preserved. #> . All alive configurations are elite and nothing is discarded #> #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> |x| 9| 9| 187| -9.549485794| 9|00:00:00| NA| NA| NA| #> |x| 4| 9| 187| -9.545343881| 16|00:00:00|+1.00|1.00|0.0000| #> |x| 6| 9| 187| -9.558448788| 24|00:00:00|+1.00|1.00|0.0000| #> |x| 5| 9| 187| -9.555400176| 31|00:00:00|+1.00|1.00|0.0000| #> |-| 1| 3| 187| -9.566894209| 38|00:00:00|+1.00|1.00|0.0000| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> Best-so-far configuration: 157 mean value: -9.544077248 #> Description of the best-so-far configuration: #> .ID. x1 x2 .PARENT. #> 157 157 3.1322 2.2942 25 #> #> # 2021-09-17 04:11:56 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks): #> x1 x2 #> 157 3.1322 2.2942 #> 25 2.9398 2.4074 #> 187 3.1363 2.2892 #> # 2021-09-17 04:11:56 UTC: Iteration 6 of 6 #> # experimentsUsedSoFar: 958 #> # remainingBudget: 42 #> # currentBudget: 42 #> # nbConfigurations: 6 #> # Markers: #> x No test is performed. #> c Configurations are discarded only due to capping. #> - The test is performed and some configurations are discarded. #> = The test is performed but no configuration is discarded. #> ! The test is performed and configurations could be discarded but elite configurations are preserved. #> . All alive configurations are elite and nothing is discarded #> #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> | | Instance| Alive| Best| Mean best| Exp so far| W time| rho|KenW| Qvar| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> |x| 10| 6| 191| -9.611075413| 6|00:00:00| NA| NA| NA| #> |x| 6| 6| 191| -9.597949963| 9|00:00:00|+1.00|1.00|0.0000| #> |x| 3| 6| 191| -9.556034445| 13|00:00:00|+1.00|1.00|0.0000| #> |x| 4| 6| 191| -9.552367804| 16|00:00:00|+1.00|1.00|0.0000| #> |-| 2| 4| 191| -9.547326955| 20|00:00:00|+1.00|1.00|0.0000| #> |!| 7| 4| 191| -9.524373854| 22|00:00:00|+1.00|1.00|0.0000| #> |!| 8| 4| 191| -9.543301648| 24|00:00:00|+1.00|1.00|0.0000| #> |!| 1| 4| 191| -9.552018473| 25|00:00:00|+1.00|1.00|0.0000| #> |!| 5| 4| 191| -9.551396449| 26|00:00:00|+1.00|1.00|0.0000| #> |-| 9| 1| 191| -9.551221974| 27|00:00:00| NA| NA| NA| #> +-+-----------+-----------+-----------+---------------+-----------+--------+-----+----+------+ #> Best-so-far configuration: 191 mean value: -9.551221974 #> Description of the best-so-far configuration: #> .ID. x1 x2 .PARENT. #> 191 191 3.1408 2.2838 187 #> #> # 2021-09-17 04:11:57 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks): #> x1 x2 #> 191 3.1408 2.2838 #> # 2021-09-17 04:11:57 UTC: Stopped because there is not enough budget left to race more than the minimum (3) #> # You may either increase the budget or set 'minNbSurvival' to a lower value #> # Iteration: 7 #> # nbIterations: 7 #> # experimentsUsedSoFar: 985 #> # timeUsed: 0 #> # remainingBudget: 15 #> # currentBudget: 15 #> # number of elites: 1 #> # nbConfigurations: 2
#> x1 x2 configuration x_domain y #> 1: 3.1408 2.2838 191 <list[2]> -9.551222
# best scoring configuration instance$result
#> x1 x2 configuration x_domain y #> 1: 3.1408 2.2838 191 <list[2]> -9.551222
# all evaluations as.data.table(instance$archive)
#> x1 x2 y race step instance configuration #> 1: 1.0000 14.7843 110.171192 1 1 3 1 #> 2: -3.3739 13.3046 -9.139562 1 1 3 2 #> 3: 2.4583 14.0913 118.500854 1 1 3 3 #> 4: -3.5824 3.9054 80.684179 1 1 3 4 #> 5: 5.8117 10.1007 89.309472 1 1 3 5 #> --- #> 981: 3.1363 2.2892 -9.656702 6 1 10 187 #> 982: 3.1408 2.2838 -9.656868 6 1 10 191 #> 983: 3.1408 2.2838 -9.613036 6 1 3 191 #> 984: 3.1408 2.2838 -9.546420 6 1 9 191 #> 985: 3.1408 2.2838 -9.549652 6 1 1 191 #> timestamp batch_nr #> 1: 2021-09-17 04:11:54 1 #> 2: 2021-09-17 04:11:54 1 #> 3: 2021-09-17 04:11:54 1 #> 4: 2021-09-17 04:11:54 1 #> 5: 2021-09-17 04:11:54 1 #> --- #> 981: 2021-09-17 04:11:57 32 #> 982: 2021-09-17 04:11:57 32 #> 983: 2021-09-17 04:11:57 33 #> 984: 2021-09-17 04:11:57 34 #> 985: 2021-09-17 04:11:57 35