From e43a069f877760310d4e7f813b30ba37ad22a992 Mon Sep 17 00:00:00 2001 From: Romain Egele Date: Sun, 19 Nov 2023 20:02:34 +0100 Subject: [PATCH] Wrong Numpy Array Type When Using Choice in MixedVariableMating (#503) * "n_last" replaced by "period" in termination documentation * Fixing wrong numpy array type (not object) when having Choice in MixedVariableMating --- pymoo/core/mixed.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pymoo/core/mixed.py b/pymoo/core/mixed.py index d49a9b2bb..9c547dea9 100644 --- a/pymoo/core/mixed.py +++ b/pymoo/core/mixed.py @@ -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])