openmmtools.mcmc.WeightedMove

class openmmtools.mcmc.WeightedMove(move_set, context_cache=None)[source]

Pick an MCMC move out of set with given probability at each iteration.

Parameters:
move_set : list of tuples (MCMCMove, float_

Each tuple associate an MCMCMoves to its probability of being selected on apply().

context_cache : openmmtools.cache.ContextCache, optional

If not None, the context_cache of all the moves in the set will be set to this (default is None).

Examples

Create and run an alanine dipeptide simulation with a weighted move.

>>> import numpy as np
>>> from simtk import unit
>>> from openmmtools import testsystems
>>> from openmmtools.states import ThermodynamicState, SamplerState
>>> test = testsystems.AlanineDipeptideVacuum()
>>> thermodynamic_state = ThermodynamicState(system=test.system,
...                                          temperature=298*unit.kelvin)
>>> sampler_state = SamplerState(positions=test.positions)
>>> # Create a move set specifying probabilities fo each type of move.
>>> move = WeightedMove([(HMCMove(n_steps=10), 0.5),
...                      (LangevinDynamicsMove(n_steps=10), 0.5)])
>>> # Create an MCMC sampler instance and run 10 iterations of the simulation.
>>> sampler = MCMCSampler(thermodynamic_state, sampler_state, move=move)
>>> sampler.run(n_iterations=2)
>>> np.allclose(sampler.sampler_state.positions, test.positions)
False
Attributes:
move_set

Methods

apply(thermodynamic_state, sampler_state) Apply one of the MCMC moves in the set to the state.
__init__(move_set, context_cache=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__(move_set[, context_cache]) x.__init__(…) initializes x; see help(type(x)) for signature
apply(thermodynamic_state, sampler_state) Apply one of the MCMC moves in the set to the state.

Attributes

statistics The statistics of all moves as a list of dictionaries.
apply(thermodynamic_state, sampler_state)[source]

Apply one of the MCMC moves in the set to the state.

The probability that a move is picked is given by its weight.

Parameters:
thermodynamic_state : openmmtools.states.ThermodynamicState

The thermodynamic state to use to propagate dynamics.

sampler_state : openmmtools.states.SamplerState

The sampler state to apply the move to.

statistics

The statistics of all moves as a list of dictionaries.