adaptive.runner.BaseRunner¶
BaseRunner
¶
BaseRunner(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, allow_running_forever: bool = False)
Base class for runners that use concurrent.futures.Executor\'s.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
learner
|
adaptive.BaseLearner instance
|
|
required |
goal
|
callable
|
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. |
None
|
loss_goal
|
float
|
Convenience argument, use instead of |
None
|
npoints_goal
|
int
|
Convenience argument, use instead of |
None
|
end_time_goal
|
datetime
|
Convenience argument, use instead of |
None
|
duration_goal
|
timedelta or number
|
Convenience argument, use instead of |
None
|
executor
|
(Executor, Client, MPIPoolExecutor, Client or get_reusable_executor)
|
The executor in which to evaluate the function to be learned.
If not provided, a new |
None
|
ntasks
|
int
|
The number of concurrent function evaluations. Defaults to the number
of cores available in |
None
|
log
|
bool
|
If True, record the method calls made to the learner by this runner. |
False
|
shutdown_executor
|
bool
|
If True, shutdown the executor when the runner has completed. If
|
False
|
retries
|
int
|
Maximum amount of retries of a certain point |
0
|
raise_if_retries_exceeded
|
bool
|
Raise the error after a point |
True
|
allow_running_forever
|
bool
|
Allow the runner to run forever when the goal is None. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
learner |
adaptive.BaseLearner instance
|
The underlying learner. May be queried for its state. |
log |
list or None
|
Record of the method calls made to the learner, in the format
|
to_retry |
list of tuples
|
List of |
tracebacks |
list of tuples
|
List of of |
pending_points |
list of tuples
|
A list of tuples with |
Methods:
| Name | Description |
|---|---|
overhead : callable |
The overhead in percent of using Adaptive. Essentially, this is
|
Source code in adaptive/runner.py
goal
instance-attribute
¶
goal = _goal(learner, goal, loss_goal, npoints_goal, end_time_goal, duration_goal, allow_running_forever)
raise_if_retries_exceeded
instance-attribute
¶
overhead
¶
overhead() -> float
Overhead of using Adaptive and the executor in percent.
This is measured as 100 * (1 - t_function / t_elapsed).
Notes
This includes the overhead of the executor that is being used. The slower your function is, the lower the overhead will be. The learners take ~5-50 ms to suggest a point and sending that point to the executor also takes about ~5 ms, so you will benefit from using Adaptive whenever executing the function takes longer than 100 ms. This of course depends on the type of executor and the type of learner but is a rough rule of thumb.