def gen_can_from_prev(self, prev_can): for i in range(0, self.patience): decs = [dec.generate_valid_val() for dec in self.decs] can = Candidate(dec_vals=list(decs)) for i in range(len(decs)): if random.random() < 0.25: can.dec_vals[i] = prev_can.dec_vals[i] if self.ok(can): return can
def gen_candidate(self): for i in range(0, self.patience): decs = [dec.generate_valid_val() for dec in self.decs] can = Candidate(dec_vals=list(decs)) if self.ok(can): return can