diff --git a/README.rst b/README.rst index 463a0ba..4820605 100644 --- a/README.rst +++ b/README.rst @@ -72,7 +72,7 @@ Requirements * Requires Python 3+. * Numpy and Pylab are required for several functions in ``ec.observers``. * Pylab and Matplotlib are required for several functions in ``ec.analysis``. - * Parallel Python (pp) is required if ``ec.evaluators.parallel_evaluation_pp`` is used. + * Parallel Python (ppft) is required if ``ec.evaluators.parallel_evaluation_pp`` is used. License diff --git a/examples/advanced/parallel_evaluation_pp_example.py b/examples/advanced/parallel_evaluation_pp_example.py index 1acfb76..07d6609 100644 --- a/examples/advanced/parallel_evaluation_pp_example.py +++ b/examples/advanced/parallel_evaluation_pp_example.py @@ -4,7 +4,7 @@ import math # Define an additional "necessary" function for the evaluator -# to see how it must be handled when using pp. +# to see how it must be handled when using ppft. def my_squaring_function(x): return x**2 @@ -15,36 +15,36 @@ def generate_rastrigin(random, args): def evaluate_rastrigin(candidates, args): fitness = [] for cs in candidates: - fit = 10 * len(cs) + sum([(my_squaring_function(x - 1) - - 10 * math.cos(2 * math.pi * (x - 1))) + fit = 10 * len(cs) + sum([(my_squaring_function(x - 1) - + 10 * math.cos(2 * math.pi * (x - 1))) for x in cs]) fitness.append(fit) return fitness - -def main(prng=None, display=False): + +def main(prng=None, display=False): if prng is None: prng = Random() - prng.seed(time()) - + prng.seed(time()) + ea = inspyred.ec.DEA(prng) if display: - ea.observer = inspyred.ec.observers.stats_observer + ea.observer = inspyred.ec.observers.stats_observer ea.terminator = inspyred.ec.terminators.evaluation_termination - final_pop = ea.evolve(generator=generate_rastrigin, + final_pop = ea.evolve(generator=generate_rastrigin, evaluator=inspyred.ec.evaluators.parallel_evaluation_pp, - pp_evaluator=evaluate_rastrigin, + pp_evaluator=evaluate_rastrigin, pp_dependencies=(my_squaring_function,), pp_modules=("math",), - pop_size=8, + pop_size=8, bounder=inspyred.ec.Bounder(-5.12, 5.12), maximize=False, max_evaluations=256, num_inputs=3) - + if display: - best = max(final_pop) + best = max(final_pop) print('Best Solution: \n{0}'.format(str(best))) return ea - + if __name__ == '__main__': main(display=True) diff --git a/inspyred/ec/evaluators.py b/inspyred/ec/evaluators.py index 5ba6e95..ee152c8 100644 --- a/inspyred/ec/evaluators.py +++ b/inspyred/ec/evaluators.py @@ -117,7 +117,7 @@ def parallel_evaluation_pp(candidates, args): documentation for `Parallel Python `_. """ - import pp + import ppft as pp logger = args['_ec'].logger try: