openmmtools.mcmc.WeightedMove

class openmmtools.mcmc.WeightedMove(move_set, **kwargs)[source]

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

Parameters:
move_setlist of tuples (MCMCMove, float_

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

Examples

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

>>> import numpy as np
>>> from openmm 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, **kwargs)[source]

Methods

__init__(move_set, **kwargs)

apply(thermodynamic_state, sampler_state[, ...])

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

Attributes

context_cache

statistics

The statistics of all moves as a list of dictionaries.