In SimEvents, is it possible to adjust the simultaneous event resolution priority for queues so that the NewHeadOfQueue event does not have priority SYS2?

3 views (last 30 days)
*Answered in a separate e-mail correspondence with MathWorks:
"Unfortunately, the NewHeadOfQueue priority is hard-coded, and there’s no direct way to influence. Our developers don’t particularly like this behavior either, and they are considering altering in the future."
Currently, the only fix is to manually set the event resolution paths leading up to the queue such that the higher priority entities will use higher event priority servers/gates/etc.*
The problem I'm having is that with multiple entity paths with their own generators and model behavior, multiple entities may reach a priority queue (downstream after a path combiner) at the same sim time, and because the NewHeadOfQueue event is scheduled at SYS2 immediately after the arrival of the first entity, this event will be executed before the other entities reach the queue at the same sim time (e.g. if they come from server blocks or gates with a priority even as high as 1, which is the highest you can set for servers). Which entity passes through the queue first then depends on different event resolution priorities in that entity's path to the queue, or, if they're all the same, which entity's generating block was placed in the model first.
Ideally, I would like my NewHeadOfQueue event to have a lower priority than any paths upstream of the queue such that if multiple entities will reach a queue at the same sim time, the highest priority entity according to the priority sorting attribute is the entity that passes through the queue first. I'm not sure if that's possible with the way SimEvents works, but I suspect it should be since hooking a queue up to a gate means that the gate's entity request event at SYS1 cuts in before the NewHeadOfQueue and can change the entity at the head of the queue between the scheduling and execution of NewHeadOfQueue.
Alternatively, if I cannot change the priority of the NewHeadOfQueue, is there some sort of other way to achieve the same behavior?
  1 Comment
Wei Li
Wei Li on 23 Jul 2015
Hi Grant,
I'm from SimEvents development team. Yes, we aware of this issue and are working on solutions in future release. For now, please consider a workaround as described by following steps:
1. Connect a SimEvents Enabled Gate block immediate after the "Priority Queue" block
2. Open the Block Parameters dialog of the "Enabled Gate" block, check the checkbox "Resolve simultaneous signal updates according to event priority". In the "Event priority" edit-box shown below, put in a large integer number (e.g. 2000) to indicate a lowered gating priority. Click "OK".
3. Open the block parameters dialog of the "Priority Queue" block, select "Statistics" tab, then check "Number of entities in queue, #n" checkbox. Click "OK".
4. Connect the newly appeared "#n" port of the "Priority Queue" with the "en" port of the "Enabled Gate".
5. Open the "Model Configuration Parameters" dialog (by selecting item in the model's "Simulation" menu). In the left-hand list, select SimEvents->Diagnostics. Then, in the right-hand panel, turn the popup list "Statistical output delayed relative to entities" to "none".
6. Now run the simulation, the priority inversion issue shall go away. The workaround here is to use an Enabled Gate block to override the SYS2 event priority of the NewHeadOfQueue event.

Sign in to comment.

Answers (0)

Categories

Find more on Messages in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!