class zfit.minimize.DefaultToyStrategy(nan_penalty=100, nan_tolerance=30, **kwargs)[source]

Bases: zfit.minimizers.baseminimizer.PushbackStrategy, zfit.minimizers.baseminimizer.ToyStrategyFail

Same as DefaultStrategy, but does not raise an error on full failure, instead return an invalid FitResult.

This can be useful for toy studies, where multiple fits are done and a failure should simply be counted as a failure instead of rising an error.

Pushback by adding nan_penalty * counter to the loss if NaNs are encountered.

The counter indicates how many NaNs occurred in a row. The nan_tolerance is the upper limit, if this is exceeded, the fallback will be used and an error is raised.

  • nan_penalty (Union[float, int]) – Value to add to the previous loss in order to penalize the step taken.

  • nan_tolerance (int) – If the number of NaNs encountered in a row exceeds this number, the fallback is used.