1

I am using a Queue and hold block together, where the hold remains blocked until all the agents arrive at the Queue block.

How to change it and want to allow only a fixed number of agents (say 5 agents) at fixed intervals of time(say every 3 minutes)? Current properties of my Queue and hold block:

queue_block_properties

enter image description here

hold_block_properties

enter image description here

James Z
  • 12,209
  • 10
  • 24
  • 44

2 Answers2

0

Create a cyclic event with recurrence time 3 minutes. Also create a variable which you can name count of type int.

In the event action field write:

count = 0;
hold.unblock();

Then, in the On enter field of the hold block write the following:

count++;
if( count == 5 ) {
   self.block();
}

The only question that I have is whether you want every 3 minutes to have exactly 5 agents leave or whether it's okay if they arrive a bit later. In other words if after 3 minutes, there are only 3 agents in the queue, do they leave and the hold remains unblocked in case another 2 arrive before the next cycle? Or does the hold block blocks again immediately?

In the solution I provided, if there are less than 5 at the cycle time occurrence, and then new agents arrive before the next cycle, they can pass.

Otherwise, create a new variable called target for example and write the following in the event action:

count= 0;

if( queue.size() >= 5 ) {
    target = 5;
    hold.unblock();

}

else if ( queue.size() > 0 ) {
    target = queue.size();
    hold.unblock();
}

And in the on enter of the hold, write:

count++;

if( count == target ) {
self.block();
target = 0;
}
Emile Zankoul
  • 2,161
  • 2
  • 6
  • 18
0

I would advise to not use a hold block for such delicate control of releasing agents. Instead, I would propose a simpler solution.

Simply let the agents build up in the queue and then you remove them using an event. The only action for this event is to remove the minimum between your set number of agents and the queue size, from the queue and send them to an enter block. The enter block is where your process flow then continues. See the screenshot below.

enter image description here

Code in the event is

for (int i = 0; i < min(5, queue.size()); i ++){
    enter.take(queue.remove(0));
}

On that note, you can also use the Wait block (Which is hidden in the Auxillary section in the PML library

enter image description here

Then you can ditch the enter block and simply call the following code

for (int i = 0; i < min(5, wait.size()); i ++){
   wait.free(wait.get(0));
}

enter image description here

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33