openbabel icon indicating copy to clipboard operation
openbabel copied to clipboard

Reimplement OpenBabel::OBRandom as a wrapper of std::mt19937_64

Open e-kwsm opened this issue 5 years ago • 8 comments

Mersenne twister is one of high-quality PRNGs and available on all platforms since C++11.

e-kwsm avatar May 25 '20 06:05 e-kwsm

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.

ghutchis avatar May 25 '20 19:05 ghutchis

I've said it before but we should be working to remove all uses of random numbers in the library.

baoilleach avatar May 26 '20 07:05 baoilleach

@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.

ghutchis avatar May 26 '20 13:05 ghutchis

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.

ghutchis avatar Aug 03 '22 14:08 ghutchis

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 avatar Aug 17 '22 02:08 e-kwsm

@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 avatar Sep 26 '22 18:09 alexander-telepov

@alexander-telepov You have to build Open Babel with -DOB_USE_OBRANDOMMT to enable the feature.

e-kwsm avatar Sep 28 '22 04:09 e-kwsm

@e-kwsm Thanks for such fast reply!

alexander-telepov avatar Sep 28 '22 07:09 alexander-telepov