Anylogic:如何让代理在队列中等待直到它改变状态?(离散事件流程图) [英] Anylogic: How to keep an agent waiting in queue until it changes state? (Discrete Events flowchart)

查看:84
本文介绍了Anylogic:如何让代理在队列中等待直到它改变状态?(离散事件流程图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始将 Anylogic 用于模拟类,为此我需要对以下行为进行建模:有一个代理流进入一个 FIFO 队列,然后进入一个服务器(我用延迟建模块),一次一个.代理有两种状态(称为 A 和 B),如果代理在状态 A 到达队列末尾,则必须等到返回状态 B 才能进入服务.

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.

欢迎使用其他方法.我只需要在延迟块之前保留代理,只要它处于状态 A,但不再保留.提前致谢.

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.

现在,当您的代理进入状态时,在该状态 B 的进入动作中,您执行以下操作:

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); 
}

您还需要在等待块的on enter"中执行此操作:

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);
}

此外,为了以防万一,在 main 中添加 0 个您的代理类型,以便能够使用 main.在您的代理状态代码中.

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.

这篇关于Anylogic:如何让代理在队列中等待直到它改变状态?(离散事件流程图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