diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-05 15:54:49 +0200 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-05 15:54:49 +0200 |
commit | 40644c636b5084304d18fa7012fd91bc273e3973 (patch) | |
tree | ef0e7a6b28d8e70fe47011dc9bf08dd3b27ef90f /lib/behaviour.py | |
parent | 56af1e3823c8a3c983988166564b0c45790a8f73 (diff) |
SDKBehaviourModel: get_trace: respect transition guards
Diffstat (limited to 'lib/behaviour.py')
-rw-r--r-- | lib/behaviour.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/behaviour.py b/lib/behaviour.py index a0ceb95..638aa93 100644 --- a/lib/behaviour.py +++ b/lib/behaviour.py @@ -100,6 +100,25 @@ class SDKBehaviourModel: raise RuntimeError( f"get_trace({name}, {param_dict}): found infinite loop at {trace}" ) + + if len(next_states) > 1 and current_state in self.transition_guard: + matching_next_states = list() + for candidate in next_states: + for condition in self.transition_guard[current_state][candidate]: + valid = True + for key, value in condition: + if param_dict[key] != value: + valid = False + break + if valid: + matching_next_states.append(candidate) + break + next_states = matching_next_states + + if len(next_states) == 0: + raise RuntimeError( + f"get_trace({name}, {param_dict}): found no valid outbound transitions at {trace}, candidates {self.transition_guard[current_state]}" + ) if len(next_states) > 1: raise RuntimeError( f"get_trace({name}, {param_dict}): found non-deterministic outbound transitions {next_states} at {trace}" @@ -111,7 +130,6 @@ class SDKBehaviourModel: states_seen.add(current_state) current_state = next_state - print(trace) return trace def learn_pta(self, observations, annotation, delta=dict(), delta_param=dict()): |