Reputation: 9
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
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