Added support for tuning of parallel tempering temperature set
What
Added a recursion that changes the distribution of temperatures defined by the user shrinking the temperature difference of replicas with low exchange acceptance rates and vice versa. Adapted from "Markov Chain Monte Carlo Simulations and Their Statistical Analysis", Section 6.3.
Why
The recursion allows one to simulate systems at lower temperature or with certain phase transitions using fewer replicas.
How
If parameter recursionIterations is greater than zero it creates a second MonteCarloStatistics() variable that tracks the replica exchange independently and it performs a recursion every recursionRate sweeps a total of recursionIterations. The recursion itself is done in the root process and then shared across processes.
Testing
I haven't implemented any tests yet, but it should be possible to create one which goes to lower temperatures and obtains the right values.
Hi David, Thanks for contributing and addressing the important issue of finding good (efficient) distributions of temperature points in parallel tempering. Your code is definitely a cool extension!
In my experience, optimizing the temperature distribution can be rather finicky, especially for difficult models with phase transitions at very low temperatures, and algorithms that automatically tune the temperature distribution tend to easily become unstable. Such a specialized use case / algorithm would therefore probably need good documentation and test coverage to make it really useful to the general user.
The codebase currently is more or less frozen since in its current state it is difficult to systematically build extensions around it. Yet, I have been thinking about making the entire project more modular and extendable in the future (which is probably more of a long-term goal). Until that happens, I would leave the pull request open to give your extension visibility, and we can hopefully revisit a merge when the codebase has been restructured.
Some technical remarks:
- You don't seem to have a control flow that checks whether measurements are occurring (i.e.,
sweeps>thermalizationSweeps). When you updatebetawhile measurements are being sampled, you might end up mixing samples across different temperatures. - If you are interested to dig deeper in the optimization of temperature point distributions: Updating the temperature distribution based on replica acceptance rate can sometimes be misleading. The approach doesn't disriminate between replica exchanges within the same phase of matter (not very useful) and replica exchanges across phase transitions (very useful since they allow low-temperature configurations to effectively re-thermalize in the high-temperature phase and explore more local energy minima). A strategy to maximize the latter is outlined e.g. in J. Stat. Mech. P03018 (2006) [https://arxiv.org/abs/cond-mat/0602085v3].
Hello. Yeah, the algorithm certainly requires close monitoring. Thanks for your in depth response. I will have the technical comments in mind in the future, I will gladly improve the merge request after a restructure of the codebase.