Skip to content

Commit

Permalink
Fix Invalid integer sampling when upper and lower bounds are the same (
Browse files Browse the repository at this point in the history
  • Loading branch information
blankjul committed Feb 27, 2023
1 parent 0da3241 commit 6795ac3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pymoo/operators/sampling/rnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6795ac3

Please sign in to comment.