Search code examples
anylogic

How create a group of agents per time and then operate with separate agents in Anylogic?


Good day! I have a problem with multiple agents in AnyLogic. I would like to generate several agents per time. It is important that this group of agents has the same Creation time. And it is important to operate the every agent of the group separately. This group should be created by Poisson distribution.

To the best of my knowledge, I have two options for creating the agents:

  1. to generate the multiple Agents per arrival in a Source (see pic.1) BUT! In this case I have to initially create the population with some quantity of agents. And it seems that AnyLogic doesn't correspond the Agent in the Specific field to the population of agents. Picture 1. Source block

2)to create the empty population and create the agent any time I want. But in this case I faced with the problem: How to generate several agents per time?

Thank you!


Solution

  • Re question 2:

    Create an event that triggers at some time and in it, create several agents using a for-loop. Simplest case:

    for(int i=0; i<10; i++){
        add_MyAgent(); // assumes your agent population is called MyAgent and lives in the same place as the event
        // if your agent type has individual parameters, you can fill them here as well using "add_MyAgent(myFirstParam, mySecondParam...);"
    }
    

    If you need to create several agents at unique times but want to do this several times, best create a Dynamic Event instead and call that at each time when you want to create a group of agents. Inside it, have the same for loop as above