ePrivacy and GPDR Cookie Consent by Cookie Consent

Choice

A choice is an element of a state machine. It is processed when it is reached by an incoming transition. When it is reached, the guards of the outgoing transitions are checked and a transition is chosen arbitrary from the set of enabled transitions.

It is recommended that it is assured that only exactly one guard evaluates to true at any time to avoid random behavior of the state machine!

When a choice is reached, the compound transition is processed up to the choice and then its processing is continued. The guards of the transitions leaving the choice are only evaluated when the execution of the compound transition reaches the choice. This is in contrast to the behavior of a junction where the guards are checked when a (compound) transition is checked if it is enabled.

A choice belongs to a region.

Symbol

A choice is shown as a diamond shaped symbol.

images/download/attachments/2785305/choice_symbol.png

Symbol in context

images/download/attachments/2785305/choice_symbol_context_1.png

If the choice is outside of the 'Composite state 1' it will be exited and re-entered when the transition to 'Simple state 2' or 'Simple state 3' is executed. Because when a choice is reached, the compound transition is processed up to the choice and then its processing is continued.

Characteristics

  • A choice has at least 1 incoming and 1 outgoing transition.

  • Transitions exiting a choice cannot have a trigger.

  • At least one outgoing transition must have a guard that evaluates to true.

  • Just the outgoing transitions with a guard that evaluates to true are enabled. If more than one transition is enabled, a sole transition is chosen arbitrary from the enabled outgoing transitions.

  • At least one outgoing transition must have a guard that evaluates to true when the choice is reached, else the state machine is ill-formed.

  • It is recommended to define one outgoing transition with no guard (an “else”) .

  • A choice has at most one outgoing transition with an "else" guard.

  • A choice is a dynamic conditional branch (in contrast junction is a static conditional branch).

Interpretation of and deviation from the UML specification

UML specification

  1. "If there are choice points in a compound transition, only guards that precede the choice point are evaluated according to the above rule. Guards downstream of a choice point are evaluated if and when the choice point is reached (using the same rule as above). In other words, for guard evaluation, a choice point has the same effect as a state." [ UML Superstructure Specification, v2.4.1, p.584 ]

  2. "If more than one of the guards evaluates to true, an arbitrary one is selected." [ UML Superstructure Specification, v2.4.1, p.551 ]

yasmine deviation

  1. When a choice is reached, the compound transition is processed up to the choice and then processing is continued.

    The choice will affect the exit/enter sequence.

  2. A choice can have at most one outgoing transition with no guards.