Description Usage Arguments Details Value Examples
View source: R/with_fixed_budget.R
Fixed budget expression evaluation
Evaluate expr
with a fixed budget for the number of times
any test function in expr
may be evaluated.
1 | with_fixed_budget(expr, budget)
|
expr |
[ |
budget |
[ |
The main use of this function is in benchmarking
(optimization) algorithms. It ensures that the algorithm does not
perform more than budget
function evaluations by tracking
the number of evaluations performed and raising a
condition
if the budget is reached. For this to
work, the function must find one and only one soofunction
object in expr
which will be replaced by a modified test
function that performs the tracking and signalling.
While elegant from a users perspective, this function is not fool proof. It is possible to construct situations were it will fail. For example, if the employed optimization algorithm is written in C and does not use the memory allocation routines provided by R, then this will certainly lead to memory leaks. You have been warned.
A list
with elements ‘par’, ‘value’
and ‘counts’ whos contents are identical to the return
value of optim
1 2 3 | fn <- generate_sphere_function(10)
res <- with_fixed_budget(optim(random_parameter(fn), fn), 25)
print(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.