This function conducts a random search on the given function with the support of parallelization and multiple termination criteria.

randomsearch(fun, ...)

# S3 method for smoof_function
randomsearch(fun, design = NULL,
  max.evals = 20, max.execbudget = NULL, = NULL,
  design.y.cols = NULL, par.dir = NULL, = NULL, ...)

# S3 method for function
randomsearch(fun, minimize = TRUE, lower, upper,
  design = NULL, max.evals = 20, max.execbudget = NULL, = NULL, design.y.cols = NULL, par.dir = NULL, = NULL, ...)



Fitness function to optimize. Can be either a smoof_function or a normal function that takes the numeric vector over that should be optimized as the first argument. For one dimensional target functions you can obtain a smoof_function by using makeSingleObjectiveFunction. For multi dimensional functions use makeMultiObjectiveFunction. It is possible to return even more information which will be stored in the optimization path. To achieve this, simply append the attribute “extras” to the return value of the target function. This has to be a named list of scalar values. Each of these values will be stored additionally in the optimization path.


Additional arguments that will be passed to each call of fun.


Initial design as data frame. If the y-values are not already present in design, randomsearch will evaluate the points. If the parameters have corresponding trafo functions, the design must not be transformed before it is passed! Functions to generate designs are available in ParamHelpers: generateDesign, generateGridDesign, generateRandomDesign. Default is NULL, which means no initial design.


Maximum number of evaulations of the objective functions. Includes the initial design.


Exceution time budget in seconds.

Traget function value.


The name of the column containing the function outcomes. One for single-crit optimization. Multiple for multi-crit optimization.


Location to store parallel communication files. Defaults to tmpfile() which might not be suitable for parallelization methods that work on multiple machines. Those need a shared directory.

How many parallel jobs do you want to run to evaluate the random search? Default is NULL which means 1 if no parallelStart* function is called. Otherwise it will detect the number through parallelGetOptions.


Wheter the function should be minimized or maximized. If this is a vector we will assume it is a multi-objective optimization. Has to have the same length as the output of the objective function fun.


Lower bounds on the variables.


Upper bounds on the variables.



Methods (by class)

  • smoof_function: optimize smoof function

  • function: optimize generic function

Examples = makeSingleObjectiveFunction( fn = function(x) x[1]^2 + sin(x[2]), par.set = makeNumericParamSet(id = "x", lower = -1, upper = 1, len = 2) ) res = randomsearch(, max.evals = 10) summary(res)
#> Randomsearch Result: #> Eval no.: 9 #> x: x=-0.193,-0.873 #> y: -0.7288329