Pathfinding and update_vel!


I started using Agents.jl recently, and I have a question regarding using pathfinding and update_vel! together.

I’m trying to use Agents to model crowd dynamics in emergency situations. Right now, I’m using the AStar function in order for the agents to find the best exit of a building, thus, instead of move_agent!, I’m using move_along_route!. However, this implementation thus does not have into account social forces, for instance, that agents usually adjust their speed to maintain a certain distance from other agents or even collisions. Since Agents has an elastic_collision! function, I decided to use it just to see how it would impact my model, however, from the videos I made it seems that it has no impact and the agents just follow the route from AStar. I also tried to update the vel field in order for agents to preserve a certain distance from each other, but once again they just followed the route from AStar.

Is it possible that I’m doing something wrong, or is it just not possible yet to update the vel field when using move_along_route!? Do you have any suggestions on the best way for me to implement this?

Thank you so much in advance :blush:



I don’t think that would play well with move_along_route!… I have to be honest, I am not sure how alternations in agent position and velocity mess with move_along_route!. The typical scenario is that you need to re-create a route if you alter them, but perhaps there are cases where you don’t have to. I’ll wait for the developer of the pathfinding ( ) to comment on that.

There was an open PR here add Force Based Motion Planning (FMP) by rmcsqrd · Pull Request #456 · JuliaDynamics/Agents.jl · GitHub on force based motion. I am not sure how related that would be for social forces. We would for sure like to have some functionality in Agents.jl for social forces, as I have seen people ask this before numerous times. But this would be a formal submodule that would take effort from someone to implement :slight_smile:

What code do you have now for social forces? Can you create a Minimal Working Example so that we have a common root to discuss on?

AStar directly sets the position of the agent, so it doesn’t really take into account update_vel! and the like. Instead, it directly accepts speed and dt to calculate how far the agent should move along the path.

What you could do is move the agent according to the external forces after calling move_along_route!. As long as the agent isn’t disrupted from its path too much, it will still follow the optimal or near-optimal path.

That said, Agents.jl would certainly benefit from more advanced pathfinding algorithms, such as FMP as @Datseris mentioned which (if I’m not wrong) is also useful for crowd dynamics simulations. Alternative algorithms (like D*/D* Lite, LPA* etc.) are also welcome. Currently, the best way of simulating dynamic pathfinding is using a hierarchical approach: Use A* on a coarse grid to find the approximate path to the end, and on a finer grid to find the best path between individual segments of the coarse path. There isn’t any functionality in the library that does this for you yet, but it should be possible with the current setup and PRs are always welcome.