def consider_other_paths_through_state(self, StateIndex, ThePath): """If 'ThePath' is completely a sub-path of another, than there is no need to even consider it. If the path has the same transition map (without wildcard) as another path, then concatinations may be made without further diving deeper into the state machine's graph. RETURNS: 'True' sub-graph has to be considered. 'False' sub-graph does not have to be considered. """ if ThePath.has_wildcard(): return True elif StateIndex not in self.info_db: return True done_f = False for path in self.info_db[StateIndex]: if not transition_map_tools.is_equal(path.transition_map, ThePath.transition_map): continue # Does 'path' cover 'ThePath' completely? if path.is_superpath(ThePath): return False self.add_result(path.get_sibling(ThePath)) # There is a path that already contains 'StateIndex' and its # transition map is also the same, so diving deeper in the # state machines graph is not necessary. done_f = True return not done_f
def accept(self, Path, StateDB): """Accepts the given Path to be walked, if the remaining transition_maps match. If additionally uniformity is required, then only states with same drop_out and entry are accepted. RETURNS: False -- Path does not fit the PathWalkerState. True -- Path can be walked by PathWalkerState and has been accepted. """ # (1) Compare the transition maps. if not transition_map_tools.is_equal(self.__original_transition_map, Path.transition_map): return False # (1b) If uniformity is required and not maintained, then refuse. # Uniformity: -- There exists uniformity in all previously accepted # paths. # -- There is a uniform command list along the path # -- The uniform command list is equivalent with the # existing one. uniform_entry_f = False if self.__uniform_entry_command_list_along_path is not None: uniform_entry = Path.get_uniform_entry_command_list_along_path() if uniform_entry is not None \ and uniform_entry.is_equivalent(self.__uniform_entry_command_list_along_path): uniform_entry_f = True if self.__uniformity_required_f: # If uniformity is required, then a non-uniform entry should never been # accepted. Thus, there **must** be a 'uniform_entry_door_id_along_all_paths'. assert self.__uniform_entry_command_list_along_path is not None # If uniformity is a required, more than one drop-out scheme should never # been accepted. assert len(Path.drop_out) == 1, repr(Path.drop_out) # (*) Check Entry Uniformity if not uniform_entry_f: return False # (*) Check Drop-Out Uniformity elif self.drop_out != Path.drop_out: return False if uniform_entry_f == False: self.__uniform_entry_command_list_along_path = None # (2) Absorb the Path # The path_id of the path to be added is the length of the current path list. # (This means: new last index = current size of the list.) path_id = len(self.__path_list) # (2a) Absorb the state sequence of the path # (verify/falsify the uniform terminal entry) self.__path_list.append(Path.sequence()) # (2b) Absorb Entry Information # Absorb entry's action_db (maps: 'transition_id --> command_list') adapted_entry = PathWalkerState.adapt_path_walker_id_and_path_id(self.index, Path.entry, PathID=path_id) self.entry.action_db.update(adapted_entry.action_db) # (2c) Absorb the drop-out information self.drop_out.update_from_other(Path.drop_out) return True
def consider_other_paths_through_state(self, StateIndex, ThePath): """If 'ThePath' is completely a sub-path of another, than there is no need to even consider it. If the path has the same transition map (without wildcard) as another path, then concatinations may be made without further diving deeper into the state machine's graph. RETURNS: 'True' sub-graph has to be considered. 'False' sub-graph does not have to be considered. """ if ThePath.has_wildcard(): return True elif StateIndex not in self.info_db: return True done_f = False for path in self.info_db[StateIndex]: if not transition_map_tools.is_equal(path.transition_map, ThePath.transition_map): continue # Does 'path' cover 'ThePath' completely? if path.is_superpath(ThePath): return False self.add_result(path.get_sibling(ThePath)) # There is a path that already contains 'StateIndex' and its # transition map is also the same, so diving deeper in the # state machines graph is not necessary. done_f = True return not done_f