Search code examples
optaplannervehicle-routingoptaweb-vehicle-routing

OptaPlanner VRPPD with Traffic and Time Windows


Is there currently a way to incorporate traffic patterns into OptaPlanner with the package and delivery VRP problem?

Eg. Let's say I need to optimize 500 pickup and deliveries today and tomorrow amongst 30 vehicles where each pickup has a 1-4hr time window. I want to avoid busy areas of the city during rush hours when possible.

New pickups can also be added (or cancelled in the meantime).

I'm sure this is a common problem. Does a decent solution exist for this in OptaPlanner?

Thanks!


Solution

  • Users often do this, but there is no out-of-the-box example of it.

    There are several ways to do it, but one way is to add a 3th dimension to the distanceMatrix, indicating the departureTime. Typically that use a granularity of 15 minutes, 30 minutes or 1 hour.

    There are 2 scaling concerns here:

    • memory. 15 minutes means 24 * 4 = 96 per day. Given that with 2 dimensions, a 10k locations distanceMatrix uses almost 2 GB RAM, clearly memory can become a concern.
    • pre-calculation time. Calculation the distance matrix can be time consuming. "bulk algorithms" can help here. For example, graphhopper community doesn't support bulk distance calculations, but their enterprise version - as well OSRM (which is free) does. Getting a 3 dimensional matrix from the remote Google Maps API, or the remote enterprise Graphhopper API, can result in bandwidth concerns (see above, the distance matrix can become several GB in size, especially in non-binary formats such as JSON or CSV).

    In any case, one that 3 dimensional matrix is there, it's just a matter of adjust OptaPlanner examples's ArrivalTimeUpdateListener to use getDistance(from, to, departureTime).