Search code examples
javaanylogic

Releasing agent from queue based on conditions anylogic


Agents currently get sent into a queue based on a condition put in a selectOuput previously. I would like the agents to be released from the queue upon satisfying a condition in the Queue block. The condition being if the agent is a morning agent or not AND there is an idle doctor for that morning or afternoon patient. Currently I have the code below in the On at exit section:

if (agent.isMorning == true && doctorMorning.idle()  > 0)
    queue1.release(agent);

if (agent.isMorning == false && doctorAfternoon.idle()  > 0)
    queue1.release(agent);

The problem is that the agents never get held up in the queue but instead pass right through it, even when there are no idle doctors i.e. even when both conditions are satisfied


Solution

  • instead of a queue use a wait block (you can find that one on at the end on the auxiliary blocks when you look it up on the process modeling library)

    then you can do the same you are already doing, but instead you use wait.free(agent)

    the queue object doesn't stop the agents from moving forward, unless there's no space...