Ekaterina
Ekaterina

Reputation: 75

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!

Upvotes: 0

Views: 352

Answers (2)

Benjamin
Benjamin

Reputation: 12640

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

Upvotes: 1

Benjamin
Benjamin

Reputation: 12640

Create an agent population myPopulation, make it initially empty. You can then create any number of agents at any point in time using add_myPopulation(), this will add 1 agent to it.

You access individual agents using myPopulation.get(index) with the index number you need.

Instead of using a source, you can start a flow chart with an Enter block and put your agents into it at any time using myEnterBlock.take(agent).

Sounds like you should study some more of the bsics, do all the tutorials in the AL help to understand more of the principles of populations, agents, flow charts...

Upvotes: 1

Related Questions