'Moving Agent A to Nearest Agent B and from their to another nearest Agent B on GIS
So I have an agent vehicle and another agent shop of about 10 on GIS. I have another agent warehouse. So I have placed the vehicle at the warehouse and want it to move to the nearest shop and drop goods and from there move to another nearest shop and return to the warehouse after it has reached all shops each only once.
I am new to anylogic and I have run this code Agent nearestShop = this.getNearestAgent(main.shops); moveTo(nearestShop)
I am stuck and don't know how to move from there using loop
Solution 1:[1]
You should use a state chart because you can only start the next route after arriving at the first Shop. This can only be done with the statechart transition set to "Agent arrival".
You can create a statechart "mimicking" a for-loop this way. Best check the example models that use state charts for agent movement to get some inspiration. Do it for 1 shop manually, then for 2 shops, then think how you can combine it into a generic state chart that just keeps on travelling to the next shop until some condition is met (run out of fuel...)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Benjamin |
