openbabel
openbabel copied to clipboard
Reimplement OpenBabel::OBRandom as a wrapper of std::mt19937_64
Mersenne twister is one of high-quality PRNGs and available on all platforms since C++11.
Looks like a good idea.
One thing that's been requested to add an OBOp plugin to set the RNG seed (e.g., #1934) - would you be willing to add that too.
I've said it before but we should be working to remove all uses of random numbers in the library.
@baoilleach - I don't think that's possible. It's good to minimize them, allow a defined seed to be set, etc. but stochastic methods are critical to several tasks in the library.
We've generally said that only major version changes (e.g., OB2 => OB3 or OB3 => OB4) would drop functions / methods.
The general concept is great, but can we either keep the existing code for backwards compatibility and add a new OBRandomMT class to use in conformer search, etc.? The other alternative would be to replace with the current code but wrap previous methods for backwards compatibility.
Otherwise we have to leave this for a while.
Done.
At the moment, i.e. OB_VERSION < OB_VERSION_CHECK(4, 0, 0), the codes still use OBRandom and thus are backward compatible (rounding error may occur).
They will be automatically changed to utilize OBRandomMT when version 4 is released.
~Explanations of OB_RANDOM_SEED environment variable in man docs are currently commented out.~
@e-kwsm thanks for such opportunity to fix seeds for reproducibility! However after build this pr I still can't repeat results when call obabel from bash, both putting seed argument in and after setting environment variable, for example for this CC1=CC(CNC2=CC=C(NC3CCC4=CC=C(C5=NNN=N5)C=C43)C=C2NC2=CC=C(F)N=C2F)=NC(C)=N1 mol. I build library with 3 option from here. Could you please suggest some workaround?
@alexander-telepov You have to build Open Babel with -DOB_USE_OBRANDOMMT to enable the feature.
@e-kwsm Thanks for such fast reply!