javasimulationanylogicevent-simulation

How to associate a probability distribution to Agents - Anylogic


I'm simulating a model on Anylogic, in which Agents flow from a Queue block to a Service block. I need to define the time spent by the angents in the service with a probability distribution like this:

I've already associated to the agents a parameter called "timeInService", I think I should work with it and maybe the Dalay time of the service but I don't know how.


Solution

  • on the delay of the service block you can put this code:

    uniform()<0.7 ? uniform(15,30) : (uniform()<2/3 ? uniform(30,45) : uniform(45,60))
    

    This will give you what you want.
    Another alternative is on the block before entering the service block you do this on the "on exit":

    double rand=uniform();
    if(rand<0.7)
        agent.timeInService=uniform(15,30);
    else if(rand<0.9)
        agent.timeInService=uniform(30,45);
    else
        agent.timeInService=uniform(45,60);
    

    And in the service delay you put agent.timeInService

    Those are two possible options.