From b0002306c747885cc7177eb11ea253cb8250d5e4 Mon Sep 17 00:00:00 2001 From: Nikita Malinin Date: Mon, 18 Sep 2023 15:03:40 +0200 Subject: [PATCH] Update pymoo version (#2145) ### Changes - Fixed `pymoo` version. - Added patch for the `IntegerRandomSampling` to avoid errors. ### Reason for changes - Bugfix --- .../torch/nas/bootstrapNAS/search/search.py | 12 +++++++++++- setup.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nncf/experimental/torch/nas/bootstrapNAS/search/search.py b/nncf/experimental/torch/nas/bootstrapNAS/search/search.py index 3858d2eeef5..a20faf6eb43 100644 --- a/nncf/experimental/torch/nas/bootstrapNAS/search/search.py +++ b/nncf/experimental/torch/nas/bootstrapNAS/search/search.py @@ -48,6 +48,16 @@ ValFnType = Callable[[TModel, DataLoaderType], float] +class FixIntegerRandomSampling(IntegerRandomSampling): + """ + Wrapper for the IntegerRandomSampling with the fix for https://github.com/anyoptimization/pymoo/issues/388. + """ + + def _do(self, problem, n_samples, **kwargs): + 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 EvolutionaryAlgorithms(Enum): NSGA2 = "NSGA2" @@ -207,7 +217,7 @@ def __init__( if evo_algo == EvolutionaryAlgorithms.NSGA2.value: self._algorithm = NSGA2( pop_size=self.search_params.population, - sampling=IntegerRandomSampling(), + sampling=FixIntegerRandomSampling(), crossover=SBX( prob=self.search_params.crossover_prob, eta=self.search_params.crossover_eta, diff --git a/setup.py b/setup.py index 78d6a03c626..44078324c7e 100644 --- a/setup.py +++ b/setup.py @@ -112,7 +112,7 @@ def find_version(*file_paths): "pandas>=1.1.5,<2.1", "psutil", "pydot>=1.4.1", - "pymoo @ git+https://github.com/anyoptimization/pymoo.git@695cb26923903f872c7256a9013609769f3cc2bd", + "pymoo>=0.6.0.1", # The recent pyparsing major version update seems to break # integration with networkx - the graphs parsed from current .dot # reference files no longer match against the graphs produced in tests.