Interleaving of Block Operations

Overview of Interleaving of Block Operations

During the simulation of a SimEvents® model, some sequences of block operations become interleaved when the application processes them. Interleaving can affect the simulation behavior. This section describes and illustrates interleaved block operations to help you understand the processing and make appropriate modeling choices.

How Interleaving of Block Operations Occurs

At all simulation times from an entity's generation to destruction, the entity resides in a block (or more than one block, if the entity advances from block to block at a given time instant). Blocks capable of holding an entity for a nonzero duration are called storage blocks. Blocks that permit an entity arrival but must output the entity at the same value of the simulation clock are called nonstorage blocks. During a simulation, whenever an entity departs from a block, the application processes enough queries, departures, arrivals, and other block operations until either a subsequent storage block detects the entity's arrival or the entity is destroyed. Some block operations, including the updates of statistical output signals that are intended to be updated after the entity's departure, are deferred until after a subsequent storage block detects the entity's arrival or the entity is destroyed.

To change the sequence of block operations, you might need to insert storage blocks in key locations along entity paths in your model, as illustrated in Sequence of Departures and Statistical Updates. A typical storage block to insert for this purpose is a server whose service time is 0.

Sequence of Departures and Statistical Updates

Consider the sequence of operations in the Time-Based Entity Generator, Set Attribute, and Attribute Scope blocks shown below (open modelmodel).

At each time T = 1, 2, 3,..., 10, the application processes the following operations in the order listed:

OrderOperationBlock
1Entity generationTime-Based Entity Generator
2Entity advancement to nonstorage blockFrom Time-Based Entity Generator to Set Attribute
3Assignment of attribute using value at A1 signal input portSet Attribute
4Entity advancement to nonstorage blockFrom Set Attribute to Attribute Scope
5Entity destructionAttribute Scope
6Update of plotAttribute Scope
7Update of signal at #d signal output portTime-Based Entity Generator

The final operation of the Time-Based Entity Generator block is deliberately processed after operations of subsequent blocks in the entity path are processed. This explains why the plot shows a value of 0, not 1, at T=1.

Alter the Processing Sequence

If you want to be sure that the Set Attribute block reads the value at the A1 signal input port after the Time-Based Entity Generator block has updated its #d output signal, then insert a storage block between the two blocks. In this simple model , you can use a Single Server block with a Service time parameter of 0. The model, table, and plot are below (open modelmodel).

OrderOperationBlock
1Entity generationTime-Based Entity Generator
2Entity advancement to storage blockFrom Time-Based Entity Generator to Single Server
3Update of signal at #d signal output portTime-Based Entity Generator
4Service completionSingle Server
5Entity advancement to nonstorage blockFrom Single Server to Set Attribute
6Assignment of attribute using value at A1 signal input portSet Attribute
9Entity advancement to nonstorage blockFrom Set Attribute to Attribute Scope
10Entity destructionAttribute Scope
11Update of plotAttribute Scope

Consequences of Inserting a Storage Block

If the storage block you have inserted to alter the processing sequence holds the entity longer than you expect (beyond the zero-duration service time, for example), be aware that your simulation might change in other ways. You should consider the impact of either inserting or not inserting the storage block.

For example, suppose you add a gate block to the preceding example and view the average intergeneration time, w, of the entity generator block. When the gate is closed, a newly generated entity cannot advance immediately to the scope block. Whether this entity stays in the entity generator or a subsequent server block affects the w signal, as shown in the figures below.

Model with Gate and Without Storage Block

Open modelmodel.

When a storage block is present, the first pending entity stays there instead of in the entity generator. The earlier departure of the first entity from the entity generator increases the value of the w signal.

Model with Gate and Storage Block

Was this topic helpful?