@@ -190,8 +190,7 @@ def apply(self, objective : Tuple[Union[SoEq, ParetoLevels]], arguments : dict):
190190 most_crowded_domain = crowded_domains [np .argmax (PBIS )]
191191
192192 if len (last_level_by_domains [most_crowded_domain ]) == 1 :
193- worst_solution = locate_pareto_worst (objective [1 ], self_args ['weights' ],
194- self_args ['best_obj' ], self .params ['PBI_penalty' ])
193+ worst_solution = last_level_by_domains [most_crowded_domain ][0 ]
195194 else :
196195 PBIS = np .fromiter (map (lambda solution : penalty_based_intersection (solution ,
197196 self_args ['weights' ][most_crowded_domain ],
@@ -367,31 +366,34 @@ def apply(self, objective: ParetoLevels, arguments: dict):
367366
368367 while objective .unplaced_candidates :
369368 offspring = objective .unplaced_candidates .pop ()
370- attempt = 1
371- attempt_limit = self .params ['attempt_limit' ]
369+ attempt = 0
370+ mutation_attempt_limit = self .params ['mutation_attempt_limit' ]
371+ offspring_attempt_limit = self .params ['offspring_attempt_limit' ]
372372 temp_offspring = deepcopy (offspring )
373373 replaced = 0
374374 while True :
375- temp_offspring = self .suboperators ['chromosome_mutation' ].apply (objective = temp_offspring ,
376- arguments = subop_args ['chromosome_mutation' ])
377375 self .suboperators ['right_part_selector' ].apply (objective = temp_offspring ,
378376 arguments = subop_args ['right_part_selector' ])
379- self .suboperators ['chromosome_fitness' ].apply (objective = temp_offspring ,
380- arguments = subop_args ['chromosome_fitness' ])
381-
382- if tuple (temp_offspring .obj_fun ) not in objective .history :
377+ temp_offspring .reset_state ()
378+ system = temp_offspring .described_variables
379+ if system not in objective .history :
380+ self .suboperators ['chromosome_fitness' ].apply (objective = temp_offspring ,
381+ arguments = subop_args ['chromosome_fitness' ])
383382 self .suboperators ['pareto_level_updater' ].apply (objective = (temp_offspring , objective ),
384383 arguments = subop_args ['pareto_level_updater' ])
385- objective .history .add (tuple ( temp_offspring . obj_fun ) )
386- # print(tuple( temp_offspring.obj_fun) )
384+ objective .history .add (system )
385+ print (temp_offspring .obj_fun )
387386 break
388- elif replaced == attempt_limit :
387+ elif replaced == offspring_attempt_limit :
389388 print ("Could not generate unique offspring" )
390389 break
391- elif attempt == attempt_limit :
390+ elif attempt == mutation_attempt_limit :
392391 temp_offspring = deepcopy (offspring )
393392 replaced += 1
394393 attempt = 0
394+ temp_offspring = self .suboperators ['chromosome_mutation' ].apply (objective = temp_offspring ,
395+ arguments = subop_args [
396+ 'chromosome_mutation' ])
395397 attempt += 1
396398 return objective
397399
@@ -437,15 +439,16 @@ def apply(self, objective : ParetoLevels, arguments : dict):
437439 for idx , candidate in enumerate (objective .unplaced_candidates ):
438440 self .suboperators ['right_part_selector' ].apply (objective = candidate ,
439441 arguments = subop_args ['right_part_selector' ])
440- self .suboperators ['chromosome_fitness' ].apply (objective = objective .unplaced_candidates [idx ],
441- arguments = subop_args ['chromosome_fitness' ])
442- while tuple (candidate .obj_fun ) in objective .history :
442+ system = candidate .described_variables
443+ while system in objective .history :
443444 candidate .create ()
444445 self .suboperators ['right_part_selector' ].apply (objective = candidate ,
445446 arguments = subop_args ['right_part_selector' ])
446- self .suboperators ['chromosome_fitness' ].apply (objective = objective .unplaced_candidates [idx ],
447- arguments = subop_args ['chromosome_fitness' ])
448- objective .history .add (tuple (candidate .obj_fun ))
447+ system = candidate .described_variables
448+ self .suboperators ['chromosome_fitness' ].apply (objective = candidate ,
449+ arguments = subop_args ['chromosome_fitness' ])
450+ objective .history .add (system )
451+ print (candidate .obj_fun )
449452 objective .initial_placing ()
450453
451454 # TODO: consider carefully, where normalizer init shall be held. If here, only the initial values are employed
0 commit comments