EA&UML日拱一卒-活动图::OMG UML2.5中文译文 16.12 Expansion Regisons

网友投稿 581 2022-10-13

EA&UML日拱一卒-活动图::OMG UML2.5中文译文 16.12 Expansion Regisons

EA&UML日拱一卒-活动图::OMG UML2.5中文译文 16.12 Expansion Regisons

16.12.1 Summary(概要)

An ExpansionRegion is a StructuredActivityNode that executes its contained elements multiple times corresponding to elements of an input collection.

扩展区域是一个结构化活动节点,它会多次执行内部元素,执行的次数符合输入元素的聚合。

16.12.2 Abstract Syntax(抽象语法)

16.12.3 Semantics(语义)

An ExpansionRegion is a StructuredActivityNode that takes as input one or more collections of values and executes its contained ActivityNodes and ActivityEdges on each value in those collections. If the computation produces results, these may be collected into output collections. The number of output collections can differ from the number of input collections.

扩展区域是一个结构化活动节点,它接受一个或多个值的聚合,然后对这些聚合中的每一个值执行它包含的活动节点和活动边。如果计算产生结果,那么这些结果被收集到输出聚合中。输出聚合的个数可以和输入聚合的个数不同。

An ExpansionNode is an ObjectNode used to indicate a flow across the boundary of an ExpansionRegion. From “outside” of the region, the values on these nodes appear as collections. From “inside” the region the values appear as elements of the collections. A “collection” is defined to be any construct supported by an execution engine that may be treated either as a whole or as a well-defined set of element values.

扩展节点一种对象节点,用于表现流穿过扩展区域的边界。从区域的外部来看,节点上的值表现为聚合,从区域的内部来看,这些值表现为聚合的元素。聚合可以被定义为任何执行引擎支持的结构,作为整体或定义良好的值的集合被处理。

An execution engine may define various kinds of collection types that it supports (sets, bags, and so on), individual instances of which may be constructed from element values and from which those element values may later be obtained. Such a collection instance is passed as a single value on a single token. An execution engine may alternatively support collections implicitly as the set of values passed in a group of tokens placed together on an ExpansionNode.

执行引擎可以定义多种支持的类型(集合,包等),这些类型的实例可以从元素值构造,后续处理可以从中取得那些值。这样的聚合实例作为单个值通过一个令牌传递。执行引擎也可以支持隐性聚合,它的值被一组扩展节点上的放置在一起的令牌传递。

If an ExpansionRegion has multiple input ExpansionNodes, then each one must handle the same kind of collection (set, bag, or so on), although the types of the elements in different collections may vary. If the kind of collection  is represented as a collection type, then this is used as the type of the ExpansionNodes. Otherwise, the type of the ExpansionNodes reflects the type of the elements in the collections.

如果扩展区域有多个输入扩展节点,那么每个扩展节点必须处理相同种类的聚合(集合,包,等),即使包含在不同聚合中的元素的类型不同时也是这样。如果这种聚合表现为一个聚合类型,那么这个类型就会被用作扩展节点的类型。否则就以聚合中元素的类型作为扩展节点的类型。

An ExpansionRegion begins executing according to the normal rules for an Action (see sub clause 16.2.3). In addition,if the input ExpansionNodes for the ExpansionRegion have collection types, then a collection instance must be placed on each ExpansionNode before the ExpansionRegion may begin executing. Otherwise, there is no constraint on whether any input ExpansionNode contains any tokens (as an ExpansionNode with no token is interpreted as the empty collection in this case). When the ExpansionRegion starts executing it removes all tokens in its input ExpansionNodes.

扩展区域按照动作(参见16.2.3)的通常规则开始执行。如果扩展区域的输入扩展节点是聚合类型,那么在 扩展区域执行之前,聚合实例必须要传递到每个扩展节点。但是并没有要求每个扩展节点上都存在某种令牌(因为在这种情况下不保有令牌的扩展节点被解释为一个 空聚合)。当扩展区域开始执行时,会移除所有输入扩展节点上的令牌。

Then the group of ActivityNodes and ActivityEdges contained in the ExpansionRegion is executed once for each element of the input collections. These will be referred to as the expansion executions for the ExpansionRegion. If the collections have different numbers of elements, then the number of expansion executions is equal to the size of the smallest collection (except in the case of mode=stream, in which case there is only one expansion execution, as discussed later). Each of the expansion executions proceeds independently from the other executions, with the same semantics as the execution of a general StructureActivityNode, except for the following special rules:

接下来,对于输入聚合的每个元素,包含在扩展区域中的活动节点和活动边 被执行一次。这就是所谓的扩展区域的扩展执行。如果聚合中元素的个数不相同,那么扩展执行的次数等于最小聚合的大小(node=stream的情况除外, 这时只有一次扩展执行,将在后面讨论)。每次扩展执行都独立于其他的执行,它的语义和通常的结构化活动节点的执行相同,但是下面的特殊规则除外:

