simulationagent-based-modelinganylogicevent-simulation

How to use stopDelay(agent) on AnyLogic


I am generating multiple agents at the source. I would like to let them wait until some event.

I am trying to access the "delay.stopDelay(agent)" however it requires an agent as a parameter.

How should I proceed?

enter image description here


Solution

  • Here is the answer:

    Tasks t = null; 
    if(delayTasks.size()>0){
    
        //use a random agent stored at delayTasks
        int i = uniform_discr(0, delayTasks.size()-1); 
        t=delayTasks.get(i); 
    
        //or use any specific condition
        for(int i=0; i< delayTasks.size(); i++){ 
        //if() any condition
            t=delayTasks.get(i); 
        } 
    
        //Then you release the agent t
        if(...){
            delayTasks.stopDelay(t);
        }
    }