vrp_oneDepot - Experimental

Warning

Possible server crash

  • These functions might create a server crash

Warning

Experimental 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 vrpRouting

    • Might depend on a deprecated function of vrpRouting

Availability

Version 0.4.1

  • Code fix

  • Result columns changed

Version 0.0.0

  • New experimental function

    • Ported pgr_vrpOneDepot from pgRouting v3.1.3

Description

  • TBD

Signatures

  • TBD

Parameters

  • TBD

Inner Queries

  • TBD

Result Columns

  • TBD

Example

BEGIN;
BEGIN
SET client_min_messages TO NOTICE;
SET
SELECT * FROM vrp_oneDepot(
    'SELECT * FROM onedepot.orders',
    'SELECT * FROM onedepot.vehicles',
    'SELECT * FROM onedepot.distances',
    1);
 seq | vehicle_seq | vehicle_id | stop_seq | stop_type | stop_id | order_id | cargo | travel_time | arrival_time | wait_time | service_time | departure_time
-----+-------------+------------+----------+-----------+---------+----------+-------+-------------+--------------+-----------+--------------+----------------
   1 |           1 |          1 |        1 |         1 |       1 |       -1 |     0 |           0 |            0 |         0 |            0 |              0
   2 |           1 |          1 |        2 |         2 |       1 |        8 |    20 |           0 |            0 |         0 |            0 |              0
   3 |           1 |          1 |        3 |         2 |       1 |        4 |    30 |           0 |            0 |         0 |            0 |              0
   4 |           1 |          1 |        4 |         2 |       1 |        2 |    50 |           0 |            0 |         0 |            0 |              0
   5 |           1 |          1 |        5 |         2 |       1 |        7 |    70 |           0 |            0 |         0 |            0 |              0
   6 |           1 |          1 |        6 |         2 |       1 |        9 |    80 |           0 |            0 |         0 |            0 |              0
   7 |           1 |          1 |        7 |         2 |       1 |        5 |   120 |           0 |            0 |         0 |            0 |              0
   8 |           1 |          1 |        8 |         2 |       1 |        3 |   150 |           0 |            0 |         0 |            0 |              0
   9 |           1 |          1 |        9 |         3 |       3 |        3 |   120 |          31 |           31 |        19 |           10 |             60
  10 |           1 |          1 |       10 |         3 |       8 |        8 |   100 |           7 |           67 |        12 |           10 |             89
  11 |           1 |          1 |       11 |         3 |       9 |        9 |    90 |           5 |           94 |         0 |           10 |            104
  12 |           1 |          1 |       12 |         3 |       7 |        7 |    70 |           6 |          110 |         0 |           10 |            120
  13 |           1 |          1 |       13 |         3 |       4 |        4 |    60 |          11 |          131 |         0 |           10 |            141
  14 |           1 |          1 |       14 |         3 |       5 |        5 |    20 |           5 |          146 |         0 |           10 |            156
  15 |           1 |          1 |       15 |         3 |       2 |        2 |     0 |           7 |          163 |         0 |           10 |            173
  16 |           1 |          1 |       16 |         6 |       1 |       -1 |     0 |          38 |          211 |         0 |            0 |            211
  17 |           2 |          2 |        1 |         1 |       1 |       -1 |     0 |           0 |            0 |         0 |            0 |              0
  18 |           2 |          2 |        2 |         2 |       1 |       10 |    20 |           0 |            0 |         0 |            0 |              0
  19 |           2 |          2 |        3 |         2 |       1 |       11 |    50 |           0 |            0 |         0 |            0 |              0
  20 |           2 |          2 |        4 |         3 |      10 |       10 |    30 |          34 |           34 |        57 |           10 |            101
  21 |           2 |          2 |        5 |         3 |      11 |       11 |     0 |           5 |          106 |        13 |           10 |            129
  22 |           2 |          2 |        6 |         6 |       1 |       -1 |     0 |          32 |          161 |         0 |            0 |            161
  23 |           3 |          3 |        1 |         1 |       1 |       -1 |     0 |           0 |            0 |         0 |            0 |              0
  24 |           3 |          3 |        2 |         2 |       1 |        6 |    20 |           0 |            0 |         0 |            0 |              0
  25 |           3 |          3 |        3 |         3 |       6 |        6 |     0 |          40 |           40 |         1 |           10 |             51
  26 |           3 |          3 |        4 |         6 |       1 |       -1 |     0 |          40 |           91 |         0 |            0 |             91
  27 |          -2 |          0 |        0 |        -1 |      -1 |       -1 |    -1 |         261 |           -1 |       102 |          100 |            463
(27 rows)

ROLLBACK;
ROLLBACK

Data

DROP SCHEMA if EXISTS onedepot CASCADE;
CREATE SCHEMA onedepot;

CREATE TABLE onedepot.orders (
    id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    amount INTEGER,
    open_time INTEGER,
    close_time INTEGER,
    service_time INTEGER,
    x float8,
    y float8
);

COPY onedepot.orders
(x, y, amount, open_time, close_time, service_time) FROM stdin;
40.000000	50.000000	0	0	240	0
25.000000	85.000000	20	145	175	10
22.000000	75.000000	30	50	80	10
22.000000	85.000000	10	109	139	10
20.000000	80.000000	40	141	171	10
20.000000	85.000000	20	41	71	10
18.000000	75.000000	20	95	125	10
15.000000	75.000000	20	79	109	10
15.000000	80.000000	10	91	121	10
10.000000	35.000000	20	91	121	10
10.000000	40.000000	30	119	149	10
\.

CREATE TABLE onedepot.vehicles (
    vehicle_id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    capacity INTEGER
);

copy onedepot.vehicles (capacity) from stdin;
200
200
200
\.

WITH
the_matrix_info AS (
  SELECT A.id AS start_vid, B.id AS end_vid, sqrt( (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) AS agg_cost
    FROM onedepot.orders AS A, onedepot.orders AS B WHERE A.id != B.id
)
SELECT start_vid, end_vid, agg_cost::INTEGER
INTO onedepot.distances
FROM the_matrix_info;

See Also

Indices and tables