Skip to content

Commit

Permalink
Wrong Numpy Array Type When Using Choice in MixedVariableMating (#503)
Browse files Browse the repository at this point in the history
* "n_last" replaced by "period" in termination documentation

* Fixing wrong numpy array type (not object) when having Choice in MixedVariableMating
  • Loading branch information
Deathn0t authored Nov 19, 2023
1 parent 52043df commit e43a069
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pymoo/core/mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ def _do(self, problem, pop, n_offsprings, parents=False, **kwargs):
crossover = self.crossover[clazz]
assert crossover.n_parents == XOVER_N_PARENTS and crossover.n_offsprings == XOVER_N_OFFSPRINGS

_parents = [[Individual(X=np.array([parent.X[var] for var in list_of_vars])) for parent in parents] for
parents in pop]
_parents = [
[Individual(X=np.array([parent.X[var] for var in list_of_vars], dtype="O" if clazz is Choice else None))
for parent in parents]
for parents in pop
]

_vars = {e: vars[e] for e in list_of_vars}
_xl = np.array([vars[e].lb if hasattr(vars[e], "lb") else None for e in list_of_vars])
Expand Down

0 comments on commit e43a069

Please sign in to comment.