Skip to content

Commit

Permalink
Merge pull request #185 from krashish8/ashish-2021
Browse files Browse the repository at this point in the history
GSoC-2021 Week-8: vrp_vroom
  • Loading branch information
krashish8 authored Jul 31, 2021
2 parents f7831ea + b4ee12c commit bd47a97
Show file tree
Hide file tree
Showing 27 changed files with 973 additions and 247 deletions.
45 changes: 45 additions & 0 deletions doc/general/sampledata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,51 @@ Orders table

.. literalinclude:: ../../tools/testers/solomon_100_rc101.data.sql

VROOM Data
-------------------------------------------------------------------------------

Jobs
...............................................................................

.. literalinclude:: ../../tools/testers/vroomdata.sql
:start-after: -- JOBS TABLE start
:end-before: -- JOBS TABLE end

Shipments
...............................................................................

.. literalinclude:: ../../tools/testers/vroomdata.sql
:start-after: -- SHIPMENTS TABLE start
:end-before: -- SHIPMENTS TABLE end

Vehicles
...............................................................................

.. literalinclude:: ../../tools/testers/vroomdata.sql
:start-after: -- VEHICLES TABLE start
:end-before: -- VEHICLES TABLE end

Matrix
...............................................................................

.. literalinclude:: ../../tools/testers/vroomdata.sql
:start-after: -- MATRIX TABLE start
:end-before: -- MATRIX TABLE end


Time Windows
...............................................................................

.. literalinclude:: ../../tools/testers/vroomdata.sql
:start-after: -- TIME WINDOWS TABLE start
:end-before: -- TIME WINDOWS TABLE end

Breaks
...............................................................................

.. literalinclude:: ../../tools/testers/vroomdata.sql
:start-after: -- BREAKS TABLE start
:end-before: -- BREAKS TABLE end

Images
-------------------------------------------------------------------------------
Expand Down
13 changes: 12 additions & 1 deletion doc/vroom/vrp_vroom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Signature
:start-after: signature start
:end-before: signature end

**Example**: Problem involving 2 jobs and 1 shipment, using a single vehicle.
**Example**: Problem involving 2 jobs and 1 shipment, using a single vehicle, similar to the VROOM Documentation
`Example 2 <https://github.com/VROOM-Project/vroom/blob/master/docs/example_2.json>`__ with a shipment.

.. literalinclude:: doc-vrp_vroom.queries
:start-after: -- q1
Expand All @@ -76,10 +77,20 @@ Result Columns
:start-after: result_columns_start
:end-before: result_columns_end

Example
-------------------------------------------------------------------------------

This example is based on the VROOM Data of the :doc:`sampledata` network:

.. literalinclude:: doc-vrp_vroom.queries
:start-after: -- q2
:end-before: -- q3

See Also
-------------------------------------------------------------------------------

* :doc:`vroom-category`
* The queries use the :doc:`sampledata` network.

.. include:: vroom-category.rst
:start-after: see_also_start
Expand Down
13 changes: 12 additions & 1 deletion doc/vroom/vrp_vroomJobs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Signature
:start-after: signature start
:end-before: signature end

**Example**: Problem involving 2 jobs, using a single vehicle.
**Example**: Problem involving 2 jobs, using a single vehicle, corresponding to the VROOM Documentation
`Example 2 <https://github.com/VROOM-Project/vroom/blob/master/docs/example_2.json>`__.

.. literalinclude:: doc-vrp_vroomJobs.queries
:start-after: -- q1
Expand All @@ -75,10 +76,20 @@ Result Columns
:start-after: result_columns_start
:end-before: result_columns_end

Example
-------------------------------------------------------------------------------

This example is based on the VROOM Data of the :doc:`sampledata` network:

.. literalinclude:: doc-vrp_vroomJobs.queries
:start-after: -- q2
:end-before: -- q3

See Also
-------------------------------------------------------------------------------

* :doc:`vroom-category`
* The queries use the :doc:`sampledata` network.

.. include:: vroom-category.rst
:start-after: see_also_start
Expand Down
14 changes: 13 additions & 1 deletion doc/vroom/vrp_vroomShipments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ Signature
:start-after: signature start
:end-before: signature end

**Example**: Problem involving 1 shipment, using a single vehicle.
**Example**: Problem involving 1 shipment, using a single vehicle, similar to the VROOM Documentation
`Example 2 <https://github.com/VROOM-Project/vroom/blob/master/docs/example_2.json>`__ without jobs
and with a shipment.

