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 implements RandomStream as the functions like LogNormDistFunction and NormDistFunction 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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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
    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
    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
    does nothing because this implementation does not support any substreams
    void
    does nothing because this implementation does not support any substreams
    void
    does nothing because this implementation does not support any substreams

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimuComDefaultRandomNumberGenerator

      public SimuComDefaultRandomNumberGenerator(long[] randomSeed)
  • Method Details

    • 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 interface de.uka.ipd.sdq.probfunction.math.IRandomGenerator
    • dispose

      public void dispose()
      Specified by:
      dispose in interface de.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 from RandomStream)
      Parameters:
      u - - array that will contain the generated uniforms
      start - - starting index, in the array u, to write uniforms from
      n - - 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 from RandomStream
      Parameters:
      i - - smallest integer that can be generated
      j - - greatest integer that can be generated
      u - - array that will contain the generated values
      start - - starting index, in the array u, to write integers from
      n - - 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 from RandomStreamBase.
      Parameters:
      i - - smallest integer that can be generated
      j - - 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