def __breakf(self, i, maxit, p, error): pstr = "Iteration %d of %d, ||error|| %g" % (i, maxit, error) self.timer.lap() if i > 0: iter_left = maxit - i mean_time = self.timer.time_so_far / i pstr += "\t(est. time to end=%d s.)" % (iter_left * mean_time) printf(pstr) if check_stop_flag(self.stop_flag): return 1
def __fetch_constraints(self): u"Fetch constraints from any worker." _sent = False while not _sent: _sent = self.cc.get_options(0, wait=False) if check_stop_flag(self.stop_flag): sys.exit(-1) resp = self.cc.resp_options(0, wait=True) self.no_vars = resp["num_params"] self.mins = resp["min_constr"] self.maxes = resp["max_constr"]
def stop_flag_criteria(ga_engine): u"GA Engine stop criteria depending on stop flag file." path = ga_engine.getParam("stop_file", None) return check_stop_flag(path)