$darkmode
|
DENOPTIM
|
Tool to generate random numbers and random decisions. More...
Public Member Functions | |
| Randomizer () | |
| Constructor. More... | |
| Randomizer (long seed) | |
| Constructor that specifies the random seed. More... | |
| long | getSeed () |
| void | initialiseRNG () |
| Initializes this random number generator (RNG) using a random seed that is generated on-the-fly randomly. More... | |
| void | initialiseRNG (long seed) |
| Initialized this random number generator using the given seed. More... | |
| double | nextDouble () |
| Returns the next pseudo-random, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence. More... | |
| double | nextNormalDouble () |
| Returns the next pseudo-random, normally distributed double value between 0.0 and 1.0 from this random number generator's sequence. More... | |
| int | nextInt (int i) |
| Returns a pseudo-random, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. More... | |
| boolean | nextBoolean () |
| Returns the next pseudo-random, uniformly distributed boolean value from this random number generator's sequence. More... | |
| boolean | nextBoolean (double prob) |
| Returns whether the next pseudo-random, uniformly distributed double is lower than the specified value. More... | |
| Point3d | getNoisyPoint (double maxAbsValue) |
| Returns a point in three-dimensional space with a random set of coordinates, the absolute value of which is at most the value given as argument. More... | |
| Point3d | getNormallyNoisyPoint (double maxAbsValue) |
| Returns a point in three-dimensional space with a random set of coordinates, the absolute value of which is at most the value given as argument. More... | |
Package Functions | |
| public< T > T | randomlyChooseOne (Collection< T > c) |
| Chooses one member among the given collection. More... | |
| public< T > void | shuffle (List< T > list) |
| Fisher-Yates shuffle of the given list. More... | |
Private Member Functions | |
| void | setSeed (long value) |
| Sets the random seed. More... | |
| MersenneTwister | getRNG () |
| Returns the random number generator. More... | |
| void | print (Object val, String type) |
| Utility to debug: writes some log in file '/tmp/rng_debug_log'. More... | |
| void | initialiseSeed () |
Private Attributes | |
| long | rndSeed = 0L |
| Seed used to control the generation of random numbers and decisions. More... | |
| MersenneTwister | mt = null |
| The implementation of the pseudo-random number generation. More... | |
| final boolean | debug = false |
| local flag used only to enable highly detailed logging. More... | |
Tool to generate random numbers and random decisions.
Definition at line 35 of file Randomizer.java.
| denoptim.utils.Randomizer.Randomizer | ( | ) |
Constructor.
Definition at line 58 of file Randomizer.java.
References denoptim.utils.Randomizer.initialiseRNG().
| denoptim.utils.Randomizer.Randomizer | ( | long | seed | ) |
Constructor that specifies the random seed.
Definition at line 68 of file Randomizer.java.
References denoptim.utils.Randomizer.initialiseRNG().
| Point3d denoptim.utils.Randomizer.getNoisyPoint | ( | double | maxAbsValue | ) |
Returns a point in three-dimensional space with a random set of coordinates, the absolute value of which is at most the value given as argument.
Values are uniformely distributed [-maxAbsValue,maxAbsValue].
| maxAbsValue | the maximum absolute value of any Cartesian coordinate. |
Definition at line 251 of file Randomizer.java.
References denoptim.utils.Randomizer.nextBoolean(), and denoptim.utils.Randomizer.nextDouble().
Referenced by denoptim.fragmenter.FragmentClustererTest.getNoisyPoint(), and denoptim.utils.RandomizerTest.tesGetNoisyPoint().
| Point3d denoptim.utils.Randomizer.getNormallyNoisyPoint | ( | double | maxAbsValue | ) |
Returns a point in three-dimensional space with a random set of coordinates, the absolute value of which is at most the value given as argument.
Values are normally distributed [-maxAbsValue,maxAbsValue].
| maxAbsValue | the maximum absolute value of any Cartesian coordinate. |
Definition at line 275 of file Randomizer.java.
References denoptim.utils.Randomizer.nextNormalDouble().
|
private |
Returns the random number generator.
Ensures there is an initialized one.
Definition at line 124 of file Randomizer.java.
References denoptim.utils.Randomizer.initialiseRNG(), and denoptim.utils.Randomizer.mt.
Referenced by denoptim.utils.Randomizer.nextBoolean(), denoptim.utils.Randomizer.nextDouble(), denoptim.utils.Randomizer.nextInt(), and denoptim.utils.Randomizer.nextNormalDouble().
| long denoptim.utils.Randomizer.getSeed | ( | ) |
Definition at line 89 of file Randomizer.java.
References denoptim.utils.Randomizer.rndSeed.
Referenced by denoptim.programs.RunTimeParameters.getRandomSeed().
| void denoptim.utils.Randomizer.initialiseRNG | ( | ) |
Initializes this random number generator (RNG) using a random seed that is generated on-the-fly randomly.
Definition at line 100 of file Randomizer.java.
References denoptim.utils.Randomizer.initialiseSeed(), denoptim.utils.Randomizer.mt, and denoptim.utils.Randomizer.rndSeed.
Referenced by denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.Randomizer().
| void denoptim.utils.Randomizer.initialiseRNG | ( | long | seed | ) |
Initialized this random number generator using the given seed.
| seed | the seed to be used. |
Definition at line 112 of file Randomizer.java.
References denoptim.utils.Randomizer.mt, denoptim.utils.Randomizer.rndSeed, and denoptim.utils.Randomizer.setSeed().
|
private |
Definition at line 340 of file Randomizer.java.
References denoptim.utils.Randomizer.rndSeed.
Referenced by denoptim.utils.Randomizer.initialiseRNG().
| boolean denoptim.utils.Randomizer.nextBoolean | ( | ) |
Returns the next pseudo-random, uniformly distributed boolean value from this random number generator's sequence.
Definition at line 220 of file Randomizer.java.
References denoptim.utils.Randomizer.debug, denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.print().
Referenced by denoptim.ga.GraphOperations.addFusedRing(), denoptim.ga.GraphOperations.applySymmetry(), denoptim.utils.Randomizer.getNoisyPoint(), and denoptim.ga.EAUtils.searchRingFusionSites().
| boolean denoptim.utils.Randomizer.nextBoolean | ( | double | prob | ) |
Returns whether the next pseudo-random, uniformly distributed double is lower than the specified value.
| prob | the bound on the random double. |
true is the next double is lower than the specified value. Definition at line 237 of file Randomizer.java.
References denoptim.utils.Randomizer.nextDouble().
| double denoptim.utils.Randomizer.nextDouble | ( | ) |
Returns the next pseudo-random, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
Definition at line 171 of file Randomizer.java.
References denoptim.utils.Randomizer.debug, denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.print().
Referenced by denoptim.utils.Randomizer.getNoisyPoint(), denoptim.utils.Randomizer.nextBoolean(), denoptim.ga.SelectionHelper.performRWS(), denoptim.ga.SelectionHelper.performSUS(), denoptim.ga.EAUtils.pickNewCandidateGenerationMode(), and denoptim.utils.RandomizerTest.testRandomizerReproducibility().
| int denoptim.utils.Randomizer.nextInt | ( | int | i | ) |
Returns a pseudo-random, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
| i | the bound on the random number to be returned. Must be positive. |
Definition at line 205 of file Randomizer.java.
References denoptim.utils.Randomizer.debug, denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.print().
Referenced by denoptim.molecularmodeling.ThreeDimTreeBuilder.getRandomPoint(), denoptim.fragspace.FragmentSpace.makeRandomScaffold(), denoptim.graph.rings.RandomCombOfRingsIterator.next(), denoptim.utils.Randomizer.randomlyChooseOne(), and denoptim.utils.Randomizer.shuffle().
| double denoptim.utils.Randomizer.nextNormalDouble | ( | ) |
Returns the next pseudo-random, normally distributed double value between 0.0 and 1.0 from this random number generator's sequence.
Standard deviation 1.0.
Definition at line 188 of file Randomizer.java.
References denoptim.utils.Randomizer.debug, denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.print().
Referenced by denoptim.utils.Randomizer.getNormallyNoisyPoint(), and denoptim.fragmenter.FragmentClusterer.getRMSDStatsOfNoisyDistorsions().
|
private |
Utility to debug: writes some log in file '/tmp/rng_debug_log'.
Definition at line 138 of file Randomizer.java.
References denoptim.io.DenoptimIO.writeData().
Referenced by denoptim.utils.Randomizer.nextBoolean(), denoptim.utils.Randomizer.nextDouble(), denoptim.utils.Randomizer.nextInt(), and denoptim.utils.Randomizer.nextNormalDouble().
|
package |
Chooses one member among the given collection.
Works on either ordered or unordered collections. However, be aware! If the choice you hare asking this method to make has to be random but reproducible, i.e., controlled by the random seed that configures the random number generation, so that independent runs of pseudo-random experiments will produce the same numerical outcome, then the collection must have a given order. A type Set is permitted by is not compatible with the reproducibility requirement.
Definition at line 300 of file Randomizer.java.
References denoptim.utils.Randomizer.nextInt().
Referenced by denoptim.ga.GraphOperations.addFusedRing(), denoptim.ga.GraphOperations.addRing(), denoptim.fragspace.APMapFinder.findAllMappings(), denoptim.fragspace.FragmentSpace.getCappingFragment(), denoptim.ga.GraphOperations.getRCVForSrcAp(), denoptim.ga.EAUtils.performFBCC(), denoptim.ga.SelectionHelper.performRandomSelection(), denoptim.ga.SelectionHelper.performTournamentSelection(), denoptim.graph.DGraph.replaceSingleSubGraph(), denoptim.programs.genetweeker.GeneOpsRunner.runMutation(), denoptim.programs.genetweeker.GeneOpsRunner.runXOver(), denoptim.ga.EAUtils.selectNonScaffoldNonCapVertex(), and denoptim.utils.RandomizerTest.testRandomlyChooseOne().
|
private |
Sets the random seed.
| value | the new value |
Definition at line 79 of file Randomizer.java.
References denoptim.utils.Randomizer.rndSeed.
Referenced by denoptim.utils.Randomizer.initialiseRNG().
|
package |
Fisher-Yates shuffle of the given list.
The outcome is reproducible for a given random seed of this Randomizer.
| <T> | the type of the list elements. |
| list | the list to shuffle in place. |
Definition at line 327 of file Randomizer.java.
References denoptim.utils.Randomizer.nextInt().
Referenced by denoptim.ga.GraphOperations.locateCompatibleXOverPoints().
|
private |
local flag used only to enable highly detailed logging.
Definition at line 51 of file Randomizer.java.
Referenced by denoptim.utils.Randomizer.nextBoolean(), denoptim.utils.Randomizer.nextDouble(), denoptim.utils.Randomizer.nextInt(), and denoptim.utils.Randomizer.nextNormalDouble().
|
private |
The implementation of the pseudo-random number generation.
Definition at line 46 of file Randomizer.java.
Referenced by denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.initialiseRNG().
|
private |
Seed used to control the generation of random numbers and decisions.
This allows to make these random numbers/decisions reproducible.
Definition at line 41 of file Randomizer.java.
Referenced by denoptim.utils.Randomizer.getSeed(), denoptim.utils.Randomizer.initialiseRNG(), denoptim.utils.Randomizer.initialiseSeed(), and denoptim.utils.Randomizer.setSeed().