元件詳解:離散事件 - 流程模型 - Service

Service 元件圖

若注意看Service元件圖的內部,是否有似曾相識的感覺。沒錯,他就是由QueueDelay所組成。
因為,Delay常常需要Resource來支援,所以,叫用Resource的Seize也內建在Service元件中。
有叫用Resource來完成這個Service,自然在完成後,就會Release Resource。
若實務情境是很單純,例如一個櫃台。Entity會過來乖乖地排隊,不會東跑西跑;資源也是乖乖地就定位;然後作業時間也沒有那麼多條件變化,就可以考慮使用Service。當你使用PEL版本搞複雜模型時,Service就很重要了。

配對元件

類似元件

  • Assembler

相關元件

  1. Name:此物件名稱。主要是用在程式面。
  2. 這個等同Seize元件。
  3. 這個等同Queue元件。
  4. 這個等同Delay元件。
  5. 這個等同Seize元件。
  6. 如屬性名稱所示,設定Network相對應節點位置。

事件

On enter
當Entity進入時。Local variable: agent - the agent 本身
On exit (timeout)
[選擇Queue: exit on timeout時出現] 
當Entity發生timeout時。Local variable: agent - the agent本身
On exit (preempted) [code]
[選擇Queue: enable preemption時出現] 
Entity從preemption port被擠出時。Local variable: agent - the agentㄅ本身
On seize unit
當Entity有抓到資源時。
Local variables: agent - the agent本身
                          Agent unit - 所抓到的資源
On enter delay
當Entity開始進入delay狀態時。Local variables:  T agent - the agent 本身
                           double delayTime - 此Entity所取得的delay時間。
On at exit 
當Entity到達離開點時。Local variable: agent - the agent本身
On exit
當Entity以正常狀態離開時。Local variable: agent - the agent本身
On task suspended
[當Task preemption policy 被設成Wait for original resource 或抓取任何resource時顯示]  
當Entity處理暫停狀態時。例如在等候資源的時候,並沒有真正進入Delay狀態。
Local variables: agent - the agent本身
                          Agent unit - 所抓取的資源
On task resumed 
[Task preemption policy 被設成Wait for original resource 或抓取任何resource時顯示]
當Entity重新恢復到Delay狀態時。有些情況做到一半,需要其他資源,那就會到suspended狀態。等抓到資源可以重新執行,就啟動resumed。
Local variables: agent - the agent
                          Agent unit - 所抓取的資源
On task terminated 
[當Task preemption policy被設成Terminate serving
因為資源取得是設定優先序,目前這個Entity輸給別人資源被強走,此Delay被中斷時。
Local variables: agent - the agent本身
                          Agent unit - the unit which has originated termination.原本抓取到的資源
On remove 
當Entity被離開這個Service元件時。也就是被強迫中斷。
Local variable: agent - the agent本身


函數

int queueSize() - 回傳目前 Queue區塊中的個數。
T queueGet(int index) -  回傳目前在Queue區塊中,第index的Enity (0 則是取在exit那一個Entity)。
T queueRemove(Agent agent) - 從 Queue區塊 中移除某 agent,並回傳本身。
int delaySize() - 回傳目前在 Delay區塊中的個數
T delayGet(int index) - 回傳目前在Delay區塊中,第index的Enity (0 是只最早進來的Entity)。
T delayRemove(Agent agent) - 從Delay區塊中移除某agent,並回傳本身。
T remove(Agent agent) - 從Service中移除某 agent,並回傳本身。若此agent不在這Service中,則傳回null
int size() - 回傳目前在Service中的個數。
T resume(Agent agent) - 將某個在Delay區塊中的Agent,從暫停轉到恢復。若無此Agent則造成錯誤。
T suspend(Agent agent) - 讓delay呈現暫停狀態,暫停時間timeout dt.
double utilization() -  回傳Service的使用率。
<U extends Agent> List<U> getResourceUnits(agent) - 回傳此Agent在Service所抓取到的所有資源。

留言

這個網誌中的熱門文章

等候理論

AnyLogic簡單介紹

機率分配 - Part 6 Poisson