Search code examples
scheduleanylogic

AnyLogic schedule for arrival rate


I want to use a schedule for my arrival rate. e.g. I want 33 trucks to arrive randomly between 08:00 and 09:00 and so on.

I added a rate schedule starting 8 till 9 and entered a value of 0.55

So it looked like this https://i.sstatic.net/dJubj.jpg

But when I started my simulation there were just 24 trucks within this period.


Solution

  • If you want exactly 33 trucks to arrive randomly between 8am and 9am you can do this:

    1) create an event that runs cyclically ever day at 8am

    2) create a dynamic event called GenerateTruck .

    3) put the following code in the action of the event:

    for(int i=0;i<33;i++){
        double rand=uniform(0, 1);
        create_GenerateTruck(rand,HOUR);
    
    }
    

    4) put the following code in the action of the dynamic event

    source.inject();//assuming a source generates your trucks