def __call__(self, population, num_generations, num_evaluations, args): if self.progress is None: self.max_evaluations = args.get('max_evaluations', 50000) self.progress = ProgressBar(self.max_evaluations) self.progress.start() if num_evaluations % args.get('n', 1) == 0: if num_evaluations > self.max_evaluations: self.progress.update(self.max_evaluations) else: self.progress.update(num_evaluations)
class ProgressObserver(object): """ Progress bar to in command line """ __name__ = "Progress Observer" def __init__(self): self.progress = None def __call__(self, population, num_generations, num_evaluations, args): if self.progress is None: self.max_evaluations = args.get('max_evaluations', 50000) self.progress = ProgressBar(self.max_evaluations) self.progress.start() if num_evaluations % args.get('n', 1) == 0: if num_evaluations > self.max_evaluations: self.progress.update(self.max_evaluations) else: self.progress.update(num_evaluations) def reset(self): self.progress = None def end(self): self.progress.end()
def _process_message(self, message): i = message['index'] if not i in self.progress: print("") label = "Island %i: " % (i + 1) pos = abs(len(self.clients) - i) writer = self.TerminalWriter((self.terminal.height or 1) - pos, self.terminal) self.progress[i] = ProgressBar(label=label, fd=writer, size=message['max_evaluations']) self.progress[i].start() self.progress[i].update(message['num_evaluations'])
def _create_client(self, i): self.clients[i] = IPythonNotebookMultiprocessProgressObserverClient(queue=self.queue, index=i) label = "Island %i" % (i + 1) self.progress[i] = ProgressBar(label=label, color=self.color_map[i])