.. literalinclude:: doc-vrp_vroomShipments.queries
:start-after: -- q1
Expand All @@ -75,10 +77,20 @@ Result Columns
:start-after: result_columns_start
:end-before: result_columns_end

Example
-------------------------------------------------------------------------------

This example is based on the VROOM Data of the :doc:`sampledata` network:

.. literalinclude:: doc-vrp_vroomShipments.queries
:start-after: -- q2
:end-before: -- q3

See Also
-------------------------------------------------------------------------------

* :doc:`vroom-category`
* The queries use the :doc:`sampledata` network.

.. include:: vroom-category.rst
:start-after: see_also_start
Expand Down
65 changes: 52 additions & 13 deletions docqueries/vroom/doc-vrp_vroom.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,77 @@ SELECT *
FROM vrp_vroom(
$jobs$
SELECT * FROM (
VALUES (1414, 5), (1515, 10)
VALUES (1414, 2), (1515, 3)
) AS C(id, location_index)
$jobs$,
$shipments$
SELECT * FROM (
VALUES (100, 1, 200, 30)
VALUES (100, 1, 200, 4)
) AS C(p_id, p_location_index, d_id, d_location_index)
$shipments$,
$vehicles$
SELECT * FROM (
VALUES (500, 1, 30)
VALUES (1, 1, 4)
) AS C(id, start_index, end_index)
$vehicles$,
$matrix$
SELECT * FROM (
VALUES (1, 5, 2104), (1, 10, 197), (1, 30, 1299),
(5, 1, 2103), (5, 10, 2255), (5, 30, 3152),
(10, 1, 197), (10, 5, 2256), (10, 30, 1102),
(30, 1, 1299), (30, 5, 3153), (30, 10, 1102)
VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299),
(2, 1, 2103), (2, 3, 2255), (2, 4, 3152),
(3, 1, 197), (3, 2, 2256), (3, 4, 1102),
(4, 1, 1299), (4, 2, 3153), (4, 3, 1102)
) AS C(start_vid, end_vid, agg_cost)
$matrix$
);
seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load
-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------
1 | 1 | 500 | 1 | 1 | -1 | 0 | 0 | 0 | 0 | {}
2 | 1 | 500 | 2 | 3 | 100 | 0 | 0 | 0 | 0 | {}
3 | 1 | 500 | 3 | 2 | 1414 | 2104 | 2104 | 0 | 0 | {}
4 | 1 | 500 | 4 | 2 | 1515 | 4359 | 4359 | 0 | 0 | {}
5 | 1 | 500 | 5 | 4 | 200 | 5461 | 5461 | 0 | 0 | {}
6 | 1 | 500 | 6 | 6 | -1 | 5461 | 5461 | 0 | 0 | {}
1 | 1 | 1 | 1 | 1 | -1 | 0 | 0 | 0 | 0 | {}
2 | 1 | 1 | 2 | 3 | 100 | 0 | 0 | 0 | 0 | {}
3 | 1 | 1 | 3 | 2 | 1414 | 2104 | 2104 | 0 | 0 | {}
4 | 1 | 1 | 4 | 2 | 1515 | 4359 | 4359 | 0 | 0 | {}
5 | 1 | 1 | 5 | 4 | 200 | 5461 | 5461 | 0 | 0 | {}
6 | 1 | 1 | 6 | 6 | -1 | 5461 | 5461 | 0 | 0 | {}
(6 rows)

