Search code examples
queuetimeoutanylogicpulldiscrete

Anylogic: Queue TimeOut blocks flow


I have a pretty simple Anylogic DE model where POs are launched regularly, and a certain amount of material gets to the incoming Queue in one shot (See Sample Picture below). Then the Manufacturing process starts using that material at a regular rate, but I want to check if the material in the queue gets outdated, so I'm using the TimeOut option of that queue, in order to scrap the outdated material (older than 40wks).

The problem is that every time that some material gets scrapped through this Timeout exit, the downstream Manufacturing process "stops" pulling more material, instead of continuing, and it does not get restarted until a new batch of material gets received into the Queue.

What am I doing wrong here? Thanks a lot in advance!! Kindest regards

Sample Picture


Solution

  • Your situation is interesting because there doesn't seem to be anything wrong with what you're doing. So even though what you are doing seems to be correct, I will provide you with a workaround. Instead of the Queue block, use a Wait block. You can assign a timeout and link the timeout port just like you did for the queue (seem image at the end of the answer).

    In the On Enter field of the wait block (which I will assume is named Fridge), write the following code:

    if( MFG.size() < MFG.capacity ) {
    self.free(agent);
    }
    

    In the On Enter of MFG block write the following:

    if( self.size() < self.capacity && Fridge.size() > 0 ) {
        Fridge.free(Fridge.get(0));
        }
    

    And finally, in the On Exit of your MFG block write the following:

    if( Fridge.size() > 0 ) {
        Fridge.free(Fridge.get(0));
    }
    

    What we are doing in the above, is we are manually pushing the agents. Each time an agent is processed, the model checks if there is capacity to send more, if yes, a new agent is sent.

    I know this is an unpleasant workaround, but it provides you with a solution until AnyLogic support can figure it out.

    enter image description here