Description Usage Arguments Value See Also Examples

View source: R/addCountingWrapper.R

This is a counting wrapper for a `smoof_function`

, i.e., the returned function
first checks whether the given argument is a vector or matrix, saves the
number of function evaluations of the wrapped function to compute the function
values and finally passes down the argument to the wrapped `smoof_function`

.

1 |

`fn` |
[ |

[`smoof_counting_function`

]

`getNumberOfEvaluations`

, `resetEvaluationCounter`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
fn = makeBBOBFunction(dimension = 2L, fid = 1L, iid = 1L)
fn = addCountingWrapper(fn)
# we get a value of 0 since the function has not been called yet
print(getNumberOfEvaluations(fn))
# now call the function 10 times consecutively
for (i in seq(10L)) {
fn(runif(2))
}
print(getNumberOfEvaluations(fn))
# Here we pass a (2x5) matrix to the function with each column representing
# one input vector
x = matrix(runif(10), ncol = 5L)
fn(x)
print(getNumberOfEvaluations(fn))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.