# Gridspace search different distance in each dimension

**URL:** <https://discourse.julialang.org/t/gridspace-search-different-distance-in-each-dimension/116287>\
**Category:** Modelling & Simulations\
**Tags:** agents, agentsjl\
**Created:** [June 27, 2024, 4:21am UTC](https://discourse.julialang.org/t/gridspace-search-different-distance-in-each-dimension/116287 "2024-06-27T04:21:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sea\_slug](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sea_slug/32/52907_2.png) [@sea\_slug](https://discourse.julialang.org/u/sea_slug)\
**Post date:** [June 27, 2024, 4:21am UTC](https://discourse.julialang.org/t/gridspace-search-different-distance-in-each-dimension/116287/1 "2024-06-27T04:21:57Z")

</div>

I’m using [agents.jl](https://juliadynamics.github.io/Agents.jl/stable/) to create an ABM. Looking at the help for [GridSpace](https://juliadynamics.github.io/Agents.jl/stable/api/#Agents.GridSpace) I should be able to search different distances for each of the dimensions in my `GridSpace` (assuming `metric = :chebyshev`) with functions `nearby_ids()` and `nearby_positions()`. For example, in the wolf-sheep-grass example model I should be able to get all the positions within distance 1 of a given agent in the first dimension and distance 2 in the second dimension with the following:

```julia
sheepwolfgrass = initialize_model()
nearby_positions(sheepwolfgrass[1], sheepwolfgrass, (1, 2))

```

But the above returns the error `ERROR: MethodError: no method matching bound_range(::UnitRange{Int64}, ::Int64, ::GridSpace{2, true})`

If I just want to search the same distance in all dimensions it works fine, e.g.:

```julia
nearby_positions(sheepwolfgrass[1], sheepwolfgrass, 2)

```

I’ve obviously got something wrong, any tips as to how I can search a `GridSpace` using different distances across dimensions?

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [June 27, 2024, 11:49am UTC](https://discourse.julialang.org/t/gridspace-search-different-distance-in-each-dimension/116287/2 "2024-06-27T11:49:37Z")

</div>

Seems like a bug, but without runnable code or pkg versions I can’t say much. Please open an issue at Agents.jl github repo providing a MWE that reproduces the error, the full error stacktrace, and the package versions you used. If you use Agents.jl version that is not the current latest stable, first update.

---

<div class="post-metadata">

**Author:** ![sea\_slug](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sea_slug/32/52907_2.png) [@sea\_slug](https://discourse.julialang.org/u/sea_slug)\
**Post date:** [July 4, 2024, 3:50am UTC](https://discourse.julialang.org/t/gridspace-search-different-distance-in-each-dimension/116287/3 "2024-07-04T03:50:28Z")

</div>

Apologies it took me awhile to get back to this. After updating to the latest version of Agents I was still getting the error so have now opened an [issue](https://github.com/JuliaDynamics/Agents.jl/issues/1053) with MWE.
