Package evo.search.util
Class RandomUtils
- java.lang.Object
-
- evo.search.util.RandomUtils
-
public class RandomUtils extends Object
All utility methods associated with randomness.
-
-
Constructor Summary
Constructors Constructor Description RandomUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DiscreteGenegeneratePoint(int positions, double minDistance, double maxDistance)Returns a shuffledDiscreteGene.static doubleinRange(double min, double max)Returns a randomdoublevalue betweenmin(inclusive) andmax(inclusive).static intinRange(int min, int max)Returns a randomintvalue betweenmin(inclusive) andmax(exclusive).
-
-
-
Method Detail
-
inRange
public static int inRange(int min, int max)Returns a randomintvalue betweenmin(inclusive) andmax(exclusive). Utilizes theRandomRegistryfrom jenetics for thread-safety.- Parameters:
min- Lower range boundary (inclusive).max- Upper range boundary (exclusive).- Returns:
- Random
intvalue betweenmin(inclusive) andmax(exclusive).
-
inRange
public static double inRange(double min, double max)Returns a randomdoublevalue betweenmin(inclusive) andmax(inclusive). Utilizes theRandomRegistryfrom jenetics for thread-safety.- Parameters:
min- Lower range boundary (inclusive).max- Upper range boundary (inclusive).- Returns:
- Random
doublevalue betweenmin(inclusive) andmax(inclusive).
-
generatePoint
public static DiscreteGene generatePoint(int positions, double minDistance, double maxDistance)
Returns a shuffledDiscreteGene. The point's position is randomly selected in the range [0,positions] and the distance is chosen in the range [minDistance,maxDistance). Utilizes theRandomRegistryfrom jenetics for thread-safety.- Parameters:
positions- upper boundary for the points positionminDistance- Minimal distance for the point (inclusive).maxDistance- Maximal distance for the point (exclusive).- Returns:
- shuffled discrete point
- See Also:
Random.nextDouble()
-
-