pyrevs.strategies.gktl¶
Submodules¶
Classes¶
GKTL strategy configuration. |
|
An extension class for the GKTL strategy. |
|
A strategy class implementing GKTL. |
Functions¶
|
A factory function to instanciate the extension from the database. |
Package Contents¶
- class GKTLDatabaseExtension[source]¶
Bases:
pyrevs.database.StrategyDatabaseExtensionAn extension class for the GKTL strategy.
An extension of the database to store GKTL-specific data. To be able to checkpoint a sampling run with GKTL, and to compute unbiased estimates from the biased ensemble, one need to store/read the following attributes.
At each resampling step n, the clone weights are W_i = exp(k * dA_i) and the normalization factor is R_n = mean(W_i). The (unbiased) estimate of the expectation of an observable O of the trajectories is then:
E[O] = 1/N sum_i O_i exp(-log_tilt_i) prod_n R_n
where log_tilt_i = k * sum_n dA_i,n along the ancestry of clone i.
- Variables:
_iteration_count – number of completed resampling steps
_cur_time – time of the last resampling step
_k – the bias amplitude
_log_norm – log of the normalization factor R_n of each resampling step
_log_tilt – accumulated log-tilt of each clone along its ancestry
_window_start – start time of the current resampling interval for each clone
_ancestors – parent index of each clone, for each resampling step
_times – time of each resampling step
- initialize(tdb: pyrevs.database.Database, k: float) None[source]¶
Initialize the GKTL database extension.
If an on-disk database with GKTL metadata already exists, the extension state is read from disk to enable restarts.
- Parameters:
tdb – the core trajectory database
k – the bias amplitude
- initialize_from_database(tdb: pyrevs.database.Database) None[source]¶
Initialize the GKTL database extension from an existing database.
- Parameters:
tdb – the core trajectory database
- window_start() list[float][source]¶
Return the start time of the current resampling interval for each clone.
- ancestors() list[list[int]][source]¶
Return the parent index of each clone, for each resampling step.
- log_normalization() list[float][source]¶
Return the log of the normalization factor of each resampling step.
- record_resampling(delta_a: numpy.typing.NDArray[numpy.number], parents: list[int], window_start: list[float], time: float) None[source]¶
Record a resampling step and update the clones tilt.
- Parameters:
delta_a – the observable increment of each clone over the interval (before resampling)
parents – the parent index of each clone after resampling
window_start – the start time of the next interval for each clone
time – the time of the resampling step
- clone_weights() numpy.typing.NDArray[numpy.number][source]¶
Return the estimator weight of each clone in the current ensemble.
The weights sum to one in expectation (exactly for k = 0).
- class GKTL(fmodel_t: Any, runtime_cfg: pyrevs.core.RuntimeConfig, runner_cfg: pyrevs.runner.RunnerConfig, strategy_cfg: pyrevs.strategies.gktl.config.GKTLConfig, deterministic: bool)[source]¶
Bases:
pyrevs.strategies.base.BaseSamplingStrategyA strategy class implementing GKTL.
The Giardina-Kurchan-Lecomte-Tailleur algorithm evolves an ensemble of trajectories and, at fixed resampling intervals, kills or clones each of them according to a weight exp(k * dA), where dA is an observable increment over the interval. This biases the ensemble toward large values of the observable. The bias is accounted for when computing estimates (see
GKTLDatabaseExtension).If a target score is set, trajectories that converge (reach the target score) before the end time are frozen: their observable increment is zero over later intervals. Without a target score, trajectories never converge.
Notes
This strategy relies on time management provided by BaseSamplingStrategy (e.g.
self._end_date,elapsed_time()).- run_gktl(database: pyrevs.database.Database, plot_diags: bool) bool[source]¶
Run the GKTL resampling loop.
Advance the ensemble of trajectories interval by interval, resampling the ensemble at the end of each interval (except the last one). The loop resumes from the last completed resampling step when restarting from an existing database.
- Parameters:
database – the sampling database
plot_diags – whether to plot diagnostics
- Returns:
True if the end time was reached (or all trajectories terminated)
- Raises:
RuntimeError if the runner fails –
- compute_probability(database: pyrevs.database.Database, plot_diags: bool) float[source]¶
Compute the rare-event probability using GKTL.
- Parameters:
database – the trajectory database
plot_diags – whether to plot diagnostics
- Returns:
the rare-event probability, or -1.0 if the run did not complete
- initialize_database_schema(database: pyrevs.database.Database, diag_configs: dict[str, pyrevs.core.Config] | None) None[source]¶
Initialize database core state.
- load_database_extension(tdb: pyrevs.database.Database) extension.GKTLDatabaseExtension[source]¶
A factory function to instanciate the extension from the database.