Class NumberRandom

java.lang.Object
com.adriangarcia.metaheuristics.tsmbfoa.NumberRandom

public class NumberRandom extends Object
This class is used to generate pseudo-random numbers from the Java Random class. Two instances of the Random class are realized in the class, the first uses a 48-bit seed by default and the second one uses a customized seed with up to 64 bits as the initial value.
Version:
1.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new random number generator, sets the seed with the current time in milliseconds, is returned by method: currentTimeMillis()
    NumberRandom(long seed)
    Creates a new pseudo-random number generator, using a single seed: long.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getRandomRankUnif(double min, double max)
    Returns a double uniformly distributed pseudo-random with specified range.
    int
    getRandomRankUnif(int min, int max)
    Returns a int uniformly distributed pseudo-random with specified range.
    double
    Returns a double uniformly distributed pseudo-random, between 0.0 and 1.0
    void
    setRandom(long seed)
    Adjusts the seed of the pseudo-random number generator, using a single seed: long.

    Methods inherited from class java.lang.Object

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

    • NumberRandom

      public NumberRandom()
      Creates a new random number generator, sets the seed with the current time in milliseconds, is returned by method: currentTimeMillis()

      The invocation is as follows:


      NumberRandom nbr = new NumberRandom(); 
    • NumberRandom

      public NumberRandom(long seed)
      Creates a new pseudo-random number generator, using a single seed: long.
      Parameters:
      seed - initial seed

      The invocation is as follows:


      NumberRandom nbr = new NumberRandom(seed);
      See Also:
  • Method Details

    • setRandom

      public void setRandom(long seed)
      Adjusts the seed of the pseudo-random number generator, using a single seed: long.
      Parameters:
      seed - la semilla inicial

      The invocation is as follows:


      nbr.setRandom(seed);
    • getRandomUnif

      public double getRandomUnif()
      Returns a double uniformly distributed pseudo-random, between 0.0 and 1.0
      Returns:
      value double

      The invocation is as follows:


      double random =  nbr.getRandomUnif();
    • getRandomRankUnif

      public double getRandomRankUnif(double min, double max)
      Returns a double uniformly distributed pseudo-random with specified range.
      Parameters:
      min - value double minimum specific range
      max - value double maximum specific range
      Returns:
      value double between specified range

      The invocation is as follows:


      double random =  nbr.getRandomRankUnif(min, max);
    • getRandomRankUnif

      public int getRandomRankUnif(int min, int max)
      Returns a int uniformly distributed pseudo-random with specified range.
      Parameters:
      min - value int minimum specific range
      max - value int maximum specific range
      Returns:
      nĂºmero int between specified range

      The invocation is as follows:


      int random =  nbr.getRandomRankUnif(min, max);