I have an AnyLogic simulation model using trucks and forklifts as agents (Transporter type), and among other things would like to identify each time one of them becomes within a certain distance of another one (example within 5 meters). I will record this count as a variable within the main space of the model. I am using path-guided navigation. I have seen a method "agentsInRange" which will probably be able to do the trick, but am not sure where to call this from. I assume I should be able to use the AL functionality of "Min distance to obstacle" (TransporterFleet) and "Collision detection timeout" (TransporterControl)? Thanks in advance!
Asked
Active
Viewed 136 times
1 Answers
2
Since there don't seem to be pre-built functions for this, afaik, the easiest way is to:
- add an int variable to your transporter agent type
counter
- add an event to your transporter type
checkCollision
that triggers every second or so - in the event, loop across the entire population of transporters and count the number that are closer than X meters (use
distanceTo(otherTransporter)
and write your own custom code) - add that number to
counter
Note that this might be very inefficient computationally as it is quite brute-force. But might be good enough :)

Benjamin
- 10,603
- 3
- 16
- 28