Selection Server - Outside/global variables.

I'm using the Selection Server of SimEvents but cannot get it to be applicable for my uses.
The Selection Server uses key arrivals(entity) to match them to passengers inside the queue. After a key has arrived, he looks for a corresponding passenger and destroys the key. My problem is that whenever a key hasn't been matched to a passenger (because there simply is no passenger with that key yet) it still gets destroyed. So when that next passenger arrives there is no key left and he will never leave the queue.
I've thought on 2 solutions,
  • Postpone destroying the key, ill-advised because multiple loops arise.
  • Keep Boolean Array which will be checked when a passenger arrives. If the corresponding key-Boolean is true. The passenger can leave the queue.
This Boolean array I'm referring to would be a global variable, but I have no idea how to incorporate this within an "classdef" environment.

1 个评论

In our Selection Server example, the output responses immediately to the key arrivals, while the passengers are stored in the storage. That's why we do not design a life time for the key entity. If you want the keys to live, I think your two solutions are both valid.
1. You can schedule a timer event in the "callEntryImpl" method to replace the destroy event, and in the "callTimerImpl" method you schdule the destroy event. In method "passengerEntryImpl", you also need to schedule an iterate event to loop though storage 2 to compare the input passenger with previous keys. Don't forget to change the size of storage 2.
2. You can also choose to cache the keys in an array as a private property of the system object, instead of directly using the "call" entities in storage 2 for comparison. You can refer to http://www.mathworks.com/help/matlab/matlab_oop/defining-properties.html for the peroperty definition. In the "passengerEntryImpl" method, you can use "obj.<property_name>" to access it.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File 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