diff --git a/eoh/src/eoh/methods/ael/ael.py b/eoh/src/eoh/methods/ael/ael.py index e3edc780..d2ea8f0f 100644 --- a/eoh/src/eoh/methods/ael/ael.py +++ b/eoh/src/eoh/methods/ael/ael.py @@ -135,21 +135,21 @@ def run(self): op_w = self.operator_weights[i] if (np.random.rand() < op_w): parents, offsprings = interface_ec.get_algorithm(population, op) - self.add2pop(population, offsprings) # Check duplication, and add the new offspring - for off in offsprings: - print(" Obj: ", off['objective'], end="|") - # if is_add: - # data = {} - # for i in range(len(parents)): - # data[f"parent{i + 1}"] = parents[i] - # data["offspring"] = offspring - # with open(self.output_path + "/results/history/pop_" + str(pop + 1) + "_" + str( - # na) + "_" + op + ".json", "w") as file: - # json.dump(data, file, indent=5) - # populatin management - size_act = min(len(population), self.pop_size) - population = self.manage.population_management(population, size_act) - print() + self.add2pop(population, offsprings) # Check duplication, and add the new offspring + for off in offsprings: + print(" Obj: ", off['objective'], end="|") + # if is_add: + # data = {} + # for i in range(len(parents)): + # data[f"parent{i + 1}"] = parents[i] + # data["offspring"] = offspring + # with open(self.output_path + "/results/history/pop_" + str(pop + 1) + "_" + str( + # na) + "_" + op + ".json", "w") as file: + # json.dump(data, file, indent=5) + # populatin management + size_act = min(len(population), self.pop_size) + population = self.manage.population_management(population, size_act) + print() # Save population to a file @@ -168,4 +168,3 @@ def run(self): for i in range(len(population)): print(str(population[i]['objective']) + " ", end="") print() - diff --git a/eoh/src/eoh/methods/eoh/eoh.py b/eoh/src/eoh/methods/eoh/eoh.py index e160b7d2..16030f8e 100644 --- a/eoh/src/eoh/methods/eoh/eoh.py +++ b/eoh/src/eoh/methods/eoh/eoh.py @@ -149,21 +149,21 @@ def run(self): op_w = self.operator_weights[i] if (np.random.rand() < op_w): parents, offsprings = interface_ec.get_algorithm(population, op) - self.add2pop(population, offsprings) # Check duplication, and add the new offspring - for off in offsprings: - print(" Obj: ", off['objective'], end="|") - # if is_add: - # data = {} - # for i in range(len(parents)): - # data[f"parent{i + 1}"] = parents[i] - # data["offspring"] = offspring - # with open(self.output_path + "/results/history/pop_" + str(pop + 1) + "_" + str( - # na) + "_" + op + ".json", "w") as file: - # json.dump(data, file, indent=5) - # populatin management - size_act = min(len(population), self.pop_size) - population = self.manage.population_management(population, size_act) - print() + self.add2pop(population, offsprings) # Check duplication, and add the new offspring + for off in offsprings: + print(" Obj: ", off['objective'], end="|") + # if is_add: + # data = {} + # for i in range(len(parents)): + # data[f"parent{i + 1}"] = parents[i] + # data["offspring"] = offspring + # with open(self.output_path + "/results/history/pop_" + str(pop + 1) + "_" + str( + # na) + "_" + op + ".json", "w") as file: + # json.dump(data, file, indent=5) + # populatin management + size_act = min(len(population), self.pop_size) + population = self.manage.population_management(population, size_act) + print() # Save population to a file @@ -182,4 +182,3 @@ def run(self): for i in range(len(population)): print(str(population[i]['objective']) + " ", end="") print() - diff --git a/eoh/src/eoh/methods/localsearch/ls.py b/eoh/src/eoh/methods/localsearch/ls.py index e8d4474c..277799c7 100644 --- a/eoh/src/eoh/methods/localsearch/ls.py +++ b/eoh/src/eoh/methods/localsearch/ls.py @@ -138,8 +138,7 @@ def run(self): op_w = self.operator_weights[i] if (np.random.rand() < op_w): parents, offsprings = interface_ec.get_algorithm(population, op) - - self.manage.population_management(population,offsprings[0],temperature) + self.manage.population_management(population,offsprings[0],temperature) # Save population to a file filename = self.output_path + "/results/pops/population_generation_" + str(pop + 1) + ".json" @@ -157,4 +156,3 @@ def run(self): for i in range(len(population)): print(str(population[i]['objective']) + " ", end="") print() - diff --git a/eoh/src/eoh/utils/getParas.py b/eoh/src/eoh/utils/getParas.py index e9d33982..79bfe9a8 100644 --- a/eoh/src/eoh/utils/getParas.py +++ b/eoh/src/eoh/utils/getParas.py @@ -79,8 +79,8 @@ def set_ec(self): if self.ec_operator_weights == None: self.ec_operator_weights = [1 for _ in range(len(self.ec_operators))] - elif len(self.ec_operator) != len(self.ec_operator_weights): - print("Warning! Lengths of ec_operator_weights and ec_operator shoud be the same.") + elif len(self.ec_operators) != len(self.ec_operator_weights): + print("Warning! Lengths of ec_operator_weights and ec_operators should be the same.") self.ec_operator_weights = [1 for _ in range(len(self.ec_operators))] if self.method in ['ls','sa'] and self.ec_pop_size >1: