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 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") 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',