Serve High-Priority Customers by Sorting Entities Based on Priority - MATLAB & Simulink (original) (raw)

This example shows how to minimize the time required to serve high-priority customers by using a priority queue and Entity Input Switch and Entity Output Switch blocks. Customers are served based on their service priorities. In this example, two types of customers enter a queuing system. One type represents high-priority customers with high urgency. The second type of customers are lower priority and are served with less urgency. The priority queue places high-priority customers ahead of low-priority customers.

Build the Model

In the model, arriving customers are represented by Entity Generator and Entity Generator1.

The Entity Output Switch block accepts entities generated by the Entity Generator and the Entity Generator1 blocks and forwards them to the priority queue.

The Entity Queue block represents the queueing of the customers and prioritizes them based in their service urgency.

The Simulink Function block is used to timestamp the entities that enter the Entity Queue block.

entity.starttime = getCurrentTime();

In the Simulink Function block, a Digital Clock block is used to timestamp the entity entering the Entity Queue block.

The Entity Server block represents the service the customer receives.

The Entity Output Switch block output the entities for departure.

When an entity enters the Entity Terminator block, the recordHighPriorityWaitTimes(starttime) function is called to calculate the time spent between an entity's arrival at the Entity Queue block and its departure from the Entity Terminator block.

Simulate Model and Review Results

The simulation time of the model is set to 100.

Simulate the model and observe the results displayed in the Dashboard Scope block. The block shows that the waiting time for high-priority customers is significantly less than the low-priority customers.

See Also

Entity Queue | Entity Server | Entity Output Switch | Entity Input Switch | Simulink Function

Topics