DiaLaDia
DiaLaDia

Reputation: 3

Create collection of agents already in queue in Anylogic

I'm simulating abandonment by waiting customers in a queue environment. I'm assuming that a person will abandon a queue if they notice that people who were in the queue ahead of them have left the queue (amongst other things like their own time in queue). To do this, I need to capture the details of the people already waiting in a queue when a new person joins the queue. I figure I need a collection created in the customer agent that i can store agent details of those ahead of them in queue. I can then use code to "populate" this collection via the on enter action of the queue block. but I'm not sure how to progress. I am struggling with how to find the IDs of agents in a queue and collect values of their parameters. Any help will be appreciated! Thank you.

Upvotes: 0

Views: 551

Answers (1)

Jaco-Ben Vosloo
Jaco-Ben Vosloo

Reputation: 3975

When a new agent enters the queue you can use a for loop to cycle through all the agents in the queue and add it to a variable inside the agent.

Take the following simple example.

There is a custom agent type MyAgent it has a collection of type ArrayList accepting objects of type MyAgent.

enter image description here

Now when an agent enters a queue I can store the agents ahead of it in the queue in the following way

enter image description here

Please note the limit of the for loop is i < self.size()-1, if you don't add the -1 the agent will add itself to the list. (assuming your queue is FIFO (First in first out) the new agent will be the last in the list.

Upvotes: 0

Related Questions