-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MC move refactoring #20
Comments
Effectively, we want to implement this for each MCMCMove:
|
Below I sketched out things a little more in detail. I think we agreed to name the main public function A few questions:
|
Since
|
In refactoring, a few other things have come up. New moves will only require users to define three functions:
|
As we mentioned in #24 and #23 , I think the idea will be to have functions accept and return sampler and thermodynamic states (and any other associated parameters we might want). Two place where we don't follow this: 2- Neighborlist is modified in place. I think we already discussed the idea of moving this into the sampler state to minimize the amount of stuff we need to pass around. This might be more efficient for some of the MC moves, because if we reject a move, it would basically automatically revert back, even if we had to rebuild the neighbor list in the proposed_state. I just need to think about a bit what is the easiest way to implement this (since neighbor list depends on the sampler state itself) (can probably wrap this so we don't have to explicitly pass the sampler state, just like |
I changed the code around such that the neighbor list is returned along with sampler states and thermodynamic state. One place where this might be useful is in the case of a rejected MC move, since we can just step back to the prior neighbor list state, rather than have to do another check to make sure that the neighbor list modified by the proposed state still works. I left the MCMC Sampler in place, as we will need to discuss that in the context of the multistate sampling. The PR should be ready to go. |
We need to figure out a good balance between between OOPing and code readability/extensibility.
Currently, we have a pretty significant hierarchy of inherited classes in terms of the MCMC moves.
The basic
MetropolisDisplacementMove
inherits fromMetropolizedMove
which inherits fromMCMove
, which inherits fromStateUpdateMove
. While some hierarchy is definitely going to be necessary, this might be a bit excessive from a code readability standpoint (even if it will ultimately reduce the amount of code needed for each move).The
MCMove
class seems to sketch out a reasonably clear structure (I'll note isn't necessarily followed in the moves that build upon theMetropolizedMove
class), as a starting point.In
MCMove
there are a few key functions already in there:apply_move
compute_acceptance_probability
accept_or_reject
I'll note the
MCMCSampler
class expects moves to have arun
function, so adding that into theMCMove
class would likely be a good plan (whererun
doesn't necessarily change much between different routines, as it essentially is calling a function that performs a the moven
times).In terms of a generally applicable and easy to extended structure...lets start from the
run
function for an MC displacement move.run
: this will call an_apply
function (which actually performs an MC move). This should be general for the MCMoves, effectively just calling_apply
the number of times moves specified._apply_move
: this can likely be made generic for the MC moves. As a basic pseudocode sketch:_generate_new_state
function (this will need to be an abstract function defined in each move)compute_acceptance_probability
(again, an abstract function to be defined in each move...this will need to accept the original and proposed sampler_state and associated reduced potentials)accept_or_reject
based on computed acceptance probabilityThis approach would only require a user to define
compute_acceptance_probability
and_generate_new_state
. It would make the acceptance criteria much clearer (it should not require many logic statements with regards to checking the thermodynamic state variables, unlike the currentapply
function in theMetropolizedMove
function).New
MCMove
key functions:run
-- this is the key public function that should be generic for all MC move routines_apply_move
-- this should be generic for all MC move routines_generate_new_state
-- this will need to be defined for each move_compute_acceptance_probability
-- this will need to be defined for each move_accept_or_reject
-- this should be generic and work for each movestatistics
-- stores number of accepted and proposed movesFor functions where we want to allow dynamics updates to parameters, such as the maximum volume scaling or maximum displacement to achieved a target acceptance probability, this likely can happen within the
_generate_new_state function
(before the state is actually generated).I think best course of action will be to do this in a separate PR after #14 and #19 are merged.
The text was updated successfully, but these errors were encountered: