setup_genz_function

pyapprox.benchmarks.setup_genz_function(nvars, test_name, coeff_type=None, w=0.25, c_factor=1, coeff=None)[source]

Setup one of the six Genz integration benchmarks \(f_d(x):\mathbb{R}^D\to\mathbb{R}\), where \(x=[x_1,\ldots,x_D]^\top\). The number of inputs \(D\) and the anisotropy (relative importance of each variable and interactions) of the functions can be adjusted. The definition of each function is in the Notes section.

For example, the two-dimensional oscillatory Genz problem can be defined using

>>> from pyapprox.benchmarks.benchmarks import setup_benchmark
>>> benchmark=setup_benchmark('genz',nvars=2,test_name='oscillatory')
>>> print(benchmark.keys())
dict_keys(['fun', 'mean', 'variable'])
Parameters:
nvarsinteger

The number of variables of the Genz function

test_namestring

The test_name of the specific Genz function. See notes for options the string needed is given in brackets e.g. (‘oscillatory’). Choose from [“oscillatory”, “product_peak”, “corner_peak”, “c0continuous”, “discontinuous”]

coef_typestring

Choose from [“no_decay”, “quadratic_decay”, “quartic_decay”, “exponential_decay”. “squared_exponential_decay”]

wfloat 0<=w<=1

Set \(w_d=w, d=1,\ldots,D\).

c_factorfloat c_factor>0

Scale the integrand.

coefftuple (ndarray (nvars, 1), ndarray (nvars, 1))

The coefficients \(c_d\) and \(w_d\) If provided it will overwite the coefficients defined by coeff_type, w and c_factor

Returns:
benchmarkpyapprox.benchmarks.Benchmark

Object containing the benchmark attributes

funcallable

The function being analyzed

variableJointVariable

Class containing information about each of the nvars inputs to fun

mean: np.ndarray (nvars)

The mean of the function with respect to the PDF of var

Notes

The six Genz test function are:

Oscillatory (‘oscillatory’)

\[f(z) = \cos\left(2\pi w_1 + \sum_{d=1}^D c_dz_d\right)\]

Product Peak (‘product_peak’)

\[f(z) = \prod_{d=1}^D \left(c_d^{-2}+(z_d-w_d)^2\right)^{-1}\]

Corner Peak (‘corner_peak’)

\[f(z)=\left( 1+\sum_{d=1}^D c_dz_d\right)^{-(D+1)}\]

Gaussian Peak (‘gaussian’)

\[f(z) = \exp\left( -\sum_{d=1}^D c_d^2(z_d-w_d)^2\right)\]

C0 Continuous (‘c0continuous’)

\[f(z) = \exp\left( -\sum_{d=1}^D c_d\lvert z_d-w_d\rvert\right)\]

Discontinuous (‘discontinuous’)

\[\begin{split}f(z) = \begin{cases}0 & z_1>w_1 \;\mathrm{or}\; z_2>w_2\\\exp\left(\sum_{d=1}^D c_d z_d\right) & \mathrm{otherwise}\end{cases}\end{split}\]

Increasing \(\lVert c \rVert\) will in general make the integrands more difficult.

The \(0\le w_d \le 1\) parameters do not affect the difficulty of the integration problem. We set \(w_1=w_2=\ldots=W_D\).

The coefficient types implement different decay rates for \(c_d\). This allows testing of methods that can identify and exploit anisotropy. They are as follows:

No decay (none)

\[\hat{c}_d=\frac{d+0.5}{D}\]

Quadratic decay (qudratic)

\[\hat{c}_d = \frac{1}{(D + 1)^2}\]

Quartic decay (quartic)

\[\hat{c}_d = \frac{1}{(D + 1)^4}\]

Exponential decay (exp)

\[\hat{c}_d=\exp\left(\log(c_\mathrm{min})\frac{d+1}{D}\right)\]

Squared-exponential decay (sqexp)

\[\hat{c}_d=10^{\left(\log_{10}(c_\mathrm{min})\frac{(d+1)^2}{D}\right)}\]

Here \(c_\mathrm{min}\) is argument that sets the minimum value of \(c_D\).

Once the formula are used the coefficients are normalized such that

\[c_d = c_\text{factor}\frac{\hat{c}_d}{\sum_{d=1}^D \hat{c}_d}.\]

References