class documentation
class NoisyFitness(Function):
Constructor: NoisyFitness(fitness_function, rel_noise, abs_noise)
apply noise via f += rel_noise(dim) * f + abs_noise(dim)
Method | __call__ |
Undocumented |
Method | __init__ |
attach relative and absolution noise to fitness_function. |
Instance Variable | abs |
Undocumented |
Instance Variable | rel |
Undocumented |
Inherited from Function
:
Method | initialize |
initialization of Function |
Instance Variable | evaluations |
Undocumented |
Instance Variable | ftarget |
Undocumented |
Instance Variable | target |
Undocumented |
Property | function |
attributes which are searched for to be called if no function was given to __init__ . |
Class Variable | _function |
Undocumented |
Instance Variable | __callable |
Undocumented |
Instance Variable | __initialized |
Undocumented |
def __init__(self, fitness_function, rel_noise=(lambda dim: 1.1 * np.random.randn() / dim), abs_noise=(lambda dim: 1.1 * np.random.randn())):
¶
attach relative and absolution noise to fitness_function.
Relative noise is by default computed using the length of the input argument to fitness_function. Both noise functions take dimension as input.
>>> import cma >>> from cma.fitness_transformations import NoisyFitness >>> fn = NoisyFitness(cma.ff.elli) >>> assert fn([1, 2]) != cma.ff.elli([1, 2]) >>> assert fn.evaluations == 1