summaryrefslogtreecommitdiff
path: root/lib/automata.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-09-09 08:55:56 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-09-09 08:55:56 +0200
commite5717042a42f614323c463f51e9afba1090691d9 (patch)
treecb69a8a906b86441245bdb2417c525dbb04c7f84 /lib/automata.py
parent454014918bd8be3225139f6bef4b97976a298479 (diff)
add more static accounting methods
Diffstat (limited to 'lib/automata.py')
-rwxr-xr-xlib/automata.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/automata.py b/lib/automata.py
index 30634ab..50ae179 100755
--- a/lib/automata.py
+++ b/lib/automata.py
@@ -537,6 +537,33 @@ class PTA:
"""Return PTA-specific ID of state."""
return self.get_state_names().index(state.name)
+ def get_unique_transitions(self):
+ """
+ Return list of PTA transitions without duplicates.
+
+ I.e., each transition name only occurs once, even if it has several entries due to
+ multiple origin states and/or overloading.
+ """
+ seen_transitions = set()
+ ret_transitions = list()
+ for transition in self.transitions:
+ if transition.name not in seen_transitions:
+ ret_transitions.append(transition)
+ seen_transitions.add(transition.name)
+ return ret_transitions
+
+ def get_unique_transition_id(self, transition: Transition) -> int:
+ """
+ Return PTA-specific ID of transition in unique transition list.
+
+ The followinng condition holds:
+ `
+ max_index = max(map(lambda t: pta.get_unique_transition_id(t), pta.get_unique_transitions()))
+ max_index == len(pta.get_unique_transitions) - 1
+ `
+ """
+ return self.get_unique_transitions().index(transition)
+
def get_initial_param_dict(self):
return dict([[self.parameters[i], self.initial_param_values[i]] for i in range(len(self.parameters))])