· Within each expansion execution, a single token is offered on each ActivityEdge with an input ExpansionNode as its source and its target inside the ExpansionRegion. This token contains as its value an individual element of the collection on the input ExpansionNode. For each collection on each such input ExpansionNode, a different element is offered for each expansion execution. If the collection is not a set (non-unique), duplicate values are considered to be different elements. If the collections are ordered, then the elements from each collection are aligned in order for each execution (one execution gets all elements from position 1 in the input collections, another gets all elements from position 2, and so on), up to the number of executions (this provides an effective ordering of the expansion executions). If the collections are not ordered, then it is undefined which individual elements of a collection are delivered to which execution (except that no element is delivered to more than one execution).

在每次扩展执行内部,单独的 令牌会发送给每个源节点为输入扩展节点,且目标节点在扩展区域以内的活动边。该令牌以包含的输入扩展节点聚合中的一个元素作为它的值。对于每一个输入扩展 节点上的每一个聚合,都会为每一次执行发送一个不同的令牌。如果聚合不是集合(允许重复),重复的值被看作不同的元素。如果聚合是有序的,那么来自每个聚 合的元素被有序对齐提供给每次执行(一次执行取得位置1上的元素,下一次驱动位置2上的元素,以此类推),直到达到执行次数(这种方式提供一种有效的扩展 执行次序)。如果聚合是无序的,那么聚合的哪个独立的元素传递给哪次执行是无定义的(除非没有元素分传递给多于一次执行)。

· Each expansion execution may result in tokens offered to an ActivityEdge with its source inside the ExpansionRegion and with an output ExpansionNode as its target. Such tokens are immediately accepted by the ExpansionNode and inserted into the output collection for that ExpansionNode. If the input and output collections are both ordered, then the values provided by each execution are concatenated in the same order as is induced on the executions by the input collections. If each execution produces a single value, then the output collection will have the same number of elements as the smallest input collection, and, if the output collection is ordered, it will have an output at each position corresponding to the input at the same position of the input collections. On the other hand, if each execution may or may not produce a value, then the output collection will have fewer elements than the input collections and the ExpansionRegion will act as a kind of filter. Finally, if each execution can produce more than one value, then the output collection may end up with a greater number of elements than the input collections.

每次扩展执行都可能导致令牌被发送给一个源节点在扩展区域内而目标节点为输出扩展节点的活动边。这样 的令牌被扩展节点立即接受并插入到该扩展节点的输出聚合中。如果输入聚合和输出聚合都是有序的,那么每次执行产生的值会被按照被输入聚合引导的执行次序相 同的次序连接。如果每次执行处理一个单值,那么输出聚合会和最小的输入聚合拥有相同数目的元素。并且,如果输出聚合是有序的,会在每个位置上保存和输入聚 合相同位置上对应的输出。另一方面,如果执行可能产生,也能不产生值,那么输出聚合的元素就会少于输入聚合,这时扩展区域作为一种过滤器工作。最后,如果 每次执行可以产生的值多于一个,那么结束是输出聚合中元素的个数会大于输入聚合。

· Tokens placed on the InputPins of an ExpansionRegion are duplicated for each expansion execution, so that each execution is offered a different copy of the tokens on outgoing ActivityEdges from the InputPins. In this way, tokens consumed from an InputPin in one expansion execution do not affect the tokens available from the InputPin in other executions (the tokens on the InputPin effectively appear to be “constant” across the executions). Similarly, tokens offered on ActivityEdges that cross into an ExpansionRegion from outside it (other than those to or from ExpansionNodes of the ExpansionRegion) are duplicated for each expansion execution (the target of each ActivityEdge is offered a separate copy of the tokens within each expansion execution).

放置到扩展区域的输入引脚上的令牌在每 次扩展执行是被复制,以便每次执行都从连接在输入引脚上的输出活动边上得到令牌的不同拷贝。通过这种方式,在一次扩展执行中被消费的输入引脚上的令牌不会 影响到其他的扩展执行中输入引脚上可用的令牌(在执行过程中输入引脚上的令牌事实上好像是常量)。类似的,发送给从外向内穿入活动区域的活动边的令牌(进 出扩展区域的扩展节点的活动边除外)会在每次扩展执行时被复制(每次扩展执行时活动边的目标节点每次都会得到一个令牌的单独拷贝)。

· ExpansionRegions may also have OutputPins and ActivityEdges that cross out of the ExpansionRegion from inside it. However, the semantics are undefined for offering tokens to such OutputPins or ActivityEdges from within the expansion executions of the ExpansionRegion (other than for ActivityEdges to or from ExpansionNodes of the ExpansionRegion).

