name123
name123

Reputation: 65

AnyLogic: Distribution by enter block depending on capacities in three resources

I have created multiple instances of a resource and filled them with specific delay and queue blocks. At the start of the resource I set a restricted area to check how many agents are in the resource.

Screenshot Model

My goal is to distribute incoming agents in queue1 first to resource1 until it contains 50 agents. These 50 agents are then in resource1 and are in longer delay blocks. After that resource2 should be filled until there are 50 agents in it, then resource3 and so on (theoretically still scalable upwards, but for now only for three).

The agents all arrive in time. There is a priority that first one resource is filled completely, then the next one. For this I have written a function, which is regularly updated in the event. My problem is that I don't how to make such distributions based on more and more arriving agents and additionally consider the capacities of each resource.

Screenshot Function Code

Unfortunately, since all conditions are true at the beginning and thus all if queries are true, an error is thrown. Can someone please help me here?

Upvotes: 0

Views: 67

Answers (1)

Benjamin
Benjamin

Reputation: 12605

Adjust the code as below:

if (resource1.restrictedAS.entitiesInside() < 50) {
    ...
} else if (resource2.restrictedAS.entitiesInside() < 50) {
    ...
} else if (resource3.restrictedAS.entitiesInside() < 50) {
    ...
}

Upvotes: 1

Related Questions