Package de.uka.ipd.sdq.simucomframework
Class SimuComDefaultRandomNumberGenerator
- java.lang.Object
-
- de.uka.ipd.sdq.simucomframework.SimuComDefaultRandomNumberGenerator
-
- All Implemented Interfaces:
de.uka.ipd.sdq.probfunction.math.IRandomGenerator
public class SimuComDefaultRandomNumberGenerator extends Object implements de.uka.ipd.sdq.probfunction.math.IRandomGenerator
SimuComDefaultRandomNumberGenerator generates random numbers in a separate thread. SimuComDefaultRandomNumberGenerator currently implements the interface for random numbers needed by the prob function package. However, internally it relies on a random stream implementing the RandomStream interface from JSS. SimuComDefaultRandomNumberGenerator implementsRandomStream
as the functions likeLogNormDistFunction
andNormDistFunction
in package de.uka.ipd.sdq.simucomframework.variables.functions. This class is optimized for multi-cores, thus speeding up simulation significantly for at least two cores. Here everything related to random numbers in SimuCom should be then localised, especially seed initialisation and the multi-threading stuff (which was - as always - deadlock prone while implementing). Also it locates the dependency to the [0..1] random number generator to a single place in the source (remember this needs to be changed to get away from GPL code...).
-
-
Constructor Summary
Constructors Constructor Description SimuComDefaultRandomNumberGenerator(long[] randomSeed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
void
nextArrayOfDouble(double[] u, int start, int n)
Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start.void
nextArrayOfInt(int i, int j, int[] u, int start, int n)
Generates n (pseudo)random numbers from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream and stores the result in the array u starting at index start.double
nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), using this stream, after advancing its state by one step.int
nextInt(int i, int j)
Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream.double
random()
Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), using this stream, after advancing its state by one step.void
resetNextSubstream()
does nothing because this implementation does not support any substreamsvoid
resetStartStream()
does nothing because this implementation does not support any substreamsvoid
resetStartSubstream()
does nothing because this implementation does not support any substreams
-
-
-
Method Detail
-
random
public double random()
Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), using this stream, after advancing its state by one step. The generators programmed in SSJ never return the values 0 or 1. This method takes a previously generated random number from the asynchronously running generator thread.- Specified by:
random
in interfacede.uka.ipd.sdq.probfunction.math.IRandomGenerator
-
dispose
public void dispose()
- Specified by:
dispose
in interfacede.uka.ipd.sdq.probfunction.math.IRandomGenerator
-
nextArrayOfDouble
public void nextArrayOfDouble(double[] u, int start, int n)
Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start. (doc fromRandomStream
)- Parameters:
u
- - array that will contain the generated uniformsstart
- - starting index, in the array u, to write uniforms fromn
- - number of uniforms to generate
-
nextArrayOfInt
public void nextArrayOfInt(int i, int j, int[] u, int start, int n)
Generates n (pseudo)random numbers from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream and stores the result in the array u starting at index start. (Calls nextInt n times.) (doc fromRandomStream
- Parameters:
i
- - smallest integer that can be generatedj
- - greatest integer that can be generatedu
- - array that will contain the generated valuesstart
- - starting index, in the array u, to write integers fromn
- - number of values being generated
-
nextDouble
public double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), using this stream, after advancing its state by one step. The generators programmed in SSJ never return the values 0 or 1. Calls random() which takes a previously generated random number from the asynchronously running generator thread.
-
nextInt
public int nextInt(int i, int j)
Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream. (Calls nextDouble once.) Copied fromRandomStreamBase
.- Parameters:
i
- - smallest integer that can be generatedj
- - greatest integer that can be generated
-
resetNextSubstream
public void resetNextSubstream()
does nothing because this implementation does not support any substreams
-
resetStartStream
public void resetStartStream()
does nothing because this implementation does not support any substreams
-
resetStartSubstream
public void resetStartSubstream()
does nothing because this implementation does not support any substreams
-
-