diff --git a/library/cadbiom/models/clause_constraints/mcl/CLUnfolder.py b/library/cadbiom/models/clause_constraints/mcl/CLUnfolder.py index 3a789a28cee34af82d071d1cdd9a9edba70d7452..0bbaceceda8cf271b97da821cf156ecb64e7badb 100644 --- a/library/cadbiom/models/clause_constraints/mcl/CLUnfolder.py +++ b/library/cadbiom/models/clause_constraints/mcl/CLUnfolder.py @@ -162,17 +162,27 @@ class CLUnfolder(object): self.__no_frontier_init = [[-self.__var_code_table[nfp]] for nfp in self.dynamic_system.no_frontiers] # ordered list of DIMACS codes of the frontier variables/places - self.frontier_values = [self.__var_code_table[frp] for frp in self.__dyn_sys.frontiers] - self.frontier_values.sort() ## TODO: sort utile ici ???? si non passer en frozenset et supprimer les casts partout ailleurs - # Convenient attribute for RawSolution.extract_frontier_values() - # all frontiers and their opposite version - # Set of frontier positive and negative values. - # operations with sets are much faster - ## plus forcément nécessaire... ou passer avec une @property et un lrucache dessus - ## ou mieux juste un attr avec les frontières négatives, - ## utilisé dans RawSolution.frontier_pos_and_neg_values pour faire l'intersection avec les variables d'une solution - ## utilisé dans MCLAnalyser.__solve_with_inact_fsolution directement en utilisant l'objet unfolder - self.frontiers_negative_values = frozenset(-frontier for frontier in self.frontier_values) + self.frontier_values = [self.__var_code_table[frp] for frp in self.dynamic_system.frontiers] + self.frontier_values.sort() + ## TODO: sort utile ici ???? si non passer en frozenset et supprimer les casts partout ailleurs + ## Cf RawSolution.frontier_pos_and_neg_values BACKWARD, encore utilisé avec index + ## Cf TestCLUnfolder.test_frontier indexable mais peut etre contourné + + # Precompute convenient attributes for: + # frontiers_pos_and_neg: + # - RawSolution.frontier_pos_and_neg_values + # (set operation with solution variables) + # frontiers_negative_values: + # - MCLQuery.from_frontier_sol_new_timing + # - MCLQuery.frontiers_negative_values + # - MCLAnalyser.__solve_with_inact_fsolution + # - TestCLUnfolder.test_prune + # + # Set of frontier positive and negative values + # (all frontiers and their opposite version). + # => operations with sets are much faster + self.frontiers_negative_values = \ + frozenset(-frontier for frontier in self.frontier_values) self.frontiers_pos_and_neg = \ self.frontiers_negative_values | frozenset(self.frontier_values) @@ -191,7 +201,7 @@ class CLUnfolder(object): self.reset() # Logical constraints: - # result from unfolding of base constraints + # Result from unfolding of base constraints # Boolean vectors signification: # X: Current state of places (activated/unactivated) # X': Future state of places