# pgRouting Manual (2.1.0)

## pgr_vrppdtw - Pickup and Delivery problem

## Name

`pgr_gsoc_vrppdtw` — Returns optimized solution

## Synopsis

Vehicle Routing Problem with Pickup and Delivery (VRPPD): A number of goods need to be moved from certain pickup locations to other delivery locations. The goal is to find optimal routes for a fleet of vehicles to visit the pickup and drop-off locations.

    pgr_gsoc_vrppdtw(text sql, integer , integer;

## Description

sql:

a SQL query, which should return a set of rows with the following columns:

    select * from pgr_gsoc_vrppdtw(
                                    'select * from customer order by id'::text, 25,200
                                                    );

Returns set of pgr_costResult[]:

seq: | row sequence
rid: | route ID
nid: | node ID (`-1` for the last row)
cost: | cost to traverse to `seq`

## Examples

            SELECT  * from pgr_gsoc_vrppdtw(
                                            'select * from customer order by id'::text, 25,200
                                                            );

     seq | rid  | nid  | cost
    -----+------+------+------
       0 |    7 |    8 |    1
       1 |    8 |    9 |    1
       2 |    9 |   15 |    1
       3 |   12 |   -1 |    0
       . |   .  |   .  |    .
       . |   .  |   .  |    .

## See Also

- pgr_costResult[]
- http://en.wikipedia.org/wiki/Vehicle_routing_problem