JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
725 stars 117 forks source link

Version where agents are `struct`s instead of `mutable struct`s #860

Closed Tortar closed 1 year ago

Tortar commented 1 year ago

In a blogpost by Bogumił Kamiński at https://bkamins.github.io/julialang/2020/10/16/gctime.html, he describes that using struct's instead of mutable struct's as agents can be beneficial even when fields are updated with Accessors.jl.

I'm not sure that this is true for any number and any type of fields but I think this could be nonetheless investigated.

If proved beneficial in at least some useful situations, this could be allowed along with the mutable version, but I think that integrating this version will require many updates to the codebase.

Tortar commented 1 year ago

Actually some experimentation tells that this doesn't give almost any edge even in elementary models where the number of fields is low (almost same time for Schelling and Flocking).

See https://github.com/Tortar/Agents.jl/tree/agents_structs for how structs can be used instead of mutables one, this requires hacky code (this still doesn't pass all tests) and it doesn't even change that much the performance, so I think it's a dead-end