Aqeel Tariq
Aqeel Tariq

Reputation: 313

Priority queue is not working in AnyLogic

I have two variables in agent

  1. handicap = RandonTrue(0.3)
  2. priority.

The priority variable value set in source exit based on wither agent is handicap or not, as shown in the image below.

enter image description here

Now in the queue I set Queuing to priority base and set agent priority to agent.priority . Shown in image below.

enter image description here

Note: Queue capacity is set to 10.

Now when I run the model and 10 agents enter I the queue, according to the priority handicap agents should be on the top of the queue but that is not happening. shown in the image below.

enter image description here

When the agents enter the delay after the queue, I also print their priorities on the console. The result is still the same, no priority is followed.

enter image description here

In the above image it is clear that they are not sorted based on priority. Why priority queue is not working?

Moreover, I also changed the Queuing to LIFO, queue showed the same result, showing zero effect on agents.

Upvotes: 0

Views: 112

Answers (1)

Felipe
Felipe

Reputation: 9421

this happens because contrary to the intuitive idea that events happen in the order you see, they don't... Things occur in the following order:

  1. agent is created with the default value for the priority value
  2. on at exit action is executed
  3. the queue priority value is checked for the queue
  4. the on exit action is executed

So from the point of view of the queue, the priority for all agents is the same

Solution Instead of setting the priority value "on exit" do it on the "on at exit" action of the source block

Upvotes: 1

Related Questions