From 6795ac3ed1febe35ecac62ef04c88cd1714a1ee4 Mon Sep 17 00:00:00 2001 From: Julian Blank Date: Sun, 26 Feb 2023 20:11:46 -0800 Subject: [PATCH] Fix Invalid integer sampling when upper and lower bounds are the same (#388) --- pymoo/operators/sampling/rnd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymoo/operators/sampling/rnd.py b/pymoo/operators/sampling/rnd.py index 8cb2c6da1..946defcda 100644 --- a/pymoo/operators/sampling/rnd.py +++ b/pymoo/operators/sampling/rnd.py @@ -29,8 +29,8 @@ def _do(self, problem, n_samples, **kwargs): class IntegerRandomSampling(FloatRandomSampling): def _do(self, problem, n_samples, **kwargs): - X = super()._do(problem, n_samples, **kwargs) - return np.around(X).astype(int) + n, (xl, xu) = problem.n_var, problem.bounds() + return np.column_stack([np.random.randint(xl[k], xu[k]+1, size=(n_samples)) for k in range(n)]) class PermutationRandomSampling(Sampling):