class documentation

noise wrapper for an observed problem.

The noise is applied with different probabilities for

  • subtracting a value (leading to good outliers)
  • adding a value (leading to bad outliers)
  • adding a small epsilon normally distributed noise

The noise is frozen in x and y: whether the noise is applied to y and its value depend both _deterministically_ on the input x.

The outlier noise distribution is a half Cauchy distribution multiplied by pi/2, which generates values larger than k with a probability awfully close to 1/k when k >= 10.

Example:

import cocoex  # experimentation module
import scipy  # to define the solver to be benchmarked

### input
suite_name = "bbob"
fmin = scipy.optimize.fmin  # optimizer to be benchmarked

### prepare
suite = cocoex.Suite(suite_name, "", "")
observer = cocoex.Observer(suite_name, "")
noisifier = cocoex.noiser.Noisifier()  # wrapper without internal state

### go
for problem in suite:  # this loop may take several minutes or more
    problem.observe_with(observer)  # generates the data for cocopp
    problem = noisifier.noisify(problem)  # wrap problem as noisy
    fmin(problem, problem.initial_solution, disp=False)

The problem is now a Noisifier but it still abides by the interface of the original problem.

Details: the random number generators can be passed as argument and need to obey the interface of noiser.rand. By default, rands[0] is uniform in [0,1] and rands[1] is Gaussian noise, abs(rands[2]) and abs(rands[-1]) are used to sample added and subtracted noise, respectively. Both are by default the same Cauchy noise generator and the numbers scaled by pi/2 such that P(number > k) equals about 1/k when k >= 5.

Parameter settings are by default saved to the file indicated by the module global variable cocoex.noiser.parameters_file if bool(cocoex.noiser.save_parameters) is True.

A minimal regression test:

>>> import cocoex
>>> def eq(x, y):
...     return [cocoex.utilities.about_equal(xi, yi)
...             for xi, yi in zip(x, y)]
>>> def fun(x):
...     return 2 * x[0], 3 * x[1]
>>> n = cocoex.noiser.Noisifier(p_add=.5)
>>> f = n.noisify(fun)
>>> assert all(eq(f([1, 2]), [2, 41.39010606165791])
...            ), f([1, 2])
>>> assert all(eq(f([2, 3, 4]), [11.518074565992698, 9.705537168513859])
...            ), f([2, 3, 4])  # x[2:] have no influence here
>>> assert all(eq(f([-1, 2]), [-2, 6])
...            ), f([-1, 2])

See also https://github.com/numbbo/coco-experiment/issues/36 and https://github.com/numbbo/coco-experiment/blob/main/build/python/example/example_experiment_complete.py

Method __call__ Undocumented
Method __getattr__ pretend to be a COCO problem as passed in noisify
Method __init__ constructor with 4 optional parameters for the noise model,
Method constraint return noisy constraint values
Method noisify wrap problem with frozen noise
Method rand0 uniform by default
Method rand1 Gaussian by default
Method rand2 Cauchy by default
Method save_parameters save parameter dict to a json file
Class Variable p_add_single_default Undocumented
Property parameters Undocumented
Method _cnoise Undocumented
Method _fnoise x-dependent abs Cauchy noise with median pi/2
Method _set_params set parameters from file filename or filename passed at
Instance Variable _params Undocumented
Instance Variable _problem Undocumented
def __call__(self, x):

Undocumented

def __getattr__(self, name):

pretend to be a COCO problem as passed in noisify

def __init__(self, p_add=None, p_subtract=0.0, p_epsilon=0.0, epsilon=0.0001, rands=(rand, randn, randc), filename=None):

constructor with 4 optional parameters for the noise model,

p_add: probability for adding a positive heavy tail random value making the solution look worse than it actually is. The default is 0.2 iff p_subtract == p_epsilon == 0 and 0.0 otherwise.

p_subtract: probability for subtracting a positive heavy tail random value making the solution look better than it is.

p_epsilon: probability for adding a Gaussian random value

epsilon: standard deviation of the Gaussian random value

filename: for saving parameter setting, if not given use module global variable cocoex.noiser.parameters_file, saving depends on the module variable save_parameters.

def constraint(self, x):

return noisy constraint values

def noisify(self, problem):

wrap problem with frozen noise

def rand0(self, x, fac=1):

uniform by default

def rand1(self, x, fac=1):

Gaussian by default

def rand2(self, x, fac=1):

Cauchy by default

def save_parameters(self, filename=None):

save parameter dict to a json file

p_add_single_default: float =

Undocumented

@property
parameters =

Undocumented

def _cnoise(self, x):

Undocumented

def _fnoise(self, x):

x-dependent abs Cauchy noise with median pi/2

def _set_params(self, filename=None, **kwargs):

set parameters from file filename or filename passed at

instantiation or cocoex.noiser.parameters_file.

_params =

Undocumented

_problem =

Undocumented