Eclipse Community Forums Forum Search:

Home » Eclipse Projects » Papyrus for Real Time » What is the difference between a Choice and a Junction?
What is the difference between a Choice and a Junction? Thu, 02 February 2017 05:16
 Harshith VasanthMessages: 1Registered: February 2017 Junior Member
I wanted to know what is the difference between a Choice and a Junction.

Thanks
Re: What is the difference between a Choice and a Junction? [message #1753196 is a reply to message #1753124] Thu, 02 February 2017 16:01
 Ernesto PosseMessages: 438Registered: March 2011 Senior Member
The simple answer is that a choice point is used to make a selection. It is essentially a conditional "if ... else if ... else if ... else ...". A junction point, on the other hand, is essentially just a convenience. It is used to combine multiple transitions to make the diagram more readable. For example, instead of having two transitions t1 : S1 -> S and t2: S2 -> S, you can have a junction point j, and transitions t1: S1 -> j, t2 : S2 -> j and t : j -> S. This may make the graph "nicer" in some cases, and it may also allow you to share actions, if the last actions of t1 and t2 are the same, they may be refactored into a common action in t.

The official answer is from the UML spec:

Quote:

choice This type of Pseudostate is similar to a junction Pseudostate (see above) and serves similar purposes, with the difference that the guard Constraints on all outgoing Transitions are evaluated dynamically, when the compound transition traversal reaches this Pseudostate. Consequently, choice is used to realize a dynamic conditional branch. It allows splitting of compound transitions into multiple alternative paths such that the decision on which path to take may depend on the results of Behavior executions performed in the same compound transition prior to reaching the choice point. If more than one guard evaluates to true, one of the corresponding Transitions is selected. The algorithm for making this selection is not defined. If none of the guards evaluates to true, then the model is considered ill formed. To avoid this, it is recommended to define one outgoing Transition with the predefined "else" guard for every choice Pseudostate.

and

Quote:

junction This type of Pseudostate is used to connect multiple Transitions into compound paths between States. For example, a junction Pseudostate can be used to merge multiple incoming Transitions into a single outgoing Transition representing a shared continuation path. Or, it can be used to split an incoming Transition into multiple outgoing Transition segments with different guard Constraints.
NOTE. Such guard Constraints are evaluated before any compound transition containing this Pseudostate is executed, which is why this is referred to as a static conditional branch.
It may happen that, for a particular compound transition, the configuration of Transition paths and guard values is such that the compound transition is prevented from reaching a valid state configuration. In those cases, the entire compound transition is disabled even though its Triggers are enabled. (As a way of avoiding this situation in some cases, it is possible to associate a predefined guard denoted as "else" with at most one outgoing Transition. This Transition is enabled if all the guards attached to the other Transitions evaluate to false). If more than one guard evaluates to true, one of these is chosen. The algorithm for making this selection is not defined.
Re: What is the difference between a Choice and a Junction? [message #1753298 is a reply to message #1753196] Fri, 03 February 2017 14:06
 Peter CigehnMessages: 49Registered: September 2014 Member
Hi,

Apart from Ernestos' explanation about making the graph "nicer" and able to "reuse" action code, I think it is important to highlight this difference in dynamic vs. static evaluation of guards, as explained in the quotes from the UML specification. This is a pretty fundamental difference since the evaluation of guards for a choice point can depend on computation performed on transitions earlier in the chain, whereas guards for a junction point are calculated statically before the chain is even started, and thus they cannot depend on any computations done in the effect code for transitions earlier in the chain.

/Peter Cigéhn
Re: What is the difference between a Choice and a Junction? [message #1753307 is a reply to message #1753298] Fri, 03 February 2017 16:05
 Peter CigehnMessages: 49Registered: September 2014 Member
Peter Cigehn wrote on Fri, 03 February 2017 14:06

Apart from Ernestos' explanation about making the graph "nicer" and able to "reuse" action code, I think it is important to highlight this difference in dynamic vs. static evaluation of guards, as explained in the quotes from the UML specification. This is a pretty fundamental difference since the evaluation of guards for a choice point can depend on computation performed on transitions earlier in the chain, whereas guards for a junction point are calculated statically before the chain is even started, and thus they cannot depend on any computations done in the effect code for transitions earlier in the chain.

Since we are in a Papyrus-RT forum, I probably should clarify my response a bit, which were more applicable to UML in general and the quotes from the UML specification.

In UML-RT however, there is constraint that limits a junction point to have at most one outgoing transition, and this transition must not have a guard.

This is a simplification exactly to avoid these kinds of aspects of dynamic vs. static evaluation of guards, and also to avoid confusion about when to use what.

So UML-RT basically only have choice-points for modeling if-else if-else if-else and junction points is, as Ernesto originally wrote, more related to structuring the graph.

Hope this clarifies the use of choice points vs. junction points in the context of UML-RT and Papyrus-RT.

/Peter Cigéhn
 Previous Topic: Do activities Next Topic: Building Workspace has encountered a Problem
Goto Forum:

Current Time: Tue Sep 10 01:09:20 GMT 2024

.:: Contact :: Home ::.