-- q2
SELECT *
FROM vrp_vroom(
'SELECT * FROM vroom.jobs',
'SELECT * FROM vroom.shipments',
'SELECT * FROM vroom.vehicles',
'SELECT * FROM vroom.matrix'
);
seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load
-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------
1 | 1 | 1 | 1 | 1 | -1 | 300 | 0 | 0 | 0 | {30}
2 | 1 | 1 | 2 | 5 | -1 | 300 | 0 | 0 | 0 | {30}
3 | 1 | 1 | 3 | 2 | 2 | 350 | 50 | 250 | 900 | {30}
4 | 1 | 1 | 4 | 3 | 14 | 1500 | 50 | 2250 | 11850 | {40}
5 | 1 | 1 | 5 | 3 | 10 | 15650 | 100 | 2250 | 0 | {60}
6 | 1 | 1 | 6 | 4 | 15 | 17950 | 150 | 2250 | 225 | {50}
7 | 1 | 1 | 7 | 4 | 11 | 20425 | 150 | 2250 | 200 | {30}
8 | 1 | 1 | 8 | 6 | -1 | 22925 | 200 | 0 | 0 | {30}
9 | 2 | 2 | 1 | 1 | -1 | 275 | 0 | 0 | 0 | {70}
10 | 2 | 2 | 2 | 5 | -1 | 275 | 0 | 10 | 0 | {70}
11 | 2 | 2 | 3 | 2 | 5 | 360 | 75 | 250 | 665 | {70}
12 | 2 | 2 | 4 | 2 | 3 | 1325 | 125 | 250 | 1400 | {70}
13 | 2 | 2 | 5 | 2 | 4 | 2975 | 125 | 250 | 550 | {70}
14 | 2 | 2 | 6 | 6 | -1 | 3775 | 125 | 0 | 0 | {70}
15 | 3 | 3 | 1 | 1 | -1 | 0 | 0 | 0 | 0 | {20}
16 | 3 | 3 | 2 | 5 | -1 | 0 | 0 | 0 | 0 | {20}
17 | 3 | 3 | 3 | 2 | 1 | 0 | 0 | 250 | 3625 | {20}
18 | 3 | 3 | 4 | 3 | 12 | 3875 | 0 | 2250 | 2500 | {40}
19 | 3 | 3 | 5 | 4 | 13 | 8700 | 75 | 2250 | 225 | {20}
20 | 3 | 3 | 6 | 6 | -1 | 11250 | 150 | 0 | 0 | {20}
21 | 4 | 4 | 1 | 1 | -1 | 250 | 0 | 0 | 0 | {0}
22 | 4 | 4 | 2 | 5 | -1 | 250 | 0 | 0 | 0 | {0}
23 | 4 | 4 | 3 | 3 | 8 | 275 | 25 | 2250 | 100 | {10}
24 | 4 | 4 | 4 | 3 | 6 | 2650 | 50 | 2250 | 0 | {20}
25 | 4 | 4 | 5 | 4 | 9 | 4990 | 140 | 2250 | 0 | {10}
26 | 4 | 4 | 6 | 4 | 7 | 7351 | 251 | 2250 | 17574 | {0}
27 | 4 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0}
(27 rows)

-- q3
ROLLBACK;
ROLLBACK
22 changes: 15 additions & 7 deletions docqueries/vroom/doc-vrp_vroom.test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,34 @@ SELECT *
FROM vrp_vroom(
$jobs$
SELECT * FROM (
VALUES (1414, 5), (1515, 10)
VALUES (1414, 2), (1515, 3)
) AS C(id, location_index)
$jobs$,
$shipments$
SELECT * FROM (
VALUES (100, 1, 200, 30)
VALUES (100, 1, 200, 4)
) AS C(p_id, p_location_index, d_id, d_location_index)
$shipments$,
$vehicles$
SELECT * FROM (
VALUES (500, 1, 30)
VALUES (1, 1, 4)
) AS C(id, start_index, end_index)
$vehicles$,
$matrix$
SELECT * FROM (
VALUES (1, 5, 2104), (1, 10, 197), (1, 30, 1299),
(5, 1, 2103), (5, 10, 2255), (5, 30, 3152),
(10, 1, 197), (10, 5, 2256), (10, 30, 1102),
(30, 1, 1299), (30, 5, 3153), (30, 10, 1102)
VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299),
(2, 1, 2103), (2, 3, 2255), (2, 4, 3152),
(3, 1, 197), (3, 2, 2256), (3, 4, 1102),
(4, 1, 1299), (4, 2, 3153), (4, 3, 1102)
) AS C(start_vid, end_vid, agg_cost)
$matrix$
);
\echo -- q2
SELECT *
FROM vrp_vroom(
'SELECT * FROM vroom.jobs',
'SELECT * FROM vroom.shipments',
'SELECT * FROM vroom.vehicles',
'SELECT * FROM vroom.matrix'
);
\echo -- q3
42 changes: 32 additions & 10 deletions docqueries/vroom/doc-vrp_vroomJobs.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,53 @@ SELECT *
FROM vrp_vroomJobs(
$jobs$
SELECT * FROM (
VALUES (1414, 5), (1515, 10)
VALUES (1414, 2), (1515, 3)
) AS C(id, location_index)
$jobs$,
$vehicles$
SELECT * FROM (
VALUES (500, 1, 30)
VALUES (1, 1, 4)
) AS C(id, start_index, end_index)
$vehicles$,
$matrix$
SELECT * FROM (
VALUES (1, 5, 2104), (1, 10, 197), (1, 30, 1299),
(5, 1, 2103), (5, 10, 2255), (5, 30, 3152),
(10, 1, 197), (10, 5, 2256), (10, 30, 1102),
(30, 1, 1299), (30, 5, 3153), (30, 10, 1102)
VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299),
(2, 1, 2103), (2, 3, 2255), (2, 4, 3152),
(3, 1, 197), (3, 2, 2256), (3, 4, 1102),
(4, 1, 1299), (4, 2, 3153), (4, 3, 1102)
) AS C(start_vid, end_vid, agg_cost)
$matrix$
);
seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load
-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------
1 | 1 | 500 | 1 | 1 | -1 | 0 | 0 | 0 | 0 | {}
2 | 1 | 500 | 2 | 2 | 1414 | 2104 | 2104 | 0 | 0 | {}
3 | 1 | 500 | 3 | 2 | 1515 | 4359 | 4359 | 0 | 0 | {}
4 | 1 | 500 | 4 | 6 | -1 | 5461 | 5461 | 0 | 0 | {}
1 | 1 | 1 | 1 | 1 | -1 | 0 | 0 | 0 | 0 | {}
2 | 1 | 1 | 2 | 2 | 1414 | 2104 | 2104 | 0 | 0 | {}
3 | 1 | 1 | 3 | 2 | 1515 | 4359 | 4359 | 0 | 0 | {}
4 | 1 | 1 | 4 | 6 | -1 | 5461 | 5461 | 0 | 0 | {}
(4 rows)

