Schedule Timeout Block workaround

조회 수: 3 (최근 30일)
Zach Anthis
Zach Anthis 2019년 12월 3일
댓글: Dan Hernandez 2021년 2월 2일
How can I preset a threshold for entities based on attribute (e.g. patience) whilst keeping counts of early departures from a FIFO queue in SimEvents r2019b?

답변 (2개)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 5월 28일
AFAIK You cannot implement it by SImEvent's default blocks. What you need is a customized FIFO queue and is only possible using the MATLAB Discrete-Event System (MDES). This block allows you to programmatically define your customized queue.
Your MDES would need two input ports, two storages, and one output. Your customers (which are entities with two attributes of WaitingTime and EntryTime) arrive at the first storage and are stored in storage 1 which has a FIFO layout. Patience update events (entities) arrive at the second input port. They invoke an event to iterate over the existing entities in the storage 1 (using the method obj.eventIterate). You define an event action method for the iteration (say, CustomerIterate) which was invoked inside the obj.eventIterate and assign new values to the attribute WaitingTime. The new WaitingTime is calculated by subtracting the EntryTime from the current simulation time. In order to get the current simulation time, you need to create a simulink function which has a digital clock in it. You must declate this simulink function using the getSimulinkFunctionNamesImpl method.

Dan Hernandez
Dan Hernandez 2021년 1월 26일
Hi, I'm going to give my own take on this one. Bear in mind that this approach is admitedly a hack.
An alternative to Discrete-Event System could be using the Entity Find block to find and extract entities after they have spent a set amount of time in a block. This is a variation of the Find and Extract pattern. See below.
Essentially, you can use the timestamp pattern to record when an entity gets created (the entry event action of an entity generator). A second attribute can be used to define "Patience" (how long an entity is willing to wait in a certain block). Then, we constantly monitor entities and subtract current simulation time from the creation timestamp, if the value is greater than the Patience attribute we extract the entity. See the model below.
In the entity generator we have:
We connect a Resource Acquirer to the Generator and then we add the Entity Server and the terminator.
We add a Resource Pool, the settings as default. Then we add another Entity generator and we call that the Trigger Entity Generator. In here we keep Period to 1, and change entity type to Trigger.
We connect the Trigger Entity Generator to the Entity Find block, and tick the options Extract found entities and Additional filtering condition.
For the additional filter condition, you would write
The last bit then, is to add the timestamp function itself, which can be done with a Simulink Function. Just see the pattern here.
I hope that helps.

카테고리

Help CenterFile Exchange에서 Discrete-Event Simulation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by