Priority Queue (Obsolete)

Store entities in sorted sequence for undetermined length of time




This block stores up to N entities simultaneously in a sorted sequence, where N is the Capacity parameter value. The queue sorts entities according to the values of an attribute, in either ascending or descending order. Use the Sorting attribute name and Sorting direction parameters to determine the sorting behavior. The block accepts real numbers, Inf, and -Inf as valid values of the sorting attribute.

The block attempts to output an entity through the OUT port but retains the entity if the OUT port is blocked. If an entity in this block is scheduled to time out, then it might depart prematurely via the optional TO port. The length of time that an entity stays in this block cannot be determined in advance. The IN port is unavailable whenever this block stores exactly N entities. In this case, the queue is said to be full.

While you can view the value of the sorting attribute as an entity priority, this value has nothing to do with event priorities or block priorities.


Entity Input Ports

INPort for arriving entities, which will be stored.

Entity Output Ports

OUTPort for departing entities that do not time out while in this block.
TOPort for entities that time out while in this block. You see this port only if you 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 When Entity Departs
#dNumber of entities that have departed from this block via the OUT port since the start of the simulation.After entity departure via the OUT port3
#nNumber of entities currently in the queue.After entity arrival and after entity departure2
wSample mean of the waiting times in this block for all entities that have departed via any port.After entity departure1
lenAverage number of entities in the queue over time, that is, the time average of the #n signal.After entity arrival and after entity departure.1
#toNumber of entities that have timed out from this block since the start of the simulation.After entity departure via the TO port3

Output signals having the same number in the Order of Update column in the table above are updated in an arbitrary sequence relative to each other; you should not rely on a specific sequence for your simulation results.

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.


Priority Queue Tab


Determines how many entities the block can store at a time. The capacity must be a positive integer or Inf.

Sorting attribute name

The block uses this attribute to sort entities in the queue.

Sorting direction

Determines whether the entity at the head of the queue is the one with the smallest (Ascending) or largest (Descending) value of the attribute named above. Entities sharing the same attribute value are sorted in FIFO sequence.

Timeout Tab

Enable TO port for timed-out entities

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 If entity has no destination when timeout occurs parameter of the Schedule Timeout (Obsolete) block.

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 preceding table, "Signal Output Ports".

Number of entities departed

Allows you to use the signal output port labeled #d.

Number of entities in queue

Allows you to use the signal output port labeled #n.

Average wait

Allows you to use the signal output port labeled w.

Average queue length

Allows you to use the signal output port labeled len.

Number of entities timed out

Allows you to use the signal output port labeled #to.

Introduced before R2006a

Was this topic helpful?