Beispiel #1
0
 def step(self, count=1):
     for i in range(count):
         self.age += 1
         self.evaluate()
         if len(self.children_before_eval) == 0:
             new_generation = self.survival_selection()
             self.population.extend(new_generation)
             parents = self.select_parents()
             self.children_before_eval = crossoverer.rex(parents, self.nchi)
             for i in self.children_before_eval:
                 i.birth_year = self.age
Beispiel #2
0
 def until_goal(self, goal=10e-7, max_count=200000):
     for i in range(max_count):
         self.age += 1
         self.evaluate()
         if len(self.children_before_eval) == 0:
             if self.get_best_individual().raw_fitness < goal:
                 # print("goal")
                 return True
             new_generation = self.survival_selection()
             self.population.extend(new_generation)
             parents = self.select_parents()
             self.children_before_eval = crossoverer.rex(parents, self.nchi)
             for i in self.children_before_eval:
                 i.birth_year = self.age
     # print("time is up")
     return False
Beispiel #3
0
 def generate_first_children(self):
     parents = self.select_parents()
     self.children_before_eval = crossoverer.rex(parents, self.nchi)
     self.children_after_eval = []
Beispiel #4
0
 def op(x):
     x.sort(key=lambda i: i.fitness)
     return crossoverer.rex(x[:npar])
Beispiel #5
0
def gaq_op_plain_origopt(x):
    x.sort(key=lambda i: i.fitness)
    n = x[0].n
    return crossoverer.rex(x[:n + 1])
Beispiel #6
0
def gaq_op_plain_origopt(x):
    x.sort(key=lambda i: i.fitness)
    parents = x[:n + 1]
    for p in parents:
        p.state = State.USED_IN_GAQ
    return crossoverer.rex(parents)