Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use random_nearby in wolf sheep? #66

Open
Datseris opened this issue Aug 6, 2023 · 5 comments
Open

Use random_nearby in wolf sheep? #66

Datseris opened this issue Aug 6, 2023 · 5 comments

Comments

@Datseris
Copy link
Member

Datseris commented Aug 6, 2023

In Agents.jl we have spent considerable development effort optimizing functions that pick a "random nearby thing" but these aren't used here anywhere even though picking a "random nearby thing" is an extremely common ABM programming pattern.

Maybe we can use the random nearby in the wolf sheep model?

here: https://github.com/JuliaDynamics/ABM_Framework_Comparisons/blob/main/WolfSheep/Agents/WolfSheep.jl#L78

@Tortar
Copy link
Member

Tortar commented Aug 6, 2023

Yes, indeed this is what I was referring to when I was saying that there is some other API calls to add there, but we need to add some new methods in Agents.jl before so, will do a pr there in a couple of days when I find the time!

@Datseris
Copy link
Member Author

Datseris commented Aug 7, 2023

be careful though to only add API methods that are generally useful. We don't want to "cheat" and just add functions to Agents.jl API that would only be used in this comparison repo.

What is the method that is "missing" here?

@Datseris
Copy link
Member Author

Datseris commented Aug 7, 2023

@Datseris
Copy link
Member Author

Datseris commented Aug 7, 2023

BTW this function seems to allocate the collection anyways: https://github.com/JuliaDynamics/Agents.jl/blob/main/src/core/space_interaction_API.jl#L414C30-L414C30

Which makes me think, how is it more performant than directly collecting the iterator and calling rand on it...?

@Tortar
Copy link
Member

Tortar commented Aug 7, 2023

It is more performant since it doesn't test the condition on all the data, just on the part needed to find a value respecting the condition, some benchmarks we did saw some benefit doing that even for simple condition functions.

Yes, anyway I'm (almost) sure those functions will be beneficial for the users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants