def heap_select(self, heap_list, pop_count, fitness_calc): fitness_calc(heap_list) if self.use_nsga2: selected = selection.selNSGA2(heap_list, pop_count, nd='log') else: selected = selection.sortLogNondominated(heap_list, pop_count, True) selected = [ s for slist in selected for s in slist] # print("selected", selected) return selected
def heap_pop(self, heap_list, pop_count, fitness_calc): fitness_calc(heap_list) if self.use_nsga2: popped = selection.selNSGA2(heap_list, pop_count, nd='log') else: popped = selection.sortLogNondominated(heap_list, pop_count, True) popped = [ p for plist in popped for p in plist] # print("popped", popped) heap_list = [m for m in heap_list if not m in popped] if self.max_heap_size > 0 and len(heap_list) > self.max_heap_size: heap_list = heap_list[:self.max_heap_size] return popped, heap_list