Skip to content
Merged
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
9 changes: 8 additions & 1 deletion epde/operators/multiobjective/moeadd_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,25 @@ def apply(self, objective: ParetoLevels, arguments: dict):
attempt_limit = self.params['attempt_limit']
temp_offspring = self.suboperators['chromosome_mutation'].apply(objective=offspring,
arguments=subop_args['chromosome_mutation'])
replaced = False
while True:
self.suboperators['right_part_selector'].apply(objective=temp_offspring,
arguments=subop_args['right_part_selector'])
self.suboperators['chromosome_fitness'].apply(objective=temp_offspring,
arguments=subop_args['chromosome_fitness'])

if all([not np.array_equal(temp_offspring.obj_fun, solution.obj_fun) for solution in objective.population]):
if all([not np.allclose(temp_offspring.obj_fun, solution.obj_fun) for solution in objective.population]):
self.suboperators['pareto_level_updater'].apply(objective=(temp_offspring, objective),
arguments=subop_args['pareto_level_updater'])
break
elif attempt >= attempt_limit and replaced:
print("Allowed replication")
self.suboperators['pareto_level_updater'].apply(objective=(temp_offspring, objective),
arguments=subop_args['pareto_level_updater'])
break
elif attempt >= attempt_limit:
temp_offspring.create()
replaced = True
attempt = 1
self.suboperators['chromosome_mutation'].apply(objective=temp_offspring,
arguments=subop_args['chromosome_mutation'])
Expand Down
4 changes: 2 additions & 2 deletions epde/optimizers/moeadd/moeadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def delete_point(self, point):
for level in self.levels:
temp = []
for element in level:
if not np.array_equal(element.obj_fun, point.obj_fun) or any(np.array_equal(element.obj_fun, h) for h in history):
if not np.allclose(element.obj_fun, point.obj_fun) or any(np.allclose(element.obj_fun, h) for h in history):
temp.append(element)
history.append(element.obj_fun)
if not len(temp) == 0:
Expand All @@ -166,7 +166,7 @@ def delete_point(self, point):
population_cleared = []
history = []
for elem in self.population:
if not np.array_equal(elem.obj_fun, point.obj_fun) or any(np.array_equal(elem.obj_fun, h) for h in history):
if not np.allclose(elem.obj_fun, point.obj_fun) or any(np.allclose(elem.obj_fun, h) for h in history):
population_cleared.append(elem)
history.append(elem.obj_fun)

Expand Down