0
votes

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. So if the agent is located in node1 it will seize resource1 otherwise it will seize resource2? 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.

1

1 Answers

0
votes

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.

enter image description here

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:

<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