How can I select an entity with a specified attribute within a queue?

6 ビュー (過去 30 日間)
Alessio
Alessio 2013 年 9 月 17 日
In SimEvents I want to get out of a queue an entity that possesses a specified attribute. If the entity does not meet the requirement, it remains in the queue.

採用された回答

Devdatt Lad
Devdatt Lad 2013 年 9 月 17 日
You can create an interative scheme in which each entity is moved out of the queue, then tested, and if it fails the test then routed back to the queue (via an Output Switch and a Path Combiner). If it passes the test then route it via the Output Switch outside the iteration loop. You can create several variations of this design pattern to implement:
  • find the first entity that satisfies a predicate
  • find all entities that satisfy a predicate
  • find first N entities that satisfy a predicate etc.
Not the most convenient syntax, but it should work.
  1 件のコメント
Felix
Felix 2013 年 9 月 19 日
編集済み: Felix 2013 年 9 月 19 日
I just had the same question - so thank you Devdatt for your answer. I understood your basic logic but could you please give me a hint how to implement a design that "finds the first N entities that satisfy a defined attribute".
Lets say I have a queue which acts as an inventory for 10 product types (defined by attribute). There are several entities of each product type in the inventory/queue. Now I only want to get 5 entities of type X out of the queue even though there might be 20 available. The other 15 entities should stay in the queue. Could you give me a hint? Thanks in advance!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete-Event Simulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by