search_space = domain = ps(x = p_dbl(lower = -1, upper = 1))
codomain = ps(y = p_dbl(tags = "minimize"))
objective_function = function(xs) {
list(y = as.numeric(xs)^2)
}
objective = ObjectiveRFun$new(
fun = objective_function,
domain = domain,
codomain = codomain)
instance = OptimInstanceBatchSingleCrit$new(
objective = objective,
search_space = search_space,
terminator = trm("evals", n_evals = 100))
# evaluate an initial sample of 10 points uniformly at random
# choose the best 3 points as the initial points
# for each of these points generate 10 neighbors
# repeat this process
optimizer = opt("local_search",
n_initial_points = 3,
initial_random_sample_size = 10,
neighbors_per_point = 10)
# modifies the instance by reference
optimizer$optimize(instance)
# returns best scoring evaluation
instance$result
# allows access of data.table of full path of all evaluations
as.data.table(instance$archive$data)
Run the code above in your browser using DataLab