UML state machine: Conflict AFTER choice

397 views Asked by At

What happens in an UML state machine if the transition selection algorithm (TSA) finds two transitions that should both fire and the following holds true:

  • transition #1 ends directly in a state
  • transition #2 ends (intermediately) in a choice pseudostate

As both the transitions fire, they cannot be in conflict. Else they would not have been chosen by the TSA in the first place.

Now the following occurs: As the choice is evaluated (after transition #2), it takes a path (transition) that would lead to the exit of an ancestor state of the source state of transition #2. Due to this exit of an ancestor state, a conflict with transition #1 occurs.

UML diagram showing such a situation

(improved according to the discussion with Thomas Kilian in comments to his (now deleted) answer)

... if Event_1 occurs and x < 0.

Example UML diagram

Questions

  • Is the state machine ill-formed or what is supposed to happen now?
  • Is it illegal for a transtions after a choice to exit a state? At least it doesn't play together well with the "transition execution sequence" (exit(s), transition behavior(s), enter(s)). As it would be exit, behavior, exit, behavior, enter(s) in that case. I could not find anything about that in the UML Superstructure Specification (chapter 15). But then everything about orthogonal regions is very vaguely described in that document...

Motivation

I am asking the question out of the perspective of a library implementer. So my focus is not on how to design this situation in a nicer manner. I need to figure out how to deal with this situation correctly (or I need to know that it is an illegal situation).

1

There are 1 answers

8
CharlesRivet On

This is one reason why there is a "Precise Semantics of UML State Machine" at the OMG...

First, it is legal for most transitions to exit a state. There are a few restrictions in the UML spec, but none that would concern your design.

You should always have a single state that is potentially active within any state machine region. As it stand, you have an implicit region in your "StateMachine1" that contains both the "X" and"Y" states. This would mean that your state machine could be in both "StateMachine1::X" and "StateMachine1::Y" states at the same time! As you probalby already know, orthogonal states are there do deal with such a situation. Perhaps you need to bring "X" and "Y" within state StateMachine1::S' regions?

Also a warning that by default in UML, states have shallow history. This means that, as it stands, the initial transitons within StateMachine1::S' regions will only be taken once. If you try to get back into "S" (I know, you don't have a transition for that - just speculating), it will go back to the last states (one per region) before if left the state, which, after event1, would be "A" and "E".

It would be difficult to comment more without knowing what you are trying to model, but I hope this helps.