From cf56c5b8d35988896bfac6e2702b0cd04a8fa4b2 Mon Sep 17 00:00:00 2001 From: Gideon Oludeyi <49620086+gideonoludeyi@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:47:59 -0400 Subject: [PATCH 1/2] fix NoCrossover missing offsprings --- pymoo/operators/crossover/nox.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pymoo/operators/crossover/nox.py b/pymoo/operators/crossover/nox.py index 38fee1a7..26155b08 100644 --- a/pymoo/operators/crossover/nox.py +++ b/pymoo/operators/crossover/nox.py @@ -1,3 +1,5 @@ +import itertools + from pymoo.core.crossover import Crossover from pymoo.core.population import Population @@ -7,4 +9,4 @@ def __init__(self, *, n_parents=1, n_offsprings=1, prob=0.0, **kwargs): super().__init__(n_parents, n_offsprings, prob, **kwargs) def do(self, problem, pop, *args, random_state, **kwargs): - return Population.create(*[random_state.choice(parents) for parents in pop]) + return Population.create(*itertools.chain.from_iterable(pop)) From ab1dc5b7f73b4421c1fd7c2349f61c891643b7b4 Mon Sep 17 00:00:00 2001 From: Gideon Oludeyi <49620086+gideonoludeyi@users.noreply.github.com> Date: Sun, 3 Aug 2025 18:22:03 -0400 Subject: [PATCH 2/2] enforce consistent number of parents and offsprings in NoCrossover --- pymoo/operators/crossover/nox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymoo/operators/crossover/nox.py b/pymoo/operators/crossover/nox.py index 26155b08..7485cb43 100644 --- a/pymoo/operators/crossover/nox.py +++ b/pymoo/operators/crossover/nox.py @@ -5,8 +5,8 @@ class NoCrossover(Crossover): - def __init__(self, *, n_parents=1, n_offsprings=1, prob=0.0, **kwargs): - super().__init__(n_parents, n_offsprings, prob, **kwargs) + def __init__(self, *, n_parents=1, prob=0.0, **kwargs): + super().__init__(n_parents, n_parents, prob, **kwargs) def do(self, problem, pop, *args, random_state, **kwargs): return Population.create(*itertools.chain.from_iterable(pop))