From 314db825aaa6484df469e7f1445b9aac6171fd6f Mon Sep 17 00:00:00 2001 From: Krzysztof Arendt Date: Sat, 6 Feb 2021 17:14:31 +0100 Subject: [PATCH 1/3] Add test for passing args with 2 workers --- modestga/test/test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modestga/test/test.py b/modestga/test/test.py index 69589b6..603082f 100644 --- a/modestga/test/test.py +++ b/modestga/test/test.py @@ -188,6 +188,26 @@ def fun_args_wrapper(x, *args): options=options, workers=1) + def test_args_passing_2workers(self): + x0 = tuple(np.random.random(5)) + bounds = tuple([(-1, 5) for i in x0]) + args = ['arg0_ok', 'arg1_ok'] + options = {'generations': 3} + + def fun_args_wrapper(x, *args): + arg0 = args[0] + arg1 = args[1] + self.assertEqual(arg0, 'arg0_ok') + self.assertEqual(arg1, 'arg1_ok') + return self.fun(x) + + res = ga.minimize(fun_args_wrapper, + bounds, + x0=x0, + args=args, + options=options, + workers=2) + if __name__ == "__main__": logging.basicConfig(filename="test.log", level="DEBUG", filemode="w") From 40137f769ec2b23c134ef316d2ca7578dd13e71f Mon Sep 17 00:00:00 2001 From: Krzysztof Arendt Date: Sat, 6 Feb 2021 17:16:34 +0100 Subject: [PATCH 2/3] Pass args to population in full parallel --- modestga/parallel/full.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modestga/parallel/full.py b/modestga/parallel/full.py index b181b5b..ef2dcdb 100644 --- a/modestga/parallel/full.py +++ b/modestga/parallel/full.py @@ -26,7 +26,7 @@ def parallel_pop(pipe, fun = cloudpickle.loads(pickled_fun) # Initialize population - pop = population.Population(pop_size, bounds, fun, evaluate=False) + pop = population.Population(pop_size, bounds, fun, args=args, evaluate=False) while not end_event.is_set(): # Check if there's some data From 8302ffeec0000b826aaf2e5b1ea2dc6e02066360 Mon Sep 17 00:00:00 2001 From: Krzysztof Arendt Date: Sat, 6 Feb 2021 17:39:06 +0100 Subject: [PATCH 3/3] Bump version to 0.5.8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6f347f0..bd905af 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import setuptools setup(name='modestga', - version='0.5.7', + version='0.5.8', description='Genetic Algorithm minimization', url='https://github.com/krzysztofarendt/modestga', keywords='genetic algorithm optimization',