Class RandomUtils


  • public class RandomUtils
    extends Object
    All utility methods associated with randomness.
    • Constructor Detail

      • RandomUtils

        public RandomUtils()
    • Method Detail

      • inRange

        public static int inRange​(int min,
                                  int max)
        Returns a random int value between min (inclusive) and max (exclusive). Utilizes the RandomRegistry from jenetics for thread-safety.
        Parameters:
        min - Lower range boundary (inclusive).
        max - Upper range boundary (exclusive).
        Returns:
        Random int value between min (inclusive) and max (exclusive).
      • inRange

        public static double inRange​(double min,
                                     double max)
        Returns a random double value between min (inclusive) and max (inclusive). Utilizes the RandomRegistry from jenetics for thread-safety.
        Parameters:
        min - Lower range boundary (inclusive).
        max - Upper range boundary (inclusive).
        Returns:
        Random double value between min (inclusive) and max (inclusive).
      • generatePoint

        public static DiscreteGene generatePoint​(int positions,
                                                 double minDistance,
                                                 double maxDistance)
        Returns a shuffled DiscreteGene. The point's position is randomly selected in the range [0, positions] and the distance is chosen in the range [minDistance, maxDistance). Utilizes the RandomRegistry from jenetics for thread-safety.
        Parameters:
        positions - upper boundary for the points position
        minDistance - Minimal distance for the point (inclusive).
        maxDistance - Maximal distance for the point (exclusive).
        Returns:
        shuffled discrete point
        See Also:
        Random.nextDouble()