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

random_nearby_position() might return out-of-bounds positions #1020

Closed
sosiristseng opened this issue Apr 10, 2024 · 3 comments
Closed

random_nearby_position() might return out-of-bounds positions #1020

sosiristseng opened this issue Apr 10, 2024 · 3 comments

Comments

@sosiristseng
Copy link
Contributor

Describe the bug

I found that the random_nearby_position() function returned out-of-bounds positions when I failed to run the event ABM example.

Minimal Working Example

https://github.com/sosiristseng/agents-out-of-bounds/blob/main/main.jl

The results: https://github.com/sosiristseng/agents-out-of-bounds/actions/runs/8627726973/job/23648255748

Agents.jl version

Agents v6.0.7

@sosiristseng
Copy link
Contributor Author

Digging deeper, I found that IteratorSampling.jl might return an out-of-bound output when given an empty iterator. Maybe this issue should be transferred there.

iter = nearby_positions(model[1], model, 1)
iter_filtered = Iterators.filter(pos -> isempty(pos, model), iter)

# If I run collect(iter_filtered), it will return an empty array

# Returns a random, maybe out-of-bound output
IteratorSampling.itsample(abmrng(model), iter_filtered; method=:alg_R) 

@Tortar
Copy link
Member

Tortar commented Apr 10, 2024

my mistake :q

I made it during a major overall of the IteratorSampling library, should be fixed by JuliaDynamics/StreamSampling.jl#48

@sosiristseng
Copy link
Contributor Author

@Tortar thank you for your reply. It's resolved after IteratorSampling v0.2.10.

https://github.com/sosiristseng/agents-out-of-bounds/actions/runs/8628924786/job/23652013609

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