@@ -58,9 +58,9 @@ def penalty_based_intersection(sol_obj, weight, ideal_obj,
5858 Normalizer for solution objective functions.
5959
6060 '''
61- print (f'Objective before normalization: { sol_obj .obj_fun } for normalizer { obj_normalizer } ' )
61+ # print(f'Objective before normalization: {sol_obj.obj_fun} for normalizer {obj_normalizer}')
6262 solution_objective = sol_obj .obj_fun if obj_normalizer is None else obj_normalizer (sol_obj .obj_fun )
63- print (f'Objective after expected normalization: { solution_objective } ' )
63+ # print(f'Objective after expected normalization: {solution_objective}')
6464
6565 d_1 = np .dot ((solution_objective - ideal_obj ), weight ) / np .linalg .norm (weight )
6666 d_2 = np .linalg .norm (solution_objective - (ideal_obj + d_1 * weight / np .linalg .norm (weight )))
@@ -378,32 +378,38 @@ def apply(self, objective: ParetoLevels, arguments: dict):
378378 offspring = objective .unplaced_candidates .pop ()
379379 attempt = 1
380380 attempt_limit = self .params ['attempt_limit' ]
381- temp_offspring = self .suboperators ['chromosome_mutation' ].apply (objective = offspring ,
382- arguments = subop_args ['chromosome_mutation' ])
381+ temp_offspring = offspring
383382 replaced = 0
384383 while True :
384+ # temp_offspring = self.suboperators['chromosome_mutation'].apply(objective=offspring,
385+ # arguments=subop_args['chromosome_mutation'])
386+ temp_offspring = self .suboperators ['chromosome_mutation' ].apply (objective = temp_offspring ,
387+ arguments = subop_args [
388+ 'chromosome_mutation' ])
389+ # temp_offspring.reset_state()
385390 self .suboperators ['right_part_selector' ].apply (objective = temp_offspring ,
386391 arguments = subop_args ['right_part_selector' ])
387392 self .suboperators ['chromosome_fitness' ].apply (objective = temp_offspring ,
388393 arguments = subop_args ['chromosome_fitness' ])
389394
390395 if tuple (temp_offspring .obj_fun ) not in objective .history :
396+ # for obj_idx, obj in enumerate(temp_offspring.obj_fun):
397+ # obj = obj / objective.max_obj[obj_idx]
391398 self .suboperators ['pareto_level_updater' ].apply (objective = (temp_offspring , objective ),
392399 arguments = subop_args ['pareto_level_updater' ])
393400 objective .history .add (tuple (temp_offspring .obj_fun ))
401+ # print(tuple(temp_offspring.obj_fun))
394402 break
395- elif replaced >= attempt_limit :
396- print ("Allowed replication" )
397- self .suboperators ['pareto_level_updater' ].apply (objective = (temp_offspring , objective ),
398- arguments = subop_args ['pareto_level_updater' ])
403+ # return objective
404+ elif replaced == attempt_limit :
405+ print ("Could not generate unique offspring" )
399406 break
400- elif attempt >= attempt_limit :
401- temp_offspring .create ()
407+ elif attempt == attempt_limit :
408+ # temp_offspring.create()
409+ temp_offspring = offspring
410+ # temp_offspring.reset_state()
402411 replaced += 1
403- attempt = 1
404-
405- self .suboperators ['chromosome_mutation' ].apply (objective = temp_offspring ,
406- arguments = subop_args ['chromosome_mutation' ])
412+ attempt = 0
407413 attempt += 1
408414 return objective
409415
0 commit comments