pyrevs.strategies.base¶
Submodules¶
Classes¶
An interface for all rare-event algorithms. |
|
Termination criterion based on score. |
|
Termination criterion based on model. |
|
Convergence criterion based on a target score. |
|
Termination criterion interface. |
|
Interruption criterion based on time. |
|
Termination criterion based on time. |
Package Contents¶
- class BaseSamplingStrategy[source]¶
Bases:
abc.ABCAn 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
- 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_samplingand should regularly checkout_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.
- abstractmethod initialize_database_schema(database: pyrevs.database.Database, diag_configs: dict[str, pyrevs.core.Config] | None) None[source]¶
Initialize the schema of the database.
- class LowScoreTerminationCriterion(score_threshold: float)[source]¶
Bases:
TerminationCriterionTermination criterion based on score.
Will trigger termination if the current score is less than or equal to a threshold.
- should_terminate(model: pyrevs.core.ForwardModelBaseClass[T_Noise, T_State], trajectory: pyrevs.trajectory.Trajectory) pyrevs.trajectory.TrajectoryStateType[source]¶
Check if the trajectory should terminate.
- class ModelTerminationCriterion[source]¶
Bases:
TerminationCriterionTermination criterion based on model.
Will trigger termination if the forward model has decides to.
- should_terminate(model: pyrevs.core.ForwardModelBaseClass[T_Noise, T_State], trajectory: pyrevs.trajectory.Trajectory) pyrevs.trajectory.TrajectoryStateType[source]¶
Check if the trajectory should terminate.
- class TargetScoreConvergenceCriterion(target_score: float)[source]¶
Bases:
TerminationCriterionConvergence criterion based on a target score.
Will trigger convergence if the forward model decides that the current score reached the target score (by default, if the score is greater than or equal to the target score).
- should_terminate(model: pyrevs.core.ForwardModelBaseClass[T_Noise, T_State], trajectory: pyrevs.trajectory.Trajectory) pyrevs.trajectory.TrajectoryStateType[source]¶
Check if the trajectory has converged.
- class TerminationCriterion[source]¶
Bases:
ProtocolTermination criterion interface.
- abstractmethod should_terminate(model: pyrevs.core.ForwardModelBaseClass[T_Noise, T_State], trajectory: pyrevs.trajectory.Trajectory) pyrevs.trajectory.TrajectoryStateType[source]¶
Check if the trajectory should terminate.
- Parameters:
model – the forward model
trajectory – the trajectory
- Returns:
One of the TrajectoryStateType
- class TimeInterruptionCriterion(end_time: float)[source]¶
Bases:
TerminationCriterionInterruption criterion based on time.
Will trigger interruption if the current time is greater than or equal to the end time.
- should_terminate(model: pyrevs.core.ForwardModelBaseClass[T_Noise, T_State], trajectory: pyrevs.trajectory.Trajectory) pyrevs.trajectory.TrajectoryStateType[source]¶
Check if the trajectory should terminate.
- class TimeTerminationCriterion(end_time: float)[source]¶
Bases:
TerminationCriterionTermination criterion based on time.
Will trigger termination if the current time is greater than or equal to the end time.
- should_terminate(model: pyrevs.core.ForwardModelBaseClass[T_Noise, T_State], trajectory: pyrevs.trajectory.Trajectory) pyrevs.trajectory.TrajectoryStateType[source]¶
Check if the trajectory should terminate.