JuliaDynamics / Agents.jl

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

Can the open street map graph be altered during the simulation? #1021

Closed simsurace closed 2 months ago

simsurace commented 2 months ago

https://github.com/JuliaDynamics/Agents.jl/blob/ebaa7cd160d8d87fe3b91df187940cd654da8cf8/src/spaces/graph.jl#L22 It is not clear from this docstring whether the graph can be changed during the simulation. At least if it is a SimpleGraph, I would think that it can't, because the indices are not persistent.

Tortar commented 2 months ago

mmh, I think it can be done, rem_vertex! and add_vertex! are specialized for GraphSpace and they work also on a SimpleGraph

Tortar commented 2 months ago

But if you have a way to make the docstring clearer, go for it!

simsurace commented 2 months ago

The node-to-index and index-to-node mappings in OSMGraph will be broken after removing vertices, since a SimpleGraph will always have indices 1:n. Or am I missing something?

Tortar commented 2 months ago

I think that rem_vertex!(and add_vertex!) are only implemented for a GraphSpace, not for a OpenStreetMapSpace, which means that even if OSMGraph supports mutation, it can break how OpenStreetMapSpace works. But this seems it is a feature it can be added if OSMGraph supports mutation.

simsurace commented 2 months ago

Ah yes, I got confused between the two spaces. It seems to be true that removing nodes from the GraphSpace is safe. For the OSM space it would be more involved, and I'd be worried to rely on too much internal stuff.

Datseris commented 2 months ago

As far as I can tell @simsurace you need to open an issue at OpenStreetMapX.jl (the backend package) to implement an API for mutation. From our side even if we offer something it would be clunky, unsafe, and unmaintainable.

simsurace commented 2 months ago

I think you meant LightOSM.jl, right? In any case, this is what I thought as well, this would belong to the backend for sure. Just wanted to be sure I wasn‘t missing anything.

Datseris commented 2 months ago

Sorry, yes LightOSM!