def gen_hypothesis(self) -> Onfsm: """ Generate automaton based on the values found in the abstracted observation table. Returns: Current abstracted hypothesis """ state_distinguish = dict() states_dict = dict() initial = None unified_S = self.S + self.S_dot_A stateCounter = 0 for prefix in self.S: state_id = f's{stateCounter}' states_dict[prefix] = OnfsmState(state_id) states_dict[prefix].prefix = prefix state_distinguish[self.row_to_hashable( prefix)] = states_dict[prefix] if prefix == self.S[0]: initial = states_dict[prefix] stateCounter += 1 for prefix in self.S: similar_rows = [] for row in unified_S: if self.row_to_hashable(row) == self.row_to_hashable(prefix): similar_rows.append(row) for row in similar_rows: for a in self.A: for t in self.observation_table.T[row][a]: if (row[0] + a, row[1] + tuple([t])) in unified_S: state_in_S = state_distinguish[ self.row_to_hashable( (row[0] + a, row[1] + tuple([t])))] if (t, state_in_S ) not in states_dict[prefix].transitions[a[0]]: states_dict[prefix].transitions[a[0]].append( (t, state_in_S)) assert initial automaton = Onfsm(initial, [s for s in states_dict.values()]) automaton.characterization_set = self.E return automaton
def gen_hypothesis(self) -> Automaton: """ Generate automaton based on the values found in the observation table. Returns: Current hypothesis """ state_distinguish = dict() states_dict = dict() initial = None stateCounter = 0 for prefix in self.S: state_id = f's{stateCounter}' states_dict[prefix] = OnfsmState(state_id) states_dict[prefix].prefix = prefix state_distinguish[self.row_to_hashable( prefix)] = states_dict[prefix] if prefix == self.S[0]: initial = states_dict[prefix] stateCounter += 1 for prefix in self.S: curr_node = self.sul.pta.get_to_node(prefix[0], prefix[1]) for a in self.A: trace = self.sul.pta.get_all_traces(curr_node, a) for t in trace: reached_row = (prefix[0] + a, prefix[1] + (t[-1], )) if self.row_to_hashable( reached_row) not in state_distinguish.keys(): print('reeee') state_in_S = state_distinguish[self.row_to_hashable( reached_row)] assert state_in_S # shouldn't be necessary because of the if condition states_dict[prefix].transitions[a[0]].append( (t[-1], state_in_S)) assert initial automaton = Onfsm(initial, [s for s in states_dict.values()]) automaton.characterization_set = self.E return automaton
def gen_hypothesis(self) -> Automaton: """ Generate automaton based on the values found in the observation table. Returns: Current hypothesis """ state_distinguish = dict() states_dict = dict() initial = None stateCounter = 0 for prefix in self.S: state_id = f's{stateCounter}' states_dict[prefix] = OnfsmState(state_id) states_dict[prefix].prefix = prefix state_distinguish[self.row_to_hashable( prefix)] = states_dict[prefix] if prefix == self.S[0]: initial = states_dict[prefix] stateCounter += 1 for prefix in self.S: for a in self.A: for t in self.T[prefix][a]: state_in_S = state_distinguish[self.row_to_hashable( (prefix[0] + a, prefix[1] + tuple([t])))] assert state_in_S states_dict[prefix].transitions[a[0]].append( (t, state_in_S)) assert initial automaton = Onfsm(initial, [s for s in states_dict.values()]) automaton.characterization_set = self.E return automaton