<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hello Tom.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I am the one working on the code of the VRP pick & delivery, and I will write a little about the pgr_gsoc_vrppdtw and how I changing it.<br>This will help me flush my ideas in an organized manner, while trying to understand the problem.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">At the end I talk about your problem in particular.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hope this helps<br><br></div>Regards<br>Vicky<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The VRP problem makes some assumptions, like having a single depot, a
homogeneous fleet of vehicles, one route per vehicle. if you have one Vehicle then it becomes the TSP problem, which is NP-HARD optimization problem.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>Then you have different flavours of VRP like:<br>CVRP<br>VRPPD<br>VRPTW<br>CVRPTW<br>VRPMT<br>OVRP<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Each one has the own assumptions.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The Vehicle kind: truck, car, bicycle, air plane, tractor trailor, as a start is irrelevant<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>The methods to solve any of them, can go from brute force search trying all possible permutations, or simulated annaeling, or tabu search and many more that I don't know about. I am doing sort a of tabu-search: get different initail solutions with optimize until It can't. <br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Traveling salesman problem<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The inputs:<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">One Vehicle.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">A set N of locations<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">PROBLEM<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The Vehicles start and end the trip from the same location and visit all locations, (no location is visited twice).<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">SOLVE<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">with any of "know" methods<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><a href="http://www.math.uwaterloo.ca/tsp/">http://www.math.uwaterloo.ca/tsp/</a><br></div>The problem is NP<br> - with luck then its the global minimum<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> - with brute force them N! (N factorial) seconds later get the global minimum<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">RESULT<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">A route for the single truck that is a local minimum<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">VRP<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The inputs:<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">A set of homogenous vehicles.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">A set of locations<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">PROBLEM<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The Vehicles start and end the trip from the same location and visit all locations, (no location is visited twice).<br></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">SOLVE TRY 1<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Distribute the locations among the Vehicles<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Solve TSP for each Vehicle<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Distributing the locations, was it a good distribution?, maybe not, so:<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>SOLVE TRY 2<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">While (I am not happy with the solution) {<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> Distribute the locations among the Vehicles<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> Solve TSP for each Vehicle of the fleet<br>}<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">lets refine a little:<br></div>SOLVE TRY 3<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Distribute the locations the Vehicles<br></div>Solve TSP for each Vehicle of the fleet<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">While (I am not happy with the solution) {<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> Re-distribute some of the locations among a subset of the Vehicles<br></div> Solve TSP for each modified Vehicle of the fleet<br></div>}<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">more refining:<br></div>SOLVE TRY 3<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Distribute the locations among Vehicles<br></div>Solve TSP for each Vehicle of the fleet<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Now there is an initial solution<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">While (I am not happy with the solution) {<br><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> Re-distribute "wisely" some of the locations among a subset of the Vehicles<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> - by inserting the location in the "best place" because the current trip is already in a local minimum<br></div> Re-Evaluate the whole trips of the fleet<br></div>}<br><br></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Adding Time Windows<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The Drivers shift defines the Vehicle's trip time windows: From what time can the Vehicle depart, to what time can the Vehicle arrive<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Remember they depart from the same location. well what actually I am doing is that its not the same concept of location now.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Before: depot location location(x,y)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Now: depot location (x,y,open,close)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The before in terms of now: location(x,y,0,inf)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Time is involved now, before everything was distance. more information is needed about the truck, like Speed.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">When reading some papers the Speed is implicitly 1 and they don't bother about the speed, actually pgr_gsoc_vrppdtw, does exactly that.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>Adding time windows will affect the code, as a start TSP, keeping track of the time is needed now, and the "solution" found might be invalid because it can make the truck arrive time to the destination late. So the way to distribute the locations becomes difficult, consider that It will become NP-HARD, because to get the initial solution:<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">while (The solution found is not valid)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> Distribute the locations among the Vehicles<br></div> Solve TSP for each Vehicle of the fleet<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">}<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Currently this is what I am trying to improve.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br><br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><b>So, talking about the trailer trucks of your problem using pgRouting:</b><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">its an almost pick and delivery? Cargo goes from A to H:<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">- traliler 1 departs from A, arrives at B delivers cargo, continues trip, arrives at destination C<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">- trailer 2 departs from D, arrives at B pickups cargo, on arrival at E delivers cargo, continues trip, arrives at destination F<br>- trailer 3 departs from G, arrves at E pickups cargo, continues trip, arrives at destination H and unloads cargo<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I say almost, because for example at point B:<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">- truck 1 arrives unload the cargo, after that it can leave<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">- truck 2 arrives loads the cargo, it can leave after that.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>So data is needed somehow like this:<br>From the point of view of truck 1, the cargo at point B might have a time window [8:15, 8:30] with a service time of 0:02 minutes (time to unload the cargo)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>>From point of view of truck 2 the cargo at point B has a time window [8:10, 8:35] with a service time of 0:19, that is, make sure it arrives before the one that unloads, make sure it leaves after the one that unloaded, and the 19 minutes is the time window length of the possible arrival time of the cargo + 2 minutes of uloading of the other truck + 2 minutes of loading to this truck.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">So the same cargo is a different cargo (different location, different time, different truck, different time window) the only similarity might be that is the same weight.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Note that the time windows are given as data, they are not calculated.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">What I mean by this, is that, the algorithm will try to find a suitable trucks that can accomplish the time windows restriction.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">What the algorithm will not do is that based on the arrival time of the cargo, change the time windows of thcost matrixe departure time of another cargo.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">btw <br>- locations given by (x,y) and speed 1 is pgr_gsoc_vrppdtw<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">- working on: locations given by (x,y) and different speeds on vehicles (so the vehicles are no homogeneous)<br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">- working on: cost matrix is an input <br> - if the cost matrix is a distance matrix, then trucks must have a speed<br> - if the cost matrix is a time matrix, then trucks must have a factor (to simulate different speeds)<br><br><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">(If being working on this topic since November any donation is appreciated. <a href="http://pgrouting.org/">http://pgrouting.org/</a>)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 11, 2017 at 8:45 AM, Tom White <span dir="ltr"><<a href="mailto:tom.white@gmail.com" target="_blank">tom.white@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hello,<br><br></div>I am trying to figure out a way to evaluate a swap between two vehicles. Tractor-trailers can meet and swap trailers and continue to each other's destinations. The advantage lies in drivable hours - drivers are limited to a certain number of driving hours and are required to take breaks of varying lengths. One truck may have enough hours available to prevent a load from being late. One truck may even have two drivers.<br><br></div>Does anyone know of any previous work in this area, either open source or academic research? Does anybody have an idea how this could be solved with pgRouting tools?<br><br></div>Thank you,<br><br></div>Tom White<br></div>
<br>______________________________<wbr>_________________<br>
Pgrouting-users mailing list<br>
<a href="mailto:Pgrouting-users@lists.osgeo.org">Pgrouting-users@lists.osgeo.<wbr>org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/pgrouting-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/pgrouting-<wbr>users</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><pre>Georepublic UG (haftungsbeschränkt)
Salzmannstraße 44,
81739 München, Germany
Vicky Vergara
Operations Research
eMail: vicky@<a href="http://georepublic.de" target="_blank">georepublic.de</a>
Web: <a href="https://georepublic.info" target="_blank">https://georepublic.info</a>
Tel: +49 (089) 4161 7698-1
Fax: +49 (089) 4161 7698-9
Commercial register: Amtsgericht München, HRB 181428
CEO: Daniel Kastl
<span></span></pre></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>