# pgr_gsoc_vrppdtw - Proposed¶

## Name¶

pgr_gsoc_vrppdtw — Returns a solution for Pick and Delivery with time windows Vehicle Routing Problem

Warning

These are proposed functions

• They are not officially of the current release.
• They likely will not be officially be part of the next release:
• The functions might not make use of ANY-INTEGER and ANY-NUMERICAL
• Name might change.
• Signature might change.
• Functionality might change.
• pgTap tests might be missing.
• Might need c/c++ coding.
• May lack documentation.
• Documentation if any might need to be rewritten.
• Documentation examples might need to be automatically generated.
• Might need a lot of feedback from the comunity.
• Might depend on a proposed function of pgRouting
• Might depend on a deprecated function of pgRouting

## Signature Summary¶

pgr_gsoc_vrppdtw(sql, vehicle_num, capacity)
RETURNS SET OF pgr_costResult[]:


## Signatures¶

### Complete signature¶

pgr_gsoc_vrppdtw(sql, vehicle_num, capacity)
Returns set of pgr_costResult[]:


Example: Show the id1

SELECT DISTINCT(id1) FROM pgr_gsoc_vrppdtw(
'SELECT * FROM customer ORDER BY id', 25, 200)
ORDER BY id1;
id1
-----
1
2
3
4
5
6
7
8
9
10
(10 rows)



## Description of the Signatures¶

### Description of the sql query¶

Column Type Description
id ANY-INTEGER

Identifier of the customer.

• A value of 0 identifies the starting location
x ANY-NUMERICAL X coordinate of the location.
y ANY-NUMERICAL Y coordinate of the location.
demand ANY-NUMERICAL

How much is added / removed from the vehicle.

• Negative value is a delivery,
• Positive value is a pickup,
openTime ANY-NUMERICAL The time relative to 0, when the customer opens.
closeTime ANY-NUMERICAL The time relative to 0, when the customer closes.
serviceTime ANY-NUMERICAL The duration of the loading / unloading.
pIndex ANY-INTEGER Value used when the current customer is a Delivery to find the corresponding Pickup
dIndex ANY-INTEGER Value used when the current customer is a Pickup to find the corresponding Delivery

### Description of the parameters of the signatures¶

Column Type Description
sql TEXT SQL query as described above.
vehicle_num INTEGER Maximum number of vehicles in the result. (currently is ignored)
capacity INTEGER Capacity of the vehicle.

### Description of the result¶

RETURNS SET OF pgr_costResult[]:

Column Type Description
seq INTEGER Sequential value starting from 1.
id1 INTEGER Current vehicle identifier.
id2 INTEGER Customer identifier.
cost FLOAT
Previous cost plus travel time plus wait time plus service time.
• when id2 = 0 for the second time for the same id1, then has the total time for the current id1

## Examples¶

Example: Total number of rows returned

SELECT count(*) FROM pgr_gsoc_vrppdtw(
'SELECT * FROM customer ORDER BY id', 25, 200);
count
-------
126
(1 row)



Example: Results for only id1 values: 1, 5, and 9

SELECT * FROM pgr_gsoc_vrppdtw(
'SELECT * FROM customer ORDER BY id', 25, 200)
WHERE id1 in (1, 5, 9);
seq | id1 | id2 |       cost
-----+-----+-----+------------------
1 |   1 |   0 |                0
2 |   1 |   5 | 105.132745950422
3 |   1 |   3 | 196.132745950422
4 |   1 |   7 | 288.132745950422
5 |   1 |   8 | 380.961173075168
6 |   1 |  10 | 474.566724350632
7 |   1 |  11 | 567.566724350632
8 |   1 |   9 |   660.7290020108
9 |   1 |   6 |   752.9650699883
10 |   1 |   4 |   845.2011379658
11 |   1 |   2 | 938.806689241264
12 |   1 |   1 | 1030.80668924126
13 |   1 |  75 | 1123.80668924126
14 |   1 |   0 | 1139.61807754211
51 |   5 |   0 |                0
52 |   5 |  43 | 106.552945357247
53 |   5 |  42 | 199.552945357247
54 |   5 |  41 | 291.552945357247
55 |   5 |  40 | 383.552945357247
56 |   5 |  44 | 476.552945357247
57 |   5 |  46 | 569.381372481993
58 |   5 |  45 | 661.381372481993
59 |   5 |  48 | 753.381372481993
60 |   5 |  51 | 756.381372481993
61 |   5 | 101 | 846.381372481993
62 |   5 |  50 | 938.617440459493
63 |   5 |  52 | 1031.77971811966
64 |   5 |  49 | 1124.77971811966
65 |   5 |  47 | 1216.77971811966
66 |   5 |   0 | 1234.80747449698
103 |   9 |   0 |                0
104 |   9 |  90 | 110.615528128088
105 |   9 |  87 | 205.615528128088
106 |   9 |  86 | 296.615528128088
107 |   9 |  83 | 392.615528128088
108 |   9 |  82 | 485.615528128088
109 |   9 |  84 | 581.446480022934
110 |   9 |  85 |  674.27490714768
111 |   9 |  88 |  767.27490714768
112 |   9 |  89 | 860.103334272426
113 |   9 |  91 |  953.70888554789
114 |   9 |   0 | 976.069565322888
(42 rows)