Skip to content

Commit

Permalink
Merge pull request #169 from JanisHe/bugfix/ordinal_parameters
Browse files Browse the repository at this point in the history
fixed bug for ordinal parameters (second round)
  • Loading branch information
mcw92 authored Dec 10, 2024
2 parents 50fdddf + fff8e05 commit c871665
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion propulate/propagators/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def __call__(self, ind: Individual) -> Individual: # type: ignore[override]
for i in to_mutate:
if isinstance(ind[i], int):
# Return randomly selected element from int range(start, stop, step).
ind[i] = self.rng.randint(*self.limits[i])
if len(self.limits[i]) == 2:
ind[i] = self.rng.randint(*self.limits[i])
# Return randomly selected element from given tuple of elements.
else:
ind[i] = self.rng.choice(self.limits[i])
elif isinstance(ind[i], float):
# Return random floating point number within limits.
ind[i] = self.rng.uniform(*self.limits[i])
Expand Down

0 comments on commit c871665

Please sign in to comment.