Skip to content

Commit

Permalink
Merge pull request #28 from krzysztofarendt/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
krzysztofarendt authored Feb 6, 2021
2 parents 861393d + fdc48dd commit dc6a602
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modestga/parallel/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions modestga/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit dc6a602

Please sign in to comment.