'Assigning certain agents to a certain resource unit based on source

I currently have 2 different source blocks, 1 that sources agents for one half of the day, the other for the other half. Both converge into the same starting point of the model. I am only using 2 different sources to help simulate 2 different halves of the day.

I also have a resourcePool that increases in capacity from 1 to 2 at time() == 150. How can I ensure that the 1st resource unit that starts the day interacts only with those agents coming from source1, and the 2nd resource unit that arrives at time 150 only interacts with those agents coming from source2? Agents from both sources go through the same seize blocks that seize 1 unit each of 2 different resources at the same time.

There is a short overlap in which both resource units are working, so I want to ensure that one is not interacting with the other's agents.



Solution 1:[1]

You need to make use of the resource choice option inside a size block.

To do this start by having a new agent that will represent the resources inside your resource pool and give it a variable that you can use for assigning what source agents it will take. e.g. have an int variable sourceNumber

enter image description here

Now when you increase the number of resources in the resource pool from 1 to 2, you assign the source number of the second resource to 2.

resourcePool.set_capacity(2);
int counter = 0;
for (MyResource r:resourcePool) {
    r.sourceNumber = counter;
}

If the agents that need to seize the resource all use the same seize blocks it is perhaps best to make a custom agent and send the seize block from which they came to the agent.

enter image description here

Then inside the source the resource choice field van be used to dictate the correct resource to use

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1