@@ -360,18 +360,22 @@ def apply(self, objective: ParetoLevels, arguments: dict):
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 ]):
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+
367+ self .suboperators ['pareto_level_updater' ].apply (objective = (temp_offspring , objective ),
368+ arguments = subop_args ['pareto_level_updater' ])
369+ objective .history .add (tuple (temp_offspring .obj_fun ))
370+ break
371+ elif replaced >= attempt_limit :
372+ print ("Allowed replication" )
364373 self .suboperators ['pareto_level_updater' ].apply (objective = (temp_offspring , objective ),
365374 arguments = subop_args ['pareto_level_updater' ])
366375 break
367- # elif attempt >= attempt_limit and replaced:
368- # print("Allowed replication")
369- # self.suboperators['pareto_level_updater'].apply(objective=(temp_offspring, objective),
370- # arguments=subop_args['pareto_level_updater'])
371- # break
372376 elif attempt >= attempt_limit :
373377 temp_offspring .create ()
374- replaced = True
378+ replaced += 1
375379 attempt = 1
376380 self .suboperators ['chromosome_mutation' ].apply (objective = temp_offspring ,
377381 arguments = subop_args ['chromosome_mutation' ])
@@ -430,6 +434,7 @@ def apply(self, objective : ParetoLevels, arguments : dict):
430434
431435 self .suboperators ['chromosome_fitness' ].apply (objective = objective .unplaced_candidates [idx ],
432436 arguments = subop_args ['chromosome_fitness' ])
437+ objective .history .add (tuple (candidate .obj_fun ))
433438 objective .initial_placing ()
434439 return objective
435440
0 commit comments