Now I set two types of agents: Atype and Btype, and use the pedsource to let these two types of agents run between two target lines.
I want to get an agent belonging to Atype, and another agent belonging to Btype, And then add some calculations.
so I write this code: for(Atype p : get_Main().Atype)
and for(Btype b : get_Main().Btype)
but it didn't work well.
How can I solve this problem?
Thanks!
CodePudding user response:
You must add those agents to a population and loop over that population.
First, drag in the agent type to create an empty population (see the help).
In your source, tell it to add new agents to that population:
Last, loop over it, for example
for (Atype currAgent : myNewPopulationOfAType) {
// do cool things with currAgent
}