class documentation
class FBoundTransform(ComposedFunction):
Constructor: FBoundTransform(fitness_function, bounds)
shortcut for ComposedFunction([f, BoundTransform(bounds).transform]), see also below.
Maps the argument into bounded or half-bounded (feasible) domain before evaluating f.
Example with lower bound at 0, which becomes the image of -0.05 in
BoundTransform.transform
:
>>> import cma, numpy as np >>> f = cma.fitness_transformations.FBoundTransform(cma.ff.elli, ... [[0], None]) >>> assert all(f[1](np.random.randn(200)) >= 0) >>> assert all(f[1]([-0.05, -0.05]) == 0) >>> assert f([-0.05, -0.05]) == 0
A slightly more verbose version to implement the lower bound at zero in the very same way:
>>> import cma >>> felli_in_bound = cma.s.ft.ComposedFunction( ... [cma.ff.elli, cma.BoundTransform([[0], None]).transform])
Method | __init__ |
bounds[0] are lower bounds, bounds[1] are upper bounds |
Instance Variable | bound |
Undocumented |
Inherited from ComposedFunction
:
Method | __call__ |
Undocumented |
Method | inverse |
evaluate the composition of inverses on x. |
Instance Variable | list |
Undocumented |
Inherited from Function
(via ComposedFunction
):
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 |