diff --git a/main_package/classes/optimizers/constraint_based_optimizer.py b/main_package/classes/optimizers/constraint_based_optimizer.py index 98b4039..4ee69d1 100644 --- a/main_package/classes/optimizers/constraint_based_optimizer.py +++ b/main_package/classes/optimizers/constraint_based_optimizer.py @@ -66,36 +66,17 @@ class ConstraintBasedOptimizer(Optimizer): child_states_numb = self.structure_estimator.sample_path.structure.get_states_number(self.node_id) b = 0 while b < len(u): - #for parent_id in u: parent_indx = 0 - list_parent= copy.deepcopy(u) - for possible_parent in list_parent: + while parent_indx < len(u): removed = False - #if not list(self.structure_estimator.generate_possible_sub_sets_of_size(u, b, u[parent_indx])): - #break - S = self.structure_estimator.generate_possible_sub_sets_of_size(u, b, possible_parent) - #print("U Set", u) - #print("S", S) - test_parent = possible_parent - #print("Test Parent", test_parent) + S = self.structure_estimator.generate_possible_sub_sets_of_size(u, b, u[parent_indx]) + test_parent = u[parent_indx] for parents_set in S: - #print("Parent Set", parents_set) - #print("Test Parent", test_parent) if self.structure_estimator.complete_test(test_parent, self.node_id, parents_set, child_states_numb, self.tot_vars_count): - #print("Removing EDGE:", test_parent, self.node_id) graph.remove_edges([(test_parent, self.node_id)]) - other_nodes.remove(test_parent) - print(f"TEST PARENT: {test_parent}") - try: - u.remove(test_parent) - except: - print(f"u: {u}") - print(f"utest_parent: {test_parent}") - + u.remove(test_parent) removed = True break - #else: - #parent_indx += 1 if not removed: parent_indx += 1 b += 1 diff --git a/main_package/classes/structure_graph/sample_path.py b/main_package/classes/structure_graph/sample_path.py index c2d470b..0c4a287 100644 --- a/main_package/classes/structure_graph/sample_path.py +++ b/main_package/classes/structure_graph/sample_path.py @@ -45,11 +45,11 @@ class SamplePath(asam.AbstractSamplePath): self.importer.import_data() #TODO: VALUTARE PARAMETRO PER DATA AUGMENTATION - trajects_samples = pd.concat([self.importer.concatenated_samples, - self.importer.concatenated_samples]) + #trajects_samples = pd.concat([self.importer.concatenated_samples, + # self.importer.concatenated_samples]) self._trajectories = \ - tr.Trajectory(self.importer.build_list_of_samples_array(trajects_samples), + tr.Trajectory(self.importer.build_list_of_samples_array(self.importer.concatenated_samples), len(self.importer.sorter) + 1) #self.trajectories.append(trajectory) self.importer.clear_concatenated_frame() diff --git a/main_package/tests/estimators/test_structure_constraint_based_estimator.py b/main_package/tests/estimators/test_structure_constraint_based_estimator.py index 1bf1bdc..57d51f1 100644 --- a/main_package/tests/estimators/test_structure_constraint_based_estimator.py +++ b/main_package/tests/estimators/test_structure_constraint_based_estimator.py @@ -22,7 +22,7 @@ class TestStructureConstraintBasedEstimator(unittest.TestCase): @classmethod def setUpClass(cls): #cls.read_files = glob.glob(os.path.join('../../data', "*.json")) - cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_ternary_data_01_6.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name') + cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_ternary_data_15.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.s1 = sp.SamplePath(cls.importer) cls.s1.build_trajectories() cls.s1.build_structure() @@ -32,7 +32,7 @@ class TestStructureConstraintBasedEstimator(unittest.TestCase): true_edges = set(map(tuple, true_edges)) se1 = se.StructureConstraintBasedEstimator(self.s1,0.1,0.1) - edges = se1.estimate_structure(disable_multiprocessing=True) + edges = se1.estimate_structure(disable_multiprocessing=False) self.assertEqual(edges, true_edges)