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 DiscreteGene
generatePoint(int positions, double minDistance, double maxDistance)
Returns a shuffledDiscreteGene
.static double
inRange(double min, double max)
Returns a randomdouble
value betweenmin
(inclusive) andmax
(inclusive).static int
inRange(int min, int max)
Returns a randomint
value betweenmin
(inclusive) andmax
(exclusive).
-
-
-
Method Detail
-
inRange
public static int inRange(int min, int max)
Returns a randomint
value betweenmin
(inclusive) andmax
(exclusive). Utilizes theRandomRegistry
from jenetics for thread-safety.- Parameters:
min
- Lower range boundary (inclusive).max
- Upper range boundary (exclusive).- Returns:
- Random
int
value betweenmin
(inclusive) andmax
(exclusive).
-
inRange
public static double inRange(double min, double max)
Returns a randomdouble
value betweenmin
(inclusive) andmax
(inclusive). Utilizes theRandomRegistry
from jenetics for thread-safety.- Parameters:
min
- Lower range boundary (inclusive).max
- Upper range boundary (inclusive).- Returns:
- Random
double
value 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 theRandomRegistry
from 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()
-
-