[英]Anylogic - Seize resource based on agent location
I'm a novice AnyLogic user and I am wondering whether it is possible to seize a resource from a resource pool, based on the seizing agent's location.我是 AnyLogic 的新手,我想知道是否可以根据获取代理的位置从资源池中获取资源。 So if the agent is located in node1 it will seize resource1 otherwise it will seize resource2?
因此,如果代理位于节点 1 中,它将占用资源 1,否则将占用资源 2? If it is, what code can I use?
如果是,我可以使用什么代码?
I have tried using the "Customize resource choice" and "Resource choice condition", but it hasn't worked.我曾尝试使用“自定义资源选择”和“资源选择条件”,但没有奏效。
There is in fact a very simple way.其实有一个非常简单的方法。 The resource pool field is a dynamic one.
资源池字段是动态的。 Clicking on the equal symbol in the service properties turns the equal symbol to a circular arrow which means this field is dynamic and can thus be defined based on agent properties dynamically.
单击服务属性中的等号会将等号变为圆形箭头,这意味着该字段是动态的,因此可以根据代理属性动态定义。
Now, in this field you can enter your code.现在,您可以在此字段中输入您的代码。 The code here is not your regular code, so you should not use "if", use the following syntax instead:
这里的代码不是你的常规代码,所以你不应该使用“if”,而是使用以下语法:
<statement> ? <value if true> : <value if false>
Finally, to refer to the agent, you just need to use the word agent.最后,要引用代理,您只需要使用代理一词即可。 Here is an example with three resource pools:
下面是一个包含三个资源池的示例:
node1.contains(agent) ? ResourcePool1 : node2.contains(agent) ? ResourcePool2 : ResourcePool3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.