In Agents.jl, is there a built-in method to compute the distance from an agent within a GridSpace that automatically uses the appropriate distance metric (consistent with the one specified during the space’s initialization) and correctly handles periodic boundary conditions?
So far, I have only encountered workarounds that either manually select the distance function based on the metric chosen at space creation and then handling periodicity, or just relying on a Pathfinder to infer distance from path length. But it feels like I’ve missed something.
yes, use the distance functions:
depending on your metric
This works for those two distances, but I could not find the version for the case when metric = :chebyshev, so that would have to be handled manually.
Maybe computing distances is not that usual in many cases, but I found strange that despite having an ABM with a space being initialized with a defined metric, there’s no standard, automated way to compute distances without explicitly checking and switching on the value of abmspace(model).metric.
Yeah it is strange that this version is missing, but perhaps you can consider doing a pull request that adds it?