扩展区域也可以拥有从内向外穿出活动区域的输出引脚和活动边。但是从扩展区域的扩展执行中向这样的输出引脚和活动边发送令牌的语义没有被定义(进出扩展区域的扩展节点的活动边除外)。

When the ExpansionRegion completes all expansion executions, it offers the output collections on its output ExpansionNodes on any ActivityEdges outgoing from those nodes (they are not offered during the execution of the ExpansionRegion). If the ExpansionRegion contains an ActivityFinalNode immediately within it, then, if the ActivityFinalNode accepts a token within any expansion execution, all currently ongoing expansion executions are terminated and the ExpansionRegion as a whole completes its execution. In this case, output collections are still offered from the output ExpansionNodes, though the collections may only be partially filled.

当扩展区域结束了所有的扩展执行以后,扩展区域将所有输出扩展节点上的输入聚合发送到各节点的输 出活动边(在扩展区间执行期间它们不会被发送)。如果扩展区域直接包含活动终止节点,那么,如果活动终止节点在扩展执行期间接受到一个令牌,所有正在进行 的扩展执行会被终止,而且扩展区域整体的执行也会结束。这种情况下,输出聚合还是会被发送到输出扩展节点上,虽然它们可能只是被部分填充了。

The mode of an ExpansionRegion controls how its expansion executions proceed.

扩展区间的模式控制扩展执行如何进行。

· If the value is parallel, the expansion executions proceed concurrently. This allows an execution engine to run the executions in parallel, or otherwise overlapping in time, but this is not required. However, if the executions are run sequentially, then the order in which they are run is not defined.

如果设定值为parallel,则扩展执行会并行处理。这时允许执行引擎并行执行处理,或者在时间上重叠,但这并不是必须的。如果执行被顺序地处理,则处理的次序无定义。

· If the value is iterative, the expansion executions must occur in an iterative sequence, with one completing before another can begin. The first expansion execution begins immediately when the ExpansionRegion starts executing, with subsequent executions starting when the previous execution is completed. If the input collections are ordered, then the expansion executions are sequenced in the order induced by the input collection. Otherwise, the order of the expansion executions is not defined.

如果设定值为iterative,那么扩展执行必须按照循环次序发生,另一次开始之前结束前一次执行。当扩展区域执行开始 后第一次扩展执行马上开始,当前一次执行结束后下一次执行开始。如果输入聚合是有序的,那么扩展执行会按照输入聚合的引导而顺序进行。否则扩展执行的顺序 无定义。

· If the value is stream, there is exactly one expansion execution, and element values are offered to this execution in a stream from each collection. That is, each element of a collection on an input ElementNode is offered separately as a token, one by one, on all outgoing ActivityEdges from the ExpansionRegion (up to a number of tokens equal to the size of the smallest input collection). If the input collections are ordered, then this sequence of offers is made in the same order as the elements of each collection; otherwise the order is not defined. During the course of the single expansion execution, multiple tokens may be accepted by each output ExpansionNode in order to construct the output collections from the ExpansionRegion. If an output collection is ordered, then the elements of the collection are ordered corresponding to the order in which tokens are received by the ExpansionNode.

如果设定值为stream,那么只会有一次扩展执行,而且发送给执行的来自每个聚合中的元素会被写到流中。也 就是说,输入节点上的聚合中的每个元素,会被作为令牌单独地,一个接一个地发送到扩展区域的输入活动边上(直到令牌的数量等于最小输入聚合的大小)。如果 输入聚合是有序的,那么发送的顺序就会和每个聚合中元素的顺序一致;否则顺序无定义。在一次扩展执行过程中,每个输出扩展节点可以接受多个令牌,目的是创 建扩展区域的输出聚合。如果输入聚合是有序的,那么元素会按照令牌被扩展节点接受的次序排列。

16.12.4 Notation(记法)

An ExpansionRegion is shown as a dashed rounded box with one of the keywords «parallel», «iterative» or «stream» in the upper left corner (see Figure 16.48). Input and output ExpansionNodes are drawn as small rectangles divided by vertical bars into small compartments. (The symbol is meant to suggest a list of elements.) The ExpansionNode symbols are placed on the  boundary of the dashed box. Usually, ActivityEdge arrows inside and outside the ExpansionRegion will distinguish input and output expansion nodes. If not, then a small arrow can be used as with Pins (Figure 16.5).

扩展区域表示为一个圆角虚线框,在它的左上角(参见图16.48)标注 «parallel», «iterative» 或«stream»这三个关键字的某一个。输入和输出扩展节点表示为被竖线分割成若干区间的小矩形。(这个符号希望让人联想到元素的列表。)扩展节点符号 被放置在虚线框的边界上。通过活动区域内部,外部的活动边的箭头会区别输入和输出扩展节点。如果没有,可以向引脚一样可以使用一个小箭头来区分(图 16.5)。

