diff --git a/.gitignore b/.gitignore index 82951579..6240f463 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,5 @@ local.properties *.cobaltlog *.error *.output + +bench/qc_simulation/data/ \ No newline at end of file diff --git a/qtensor/optimisation/Optimizer.py b/qtensor/optimisation/Optimizer.py index 03df0dab..4599b8b6 100644 --- a/qtensor/optimisation/Optimizer.py +++ b/qtensor/optimisation/Optimizer.py @@ -236,17 +236,28 @@ def _get_ordering_ints(self, graph, inplace=True): return peo, [self.treewidth] class TamakiOptimizer(GreedyOptimizer): - def __init__(self, max_width=None, *args, wait_time=5, **kwargs): + def __init__(self, max_width=None, *args, wait_time=5, + update_callback=None, + **kwargs): + """ + Args: + - max_width: stop when width is less than max_width + - wait_time: maximum time to wait for tamaki to finish + - update_callback: callback function to update progress bar accepts tuple + (time, width). Called when width is changed. + """ super().__init__(*args, **kwargs) self.wait_time = wait_time self.max_width = max_width - self._update_callback = **kwargs.get('update_callback') + self._update_callback = update_callback def _get_ordering(self, graph, inplace=True): node_names = nx.get_node_attributes(graph, 'name') node_sizes = nx.get_node_attributes(graph, 'size') peo, tw = qtree.graph_model.peo_calculation.get_upper_bound_peo_pace2017_interactive( - graph, method="tamaki", max_time=self.wait_time, max_width=self.max_width) + graph, method="tamaki", max_time=self.wait_time, max_width=self.max_width, + callback=self._update_callback + ) peo = [qtree.optimizer.Var(var, size=node_sizes[var],