diff --git a/main_package/classes/estimators/structure_score_based_estimator.py b/main_package/classes/estimators/structure_score_based_estimator.py index 9c9ceec..63e6d90 100644 --- a/main_package/classes/estimators/structure_score_based_estimator.py +++ b/main_package/classes/estimators/structure_score_based_estimator.py @@ -51,7 +51,7 @@ class StructureScoreBasedEstimator(se.StructureEstimator): @timing def estimate_structure(self, max_parents:int = None, iterations_number:int= 40, - patience:int = None, tabu_length:int = None, tabu_rules_duration:int = 5, + patience:int = None, tabu_length:int = None, tabu_rules_duration:int = None, optimizer: str = 'hill' ): """ Compute the score-based algorithm to find the optimal structure diff --git a/main_package/classes/optimizers/tabu_search.py b/main_package/classes/optimizers/tabu_search.py index fdce6a2..04aa5ae 100644 --- a/main_package/classes/optimizers/tabu_search.py +++ b/main_package/classes/optimizers/tabu_search.py @@ -31,8 +31,8 @@ class TabuSearch(Optimizer): max_parents:int = None, iterations_number:int= 40, patience:int = None, - tabu_length:int = 0, - tabu_rules_duration = 5 + tabu_length:int = None, + tabu_rules_duration = None ): """ Compute Optimization process for a structure_estimator @@ -71,6 +71,14 @@ class TabuSearch(Optimizer): other_nodes = set([node for node in self.structure_estimator.sample_path.structure.nodes_labels if node != self.node_id]) actual_best_score = self.structure_estimator.get_score_from_graph(graph,self.node_id) + + 'initialize tabu_length and tabu_rules_duration if None' + if self.tabu_length is None: + self.tabu_length = len(other_nodes) + + if self.tabu_rules_duration is None: + self.tabu_tabu_rules_durationength = len(other_nodes) + tabu_set = set() tabu_queue = queue.Queue() diff --git a/main_package/tests/optimizers/test_tabu_search.py b/main_package/tests/optimizers/test_tabu_search.py index 4deb126..87ed6f4 100644 --- a/main_package/tests/optimizers/test_tabu_search.py +++ b/main_package/tests/optimizers/test_tabu_search.py @@ -37,7 +37,7 @@ class TestTabuSearch(unittest.TestCase): se1 = se.StructureScoreBasedEstimator(self.s1) edges = se1.estimate_structure( max_parents = None, - iterations_number = 100, + iterations_number = 40, patience = None, tabu_length = 15, tabu_rules_duration = 15,