Anylogic: How to keep an agent waiting in queue until it changes state? (Discrete Events flowchart)

≯℡__Kan透↙ 提交于 2020-03-04 18:19:04

问题


I'm starting to use Anylogic for a simulation class, and for this I need to model the following behaviour: there's a stream of agents that enter a FIFO queue, and then enter into a server (that I modeled with a delay block), one at a time. The agents have two states (call them A and B), and if an agent reaches the end of the queue in state A, it has to wait until it returns to state B to go into the service.

I think a wait block with capacity for one agent, between the queue and the delay block could potentially solve this situation. But I don't know how to make the wait block to free the agent as soon as it changes state.

Other methods are welcome. I just need the agent to be retained before the delay block as long as it is in the state A, but not any longer. Thanks in advance.


回答1:


Yes... a wait block with capacity 1 after your queue block is what I would do.

Now when your agent enters the state, on the entry action of that stateB you do the following:

if(currentBlock().equals(main.waitBlock) && main.service.size()==0){
    main.waitBlock.free(this); 
}

You will also need to do this in the "on enter" of the wait block:

if(agent.inState(agent.stateB) && service.size()==0){
    self.free(agent);
}

also, just in case, add a population of 0 of your agent type in main, to be able to use main. in your agent state code.



来源:https://stackoverflow.com/questions/58618511/anylogic-how-to-keep-an-agent-waiting-in-queue-until-it-changes-state-discret

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!