1
0
Fork 0

Added hybrid set up for tabu_length and tabu_rules_duration

master
Luca Moretti 4 years ago
parent 7efe6778c0
commit 0f44006371
  1. 2
      main_package/classes/estimators/structure_score_based_estimator.py
  2. 12
      main_package/classes/optimizers/tabu_search.py
  3. 2
      main_package/tests/optimizers/test_tabu_search.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

@ -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()

@ -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,