1
0
Fork 0

Updated mono process version of both the algorithms

master
Luca Moretti 4 years ago
parent d0593726d2
commit 9251de0fb6
  1. 9
      main_package/classes/estimators/structure_constraint_based_estimator.py
  2. 5
      main_package/classes/estimators/structure_score_based_estimator.py
  3. 2
      main_package/tests/estimators/test_structure_score_based_estimator.py

@ -236,9 +236,7 @@ class StructureConstraintBasedEstimator(se.StructureEstimator):
'get the number of CPU'
cpu_count = multiprocessing.cpu_count()
if disable_multiprocessing:
print("DISABILITATO")
cpu_count = 1
'Remove all the edges from the structure'
self.sample_path.structure.clean_structure_edges()
@ -246,6 +244,11 @@ class StructureConstraintBasedEstimator(se.StructureEstimator):
'Estimate the best parents for each node'
#with multiprocessing.Pool(processes=cpu_count) as pool:
#with get_context("spawn").Pool(processes=cpu_count) as pool:
if disable_multiprocessing:
print("DISABILITATO")
cpu_count = 1
list_edges_partial = [ctpc_algo(n,total_vars_numb) for n in self.nodes]
else:
with concurrent.futures.ProcessPoolExecutor(max_workers=cpu_count) as executor:
list_edges_partial = executor.map(ctpc_algo,
self.nodes,

@ -102,6 +102,9 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
#with multiprocessing.Pool(processes=cpu_count) as pool:
'Estimate the best parents for each node'
if disable_multiprocessing:
list_edges_partial = [estimate_parents(n,max_parents,iterations_number,patience,tabu_length,tabu_rules_duration,optimizer) for n in self.nodes]
else:
with concurrent.futures.ProcessPoolExecutor(max_workers=cpu_count) as executor:
list_edges_partial = executor.map(estimate_parents,
self.nodes,
@ -114,8 +117,6 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
# list_edges_partial = [estimate_parents(n,max_parents,iterations_number,patience,tabu_length,tabu_rules_duration,optimizer) for n in self.nodes]
#list_edges_partial = p.map(estimate_parents, self.nodes)
#list_edges_partial= estimate_parents('Q',max_parents,iterations_number,patience,tabu_length,tabu_rules_duration,optimizer)

@ -23,7 +23,7 @@ class TestStructureScoreBasedEstimator(unittest.TestCase):
@classmethod
def setUpClass(cls):
#cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_10.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_15.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.s1 = sp.SamplePath(cls.importer)
cls.s1.build_trajectories()
cls.s1.build_structure()