JuliaDynamics / Agents.jl

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

Extend sampling functions to more than one item #837

Open Tortar opened 1 year ago

Tortar commented 1 year ago

Currently we support only single versions of specialized sampling function, but we could support also the multi-versions so that the new function sample without replacement for more than one item

Tortar commented 12 months ago

I think that here we can even create a new package specialized for these sampling function, the reason is that these sampling function aren't useful only for agent based modeling, they can be used with any iterator

Tortar commented 7 months ago

created: https://github.com/Tortar/IteratorSampling.jl

it will be be easier to solve this issue with it

Tortar commented 7 months ago

With iteratorsampling.jl it should be easy to create a fast version of multiple elements sampling functions, the problem is our current naming convetions which assume only one agent e.g. random_agent, random_nearby_agent, do you have any idea on how to handle this @Datseris ?

Datseris commented 7 months ago

What does multiple elements mean here. what should random_agents mean for multiple elements?

Tortar commented 7 months ago

say instead of a single random agent, between all nearby agents, you want two of them, currently you either need to repeat (and maybe reject) random_agent two times or collect and sample. Instead if we talk about random_agents(model, n) this would return n random agents in the model. Do you think that "duplicating" random_agent, ecc... with random_agents, ecc... could be acceptable?

Datseris commented 7 months ago

yes, that would be acceptable. We cross ref the two functions in their docsttrings.