-- q2
SELECT *
FROM vrp_vroomJobs(
'SELECT * FROM vroom.jobs',
'SELECT * FROM vroom.vehicles',
'SELECT * FROM vroom.matrix'
);
seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load
-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+-------
1 | 1 | 1 | 1 | 1 | -1 | 300 | 0 | 0 | 0 | {20}
2 | 1 | 1 | 2 | 5 | -1 | 300 | 0 | 0 | 0 | {20}
3 | 1 | 1 | 3 | 2 | 1 | 300 | 0 | 250 | 3325 | {20}
4 | 1 | 1 | 4 | 6 | -1 | 3875 | 0 | 0 | 0 | {20}
5 | 2 | 2 | 1 | 1 | -1 | 275 | 0 | 0 | 0 | {100}
6 | 2 | 2 | 2 | 5 | -1 | 275 | 0 | 10 | 0 | {100}
7 | 2 | 2 | 3 | 2 | 2 | 335 | 50 | 250 | 915 | {100}
8 | 2 | 2 | 4 | 2 | 5 | 1590 | 140 | 250 | 0 | {100}
9 | 2 | 2 | 5 | 2 | 3 | 1890 | 190 | 250 | 835 | {100}
10 | 2 | 2 | 6 | 2 | 4 | 2975 | 190 | 250 | 550 | {100}
11 | 2 | 2 | 7 | 6 | -1 | 3775 | 190 | 0 | 0 | {100}
(11 rows)

-- q3
ROLLBACK;
ROLLBACK
19 changes: 13 additions & 6 deletions docqueries/vroom/doc-vrp_vroomJobs.test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ SELECT *
FROM vrp_vroomJobs(
$jobs$
SELECT * FROM (
VALUES (1414, 5), (1515, 10)
VALUES (1414, 2), (1515, 3)
) AS C(id, location_index)
$jobs$,
$vehicles$
SELECT * FROM (
VALUES (500, 1, 30)
VALUES (1, 1, 4)
) AS C(id, start_index, end_index)
$vehicles$,
$matrix$
SELECT * FROM (
VALUES (1, 5, 2104), (1, 10, 197), (1, 30, 1299),
(5, 1, 2103), (5, 10, 2255), (5, 30, 3152),
(10, 1, 197), (10, 5, 2256), (10, 30, 1102),
(30, 1, 1299), (30, 5, 3153), (30, 10, 1102)
VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299),
(2, 1, 2103), (2, 3, 2255), (2, 4, 3152),
(3, 1, 197), (3, 2, 2256), (3, 4, 1102),
(4, 1, 1299), (4, 2, 3153), (4, 3, 1102)
) AS C(start_vid, end_vid, agg_cost)
$matrix$
);
\echo -- q2
SELECT *
FROM vrp_vroomJobs(
'SELECT * FROM vroom.jobs',
'SELECT * FROM vroom.vehicles',
'SELECT * FROM vroom.matrix'
);
\echo -- q3
Loading

0 comments on commit bd47a97

Please sign in to comment.