import time from multiprocessing import Process, Pipe from rq.timeouts import JobTimeoutException from .util import get_args from pyvotune.log import logger log = logger() def rq_runner(candidates, args): log.debug("Runner process called") timeout_val = args.setdefault('rq_timeout_fitness', 0) try: rq_timeout = args['rq_timeout'] pickled_args = get_args(args) parent_conn, child_conn = Pipe() proc = Process( target=_child_runner, args=(child_conn, candidates, get_args(args))) try: proc.start() res = parent_conn.poll(rq_timeout)
import inspyred from pyvotune.log import logger log = logger() def stats_observer(population, num_generations, num_evaluations, args): """Print the statistics of the evolutionary computation to the screen. This function displays the statistics of the evolutionary computation to the screen. The output includes the generation number, the current number of evaluations, the maximum fitness, the minimum fitness, the average fitness, and the standard deviation. .. note:: This function makes use of the ``inspyred.ec.analysis.fitness_statistics`` function, so it is subject to the same requirements. .. Arguments: population -- the population of Individuals num_generations -- the number of elapsed generations num_evaluations -- the number of candidate solution evaluations args -- a dictionary of keyword arguments """ stats = inspyred.ec.analysis.fitness_statistics(population) worst_fit = '{0:>10}'.format(stats['worst'])[:10] best_fit = '{0:>10}'.format(stats['best'])[:10] avg_fit = '{0:>10}'.format(stats['mean'])[:10] med_fit = '{0:>10}'.format(stats['median'])[:10]