Figure 16.48 Expansion Region

As a shorthand notation, the ExpansionNode “list box” notation may be placed directly on an Action symbol, replacing the pins of the action (Figure 16.49). This indicates an expansion region containing a single Action. The equivalent full form is shown in Figure 16.50. In the shorthand notation, there must be one input ExpansionNode corresponding to each in or inout parameter of the behavior (which must have at least one such parameter) and one output ExpansionNode corresponding to each out, inout, or return parameter of the behavior.

作为简略记法,扩展节点列表框符号可以直接放到一个动作符号上以代替动作的引脚(图16.49)。这表示扩展区域包含一个唯一的动作。等价的完整形式如图 16.50。

Figure 16.49 Shorthand notation for expansion region containing single node

Figure 16.50 Full form of previous shorthand notation

图 16.51显示了一个更加简略的方式,来表示一个包含单个调用行为动作的扩展区域。这里使用了图16.49中的记法,但是没有模式关键词,而是在符号的右 上角记入了一个“*”(目的是表明“多次执行”)。这个记法等价于一个包含调用行为动作的扩展区域(如图16.50),外加模式值为parallel。

Figure 16.51 Notation for expansion region with one behavior invocation

16.12.5 Examples(示例)

Figure 16.52 shows an ExpansionRegion with two inputs and one output that is executed in parallel. Execution of the ExpansionRegion does not begin until both input collections are available. Both collections are expected to have the same number of elements. The interior of the ExpansionRegion is executed once for each element in the input collections. During each execution of the region, a pair of values, one from each collection, is available to the interior from the input ExpansionNodes. Each expansion execution produces a result value on the output ExpansionNode. All of the result values are formed into a collection of the same size as the input collections. This output collection is available outside the ExpansionRegion on the output ExpansionNode after all the parallel expansion executions have completed.

图16.52表示一个并发执行的扩展区域,有两个输入和一个输出。扩展区域直到每个输入聚合都给可用时才会开始执行。 这里希望每个聚合拥有同样数量的元素。对于输入聚合的每个元素,扩展区域的内部都会执行一次。在每次执行期间,从输入扩展节点取得一对值(每个聚合一个) 以供内部使用。每次扩展执行在输出扩展节点上产生一个结果值。所有的结果值组成与输入聚合相同大小的输出聚合。当所有的并发扩展执行结束后,输出扩展节点 上的输出聚合可以被扩展区域的外部使用。

Figure 16.52 Expansion region with two inputs and one output

Figure 16.53 shows a fragment of a Fast Fourier Transform (FFT) computation containing an ExpansionRegion. Outside the ExpansionRegion, there are operations on arrays of complex numbers. S, Slower, Supper, and V are arrays. Cut and shuffle are operations on arrays. Inside the region, two arithmetic operations are performed on elements of the three input arrays, yielding two output arrays. Different positions in the arrays do not interact, therefore the ExpansionRegion can be executed in parallel on all positions.

图16.53展示了快速傅里叶变换(FFT)处理的一个片段,它包含了一个扩展区域。在扩展区域的外 面,有个针对复数数组的操作,S,Slower,Supper和V都是数组,操作的内容是分割和打乱数组。在扩展区域内部,对三个输入数组进行两个数学计 算后,产生两个输出数组。数组中的不同位置的数据不会相互影响,所以这个扩展区域可以对所有位置上的数据进行并行处理。

Figure 16.53 Expansion Region

Figure 16.54 shows a use of the shorthand notation for an ExpansionRegion with a single Action. In this example, the Specify Trip Route action outputs sets of flights and sets of hotels to book. The hotels may be booked independently and in parallel with each other and with booking the flight.   图16.54展示了包含一个单独动作的扩展区域的简略记法的使用方法。在这个例子中,Specify Trip Route动作输出航班和酒店的集合用于预订,一家酒店可以独立地和其他酒店或航班并行预订。

Figure 16.54 Examples of expansion region shorthand

In Figure 16.55, Specify Trip Route can result in multiple flight segments, each of which must be booked separately. The Book Flight action will invoke the Book Flight Behavior multiple times, once for each flight segment in the set passed to Book Flight.

在图16.55中,SpecifyTripRoute动作可以给生成多个航段,每个必须独立预定,预定航班动作将会调用预定航班行为多次,对传递给BookFlight扩展区域的每个航段执行一次。

Figure 16.55 Shorthand notation for expansion region

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:jWebapp- MVC框架
下一篇:开发租赁小程序(开发小程序需要租服务器吗)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~