Search code examples
repast-hpc

What is a quick way to filter agents retrieved by Moore2DGridQuery


I am developing a model on RepastHPC, where I have multiple types of agents inhabiting the same discrete grid projection. On each tick the agents of one of the types need to query the grid projection and find the agents at their current location. However, they need to only consider the agents of a specific type. I use Moore2DGridQuery to get all agents at that grid position, however I cannot find a quick way to filter the set of agents to only get the agents of a specified type. I am currently iterating normally through the vector of agents, however that could result is slow-downs when I have great counts of agents running in the model.

Is there any way I could filter them quicker? Thanks in advance!


Solution

  • Unfortunately, I don't think there's a quick filter you can apply. If you iterate through the vector as part of the model behavior you could check the type there, or use the standard library to copy only the agents you want into another vector. See https://www.cppstories.com/2021/filter-cpp-containers/