ObjectivePerturbation#
- class ObjectivePerturbation(func, func_args, n_red=1)[source]#
Bases:
Perturbation,ABCBase class for perturbations performed by decreasing an objective function.
- Parameters:
func (
Callable) – The objective function to be perturbed.func_args (
List) – The arguments to be passed to the objective function.n_red (
int) – The number of reduction steps to perform in one perturbation iteration (default is 1).
- Attributes:
- funcFuncWrapper
A wrapped version of the objective function with its arguments.
- n_redint
The number of reduction steps to perform.
- _kint
Keeps track of the number of performed perturbations.
Methods
Perform n_red perturbation steps on the input array.
post_step(x, *args, **kwargs)If required perform any form of step after each perturbation in each iteration.
pre_step(x, *args, **kwargs)If required perform any form of step previous to each perturbation in each iteration.
reset()Reset the perturbation to its initial state.
- perturbation_step(x)[source]#
Perform n_red perturbation steps on the input array.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – The input array to be perturbed.- Return type:
ndarray- Returns:
The perturbed array after applying the reduction steps.
- post_step(x, *args, **kwargs)[source]#
If required perform any form of step after each perturbation in each iteration.
This method is intended to be overridden by subclasses to implement specific post-step logic. By default, it does nothing.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Current iterate.- Return type:
None
- pre_step(x, *args, **kwargs)[source]#
If required perform any form of step previous to each perturbation in each iteration.
This method is intended to be overridden by subclasses to implement specific pre-step logic. By default, it does nothing.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Current iterate.- Return type:
None