Skip to content

Commit 63cf91f

Browse files
committed
verbose obj_fun added
1 parent df8d7bd commit 63cf91f

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

epde/globals.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ class VerboseManager:
9797
show_iter_idx : bool
9898
iter_fitness : bool
9999
iter_stats : bool
100-
show_ann_loss : bool
100+
show_ann_loss : bool
101101
show_warnings : bool
102+
candidate_objectives : bool
102103

103-
def init_verbose(plot_DE_solutions : bool = False, show_iter_idx : bool = True,
104-
show_iter_fitness : bool = False, show_iter_stats : bool = False,
105-
show_ann_loss : bool = False, show_warnings : bool = False):
104+
def init_verbose(plot_DE_solutions : bool = False, show_iter_idx : bool = True,
105+
show_iter_fitness : bool = False, show_iter_stats : bool = False,
106+
show_ann_loss : bool = False, show_warnings : bool = False,
107+
candidate_objectives : bool = False):
106108
"""
107109
Method for initialized of manager for output in text form
108110
@@ -121,8 +123,9 @@ def init_verbose(plot_DE_solutions : bool = False, show_iter_idx : bool = True,
121123
global verbose
122124
if not show_warnings:
123125
warnings.filterwarnings("ignore")
124-
verbose = VerboseManager(plot_DE_solutions, show_iter_idx, show_iter_fitness,
125-
show_iter_stats, show_ann_loss, show_warnings)
126+
verbose = VerboseManager(plot_DE_solutions, show_iter_idx, show_iter_fitness,
127+
show_iter_stats, show_ann_loss, show_warnings,
128+
candidate_objectives)
126129

127130
def reset_control_nn(n_control: int = 1, ann: torch.nn.Sequential = None,
128131
ctrl_args: list = [(0, [None,]),], device: str = 'cpu'):

epde/operators/multiobjective/moeadd_specific.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from epde.optimizers.moeadd.moeadd import ParetoLevels, ObjFunNormalizer
1515
from epde.operators.utils.template import CompoundOperator, add_base_param_to_operator
16+
import epde.globals as global_var
1617
from epde.operators.multiobjective.mutations import get_basic_mutation
1718

1819
from epde.structure.main_structures import SoEq
@@ -447,10 +448,12 @@ def apply(self, objective: ParetoLevels, arguments: dict):
447448
self.suboperators['pareto_level_updater'].apply(objective=(temp_offspring, objective),
448449
arguments=subop_args['pareto_level_updater'])
449450
objective.history.add(system)
450-
print(temp_offspring.obj_fun)
451+
if global_var.verbose.candidate_objectives:
452+
print(temp_offspring.obj_fun)
451453
break
452454
if replaced == offspring_attempt_limit:
453-
print("Could not generate unique offspring")
455+
if global_var.verbose.candidate_objectives:
456+
print("Could not generate unique offspring")
454457
break
455458
if attempt == mutation_attempt_limit:
456459
temp_offspring.create()
@@ -533,7 +536,8 @@ def apply(self, objective : ParetoLevels, arguments : dict):
533536
self.suboperators['chromosome_fitness'].apply(objective=candidate,
534537
arguments=subop_args['chromosome_fitness'])
535538
objective.history.add(system)
536-
print(candidate.obj_fun)
539+
if global_var.verbose.candidate_objectives:
540+
print(candidate.obj_fun)
537541
objective.associate_weights()
538542
objective.initial_placing()
539543

epde/structure/main_structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ def add_random_term(self):
722722
mandatory_family=None, passed_term=None)
723723

724724
attempt = 0
725-
while new_term.term_label in self.terms_labels and attempt < 10:
725+
while new_term.term_label in self.terms_labels or attempt < 10:
726726
new_term.randomize()
727727
attempt += 1
728728

0 commit comments

Comments
 (0)