Rawand Smadi
Rawand Smadi

Reputation: 9

How can I choose number of agents from a population (Anylogic)?

In Anylogic, If I have a 6000 agents in X population..How can I choose 2000 form this population to do a specific task ??

Thank you.

Upvotes: 0

Views: 291

Answers (1)

T_D
T_D

Reputation: 1728

If it is ok that you always select the same 2000 agents then this would work:

int i=0;
ArrayList<Agent> subsetOfAgents = new ArrayList<Agent>(2000);
for(Agent a : population)
{
   if(i >= 2000) break;
   subsetOfAgents.add(a);
   i++;
}

Your 2000 agents are then available in subsetOfAgents.

Upvotes: 1

Related Questions