Skip to content

Commit 62e4266

Browse files
authored
Merge pull request #47 from Gromwud/main
remove duplicates from initial population and ajust evolution proccess
2 parents 6ad2ce3 + d0122d8 commit 62e4266

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

epde/operators/multiobjective/moeadd_specific.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,14 @@ def apply(self, objective: ParetoLevels, arguments: dict):
353353
attempt_limit = self.params['attempt_limit']
354354
temp_offspring = self.suboperators['chromosome_mutation'].apply(objective=offspring,
355355
arguments=subop_args['chromosome_mutation'])
356-
replaced = False
356+
replaced = 0
357357
while True:
358358
self.suboperators['right_part_selector'].apply(objective=temp_offspring,
359359
arguments=subop_args['right_part_selector'])
360360
self.suboperators['chromosome_fitness'].apply(objective=temp_offspring,
361361
arguments=subop_args['chromosome_fitness'])
362362

363-
if (all([not np.allclose(temp_offspring.obj_fun, solution.obj_fun) for solution in objective.population])
364-
and tuple(temp_offspring.obj_fun) not in objective.history):
365-
# and all([not np.allclose(temp_offspring.obj_fun, obj_fun) for obj_fun in objective.history]):
366-
363+
if tuple(temp_offspring.obj_fun) not in objective.history:
367364
self.suboperators['pareto_level_updater'].apply(objective=(temp_offspring, objective),
368365
arguments=subop_args['pareto_level_updater'])
369366
objective.history.add(tuple(temp_offspring.obj_fun))
@@ -377,6 +374,7 @@ def apply(self, objective: ParetoLevels, arguments: dict):
377374
temp_offspring.create()
378375
replaced += 1
379376
attempt = 1
377+
380378
self.suboperators['chromosome_mutation'].apply(objective=temp_offspring,
381379
arguments=subop_args['chromosome_mutation'])
382380
attempt += 1
@@ -422,18 +420,16 @@ def apply(self, objective : ParetoLevels, arguments : dict):
422420

423421
if len(objective.population) == 0:
424422
for idx, candidate in enumerate(objective.unplaced_candidates):
425-
# while True:
426-
# temp_candidate = copy.deepcopy(candidate)
427423
self.suboperators['right_part_selector'].apply(objective = candidate,
428-
arguments = subop_args['right_part_selector'])
429-
# print('Hah, got ya!')
430-
# if all([temp_candidate != solution for solution in objective.unplaced_candidates[:idx] +
431-
# objective.unplaced_candidates[idx+1:]]):
432-
# objective.unplaced_candidates[idx] = temp_candidate
433-
# break
434-
424+
arguments = subop_args['right_part_selector'])
435425
self.suboperators['chromosome_fitness'].apply(objective = objective.unplaced_candidates[idx],
436426
arguments = subop_args['chromosome_fitness'])
427+
while tuple(candidate.obj_fun) in objective.history:
428+
candidate.create()
429+
self.suboperators['right_part_selector'].apply(objective=candidate,
430+
arguments=subop_args['right_part_selector'])
431+
self.suboperators['chromosome_fitness'].apply(objective=objective.unplaced_candidates[idx],
432+
arguments=subop_args['chromosome_fitness'])
437433
objective.history.add(tuple(candidate.obj_fun))
438434
objective.initial_placing()
439435
return objective

0 commit comments

Comments
 (0)