Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addCountingWrapper

Return a function which counts its function evaluations.


Description

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.

Usage

addCountingWrapper(fn)

Arguments

fn

[smoof_function]
Smoof function which should be wrapped.

Value

[smoof_counting_function]

See Also

Examples

fn = makeBBOBFunction(dimensions = 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))

smoof

Single and Multi-Objective Optimization Test Functions

v1.6.0.2
BSD_2_clause + file LICENSE
Authors
Jakob Bossek [aut, cre], Pascal Kerschke [ctb]
Initial release
2020-02-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.