Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions eoh/src/eoh/methods/ael/ael.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -168,4 +168,3 @@ def run(self):
for i in range(len(population)):
print(str(population[i]['objective']) + " ", end="")
print()

31 changes: 15 additions & 16 deletions eoh/src/eoh/methods/eoh/eoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -182,4 +182,3 @@ def run(self):
for i in range(len(population)):
print(str(population[i]['objective']) + " ", end="")
print()

4 changes: 1 addition & 3 deletions eoh/src/eoh/methods/localsearch/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -157,4 +156,3 @@ def run(self):
for i in range(len(population)):
print(str(population[i]['objective']) + " ", end="")
print()

4 changes: 2 additions & 2 deletions eoh/src/eoh/utils/getParas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down