When to update agent property that depends on moves of all other agents

Hi everyone,

I’m confused about how an agent property should be best updated within the Agents.jl package.

At each time step, each agent does some computation and then moves to a new location. The agent property should then be calculated (in this case the area of the agent’s Voronoi area). This necessarily depends on the moves of all other agents. I’m currently using the random scheduler but the same issue applies for other schedulers.

Given all agents need to have completed their move before the individual properties can be computed, how should I best gather this information?

Thank you for any discussion or helpful hints.

Tell me if I’m not understanding your question, but model_step! will be called (by default) after you’ve completed you agent step computation?
See, e.g.: 4. Evolving the model, and also the Advanced Stepping section there.

2 Likes

This is the correct approach.

You let your agents do their stuff (e.g. moving around) in your agent_step! function. Then you also add a model_step! function that iterates over your agents again (e.g. for id in allids(model); calculate_voronoi(model[id]); end) and you should be golden.

Thank you for your help and for the link. :slight_smile:

Thank you very much for responding and putting me on the right path. Can I just check - am I able to update an agent property within the model_step function. Or is this something that should be collected as a model property. Say as a vector the size of the number of agents?

1 Like

Yes.

1 Like