target of a hyperedge, no non-final node is target of that hyperedge.
∀ h ∈ HyperEdges • FN ∩ source(h) =
∧ ( FN ∩ target(h) = ⇒ target(h) ⊆ FN )
4. Hyperedges leaving the initial node have no trigger events, and the disjunc- tion of their guard expressions is a tautology.
∀ h ∈ HyperEdges • source(h) = {initial} ⇒ event (h) =⊥
∧{ guard(h) | h ∈ HyperEdges ∧ source(h) = {initial} } This constraint ensures that the initial state can be left immediately (see Constraint 5 on page 29).
3.3
From activity diagram to activity hypergraph
The mapping from activity diagrams to activity hypergraphs consists of three steps: (1) rewriting of some syntactic expressions, (2) eliminating hierarchy (com- pound activity nodes), and (3) computing hyperedges. Steps 1 and 3 have been implemented in TCM [60].
Rewriting of some syntactic expressions. First, else is replaced by the ex- pression it abbreviates. Second, we replace every after(t ) label of hyperedge h with after(t ,h). This replacement makes the after constraint unique for two hyperedges, ensuring that if two hyperedges have the same after label, there is no confusion as to for which hyperedge the timeout is meant. Third, edges leaving some activity node a and having no trigger event are labelled with term−1(a).
Eliminating hierarchy. An activity diagram can contain compound activity nodes. Every compound activity node is decomposed into another activity diagram that specifies the behaviour of the compound activity node. We require that the transitive closure of the decomposition relation be acyclic. We eliminate a compound activity node n by replacing n by its corresponding activity diagram. The initial and final nodes of the corresponding activity diagram are OR nodes, which are eliminated as follows. Every compound edge that enters n is glued together with every compound edge that leaves the initial node. Every compound edge that leaves n is glued together with every compound edge that enters one of the final nodes.
36 Chapter 3· Syntax of activity diagrams
Computing hyperedges. We first define a compound edge. A compound edge is a set of edges that are linked by AND (fork/join) and OR (decision/merge) nodes, satisfying the following constraints.
• If an edge in a compound edge ce enters or leaves an AND node, then every edge that leaves or enters the AND node is part of ce.
• If an edge in a compound edge ce enters (leaves) an OR node, then there is one edge in ce that leaves (enters) the OR node.
Not every compound edge that satisfies above rules is well-defined. Compound edges are not well-defined if they contain cycles. Cycles are bad for the following reasons.
• Sometimes a compound edge with a cycle is unreachable: the compound edge does not start with an non-pseudo node. For example, in Figure 3.7(a) there are two compound edges, namely {e1,e2,e4} and {e2,e3}. The compound edge{e2,e3} is not well-defined since it is unreachable.
• Sometimes a compound edge with a cycle is reachable but cannot be exe- cuted. For example, in Figure 3.7(b) there is one compound edge, namely {e5,e6,e7,e8}. This compound edge is reachable but not executable: Edge e6 can only be taken after e7 has been taken, whereas edge e7 can only be taken after e6 has been taken (remember that an edge denotes sequence). So e6 and e7 cannot be taken, and therefore the compound edge cannot be taken.
Above discussion can be summarised by quoting the definition of a (well- defined) compound edge in the UML standard [150]: “a [well-defined] compound edge is an acyclical, unbroken chain of edges”.
As explained on page 28, the effect of a compound edge can be specified with a hyperedge. The hyperedge specifies which nodes are left and which are entered if the compound edge is taken. The hyperedge neither refers to the edges contained in the compound edge, nor to the pseudo nodes that link them.
W1 W2 e5: e8: e6: e7: e3: e2: W1 e1: W2 e4: (a) (b)
3.3· From activity diagram to activity hypergraph 37 [h] [g] [g] [h] A A A B A B A A A B A B B C B C C C B C B C C C
Figure 3.8 Example computations of hyperedges
We compute hyperedges by processing the pseudo nodes of the activity diagram one by one. Figure 3.8 shows the most simple mappings. An OR node with n incoming or n outgoing edges maps into n new hyperedges. An AND node maps into one new hyperedge.
The only difficulty that arises is when an AND node is connected with an OR node. Then the order of processing is significant: processing an AND node before an OR node gives a different result than processing an OR node before an AND node. For example, the pseudo nodes in the activity diagram on the lefthand side in Figure 3.9 can be processed in two ways. Processing the OR node before the AND nodes gives the hypergraph in the top right, whereas processing the AND node before the OR node gives the hypergraph in the bottom right. The intended mapping is the one on the bottom right: either node W3 or W4 is entered but not both. So, AND nodes should be processed before OR nodes.
By Constraint 6 on activity diagrams, listed on page 30, we have that com- putation of a compound edge always produces a set of source nodes and a set of target nodes, rather than a bag.
Like an edge, a hyperedge has an ECA label. The ECA label of the hyperedge can be derived from the labels of the edges that are glued together. By Constraint 4 on activity diagrams, listed on page 29, at most one edge in a compound edge has a trigger event. This trigger event is the trigger event for the hyperedge. The guard condition of the hyperedge is the conjunction of the guard conditions of the edges that are part of the corresponding compound edge. The events generated
38 Chapter 3· Syntax of activity diagrams wrong right W1 W2 W3 W4 W1 W2 W1 W3 W3 W4 W4 W2
Figure 3.9 Two possible computations of hyperedges
by the hyperedge are the events generated by the edges of the compound edge.