Output Switch - Select entity output port for departure

Library

Routing

Description

This block receives entities, which depart through one of multiple entity output ports. The selected port can change during the simulation.

Managing Arrivals and Departures

When the selected port is not blocked, an arriving entity departs through that port. When an entity attempts to arrive and the selected port is blocked, the block's behavior depends on the block's configuration and state, as illustrated in the figure.

Entities that time out depart via the block's TO port. For details on timeouts, see Forcing Departures Using Timeouts.

Switching Criteria

The Switching criterion parameter indicates how the block determines which entity output port is selected for departure at any given time. The values of the Switching criterion parameter are described in the table below.

Switching criterion ValueDescription
Round robinThe first arriving entity in the simulation departs via the OUT1 port. Upon each subsequent arrival, the block selects the entity output port next to the last selected port. After exhausting all entity output ports, the block returns to the first one, OUT1.
EquiprobableAt the beginning of the simulation and upon each departure, the block randomly chooses the entity output port through which the next arriving entity departs. All entity output ports are equally likely to be selected. The Initial seed parameter initializes the random number generation process.
First port that is not blockedWhen an entity attempts to arrive, the block attempts to output the entity through OUT1. If that port is blocked, then the block attempts to output the entity through OUT2, and so on. If all entity output ports are blocked, then this block's IN port is unavailable and the entity cannot arrive.
From signal port pSelecting this option creates an additional signal input port, labeled p. The signal at this port uses integer values between 1 and the Number of entity output ports parameter value to refer to entity output ports. The block monitors the p signal's value throughout the simulation and reacts to changes by selecting the corresponding entity output port.
From attributeAn arriving entity departs through the entity output port that corresponds to the value of an attribute of your choice. Name the attribute using the Attribute name parameter. The attribute value must be an integer between 1 and the Number of entity output ports parameter value. If the indicated entity output port is blocked, then this block does not accept the entity for arrival until the entity output port becomes unblocked.

Ports

Entity Input Ports

LabelDescription
INPort for arriving entities.

Signal Input Ports

LabelDescription
pIndex of the entity output port through which an arriving entity departs. Values must be integers between 1 and Number of entity output ports. This port appears only if you set Switching criterion to From signal port p.

Entity Output Ports

LabelDescription
OUT1, OUT2, OUT3, etc.Entity ports through which an arriving entity departs, where the Switching criterion parameter determines which of multiple ports the entity departs through. The Number of entity output ports parameter determines how many of these entity output ports the block has.
TOPort for entities that time out while in this block. This port appears only if you set Switching criterion to From signal port p, select Store entity before switching, and select Enable TO port for timed-out entities. This port must not be blocked when an entity attempts to depart here.

Signal Output Ports

LabelDescriptionTime of Update When Statistic Is OnOrder of Update
#dNumber of entities that have departed from this block without timing out, since the start of the simulation.After entity departure via a port other than TO3
#toNumber of entities that have timed out from this block since the start of the simulation.After entity departure via the TO port2
peA value of 1 indicates when the block stores an entity after the entity tries and fails to depart. A value of 0 indicates when the storage location is empty or an entity departure is imminent.After storage completion event if the entity fails to depart, and when entity departure is imminent1
lastIndex of the output port through which the last entity departed, excluding timed-out entities. Aside from the initial condition, values of this signal are 1, 2, 3,..., Number of entity output ports.After entity departure via a port other than TO2

The initial output value, which is in effect from the start of the simulation until the first update by the block, is 0 for all signals.

Dialog Box

Output Switch Tab

Number of entity output ports

Determines how many entity output ports the block has. This parameter must be a literal value, not a variable or an expression requiring evaluation.

Switching criterion

The rule that determines which entity output port an arriving entity departs through.

Initial seed

A nonnegative integer that initializes the random number generator used to select an entity output port. This field appears only if you set Switching criterion to Equiprobable.

Specify initial port selection

Select this option to indicate the initially selected entity output port. For details, see Specifying an Initial Port Selection. This field appears only if you set Switching criterion to From signal port p.

Initial port selection

The entity output port that the block selects when the simulation begins. The value must be an integer between 1 and Number of entity output ports. The block uses Initial port selection instead of the p signal's value until the signal has its first sample time hit. This field appears only if you set Switching criterion to From signal port p and select Specify initial port selection.

Store entity before switching

If you select this option, the block can store one entity at a time. Furthermore, the block decouples its arrival and departure processing to give other blocks in the simulation an opportunity to update the p signal if appropriate. If you do not select this option, the block processes an arrival and departure as an atomic operation and assumes that the p signal is already up to date at the given time. For details, see Using the Storage Option to Prevent Latency Problems. This field appears only if you set Switching criterion to From signal port p.

Resolve simultaneous signal updates according to event priority

Select this option to explicitly prioritize the port-selection event, relative to other simultaneous events in the simulation. If you do not select this option, the event has priority SYS1 on the event calendar. For details, see Choosing How to Resolve Simultaneous Signal Updates. This field appears only if you set Switching criterion to From signal port p and do not select Store entity before switching.

Event priority

The priority of the port-selection event, relative to other simultaneous events in the simulation. For details, see Specifying Event Priorities to Resolve Simultaneous Signal Updates. This field appears only if you set Switching criterion to From signal port p, do not select Store entity before switching, and select Resolve simultaneous signal updates according to event priority.

Attribute name

The name of an attribute used to select an entity output port. This field appears only if you set Switching criterion to From attribute.

Timeout Tab

Enable TO port for timed-out entities

This option is available only if you set Switching criterion to From signal port p, and then select Store entity before switching on the Output Switch tab of the dialog box. This option becomes relevant if an entity times out while in this block. Selecting this option provides a TO entity output port through which the timed-out entity departs. If you clear this option in a model that uses timeouts, see the description of the If entity has no destination when timeout occurs parameter on the Schedule Timeout block reference page.

Statistics Tab

These parameters determine whether certain ports produce data throughout the simulation, produce data only when you stop or pause the simulation, or are omitted from the block. For descriptions of the affected ports, see the "Signal Output Ports" table above.

Number of entities departed

Controls the presence and behavior of the signal output port labeled #d.

Number of entities timed out

Controls the presence of the signal output port labeled #to.

Status of pending entity

Controls the presence of the signal output port labeled pe. This parameter can have the value On only if you set Switching criterion to From signal port p, and then select Store entity before switching on the Output Switch tab of the dialog box.

Last entity departure port

Controls the presence of the signal output port labeled last.

Examples

See Also

Input Switch

Using the Output Switch, Output Switching Based on a Signal

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS