add runner.max_retries
This PR (mainly) introduces runner.max_retries
and runner.raise_if_max_retries
.
With this the following function would be "learned":
import adaptive
adaptive.notebook_extension()
def f(x, offset=0):
from random import random
a = 0.01
if random() < 0.9:
raise Exception('Oops, this failed.')
return x + a**2 / (a**2 + (x - offset)**2)
learner = adaptive.Learner1D(f, bounds=(-1, 1))
runner = adaptive.BlockingRunner(learner, goal=lambda l: l.loss() < 0.05,
max_retries=20, log=True, raise_if_max_retries=False)
I also introduce BlockingRunner.overhead
and the corresponding timing functions and put the shared code of BlockingRunner
and AsyncRunner
in BaseLearner
methods.
Edited by Bas Nijholt