0

I was building a prototype of vehicle routing application using google maps and optaplanner. I change the distance based scoring to duration based scoring, where the duration value was calculated using distance / avg speed of vehicle.

Now I want to add traffic jam variable into my application. The traffic jam variable was implemented as additional duration value from the current location to another location (I using a map of location and double just like distance variable in RoadLocation class). When I tried it to run it, the result was always same with the previous one. Here is the result from the first run : enter image description here

I draw some red line to represent the traffic jam, and then try to re-run the solving phase. Here is the second result:

enter image description here

The result was the same with the previous one. My questions is, what the best method to apply the traffic jam variable into vehicle routing problem? Does anyone has any experience adding this variable? Any comment and suggestion will be appreciated. Thanks and regards.

the.wizard
  • 1,079
  • 1
  • 9
  • 25

1 Answers1

1

This paragraph is just an introduction. If you wanna skip it, do it. ;-) I have implemented a similar approach with traffic jams, but it was not a real-time system. The solution runs every X minutes, which is absolutely fine. That gave me the benefit for pre-calculating the ways and routes for the complete road network, before the actual optaPlanner calculation starts. This saves time for the real calculation of optaPlanner. The network consists of vertexes and arcs. For each arc you'll have a weight.

Here starts the real deal for you. Let's assume that you implement a Dijkstra or A-Star algorithm for the precalculation step for all places and how to get there. These way finding algorithm is seleting the arc with the lowest "travelling" costs. For each arc/road, which would be blocked, we assume a distance of DOUBLE.MAX_VALUE. This value can be interpreted as "not driveable" or drastically said: This connection between two vertexes even doesn't exist for the current solution finding process. So the way finding algorithm will simply skip this road. For every driveable road, we calculate the real costs, e.g. distance or take an approximation out of experience.

The optaplanner process itself just uses the precalculated way finding mechanism, e.g. compares the calculated distances for getting from place A to place B.

For setting the distance variable to DOUBLE.MAX_VALUE you can decide between user based information, information of other providers like google or admin based rules. As my experience goes along with user based content vs. admin based actions, I can recommend both ways.

Let's discuss the user based action: The user can have the same set of GUI actions as the admin for flagging a way as "jammed". For the next optaPlanner iteration the flag is going to be involved. If you have GPS data of your users you can get the approximate velocity. For each intervall of the GPS measurement you can calculate that velocity. If the velocity is on a road (not a crossing), and below a defined minimum velocity (let's say 1mph or 2 kmh), then you can ask the user if it's a traffic jam or not via popup OR block that road automatically without asking the user. If you chose the popup dialog then a lot of different users have to vote "yes" within a defined time slot, e.g. half an hour, then the road get's blocked. You can resolve the traffic jam, when a lot of users drive the road again and send the GPS coordinates of that road. The main advantage of the automatic approach is, that you'll have a system based approach with a low error rate.

If you take the manual approach via admin, then you have to take care of implementing a GUI for displaying the roads and enabling/disabling the blocked attribute for a road.

mchlfchr
  • 3,998
  • 4
  • 26
  • 35
  • Thanks for sharing your thoughts and experience about traffic jam in vehicle routing problem. One thing that I still confused is, what is the best source for traffic jam data? Currently, I let my user defined it by her self, but this approach actually kinda strange and not really good. – the.wizard May 26 '15 at 20:21
  • added the information about different approached of adding/removing the property of blocked roads. – mchlfchr May 28 '15 at 12:30