0

In my AnyLogic simulation model, I have two sources and going through two service blocks in a closed loop. At starting time I inject 1 50T Truck and 2 20T Trucks.

Descriptive image here:

Image of Model

At the second service block, "crusher1", I want the queue to always prioritize the agent "truck50ts" over "truck20ts". How can this be done?

Telso
  • 131
  • 8

1 Answers1

1

Replace your Service block with Seize, Queue, Delay and Release blocks (same as a Service but more options for you).

in the Queue properties, set the queue priority to "agent comparison".

In the conditional code, write agent1 instanceof Truck_50tons ? true : false as below: enter image description here

This assumes your 50t truck is an agent of a custom agent type called Truck_50tons (create those at the sources)

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Ok, did the alterations. But, does this mean that if a 20T truck is already in the queue, then the 50T truck will not move past it in the queue? The behavior I want in the end is that 50T trucks "sneak" past 20T trucks if they are already in the queue when the 50T truck arrives. – Telso Jun 17 '21 at 17:13
  • This is exactly what happens. But in the future, you should get into the habit of testing this yourself with a simple example model. Much better learning experience. Also, this is described in the help for queues ;) – Benjamin Jun 18 '21 at 04:56
  • @TellefSolberg, if this was helpful, please flag the answer as "useful" (up arrow next to it) so others find it easier in the future ;) – Benjamin Jun 18 '21 at 04:57
  • Ok, thanks. The problem was that my queue size always remained at 0 due to a 'seize' being the main queue instead. All sorted now though. Thanks a lot! – Telso Jun 18 '21 at 14:01
  • @TellefSolberg if this was helpful, please flag the answer as "useful" (up arrow next to it) so others find it easier in the future ;) – Benjamin Jun 18 '21 at 16:12
  • I would, but I do not have enough reputation points it seems :/ – Telso Jun 30 '21 at 22:36