question

Matias H avatar image
0 Likes"
Matias H asked Matias H commented

GIS - how to wait until the route query is done from the server?

I need to do a GIS model where I use large amount of different locations and routes. I have tested two ways and both have their own problems. Note, external routing server is in use.

Option 1: All the points and routes are loaded in advance and the simulation is run afterwards. Problem: If I try to create a large number of points and routes, not all routes load (picture 1). Can't FlexSim process all the responses from the server and stops because of it?
1681296963954.png
Option 2: Adding points and routes during the simulation. Problem: Travel commands do not work. Could it be because the Travel command is executed before the route has been fully received from the server and drawn on the map?


Question: Is there possibility to wait until the individual route has been fully received from the server and drawn on the map? Screenshot of the code of Option 1, where the possible wait code would come after the "function_s(navigator, "updateRoute", routeNode);"

1681297142183.png


Thanks in advance!

FlexSim 23.1.0
gis
1681296963954.png (1.3 MiB)
1681297142183.png (41.8 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Matias H commented

Option 1: gis_wait_for_route_load_1.fsm

Your proposed solution to "wait" after the "updateRoute" call would cause the downloads to happen synchronously in series instead of asynchronously in parallel, which would be really slow and make FlexSim look like it has crashed.

A better solution would be to display the progress of the downloads. In the sample model attached above, a user command has been added that checks on the status of the downloaded routes.

I added some buttons and fields to show status information about the downloading of the routes. The first button builds the model. The second button checks on the status of the downloads and displays the current progress. If any of the downloads failed, a third button is available to try downloading those routes again.

1681332308565.png

Using timers, timeouts, and more UI code, you could automatically show the progress on the dashboard, but that would be more complicated. To make this example easier to understand, I left the updating of the progress as an explicit operation performed by pushing a button.

In FlexSim 23.2, we will be adding a Delay.realTime() coroutine method that would make adding this type of status update timer to the UI a lot easier and simpler. Right now, using UI timers in dashboards is complicated.

Option 2: gis_dynamic_routing_1.fsm

By default, the routes between points in the GIS module form a network of connections that can be used to route from any point to any other point, even if they aren't directly connected. The GIS Navigator takes care of properly determining the shortest route between the web of inter-connected points.

If you wanted to arbitrarily travel between any given lat/lon coordinate and any other arbitrary lat/lon coordinate rather than using the navigator, you could dynamically move the points and recalculate the route at the precise moment when you need to travel. Attached is an example demonstrating this technique.

The model uses two points on the map for each traveler. Before traveling, it moves the destination point to an arbitrary location and downloads the new route during the simulation right then. Then when the traveler travels again, it moves the other point to a new arbitrary location and downloads the new route. Thus, the traveler just travels from Point A to B to A to B to A during the simulation, but the location of Point A and B keep changing as the simulation runs.

gis-dynamic-routing.gif

This method uses live HTTP queries to a server during the simulation though, so if something messes up that communication, the simulation model will stop.

The default method of working with GIS routing does all its queries during the model building process (before Reset) rather than during the simulation run. Caching the necessary data beforehand is much faster and reliable than communicating with a server during the model run. But if you want something truly dynamic with infinite possibilities for point locations, then this method can work.


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Matias H avatar image Matias H commented ·
Thank you very, very much for this comprehensive answer!


The Option 1 is generally good solution for all GIS models, but when the number of points will be really large (for example, movement of a courier or postman to random precise destinations), then Option 2 is exactly the right solution for that.

I tested the Option 2 with more trucks and shorter routes and at least so far the model worked very well without crashing.

1 Like 1 ·