1

I'm developing a simulation model in Anylogic where there is a vehicle fleet that provides ridesharing services to travellers. To determine if a vehicle can pick up a certain traveller, I have a function that determines how distant he is from the vehicle, that is based on this: "getDistanceByRoute​" and then I divide it by an average speed to get a value of "waiting time" (if the calculated waiting time is bellow a certain defined value, the vehicle is authorized to pick it up). In truth, what really matters is the waiting time and not the distance. But right now, I can't find a function that calculates time instead of distance. The speed of the vehicle will depend on the type of road the vehicle is using and that is entirely calculated within the GIS Map by Anylogic. But I don't know this road speed until the vehicle is already travelling the road, Ideally I should know it previously in the calculation to determine the real "waiting time" (instead of an estimate based on the calculated distance and defined average speed). Can someone help please ? Thank you for your time!

João
  • 21
  • 2
  • Could you please elaborate on this: _The speed of the vehicle will depend on the type of road the vehicle is using and that is entirely calculated within the GIS Map._ Don't you define the agent speed manually? – Yashar Ahmadov Dec 14 '21 at 17:28
  • No, because I use the function "moveToInTime" by providing latitude and longitude, and then the agent moves in the GIS Map. And although I define a certain speed for the agent at my choice, when the agent is moving through the paths/roads in the map, it takes into account and assumes the speed limits (or averages speeds maybe) of the road. Actually, the travel times correspond approximately to what Google Maps would give you for that path. – João Dec 15 '21 at 13:11
  • But `void moveToInTime(Point location, double tripTime)` has tripTime as input... – Yashar Ahmadov Dec 15 '21 at 13:50
  • Yeah, but while running the model, it doesn't take into account that time estimate, it just uses its own calculations from the GIS Map. – João Dec 16 '21 at 13:02
  • I have doubts about this explanation. Quoting AnyLogic help: When you use the function moveToInTime(), an agent moves with a constant speed so that it reaches the destination over the length of time specified as one of the function’s arguments. – Yashar Ahmadov Dec 16 '21 at 15:03
  • I understand your doubts, but I get the vehicle speeds as an output and I can watch them real time, they vary depending on the road they are driving. This is what happens. – João Dec 16 '21 at 20:54

2 Answers2

0

you have the method timeToArrival() for that.

but if you use a moveTo block to move to the destination, then you need to calculate this at least 1 milisecond after the movement started...

Any time you can do agent.timeToArrival() and if the agent is moving, then it will return a non-zero value

Felipe
  • 8,311
  • 2
  • 15
  • 31
  • But this would not actually account for speed changes through the GIS path that he seems to apply, would it? – Benjamin Dec 15 '21 at 07:25
  • it works as long as there is only 1 moveTo involved (I think) – Felipe Dec 15 '21 at 12:08
  • The problem with the method "timeToArrival()" is that it assumes the value 0 if the agent is not moving, and frequently, cars will be parked and not moving. – João Dec 15 '21 at 13:13
0

The speed of the vehicle will depend on the type of road the vehicle is using and that is entirely calculated within the GIS Map by Anylogic

Movement on the GIS map does not change the speed in any way relative to the roads; that is one of the main things 'missing' from GIS functionality in AnyLogic (i.e., no meta-knowledge of speed limits or ability to hook in to things such as traffic/roadworks). [That would be a major new feature if ever added and would definitely not 'just occur' because it would mean many historic models would then be wrong.]

I just tested it for moveTo and moveToInTime to be sure and the latter also always ensures the arrival in the time specified as expected (setting a fixed speed from the start that is the speed needed to arrive in the given time).

So you always know the potential arrival time: distance/speed if using moveTo and specified-time if using moveToInTime.

If you're seeing anything else I suspect either a bug or that you're not printing the speed you think you are (or there is something in your own model logic that is dynamically changing the speed of the vehicle).

If you explicitly change the speed whilst movement is occurring, AnyLogic will recalculate timeToArrival() when you call it. And moveToInTime will no longer arrive in the time specified (because all that does is pre-set the speed initially; it's not 'monitoring' the movement as it occurs).

Stuart Rossiter
  • 2,432
  • 1
  • 17
  • 20
  • The routes are requested from OSM server, I think that's how it calculates the speed taking into account the roads. I've confirmed, the route travel times will be very similiar to what you obtain on Google Maps, the speed is varying, this I'm sure, I print it as an output, I watch it live, and routes with the same distance will have different travel times, due to the road being a different type. – João Dec 18 '21 at 08:33
  • I've checked with AnyLogic support who confirm that no configuration of GIS movement can do what you claim. (As I said, this is a known 'limitation' of the GIS maps/data in AnyLogic, as documented in the help.) So at this point you'll need to prove it with a sample model. – Stuart Rossiter Dec 22 '21 at 07:52
  • I guess it's still theoretically possible that there's some particular routing provider (perhaps for routes in a particular country) where this somehow happens (despite being completely undocumented and the AnyLogic support team themselves --- plus all the highly experienced AnyLogic modellers on SO --- being completely unaware of it) but it absolutely does NOT happen in any normal configuration. Also, the GISRoute data AnyLogic generates does not even have the capability to store speed data (even if it was available from the routing provider). – Stuart Rossiter Dec 22 '21 at 07:53