Sort by Priority

Behavior of the Priority Queue Block

The Priority Queue block supports queuing in which entities' positions in the queue are based primarily on their attribute values. Arrival times are relevant only when attribute values are equal. You specify the attribute and the sorting direction using the Sorting attribute name and Sorting direction parameters in the block's dialog box. To assign values of the attribute for each entity, you can use the Set Attribute block as described in Set Entity Attributes.

    Note:   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.

FIFO and LIFO as Special Cases of a Priority Queue

Two familiar cases are shown in the example below (open modelmodel), in which a priority queue acts like a FIFO or LIFO queue. At the start of the simulation, the FIFO and LIFO sections of the model each generate nine entities. The first entity advances to a server. The remaining entities stay in the queues until the server becomes available. The sorting attribute is Count, whose values are the entities' arrival sequence at the queue block. In this example, the servers do not permit preemption; preemptive servers would behave differently.

The FIFO plot reflects an increasing sequence of Count values. The LIFO plot reflects a descending sequence of Count values.

Serve Preferred Customers First

In the example below (open modelmodel), two types of customers enter a queuing system. One type, considered to be preferred customers, are less common but require longer service. The priority queue places preferred customers ahead of nonpreferred customers. The model plots the average system time for the set of preferred customers and separately for the set of nonpreferred customers.

You can see from the plots that despite the shorter service time, the average system time for the nonpreferred customers is much longer than the average system time for the preferred customers.

Average System Time for Nonpreferred Customers Sorted by Priority

Average System Time for Preferred Customers Sorted by Priority

Comparison with Unsorted Behavior

If the queue used a FIFO discipline for all customers instead of a priority sorting, then the average system time would decrease slightly for the nonpreferred customers and increase markedly for the preferred customers.

Average System Time for Nonpreferred Customers Unsorted

Average System Time for Preferred Customers Unsorted

Was this topic helpful?