$darkmode
DENOPTIM
denoptim.utils.Randomizer Class Reference

Tool to generate random numbers and random decisions. More...

Collaboration diagram for denoptim.utils.Randomizer:
[legend]

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

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

Detailed Description

Tool to generate random numbers and random decisions.

Definition at line 34 of file Randomizer.java.

Constructor & Destructor Documentation

◆ Randomizer() [1/2]

denoptim.utils.Randomizer.Randomizer ( )

Constructor.

Definition at line 57 of file Randomizer.java.

References denoptim.utils.Randomizer.initialiseRNG().

Here is the call graph for this function:

◆ Randomizer() [2/2]

denoptim.utils.Randomizer.Randomizer ( long  seed)

Constructor that specifies the random seed.

Definition at line 67 of file Randomizer.java.

References denoptim.utils.Randomizer.initialiseRNG().

Here is the call graph for this function:

Member Function Documentation

◆ getNoisyPoint()

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

Parameters
maxAbsValuethe maximum absolute value of any Cartesian coordinate.
Returns
a point in Cartesian space with a random position.

Definition at line 250 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNormallyNoisyPoint()

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

Parameters
maxAbsValuethe maximum absolute value of any Cartesian coordinate.
Returns
a point in Cartesian space with a random position.

Definition at line 274 of file Randomizer.java.

References denoptim.utils.Randomizer.nextNormalDouble().

Here is the call graph for this function:

◆ getRNG()

MersenneTwister denoptim.utils.Randomizer.getRNG ( )
private

Returns the random number generator.

Ensures there is an initialized one.

Returns
the random number generator

Definition at line 123 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSeed()

long denoptim.utils.Randomizer.getSeed ( )
Returns
the current random seed.

Definition at line 88 of file Randomizer.java.

References denoptim.utils.Randomizer.rndSeed.

Referenced by denoptim.programs.RunTimeParameters.getRandomSeed().

Here is the caller graph for this function:

◆ initialiseRNG() [1/2]

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 99 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseRNG() [2/2]

void denoptim.utils.Randomizer.initialiseRNG ( long  seed)

Initialized this random number generator using the given seed.

Parameters
seedthe seed to be used.

Definition at line 111 of file Randomizer.java.

References denoptim.utils.Randomizer.mt, denoptim.utils.Randomizer.rndSeed, and denoptim.utils.Randomizer.setSeed().

Here is the call graph for this function:

◆ initialiseSeed()

void denoptim.utils.Randomizer.initialiseSeed ( )
private

Definition at line 320 of file Randomizer.java.

References denoptim.utils.Randomizer.rndSeed.

Referenced by denoptim.utils.Randomizer.initialiseRNG().

Here is the caller graph for this function:

◆ nextBoolean() [1/2]

boolean denoptim.utils.Randomizer.nextBoolean ( )

Returns the next pseudo-random, uniformly distributed boolean value from this random number generator's sequence.

Returns
the next boolean.

Definition at line 219 of file Randomizer.java.

References denoptim.utils.Randomizer.debug, denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.print().

Referenced by denoptim.ga.GraphOperations.applySymmetry(), denoptim.utils.Randomizer.getNoisyPoint(), and denoptim.ga.SelectionHelper.performTournamentSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextBoolean() [2/2]

boolean denoptim.utils.Randomizer.nextBoolean ( double  prob)

Returns whether the next pseudo-random, uniformly distributed double is lower than the specified value.

Parameters
probthe bound on the random double.
Returns
true is the next double is lower than the specified value.

Definition at line 236 of file Randomizer.java.

References denoptim.utils.Randomizer.nextDouble().

Here is the call graph for this function:

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

Returns
the next double between 0.0 and 1.0;

Definition at line 170 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextInt()

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.

Parameters
ithe bound on the random number to be returned. Must be positive.
Returns
the next integer between 0 and the specified value.

Definition at line 204 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(), and denoptim.utils.Randomizer.randomlyChooseOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextNormalDouble()

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.

Returns
the next normally distributed double between 0.0 and 1.0, with standard deviation 1.0.

Definition at line 187 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

void denoptim.utils.Randomizer.print ( Object  val,
String  type 
)
private

Utility to debug: writes some log in file '/tmp/rng_debug_log'.

Definition at line 137 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ randomlyChooseOne()

public< T > T denoptim.utils.Randomizer.randomlyChooseOne ( Collection< T >  c)
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.

Returns
the chosen item or null if the given list is empty.

Definition at line 299 of file Randomizer.java.

References denoptim.utils.Randomizer.nextInt().

Referenced by 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.programs.genetweeker.GeneOpsRunner.runXOver(), denoptim.ga.EAUtils.selectNonScaffoldNonCapVertex(), and denoptim.utils.RandomizerTest.testRandomlyChooseOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSeed()

void denoptim.utils.Randomizer.setSeed ( long  value)
private

Sets the random seed.

Parameters
valuethe new value

Definition at line 78 of file Randomizer.java.

References denoptim.utils.Randomizer.rndSeed.

Referenced by denoptim.utils.Randomizer.initialiseRNG().

Here is the caller graph for this function:

Member Data Documentation

◆ debug

final boolean denoptim.utils.Randomizer.debug = false
private

◆ mt

MersenneTwister denoptim.utils.Randomizer.mt = null
private

The implementation of the pseudo-random number generation.

Definition at line 45 of file Randomizer.java.

Referenced by denoptim.utils.Randomizer.getRNG(), and denoptim.utils.Randomizer.initialiseRNG().

◆ rndSeed

long denoptim.utils.Randomizer.rndSeed = 0L
private

Seed used to control the generation of random numbers and decisions.

This allows to make these random numbers/decisions reproducible.

Definition at line 40 of file Randomizer.java.

Referenced by denoptim.utils.Randomizer.getSeed(), denoptim.utils.Randomizer.initialiseRNG(), denoptim.utils.Randomizer.initialiseSeed(), and denoptim.utils.Randomizer.setSeed().


The documentation for this class was generated from the following file: