adaptive.BlockingRunner#
- class adaptive.BlockingRunner(learner: LearnerType, goal: Callable[[LearnerType], bool] | None = None, *, loss_goal: float | None = None, npoints_goal: int | None = None, end_time_goal: datetime | None = None, duration_goal: timedelta | int | float | None = None, executor: ExecutorTypes | None = None, ntasks: int | None = None, log: bool = False, shutdown_executor: bool = False, retries: int = 0, raise_if_retries_exceeded: bool = True)[source]#
Bases:
BaseRunnerRun a learner synchronously in an executor.
- Parameters:
learner (
BaseLearnerinstance) –goal (callable, optional) – The end condition for the calculation. This function must take the learner as its sole argument, and return True when we should stop requesting more points.
loss_goal (float, optional) – Convenience argument, use instead of
goal. The end condition for the calculation. Stop when the loss is smaller than this value.npoints_goal (int, optional) – Convenience argument, use instead of
goal. The end condition for the calculation. Stop when the number of points is larger or equal than this value.end_time_goal (datetime, optional) – Convenience argument, use instead of
goal. The end condition for the calculation. Stop when the current time is larger or equal than this value.duration_goal (timedelta or number, optional) – Convenience argument, use instead of
goal. The end condition for the calculation. Stop when the current time is larger or equal thanstart_time + duration_goal.duration_goalcan be a number indicating the number of seconds.executor (
concurrent.futures.Executor,distributed.Client, mpi4py.futures.MPIPoolExecutor, ipyparallel.Client orloky.get_reusable_executor, optional) – The executor in which to evaluate the function to be learned. If not provided, a newloky.get_reusable_executoris used.ntasks (int, optional) – The number of concurrent function evaluations. Defaults to the number of cores available in executor.
log (bool, default: False) – If True, record the method calls made to the learner by this runner.
shutdown_executor (bool, default: False) – If True, shutdown the executor when the runner has completed. If executor is not provided then the runner uses loky’s reusable executor, which is shared between runners and is therefore not shut down unless this parameter is True.
retries (int, default: 0) – Maximum amount of retries of a certain point
xinlearner.function(x). After retries is reached forxthe point is present inrunner.failed.raise_if_retries_exceeded (bool, default: True) – Raise the error after a point
xfailed retries.
- learner#
The underlying learner. May be queried for its state.
- Type:
BaseLearnerinstance
- log#
Record of the method calls made to the learner, in the format
(method_name, *args).- Type:
list or None
- to_retry#
List of
(point, n_fails). When a point has failedrunner.retriestimes it is removed but will be present inrunner.tracebacks.- Type:
list of tuples
- elapsed_time : callable
A method that returns the time elapsed since the runner was started.
- overhead : callable
The overhead in percent of using Adaptive. This includes the overhead of the executor. Essentially, this is
100 * (1 - total_elapsed_function_time / self.elapsed_time()).