pyrevs.strategies.base.strategy

Defines the generic interface for sampling strategies.

Attributes

T

Classes

BaseSamplingStrategy

An interface for all rare-event algorithms.

Module Contents

T[source]
class BaseSamplingStrategy[source]

Bases: abc.ABC

An interface for all rare-event algorithms.

Define the common interface for sampling strategies within the sampler object.

A registry is used to store all available strategies. It is managed using a decorator and entry_points.

Subclasses must implement the following methods: - sample() - out_of_time()

classmethod register(name: str) collections.abc.Callable[[type[T]], type[T]][source]

Register a new strategy.

Parameters:

name – the strategy name

classmethod create(name: str, *args: Any, **kwargs: Any) BaseSamplingStrategy[source]

Instantiate a strategy out of the registry.

Parameters:
  • name – the strategy name

  • *args – positional arguments

  • **kwargs – keyword arguments

classmethod available_strategies() list[str][source]

Return list of registered strategy names.

sample(database: pyrevs.database.Database, walltime: float, plot_diags: bool) None[source]

Run the sampling lifecycle.

This method handles walltime bookkeeping and delegates the algorithm implementation to _execute_sampling.

Subclasses must implement _execute_sampling and should regularly check out_of_time() to terminate gracefully.

Parameters:
  • database – Database used for storing results.

  • walltime – Maximum allowed runtime in seconds.

  • plot_diags – Whether to enable diagnostic plotting.

remaining_time() float[source]

Return the remaining wallclock time.

out_of_time() bool[source]

Return true if insufficient walltime remains.

elapsed_time() float[source]

Return the elapsed wallclock time.

abstractmethod initialize_database_schema(database: pyrevs.database.Database, diag_configs: dict[str, pyrevs.core.Config] | None) None[source]

Initialize the schema of the database.