diff --git a/NEWS b/NEWS index 8e1dfd633..874dce07f 100644 --- a/NEWS +++ b/NEWS @@ -2,9 +2,9 @@ v0.3.0 Release Notes ******************************************************************************* -To see all issues & pull requests closed by this release see the [Git closed milestone for 0.3.0 ](https://github.com/pgRouting/vrprouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%200.3.0%22) on Github. +To see all issues & pull requests closed by this release see the [Git closed milestone for 0.3.0](https://github.com/pgRouting/vrprouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%200.3.0%22) on Github. -*Modification of experimental functions* +**Modification of experimental functions** - VROOM @@ -15,7 +15,7 @@ To see all issues & pull requests closed by this release see the [Git closed mil - vrp_vroomJobsPlain - vrp_vroomShipmentsPlain -*Added support for VROOM 1.11.0 (#24)* +**Added support for VROOM 1.11.0 ([#24](https://github.com/pgRouting/vrprouting/issues/24))** - Added setup time in jobs and shipments to refine service time modeling. - Added support for custom cost matrices, along with the duration matrix. @@ -26,14 +26,22 @@ To see all issues & pull requests closed by this release see the [Git closed mil - Added custom scaling logic for speed_factor. - Modified parameter names to make the naming consistent. -*Fixes* +**Fixes** - Honor client cancel requests for vroom-category functions. +- Added more information in the inner query and result columns of VROOM category functions + ([#26](https://github.com/pgRouting/vrprouting/issues/26), [#27](https://github.com/pgRouting/vrprouting/issues/27)): + + - Summary row in the output, for each vehicle and for the complete problem. + - Uassigned rows in the output with vehicle_id = -1. + - Modified travel_time result column to return travel time between current and last step. + - Added data jsonb field in jobs, shipments, vehicles, breaks as well as in the result columns. + - Added departure field and location_id field in the result columns. v0.2.0 Release Notes ******************************************************************************* -*New experimental functions* +**New experimental functions** - VROOM @@ -47,11 +55,11 @@ v0.2.0 Release Notes v0.1.0 Release Notes ******************************************************************************* -*Extraction tasks* +**Extraction tasks** - Porting pgRouting's VRP functionality -*New official functions* +**New official functions** * vrp_version * vrp_full_version diff --git a/doc/general/release_notes.rst b/doc/general/release_notes.rst index dae339e1c..88a4c0e65 100644 --- a/doc/general/release_notes.rst +++ b/doc/general/release_notes.rst @@ -38,7 +38,7 @@ To see all issues & pull requests closed by this release see the `Git closed mil - vrp_vroomJobsPlain - vrp_vroomShipmentsPlain -.. rubric:: Added support for VROOM 1.11.0 (#24) +.. rubric:: Added support for VROOM 1.11.0 (`#24 `_) - Added setup time in jobs and shipments to refine service time modeling. - Added support for custom cost matrices, along with the duration matrix. @@ -52,6 +52,14 @@ To see all issues & pull requests closed by this release see the `Git closed mil .. rubric:: Fixes - Honor client cancel requests for vroom-category functions. +- Added more information in the inner query and result columns of VROOM category functions + (`#26 `_, `#27 `_): + + - Summary row in the output, for each vehicle and for the complete problem. + - Uassigned rows in the output with vehicle_id = -1. + - Modified travel_time result column to return travel time between current and last step. + - Added data jsonb field in jobs, shipments, vehicles, breaks as well as in the result columns. + - Added departure field and location_id field in the result columns. v0.2.0 Release Notes ******************************************************************************* diff --git a/docqueries/vroom/doc-vrp_vroom.result b/docqueries/vroom/doc-vrp_vroom.result index 6deb0b5b9..4d87c4ef7 100644 --- a/docqueries/vroom/doc-vrp_vroom.result +++ b/docqueries/vroom/doc-vrp_vroom.result @@ -41,36 +41,41 @@ FROM vrp_vroom( 'SELECT * FROM vroom.breaks_time_windows', '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 | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | {30} - 2 | 1 | 1 | 2 | 5 | 1 | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | {30} - 3 | 1 | 1 | 3 | 2 | 2 | 2021-09-02 09:05:50 | 00:00:50 | 00:04:10 | 00:15:00 | {30} - 4 | 1 | 1 | 4 | 3 | 5 | 2021-09-02 09:25:00 | 00:00:50 | 00:37:30 | 03:17:30 | {40} - 5 | 1 | 1 | 5 | 3 | 3 | 2021-09-02 13:20:50 | 00:01:40 | 00:37:30 | 00:00:00 | {60} - 6 | 1 | 1 | 6 | 4 | 5 | 2021-09-02 13:59:10 | 00:02:30 | 00:37:30 | 00:03:45 | {50} - 7 | 1 | 1 | 7 | 4 | 3 | 2021-09-02 14:40:25 | 00:02:30 | 00:37:30 | 00:03:20 | {30} - 8 | 1 | 1 | 8 | 6 | -1 | 2021-09-02 15:22:05 | 00:03:20 | 00:00:00 | 00:00:00 | {30} - 9 | 2 | 2 | 1 | 1 | -1 | 2021-09-02 09:04:35 | 00:00:00 | 00:00:00 | 00:00:00 | {70} - 10 | 2 | 2 | 2 | 5 | 2 | 2021-09-02 09:04:35 | 00:00:00 | 00:00:10 | 00:00:00 | {70} - 11 | 2 | 2 | 3 | 2 | 5 | 2021-09-02 09:06:00 | 00:01:15 | 00:04:10 | 00:11:05 | {70} - 12 | 2 | 2 | 4 | 2 | 3 | 2021-09-02 09:22:05 | 00:02:05 | 00:04:10 | 00:23:20 | {70} - 13 | 2 | 2 | 5 | 2 | 4 | 2021-09-02 09:49:35 | 00:02:05 | 00:04:10 | 00:09:10 | {70} - 14 | 2 | 2 | 6 | 6 | -1 | 2021-09-02 10:02:55 | 00:02:05 | 00:00:00 | 00:00:00 | {70} - 15 | 3 | 3 | 1 | 1 | -1 | 2021-09-02 09:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {20} - 16 | 3 | 3 | 2 | 5 | 3 | 2021-09-02 09:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {20} - 17 | 3 | 3 | 3 | 2 | 1 | 2021-09-02 09:00:00 | 00:00:00 | 00:04:10 | 01:00:25 | {20} - 18 | 3 | 3 | 4 | 3 | 4 | 2021-09-02 10:04:35 | 00:00:00 | 00:37:30 | 00:41:40 | {40} - 19 | 3 | 3 | 5 | 4 | 4 | 2021-09-02 11:25:00 | 00:01:15 | 00:37:30 | 00:03:45 | {20} - 20 | 3 | 3 | 6 | 6 | -1 | 2021-09-02 12:07:30 | 00:02:30 | 00:00:00 | 00:00:00 | {20} - 21 | 4 | 4 | 1 | 1 | -1 | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | {0} - 22 | 4 | 4 | 2 | 5 | 4 | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | {0} - 23 | 4 | 4 | 3 | 3 | 2 | 2021-09-02 09:04:35 | 00:00:25 | 00:37:30 | 00:01:40 | {10} - 24 | 4 | 4 | 4 | 3 | 1 | 2021-09-02 09:44:10 | 00:00:50 | 00:37:30 | 00:00:00 | {20} - 25 | 4 | 4 | 5 | 4 | 2 | 2021-09-02 10:23:10 | 00:02:20 | 00:37:30 | 00:00:00 | {10} - 26 | 4 | 4 | 6 | 4 | 1 | 2021-09-02 11:02:31 | 00:04:11 | 00:37:30 | 04:52:54 | {0} - 27 | 4 | 4 | 7 | 6 | -1 | 2021-09-02 16:33:20 | 00:04:36 | 00:00:00 | 00:00:00 | {0} -(27 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------------------+-------------+------------+--------------+--------------+---------------------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:05:00 | {30} + 2 | 1 | 1 | {} | 2 | 5 | 1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:05:00 | {30} + 3 | 1 | 1 | {} | 3 | 2 | 2 | 2 | {} | 2021-09-02 09:05:50 | 00:00:50 | 00:00:00 | 00:04:10 | 00:15:00 | 2021-09-02 09:25:00 | {30} + 4 | 1 | 1 | {} | 4 | 3 | 5 | 2 | {} | 2021-09-02 09:25:00 | 00:00:00 | 00:00:00 | 00:37:30 | 03:17:30 | 2021-09-02 13:20:00 | {40} + 5 | 1 | 1 | {} | 5 | 3 | 3 | 1 | {} | 2021-09-02 13:20:50 | 00:00:50 | 00:00:00 | 00:37:30 | 00:00:00 | 2021-09-02 13:58:20 | {60} + 6 | 1 | 1 | {} | 6 | 4 | 5 | 2 | {} | 2021-09-02 13:59:10 | 00:00:50 | 00:00:00 | 00:37:30 | 00:03:45 | 2021-09-02 14:40:25 | {50} + 7 | 1 | 1 | {} | 7 | 4 | 3 | 2 | {} | 2021-09-02 14:40:25 | 00:00:00 | 00:00:00 | 00:37:30 | 00:03:20 | 2021-09-02 15:21:15 | {30} + 8 | 1 | 1 | {} | 8 | 6 | -1 | 1 | {} | 2021-09-02 15:22:05 | 00:00:50 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 15:22:05 | {30} + 9 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:03:20 | 00:00:00 | 02:34:10 | 03:39:35 | 1970-01-01 00:00:00 | {} + 10 | 2 | 2 | {} | 1 | 1 | -1 | 1 | {} | 2021-09-02 09:04:35 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:04:35 | {70} + 11 | 2 | 2 | {} | 2 | 5 | 2 | 1 | {} | 2021-09-02 09:04:35 | 00:00:00 | 00:00:00 | 00:00:10 | 00:00:00 | 2021-09-02 09:04:45 | {70} + 12 | 2 | 2 | {} | 3 | 2 | 5 | 4 | {} | 2021-09-02 09:06:00 | 00:01:15 | 00:00:00 | 00:04:10 | 00:11:05 | 2021-09-02 09:21:15 | {70} + 13 | 2 | 2 | {} | 4 | 2 | 3 | 3 | {} | 2021-09-02 09:22:05 | 00:00:50 | 00:00:00 | 00:04:10 | 00:23:20 | 2021-09-02 09:49:35 | {70} + 14 | 2 | 2 | {} | 5 | 2 | 4 | 3 | {} | 2021-09-02 09:49:35 | 00:00:00 | 00:00:00 | 00:04:10 | 00:09:10 | 2021-09-02 10:02:55 | {70} + 15 | 2 | 2 | {} | 6 | 6 | -1 | 3 | {} | 2021-09-02 10:02:55 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 10:02:55 | {70} + 16 | 2 | 2 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:02:05 | 00:00:00 | 00:12:40 | 00:43:35 | 1970-01-01 00:00:00 | {} + 17 | 3 | 3 | {} | 1 | 1 | -1 | 1 | {} | 2021-09-02 09:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:00:00 | {20} + 18 | 3 | 3 | {} | 2 | 5 | 3 | 1 | {} | 2021-09-02 09:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:00:00 | {20} + 19 | 3 | 3 | {} | 3 | 2 | 1 | 1 | {} | 2021-09-02 09:00:00 | 00:00:00 | 00:00:00 | 00:04:10 | 01:00:25 | 2021-09-02 10:04:35 | {20} + 20 | 3 | 3 | {} | 4 | 3 | 4 | 1 | {} | 2021-09-02 10:04:35 | 00:00:00 | 00:00:00 | 00:37:30 | 00:41:40 | 2021-09-02 11:23:45 | {40} + 21 | 3 | 3 | {} | 5 | 4 | 4 | 4 | {} | 2021-09-02 11:25:00 | 00:01:15 | 00:00:00 | 00:37:30 | 00:03:45 | 2021-09-02 12:06:15 | {20} + 22 | 3 | 3 | {} | 6 | 6 | -1 | 1 | {} | 2021-09-02 12:07:30 | 00:01:15 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 12:07:30 | {20} + 23 | 3 | 3 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:02:30 | 00:00:00 | 01:19:10 | 01:45:50 | 1970-01-01 00:00:00 | {} + 24 | 4 | 4 | {} | 1 | 1 | -1 | 3 | {} | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:04:10 | {0} + 25 | 4 | 4 | {} | 2 | 5 | 4 | 1 | {} | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:04:10 | {0} + 26 | 4 | 4 | {} | 3 | 3 | 2 | 5 | {} | 2021-09-02 09:04:35 | 00:00:25 | 00:00:00 | 00:37:30 | 00:01:40 | 2021-09-02 09:43:45 | {10} + 27 | 4 | 4 | {} | 4 | 3 | 1 | 3 | {} | 2021-09-02 09:44:10 | 00:00:25 | 00:00:00 | 00:37:30 | 00:00:00 | 2021-09-02 10:21:40 | {20} + 28 | 4 | 4 | {} | 5 | 4 | 2 | 6 | {} | 2021-09-02 10:23:10 | 00:01:30 | 00:00:00 | 00:37:30 | 00:00:00 | 2021-09-02 11:00:40 | {10} + 29 | 4 | 4 | {} | 6 | 4 | 1 | 5 | {} | 2021-09-02 11:02:31 | 00:01:51 | 00:00:00 | 00:37:30 | 04:52:54 | 2021-09-02 16:32:55 | {0} + 30 | 4 | 4 | {} | 7 | 6 | -1 | 3 | {} | 2021-09-02 16:33:20 | 00:00:25 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 16:33:20 | {0} + 31 | 4 | 4 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:04:36 | 00:00:00 | 02:30:00 | 04:54:34 | 1970-01-01 00:00:00 | {} + 32 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:12:31 | 00:00:00 | 06:36:00 | 11:03:34 | 1970-01-01 00:00:00 | {} +(32 rows) /* -- q2 */ SELECT * @@ -103,15 +108,17 @@ FROM vrp_vroom( ) AS C(start_id, end_id, duration) $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 | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {} - 2 | 1 | 1 | 2 | 3 | 100 | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {} - 3 | 1 | 1 | 3 | 2 | 1414 | 1970-01-01 00:35:04 | 00:35:04 | 00:00:00 | 00:00:00 | {} - 4 | 1 | 1 | 4 | 2 | 1515 | 1970-01-01 01:12:39 | 01:12:39 | 00:00:00 | 00:00:00 | {} - 5 | 1 | 1 | 5 | 4 | 100 | 1970-01-01 01:31:01 | 01:31:01 | 00:00:00 | 00:00:00 | {} - 6 | 1 | 1 | 6 | 6 | -1 | 1970-01-01 01:31:01 | 01:31:01 | 00:00:00 | 00:00:00 | {} -(6 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------------------+-------------+------------+--------------+--------------+---------------------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 2 | 1 | 1 | {} | 2 | 3 | 100 | 1 | {} | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 3 | 1 | 1 | {} | 3 | 2 | 1414 | 2 | {} | 1970-01-01 00:35:04 | 00:35:04 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:35:04 | {} + 4 | 1 | 1 | {} | 4 | 2 | 1515 | 3 | {} | 1970-01-01 01:12:39 | 00:37:35 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 01:12:39 | {} + 5 | 1 | 1 | {} | 5 | 4 | 100 | 4 | {} | 1970-01-01 01:31:01 | 00:18:22 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 01:31:01 | {} + 6 | 1 | 1 | {} | 6 | 6 | -1 | 4 | {} | 1970-01-01 01:31:01 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 01:31:01 | {} + 7 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 01:31:01 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 8 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 01:31:01 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} +(8 rows) /* -- q3 */ ROLLBACK; diff --git a/docqueries/vroom/doc-vrp_vroomJobs.result b/docqueries/vroom/doc-vrp_vroomJobs.result index 97d6bf916..c68d1cda5 100644 --- a/docqueries/vroom/doc-vrp_vroomJobs.result +++ b/docqueries/vroom/doc-vrp_vroomJobs.result @@ -39,20 +39,23 @@ FROM vrp_vroomJobs( 'SELECT * FROM vroom.breaks_time_windows', '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 | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | {20} - 2 | 1 | 1 | 2 | 5 | 1 | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | {20} - 3 | 1 | 1 | 3 | 2 | 1 | 2021-09-02 09:05:00 | 00:00:00 | 00:04:10 | 00:55:25 | {20} - 4 | 1 | 1 | 4 | 6 | -1 | 2021-09-02 10:04:35 | 00:00:00 | 00:00:00 | 00:00:00 | {20} - 5 | 2 | 2 | 1 | 1 | -1 | 2021-09-02 09:04:35 | 00:00:00 | 00:00:00 | 00:00:00 | {100} - 6 | 2 | 2 | 2 | 5 | 2 | 2021-09-02 09:04:35 | 00:00:00 | 00:00:10 | 00:00:00 | {100} - 7 | 2 | 2 | 3 | 2 | 2 | 2021-09-02 09:05:35 | 00:00:50 | 00:04:10 | 00:15:15 | {100} - 8 | 2 | 2 | 4 | 2 | 5 | 2021-09-02 09:26:30 | 00:02:20 | 00:04:10 | 00:00:00 | {100} - 9 | 2 | 2 | 5 | 2 | 3 | 2021-09-02 09:31:30 | 00:03:10 | 00:04:10 | 00:13:55 | {100} - 10 | 2 | 2 | 6 | 2 | 4 | 2021-09-02 09:49:35 | 00:03:10 | 00:04:10 | 00:09:10 | {100} - 11 | 2 | 2 | 7 | 6 | -1 | 2021-09-02 10:02:55 | 00:03:10 | 00:00:00 | 00:00:00 | {100} -(11 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------------------+-------------+------------+--------------+--------------+---------------------+------- + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:05:00 | {20} + 2 | 1 | 1 | {} | 2 | 5 | 1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:05:00 | {20} + 3 | 1 | 1 | {} | 3 | 2 | 1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:04:10 | 00:55:25 | 2021-09-02 10:04:35 | {20} + 4 | 1 | 1 | {} | 4 | 6 | -1 | 1 | {} | 2021-09-02 10:04:35 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 10:04:35 | {20} + 5 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:04:10 | 00:55:25 | 1970-01-01 00:00:00 | {} + 6 | 2 | 2 | {} | 1 | 1 | -1 | 1 | {} | 2021-09-02 09:04:35 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:04:35 | {100} + 7 | 2 | 2 | {} | 2 | 5 | 2 | 1 | {} | 2021-09-02 09:04:35 | 00:00:00 | 00:00:00 | 00:00:10 | 00:00:00 | 2021-09-02 09:04:45 | {100} + 8 | 2 | 2 | {} | 3 | 2 | 2 | 2 | {} | 2021-09-02 09:05:35 | 00:00:50 | 00:00:00 | 00:04:10 | 00:15:15 | 2021-09-02 09:25:00 | {100} + 9 | 2 | 2 | {} | 4 | 2 | 5 | 4 | {} | 2021-09-02 09:26:30 | 00:01:30 | 00:00:00 | 00:04:10 | 00:00:00 | 2021-09-02 09:30:40 | {100} + 10 | 2 | 2 | {} | 5 | 2 | 3 | 3 | {} | 2021-09-02 09:31:30 | 00:00:50 | 00:00:00 | 00:04:10 | 00:13:55 | 2021-09-02 09:49:35 | {100} + 11 | 2 | 2 | {} | 6 | 2 | 4 | 3 | {} | 2021-09-02 09:49:35 | 00:00:00 | 00:00:00 | 00:04:10 | 00:09:10 | 2021-09-02 10:02:55 | {100} + 12 | 2 | 2 | {} | 7 | 6 | -1 | 3 | {} | 2021-09-02 10:02:55 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 10:02:55 | {100} + 13 | 2 | 2 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:03:10 | 00:00:00 | 00:16:50 | 00:38:20 | 1970-01-01 00:00:00 | {} + 14 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:03:10 | 00:00:00 | 00:21:00 | 01:33:45 | 1970-01-01 00:00:00 | {} +(14 rows) /* -- q2 */ SELECT * @@ -79,13 +82,15 @@ FROM vrp_vroomJobs( ) AS C(start_id, end_id, duration) $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 | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {} - 2 | 1 | 1 | 2 | 2 | 1414 | 1970-01-01 00:35:04 | 00:35:04 | 00:00:00 | 00:00:00 | {} - 3 | 1 | 1 | 3 | 2 | 1515 | 1970-01-01 01:12:39 | 01:12:39 | 00:00:00 | 00:00:00 | {} - 4 | 1 | 1 | 4 | 6 | -1 | 1970-01-01 01:31:01 | 01:31:01 | 00:00:00 | 00:00:00 | {} -(4 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------------------+-------------+------------+--------------+--------------+---------------------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 2 | 1 | 1 | {} | 2 | 2 | 1414 | 2 | {} | 1970-01-01 00:35:04 | 00:35:04 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:35:04 | {} + 3 | 1 | 1 | {} | 3 | 2 | 1515 | 3 | {} | 1970-01-01 01:12:39 | 00:37:35 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 01:12:39 | {} + 4 | 1 | 1 | {} | 4 | 6 | -1 | 4 | {} | 1970-01-01 01:31:01 | 00:18:22 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 01:31:01 | {} + 5 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 01:31:01 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 6 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 01:31:01 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} +(6 rows) /* -- q3 */ ROLLBACK; diff --git a/docqueries/vroom/doc-vrp_vroomJobsPlain.result b/docqueries/vroom/doc-vrp_vroomJobsPlain.result index e2c08b56b..17990bf1b 100644 --- a/docqueries/vroom/doc-vrp_vroomJobsPlain.result +++ b/docqueries/vroom/doc-vrp_vroomJobsPlain.result @@ -12,20 +12,23 @@ FROM vrp_vroomJobsPlain( 'SELECT * FROM vroom.breaks_time_windows', '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 | 2 | 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) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------+-------------+------------+--------------+--------------+-----------+------- + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 300 | 0 | 0 | 0 | 0 | 300 | {20} + 2 | 1 | 1 | {} | 2 | 5 | 1 | 1 | {} | 300 | 0 | 0 | 0 | 0 | 300 | {20} + 3 | 1 | 1 | {} | 3 | 2 | 1 | 1 | {} | 300 | 0 | 0 | 250 | 3325 | 3875 | {20} + 4 | 1 | 1 | {} | 4 | 6 | -1 | 1 | {} | 3875 | 0 | 0 | 0 | 0 | 3875 | {20} + 5 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 0 | 0 | 0 | 250 | 3325 | 0 | {} + 6 | 2 | 2 | {} | 1 | 1 | -1 | 1 | {} | 275 | 0 | 0 | 0 | 0 | 275 | {100} + 7 | 2 | 2 | {} | 2 | 5 | 2 | 1 | {} | 275 | 0 | 0 | 10 | 0 | 285 | {100} + 8 | 2 | 2 | {} | 3 | 2 | 2 | 2 | {} | 335 | 50 | 0 | 250 | 915 | 1500 | {100} + 9 | 2 | 2 | {} | 4 | 2 | 5 | 4 | {} | 1590 | 90 | 0 | 250 | 0 | 1840 | {100} + 10 | 2 | 2 | {} | 5 | 2 | 3 | 3 | {} | 1890 | 50 | 0 | 250 | 835 | 2975 | {100} + 11 | 2 | 2 | {} | 6 | 2 | 4 | 3 | {} | 2975 | 0 | 0 | 250 | 550 | 3775 | {100} + 12 | 2 | 2 | {} | 7 | 6 | -1 | 3 | {} | 3775 | 0 | 0 | 0 | 0 | 3775 | {100} + 13 | 2 | 2 | {} | 0 | 0 | 0 | 0 | {} | 0 | 190 | 0 | 1010 | 2300 | 0 | {} + 14 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 0 | 190 | 0 | 1260 | 5625 | 0 | {} +(14 rows) /* -- q2 */ SELECT * @@ -52,13 +55,15 @@ FROM vrp_vroomJobsPlain( ) AS C(start_id, end_id, duration) $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 | 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) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------+-------------+------------+--------------+--------------+-----------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {} + 2 | 1 | 1 | {} | 2 | 2 | 1414 | 2 | {} | 2104 | 2104 | 0 | 0 | 0 | 2104 | {} + 3 | 1 | 1 | {} | 3 | 2 | 1515 | 3 | {} | 4359 | 2255 | 0 | 0 | 0 | 4359 | {} + 4 | 1 | 1 | {} | 4 | 6 | -1 | 4 | {} | 5461 | 1102 | 0 | 0 | 0 | 5461 | {} + 5 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 0 | 5461 | 0 | 0 | 0 | 0 | {} + 6 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 0 | 5461 | 0 | 0 | 0 | 0 | {} +(6 rows) /* -- q3 */ ROLLBACK; diff --git a/docqueries/vroom/doc-vrp_vroomPlain.result b/docqueries/vroom/doc-vrp_vroomPlain.result index 7b47d32e2..0cdf29174 100644 --- a/docqueries/vroom/doc-vrp_vroomPlain.result +++ b/docqueries/vroom/doc-vrp_vroomPlain.result @@ -14,36 +14,41 @@ FROM vrp_vroomPlain( 'SELECT * FROM vroom.breaks_time_windows', '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 | 5 | 1500 | 50 | 2250 | 11850 | {40} - 5 | 1 | 1 | 5 | 3 | 3 | 15650 | 100 | 2250 | 0 | {60} - 6 | 1 | 1 | 6 | 4 | 5 | 17950 | 150 | 2250 | 225 | {50} - 7 | 1 | 1 | 7 | 4 | 3 | 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 | 2 | 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 | 3 | 0 | 0 | 0 | 0 | {20} - 17 | 3 | 3 | 3 | 2 | 1 | 0 | 0 | 250 | 3625 | {20} - 18 | 3 | 3 | 4 | 3 | 4 | 3875 | 0 | 2250 | 2500 | {40} - 19 | 3 | 3 | 5 | 4 | 4 | 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 | 4 | 250 | 0 | 0 | 0 | {0} - 23 | 4 | 4 | 3 | 3 | 2 | 275 | 25 | 2250 | 100 | {10} - 24 | 4 | 4 | 4 | 3 | 1 | 2650 | 50 | 2250 | 0 | {20} - 25 | 4 | 4 | 5 | 4 | 2 | 4990 | 140 | 2250 | 0 | {10} - 26 | 4 | 4 | 6 | 4 | 1 | 7351 | 251 | 2250 | 17574 | {0} - 27 | 4 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0} -(27 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------+-------------+------------+--------------+--------------+-----------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 300 | 0 | 0 | 0 | 0 | 300 | {30} + 2 | 1 | 1 | {} | 2 | 5 | 1 | 1 | {} | 300 | 0 | 0 | 0 | 0 | 300 | {30} + 3 | 1 | 1 | {} | 3 | 2 | 2 | 2 | {} | 350 | 50 | 0 | 250 | 900 | 1500 | {30} + 4 | 1 | 1 | {} | 4 | 3 | 5 | 2 | {} | 1500 | 0 | 0 | 2250 | 11850 | 15600 | {40} + 5 | 1 | 1 | {} | 5 | 3 | 3 | 1 | {} | 15650 | 50 | 0 | 2250 | 0 | 17900 | {60} + 6 | 1 | 1 | {} | 6 | 4 | 5 | 2 | {} | 17950 | 50 | 0 | 2250 | 225 | 20425 | {50} + 7 | 1 | 1 | {} | 7 | 4 | 3 | 2 | {} | 20425 | 0 | 0 | 2250 | 200 | 22875 | {30} + 8 | 1 | 1 | {} | 8 | 6 | -1 | 1 | {} | 22925 | 50 | 0 | 0 | 0 | 22925 | {30} + 9 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 0 | 200 | 0 | 9250 | 13175 | 0 | {} + 10 | 2 | 2 | {} | 1 | 1 | -1 | 1 | {} | 275 | 0 | 0 | 0 | 0 | 275 | {70} + 11 | 2 | 2 | {} | 2 | 5 | 2 | 1 | {} | 275 | 0 | 0 | 10 | 0 | 285 | {70} + 12 | 2 | 2 | {} | 3 | 2 | 5 | 4 | {} | 360 | 75 | 0 | 250 | 665 | 1275 | {70} + 13 | 2 | 2 | {} | 4 | 2 | 3 | 3 | {} | 1325 | 50 | 0 | 250 | 1400 | 2975 | {70} + 14 | 2 | 2 | {} | 5 | 2 | 4 | 3 | {} | 2975 | 0 | 0 | 250 | 550 | 3775 | {70} + 15 | 2 | 2 | {} | 6 | 6 | -1 | 3 | {} | 3775 | 0 | 0 | 0 | 0 | 3775 | {70} + 16 | 2 | 2 | {} | 0 | 0 | 0 | 0 | {} | 0 | 125 | 0 | 760 | 2615 | 0 | {} + 17 | 3 | 3 | {} | 1 | 1 | -1 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {20} + 18 | 3 | 3 | {} | 2 | 5 | 3 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {20} + 19 | 3 | 3 | {} | 3 | 2 | 1 | 1 | {} | 0 | 0 | 0 | 250 | 3625 | 3875 | {20} + 20 | 3 | 3 | {} | 4 | 3 | 4 | 1 | {} | 3875 | 0 | 0 | 2250 | 2500 | 8625 | {40} + 21 | 3 | 3 | {} | 5 | 4 | 4 | 4 | {} | 8700 | 75 | 0 | 2250 | 225 | 11175 | {20} + 22 | 3 | 3 | {} | 6 | 6 | -1 | 1 | {} | 11250 | 75 | 0 | 0 | 0 | 11250 | {20} + 23 | 3 | 3 | {} | 0 | 0 | 0 | 0 | {} | 0 | 150 | 0 | 4750 | 6350 | 0 | {} + 24 | 4 | 4 | {} | 1 | 1 | -1 | 3 | {} | 250 | 0 | 0 | 0 | 0 | 250 | {0} + 25 | 4 | 4 | {} | 2 | 5 | 4 | 1 | {} | 250 | 0 | 0 | 0 | 0 | 250 | {0} + 26 | 4 | 4 | {} | 3 | 3 | 2 | 5 | {} | 275 | 25 | 0 | 2250 | 100 | 2625 | {10} + 27 | 4 | 4 | {} | 4 | 3 | 1 | 3 | {} | 2650 | 25 | 0 | 2250 | 0 | 4900 | {20} + 28 | 4 | 4 | {} | 5 | 4 | 2 | 6 | {} | 4990 | 90 | 0 | 2250 | 0 | 7240 | {10} + 29 | 4 | 4 | {} | 6 | 4 | 1 | 5 | {} | 7351 | 111 | 0 | 2250 | 17574 | 27175 | {0} + 30 | 4 | 4 | {} | 7 | 6 | -1 | 3 | {} | 27200 | 25 | 0 | 0 | 0 | 27200 | {0} + 31 | 4 | 4 | {} | 0 | 0 | 0 | 0 | {} | 0 | 276 | 0 | 9000 | 17674 | 0 | {} + 32 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 0 | 751 | 0 | 23760 | 39814 | 0 | {} +(32 rows) /* -- q2 */ SELECT * @@ -76,15 +81,17 @@ FROM vrp_vroomPlain( ) AS C(start_id, end_id, duration) $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 | 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 | 100 | 5461 | 5461 | 0 | 0 | {} - 6 | 1 | 1 | 6 | 6 | -1 | 5461 | 5461 | 0 | 0 | {} -(6 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------+-------------+------------+--------------+--------------+-----------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {} + 2 | 1 | 1 | {} | 2 | 3 | 100 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {} + 3 | 1 | 1 | {} | 3 | 2 | 1414 | 2 | {} | 2104 | 2104 | 0 | 0 | 0 | 2104 | {} + 4 | 1 | 1 | {} | 4 | 2 | 1515 | 3 | {} | 4359 | 2255 | 0 | 0 | 0 | 4359 | {} + 5 | 1 | 1 | {} | 5 | 4 | 100 | 4 | {} | 5461 | 1102 | 0 | 0 | 0 | 5461 | {} + 6 | 1 | 1 | {} | 6 | 6 | -1 | 4 | {} | 5461 | 0 | 0 | 0 | 0 | 5461 | {} + 7 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 0 | 5461 | 0 | 0 | 0 | 0 | {} + 8 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 0 | 5461 | 0 | 0 | 0 | 0 | {} +(8 rows) /* -- q3 */ ROLLBACK; diff --git a/docqueries/vroom/doc-vrp_vroomShipments.result b/docqueries/vroom/doc-vrp_vroomShipments.result index 86a49a16d..6c72b299c 100644 --- a/docqueries/vroom/doc-vrp_vroomShipments.result +++ b/docqueries/vroom/doc-vrp_vroomShipments.result @@ -39,25 +39,28 @@ FROM vrp_vroomShipments( 'SELECT * FROM vroom.breaks_time_windows', '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 | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | {0} - 2 | 1 | 1 | 2 | 5 | 1 | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | {0} - 3 | 1 | 1 | 3 | 3 | 4 | 2021-09-02 09:05:00 | 00:00:00 | 00:37:30 | 01:41:15 | {20} - 4 | 1 | 1 | 4 | 4 | 4 | 2021-09-02 11:25:00 | 00:01:15 | 00:37:30 | 00:03:45 | {0} - 5 | 1 | 1 | 5 | 3 | 5 | 2021-09-02 12:07:45 | 00:02:45 | 00:37:30 | 00:34:45 | {10} - 6 | 1 | 1 | 6 | 3 | 3 | 2021-09-02 13:20:50 | 00:03:35 | 00:37:30 | 00:00:00 | {30} - 7 | 1 | 1 | 7 | 4 | 5 | 2021-09-02 13:59:10 | 00:04:25 | 00:37:30 | 00:03:45 | {20} - 8 | 1 | 1 | 8 | 4 | 3 | 2021-09-02 14:40:25 | 00:04:25 | 00:37:30 | 00:03:20 | {0} - 9 | 1 | 1 | 9 | 6 | -1 | 2021-09-02 15:22:05 | 00:05:15 | 00:00:00 | 00:00:00 | {0} - 10 | 2 | 4 | 1 | 1 | -1 | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | {0} - 11 | 2 | 4 | 2 | 5 | 4 | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | {0} - 12 | 2 | 4 | 3 | 3 | 2 | 2021-09-02 09:04:35 | 00:00:25 | 00:37:30 | 00:01:40 | {10} - 13 | 2 | 4 | 4 | 3 | 1 | 2021-09-02 09:44:10 | 00:00:50 | 00:37:30 | 00:00:00 | {20} - 14 | 2 | 4 | 5 | 4 | 2 | 2021-09-02 10:23:10 | 00:02:20 | 00:37:30 | 00:00:00 | {10} - 15 | 2 | 4 | 6 | 4 | 1 | 2021-09-02 11:02:31 | 00:04:11 | 00:37:30 | 04:52:54 | {0} - 16 | 2 | 4 | 7 | 6 | -1 | 2021-09-02 16:33:20 | 00:04:36 | 00:00:00 | 00:00:00 | {0} -(16 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------------------+-------------+------------+--------------+--------------+---------------------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:05:00 | {0} + 2 | 1 | 1 | {} | 2 | 5 | 1 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:05:00 | {0} + 3 | 1 | 1 | {} | 3 | 3 | 4 | 1 | {} | 2021-09-02 09:05:00 | 00:00:00 | 00:00:00 | 00:37:30 | 01:41:15 | 2021-09-02 11:23:45 | {20} + 4 | 1 | 1 | {} | 4 | 4 | 4 | 4 | {} | 2021-09-02 11:25:00 | 00:01:15 | 00:00:00 | 00:37:30 | 00:03:45 | 2021-09-02 12:06:15 | {0} + 5 | 1 | 1 | {} | 5 | 3 | 5 | 2 | {} | 2021-09-02 12:07:45 | 00:01:30 | 00:00:00 | 00:37:30 | 00:34:45 | 2021-09-02 13:20:00 | {10} + 6 | 1 | 1 | {} | 6 | 3 | 3 | 1 | {} | 2021-09-02 13:20:50 | 00:00:50 | 00:00:00 | 00:37:30 | 00:00:00 | 2021-09-02 13:58:20 | {30} + 7 | 1 | 1 | {} | 7 | 4 | 5 | 2 | {} | 2021-09-02 13:59:10 | 00:00:50 | 00:00:00 | 00:37:30 | 00:03:45 | 2021-09-02 14:40:25 | {20} + 8 | 1 | 1 | {} | 8 | 4 | 3 | 2 | {} | 2021-09-02 14:40:25 | 00:00:00 | 00:00:00 | 00:37:30 | 00:03:20 | 2021-09-02 15:21:15 | {0} + 9 | 1 | 1 | {} | 9 | 6 | -1 | 1 | {} | 2021-09-02 15:22:05 | 00:00:50 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 15:22:05 | {0} + 10 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:05:15 | 00:00:00 | 03:45:00 | 02:26:50 | 1970-01-01 00:00:00 | {} + 11 | 2 | 4 | {} | 1 | 1 | -1 | 3 | {} | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:04:10 | {0} + 12 | 2 | 4 | {} | 2 | 5 | 4 | 1 | {} | 2021-09-02 09:04:10 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 09:04:10 | {0} + 13 | 2 | 4 | {} | 3 | 3 | 2 | 5 | {} | 2021-09-02 09:04:35 | 00:00:25 | 00:00:00 | 00:37:30 | 00:01:40 | 2021-09-02 09:43:45 | {10} + 14 | 2 | 4 | {} | 4 | 3 | 1 | 3 | {} | 2021-09-02 09:44:10 | 00:00:25 | 00:00:00 | 00:37:30 | 00:00:00 | 2021-09-02 10:21:40 | {20} + 15 | 2 | 4 | {} | 5 | 4 | 2 | 6 | {} | 2021-09-02 10:23:10 | 00:01:30 | 00:00:00 | 00:37:30 | 00:00:00 | 2021-09-02 11:00:40 | {10} + 16 | 2 | 4 | {} | 6 | 4 | 1 | 5 | {} | 2021-09-02 11:02:31 | 00:01:51 | 00:00:00 | 00:37:30 | 04:52:54 | 2021-09-02 16:32:55 | {0} + 17 | 2 | 4 | {} | 7 | 6 | -1 | 3 | {} | 2021-09-02 16:33:20 | 00:00:25 | 00:00:00 | 00:00:00 | 00:00:00 | 2021-09-02 16:33:20 | {0} + 18 | 2 | 4 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:04:36 | 00:00:00 | 02:30:00 | 04:54:34 | 1970-01-01 00:00:00 | {} + 19 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:09:51 | 00:00:00 | 06:15:00 | 07:21:24 | 1970-01-01 00:00:00 | {} +(19 rows) /* -- q2 */ SELECT * @@ -84,13 +87,15 @@ FROM vrp_vroomShipments( ) AS C(start_id, end_id, duration) $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 | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {} - 2 | 1 | 1 | 2 | 3 | 100 | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | {} - 3 | 1 | 1 | 3 | 4 | 100 | 1970-01-01 00:21:39 | 00:21:39 | 00:00:00 | 00:00:00 | {} - 4 | 1 | 1 | 4 | 6 | -1 | 1970-01-01 00:21:39 | 00:21:39 | 00:00:00 | 00:00:00 | {} -(4 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------------------+-------------+------------+--------------+--------------+---------------------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 2 | 1 | 1 | {} | 2 | 3 | 100 | 1 | {} | 1970-01-01 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 3 | 1 | 1 | {} | 3 | 4 | 100 | 4 | {} | 1970-01-01 00:21:39 | 00:21:39 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:21:39 | {} + 4 | 1 | 1 | {} | 4 | 6 | -1 | 4 | {} | 1970-01-01 00:21:39 | 00:00:00 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:21:39 | {} + 5 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:21:39 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} + 6 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 1970-01-01 00:00:00 | 00:21:39 | 00:00:00 | 00:00:00 | 00:00:00 | 1970-01-01 00:00:00 | {} +(6 rows) /* -- q3 */ ROLLBACK; diff --git a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result index 726b7c3a4..1dc6458d8 100644 --- a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result +++ b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result @@ -12,25 +12,28 @@ FROM vrp_vroomShipmentsPlain( 'SELECT * FROM vroom.breaks_time_windows', '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 | {0} - 2 | 1 | 1 | 2 | 5 | 1 | 300 | 0 | 0 | 0 | {0} - 3 | 1 | 1 | 3 | 3 | 4 | 300 | 0 | 2250 | 6075 | {20} - 4 | 1 | 1 | 4 | 4 | 4 | 8700 | 75 | 2250 | 225 | {0} - 5 | 1 | 1 | 5 | 3 | 5 | 11265 | 165 | 2250 | 2085 | {10} - 6 | 1 | 1 | 6 | 3 | 3 | 15650 | 215 | 2250 | 0 | {30} - 7 | 1 | 1 | 7 | 4 | 5 | 17950 | 265 | 2250 | 225 | {20} - 8 | 1 | 1 | 8 | 4 | 3 | 20425 | 265 | 2250 | 200 | {0} - 9 | 1 | 1 | 9 | 6 | -1 | 22925 | 315 | 0 | 0 | {0} - 10 | 2 | 4 | 1 | 1 | -1 | 250 | 0 | 0 | 0 | {0} - 11 | 2 | 4 | 2 | 5 | 4 | 250 | 0 | 0 | 0 | {0} - 12 | 2 | 4 | 3 | 3 | 2 | 275 | 25 | 2250 | 100 | {10} - 13 | 2 | 4 | 4 | 3 | 1 | 2650 | 50 | 2250 | 0 | {20} - 14 | 2 | 4 | 5 | 4 | 2 | 4990 | 140 | 2250 | 0 | {10} - 15 | 2 | 4 | 6 | 4 | 1 | 7351 | 251 | 2250 | 17574 | {0} - 16 | 2 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0} -(16 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------+-------------+------------+--------------+--------------+-----------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 300 | 0 | 0 | 0 | 0 | 300 | {0} + 2 | 1 | 1 | {} | 2 | 5 | 1 | 1 | {} | 300 | 0 | 0 | 0 | 0 | 300 | {0} + 3 | 1 | 1 | {} | 3 | 3 | 4 | 1 | {} | 300 | 0 | 0 | 2250 | 6075 | 8625 | {20} + 4 | 1 | 1 | {} | 4 | 4 | 4 | 4 | {} | 8700 | 75 | 0 | 2250 | 225 | 11175 | {0} + 5 | 1 | 1 | {} | 5 | 3 | 5 | 2 | {} | 11265 | 90 | 0 | 2250 | 2085 | 15600 | {10} + 6 | 1 | 1 | {} | 6 | 3 | 3 | 1 | {} | 15650 | 50 | 0 | 2250 | 0 | 17900 | {30} + 7 | 1 | 1 | {} | 7 | 4 | 5 | 2 | {} | 17950 | 50 | 0 | 2250 | 225 | 20425 | {20} + 8 | 1 | 1 | {} | 8 | 4 | 3 | 2 | {} | 20425 | 0 | 0 | 2250 | 200 | 22875 | {0} + 9 | 1 | 1 | {} | 9 | 6 | -1 | 1 | {} | 22925 | 50 | 0 | 0 | 0 | 22925 | {0} + 10 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 0 | 315 | 0 | 13500 | 8810 | 0 | {} + 11 | 2 | 4 | {} | 1 | 1 | -1 | 3 | {} | 250 | 0 | 0 | 0 | 0 | 250 | {0} + 12 | 2 | 4 | {} | 2 | 5 | 4 | 1 | {} | 250 | 0 | 0 | 0 | 0 | 250 | {0} + 13 | 2 | 4 | {} | 3 | 3 | 2 | 5 | {} | 275 | 25 | 0 | 2250 | 100 | 2625 | {10} + 14 | 2 | 4 | {} | 4 | 3 | 1 | 3 | {} | 2650 | 25 | 0 | 2250 | 0 | 4900 | {20} + 15 | 2 | 4 | {} | 5 | 4 | 2 | 6 | {} | 4990 | 90 | 0 | 2250 | 0 | 7240 | {10} + 16 | 2 | 4 | {} | 6 | 4 | 1 | 5 | {} | 7351 | 111 | 0 | 2250 | 17574 | 27175 | {0} + 17 | 2 | 4 | {} | 7 | 6 | -1 | 3 | {} | 27200 | 25 | 0 | 0 | 0 | 27200 | {0} + 18 | 2 | 4 | {} | 0 | 0 | 0 | 0 | {} | 0 | 276 | 0 | 9000 | 17674 | 0 | {} + 19 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 0 | 591 | 0 | 22500 | 26484 | 0 | {} +(19 rows) /* -- q2 */ SELECT * @@ -57,13 +60,15 @@ FROM vrp_vroomShipmentsPlain( ) AS C(start_id, end_id, duration) $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 | 0 | 0 | 0 | 0 | {} - 2 | 1 | 1 | 2 | 3 | 100 | 0 | 0 | 0 | 0 | {} - 3 | 1 | 1 | 3 | 4 | 100 | 1299 | 1299 | 0 | 0 | {} - 4 | 1 | 1 | 4 | 6 | -1 | 1299 | 1299 | 0 | 0 | {} -(4 rows) + seq | vehicle_seq | vehicle_id | vehicle_data | step_seq | step_type | task_id | location_id | task_data | arrival | travel_time | setup_time | service_time | waiting_time | departure | load +-----+-------------+------------+--------------+----------+-----------+---------+-------------+-----------+---------+-------------+------------+--------------+--------------+-----------+------ + 1 | 1 | 1 | {} | 1 | 1 | -1 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {} + 2 | 1 | 1 | {} | 2 | 3 | 100 | 1 | {} | 0 | 0 | 0 | 0 | 0 | 0 | {} + 3 | 1 | 1 | {} | 3 | 4 | 100 | 4 | {} | 1299 | 1299 | 0 | 0 | 0 | 1299 | {} + 4 | 1 | 1 | {} | 4 | 6 | -1 | 4 | {} | 1299 | 0 | 0 | 0 | 0 | 1299 | {} + 5 | 1 | 1 | {} | 0 | 0 | 0 | 0 | {} | 0 | 1299 | 0 | 0 | 0 | 0 | {} + 6 | 0 | 0 | {} | 0 | 0 | 0 | 0 | {} | 0 | 1299 | 0 | 0 | 0 | 0 | {} +(6 rows) /* -- q3 */ ROLLBACK; diff --git a/include/c_types/column_info_t.h b/include/c_types/column_info_t.h index 571be6b42..d71edc5c6 100644 --- a/include/c_types/column_info_t.h +++ b/include/c_types/column_info_t.h @@ -40,6 +40,7 @@ enum { ANY_INTEGER, ANY_NUMERICAL, TEXT, + JSONB, CHAR1, INTEGER_ARRAY, ANY_INTEGER_ARRAY, diff --git a/include/c_types/typedefs.h b/include/c_types/typedefs.h index 0c547becf..84bb26cb2 100644 --- a/include/c_types/typedefs.h +++ b/include/c_types/typedefs.h @@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #ifdef __cplusplus #include #include +#include using TTimestamp = int64_t; using TInterval = int64_t; using Coordinate = double; @@ -66,6 +67,7 @@ using Position = size_t; #else #include #include +#include typedef int64_t TTimestamp; typedef int64_t TInterval; typedef double Coordinate; diff --git a/include/c_types/vroom/vroom_break_t.h b/include/c_types/vroom/vroom_break_t.h index 4246837ea..1a1ad4df0 100644 --- a/include/c_types/vroom/vroom_break_t.h +++ b/include/c_types/vroom/vroom_break_t.h @@ -41,11 +41,13 @@ name | description id | Identifier of break vehicle_id | Identifier of vehicle service | Duration of break +data | Metadata information of break */ struct Vroom_break_t { Idx id; /** Identifier of break */ Idx vehicle_id; /** Identifier of vehicle */ Duration service; /** Duration of break */ + char *data; /** Metadata information of break */ }; diff --git a/include/c_types/vroom/vroom_job_t.h b/include/c_types/vroom/vroom_job_t.h index a112785a9..2ec42817c 100644 --- a/include/c_types/vroom/vroom_job_t.h +++ b/include/c_types/vroom/vroom_job_t.h @@ -49,6 +49,7 @@ pickup_size | Number of pickup quantities skills | Mandatory skills skills_size | Number of mandatory skills priority | Priority level of job +data | Metadata information of job */ struct Vroom_job_t { Idx id; /** The job's identifier */ @@ -67,6 +68,8 @@ struct Vroom_job_t { size_t skills_size; /** Number of mandatory skills */ Priority priority; /** Priority level of job */ + + char *data; /** Metadata information of job */ }; #endif // INCLUDE_C_TYPES_VROOM_VROOM_JOB_T_H_ diff --git a/include/c_types/vroom/vroom_rt.h b/include/c_types/vroom/vroom_rt.h index d5961fa55..058b3cf17 100644 --- a/include/c_types/vroom/vroom_rt.h +++ b/include/c_types/vroom/vroom_rt.h @@ -40,27 +40,40 @@ name | description :----- | :------- vehicle_seq | Sequence for ordering a single vehicle vehicle_id | The vehicle's identifier +vehicle_data | The vehicle's metadata information step_seq | Step sequence of the vehicle step_type | Step sequence of the vehicle task_id | The task's identifier +location_id | Location id of task in matrix +task_data | The task's metadata information arrival_time | Estimated time of arrival -travel_time | Cumulated travel time upon arrival +travel_time | Travel time from previous step_seq to current step_seq +setup_time | Setup time at this step service_time | Service time at this step waiting_time | Waiting time upon arrival at this step +departure_time | Estimated time of departure load | Vehicle load after step completion */ struct Vroom_rt { - Idx vehicle_seq; /** Sequence for ordering a single vehicle */ - Idx vehicle_id; /** The vehicle's identifier */ - Idx step_seq; /** Step sequence of the vehicle */ - StepType step_type; /** Type of the step */ - Id task_id; /** The task's identifier */ - Duration arrival_time; /** Estimated time of arrival */ - Duration travel_time; /** Cumulated travel time upon arrival */ - Duration service_time; /** Service time at this step */ - Duration waiting_time; /** Waiting time upon arrival at this step */ - Amount *load; /** Vehicle's load after step completion array */ - size_t load_size; /** Vehicle's load array size */ + Idx vehicle_seq; /** Sequence for ordering a single vehicle */ + Idx vehicle_id; /** The vehicle's identifier */ + char *vehicle_data; /** The vehicle's metadata information */ + + Idx step_seq; /** Step sequence of the vehicle */ + StepType step_type; /** Type of the step */ + Idx task_id; /** The task's identifier */ + MatrixIndex location_id; /** Location id of task in matrix */ + char *task_data; /** The task's metadata information */ + + Duration arrival_time; /** Estimated time of arrival */ + Duration travel_time; /** Travel time from previous step_seq to current step_seq */ + Duration setup_time; /** Setup time at this step */ + Duration service_time; /** Service time at this step */ + Duration waiting_time; /** Waiting time upon arrival at this step */ + Duration departure_time; /** Estimated time of departure */ + + Amount *load; /** Vehicle's load after step completion array */ + size_t load_size; /** Vehicle's load array size */ }; #endif // INCLUDE_C_TYPES_VROOM_VROOM_RT_H_ diff --git a/include/c_types/vroom/vroom_shipment_t.h b/include/c_types/vroom/vroom_shipment_t.h index 6a91bfdaf..9719cf955 100644 --- a/include/c_types/vroom/vroom_shipment_t.h +++ b/include/c_types/vroom/vroom_shipment_t.h @@ -50,6 +50,8 @@ amount_size | Number of quantities skills | Mandatory skills skills_size | Number of skills priority | Priority level of shipment +p_data | Metadata information of pickup shipment +d_data | Metadata information of delivery shipment */ struct Vroom_shipment_t { Idx id; /** Shipment identifier */ @@ -71,6 +73,9 @@ struct Vroom_shipment_t { size_t skills_size; /** Number of skills */ Priority priority; /** Priority level of shipment */ + + char *p_data; /** Metadata information of pickup shipment */ + char *d_data; /** Metadata information of delivery shipment */ }; #endif // INCLUDE_C_TYPES_VROOM_VROOM_SHIPMENT_T_H_ diff --git a/include/c_types/vroom/vroom_vehicle_t.h b/include/c_types/vroom/vroom_vehicle_t.h index cef344ee3..85b41800a 100644 --- a/include/c_types/vroom/vroom_vehicle_t.h +++ b/include/c_types/vroom/vroom_vehicle_t.h @@ -49,6 +49,7 @@ tw_open | Time window start time tw_close | Time window end time speed_factor | Vehicle travel time multiplier max_tasks | Max number of tasks in a route for the vehicle +data | Metadata information of vehicle */ struct Vroom_vehicle_t { Idx id; /** The vehicle's identifier */ @@ -67,6 +68,8 @@ struct Vroom_vehicle_t { double speed_factor; /** Vehicle travel time multiplier */ int32_t max_tasks; /** Max number of tasks in a route for the vehicle */ + + char *data; /** Metadata information of vehicle */ }; diff --git a/include/cpp_common/base_matrix.h b/include/cpp_common/base_matrix.h index a3ba0023f..be4433986 100644 --- a/include/cpp_common/base_matrix.h +++ b/include/cpp_common/base_matrix.h @@ -108,6 +108,9 @@ class Base_Matrix { /** @brief original id -> idx */ Idx get_index(Id) const; + /** @brief original id -> idx */ + Id get_original_id(Idx) const; + private: /** @brief Traverses the matrix information to set the ids of the nodes */ void set_ids(const std::vector &); diff --git a/include/cpp_common/vrp_vroom_problem.hpp b/include/cpp_common/vrp_vroom_problem.hpp index 87bcef85a..98911a6d6 100644 --- a/include/cpp_common/vrp_vroom_problem.hpp +++ b/include/cpp_common/vrp_vroom_problem.hpp @@ -179,7 +179,7 @@ class Vrp_vroom_problem : public vrprouting::Pgr_messages { vroom::Index location_id = static_cast(m_matrix.get_index(job.location_id)); return vroom::Job(job.id, location_id, job.setup, job.service, delivery, pickup, - skills, job.priority, time_windows); + skills, job.priority, time_windows, job.data); } void problem_add_job(const Vroom_job_t &job, @@ -243,11 +243,11 @@ class Vrp_vroom_problem : public vrprouting::Pgr_messages { vroom::Job pickup = vroom::Job( shipment.id, vroom::JOB_TYPE::PICKUP, p_location_id, shipment.p_setup, shipment.p_service, amount, - skills, shipment.priority, p_time_windows); + skills, shipment.priority, p_time_windows, shipment.p_data); vroom::Job delivery = vroom::Job( shipment.id, vroom::JOB_TYPE::DELIVERY, d_location_id, shipment.d_setup, shipment.d_service, amount, - skills, shipment.priority, d_time_windows); + skills, shipment.priority, d_time_windows, shipment.d_data); return std::make_pair(pickup, delivery); } @@ -308,7 +308,7 @@ class Vrp_vroom_problem : public vrprouting::Pgr_messages { const Vroom_break_t &v_break, const std::vector &break_tws) const { std::vector tws = get_vroom_time_windows(break_tws); - return vroom::Break(v_break.id, tws, v_break.service); + return vroom::Break(v_break.id, tws, v_break.service, v_break.data); } std::vector < vroom::Break > @@ -368,7 +368,7 @@ class Vrp_vroom_problem : public vrprouting::Pgr_messages { } return vroom::Vehicle(vehicle.id, start_id, end_id, vroom::DEFAULT_PROFILE, capacity, skills, time_window, - v_breaks, "", vehicle.speed_factor, + v_breaks, vehicle.data, vehicle.speed_factor, static_cast(vehicle.max_tasks)); } @@ -432,62 +432,161 @@ class Vrp_vroom_problem : public vrprouting::Pgr_messages { } } + StepType get_job_step_type(vroom::JOB_TYPE vroom_job_type) { + StepType step_type; + switch (vroom_job_type) { + case vroom::JOB_TYPE::SINGLE: + step_type = 2; + break; + case vroom::JOB_TYPE::PICKUP: + step_type = 3; + break; + case vroom::JOB_TYPE::DELIVERY: + step_type = 4; + break; + } + return step_type; + } + + StepType get_step_type(vroom::Step step) { + StepType step_type = 0; + switch (step.step_type) { + case vroom::STEP_TYPE::START: + step_type = 1; + break; + case vroom::STEP_TYPE::END: + step_type = 6; + break; + case vroom::STEP_TYPE::BREAK: + step_type = 5; + break; + case vroom::STEP_TYPE::JOB: + step_type = get_job_step_type(step.job_type); + break; + } + return step_type; + } + std::vector < Vroom_rt > get_results(vroom::Solution solution) { std::vector < Vroom_rt > results; std::vector routes = solution.routes; Idx vehicle_seq = 1; + char *empty_desc = strdup("{}"); for (auto route : routes) { Idx step_seq = 1; + Duration prev_duration = 0; for (auto step : route.steps) { - int32_t step_type = 0; - Id task_id = static_cast (step.id); - switch (step.step_type) { - case vroom::STEP_TYPE::START: - step_type = 1; - task_id = -1; - break; - case vroom::STEP_TYPE::END: - step_type = 6; - task_id = -1; - break; - case vroom::STEP_TYPE::BREAK: - step_type = 5; - break; - case vroom::STEP_TYPE::JOB: - switch (step.job_type) { - case vroom::JOB_TYPE::SINGLE: - step_type = 2; - break; - case vroom::JOB_TYPE::PICKUP: - step_type = 3; - break; - case vroom::JOB_TYPE::DELIVERY: - step_type = 4; - break; - } - break; + Idx task_id = step.id; + MatrixIndex location_id = m_matrix.get_original_id(step.location.index()); + char *vehicle_data = strdup(route.description.c_str()); + char *task_data = strdup(step.description.c_str()); + StepType step_type = get_step_type(step); + if (step_type == 1 || step_type == 6) { + task_id = static_cast(-1); + task_data = empty_desc; } + size_t load_size = step.load.size(); Amount *load = reinterpret_cast(malloc(load_size * sizeof(Amount))); get_amount(step.load, &load); + Duration travel_time = step.duration - prev_duration; + prev_duration = step.duration; + Duration departure = step.arrival + step.setup + step.service + step.waiting_time; results.push_back({ - vehicle_seq, // vehicles_seq - route.vehicle, // vehicles_id - step_seq, // step_seq - step_type, // step_type - task_id, // task_id - step.arrival, // arrival - step.duration, // duration - step.service, // service_time - step.waiting_time, // waiting_time - load, // load - load_size // load size + vehicle_seq, // vehicles_seq + route.vehicle, // vehicles_id + vehicle_data, // vehicle_data + step_seq, // step_seq + step_type, // step_type + task_id, // task_id + location_id, // location_id + task_data, // task_data + step.arrival, // arrival + travel_time, // travel_time + step.setup, // setup_time + step.service, // service_time + step.waiting_time, // waiting_time + departure, // departure + load, // load + load_size // load size }); step_seq++; } + // The summary of this route + Idx task_id = 0; + results.push_back({ + vehicle_seq, // vehicles_seq + route.vehicle, // vehicles_id + empty_desc, // vehicle_data + 0, // step_seq = 0 for route summary + 0, // step_type = 0 for route summary + task_id, // task_id = 0 for route summary + 0, // location_id = 0 for route summary + empty_desc, // task_data + 0, // No arrival time + route.duration, // Total travel time + route.setup, // Total setup time + route.service, // Total service time + route.waiting_time, // Total waiting time + 0, // No departure time + {}, // load + 0 // load size + }); vehicle_seq++; } + + std::vector unassigned = solution.unassigned; + Idx step_seq = 1; + for (auto job : unassigned) { + StepType job_step = get_job_step_type(job.type); + Idx vehicle_id = static_cast(-1); + Idx job_id = job.id; + MatrixIndex location_id = m_matrix.get_original_id(job.location.index()); + char *task_data = strdup(job.description.c_str()); + results.push_back({ + vehicle_seq, // vehicles_seq + vehicle_id, // vehicles_id = -1 for unassigned jobs + empty_desc, // vehicle_data + step_seq, // step_seq + job_step, // step_type + job_id, // task_id + location_id, // location_id + task_data, // task_data + 0, // No arrival time + 0, // No travel_time + 0, // No setup_time + 0, // No service_time + 0, // No waiting_time + 0, // No departure time + {}, // load + 0 // load size + }); + step_seq++; + } + + // The summary of the entire problem + vroom::Summary summary = solution.summary; + Idx vehicle_id = 0; + Idx job_id = 0; + results.push_back({ + 0, // vehicles_seq = 0 for problem summary + vehicle_id, // vehicles_id = 0 for problem summary + empty_desc, // vehicle_data + 0, // step_seq = 0 for problem summary + 0, // step_type = 0 for problem summary + job_id, // task_id = 0 for problem summary + 0, // location_id = 0 for problem summary + empty_desc, // task_data + 0, // No arrival time + summary.duration, // Total travel time + summary.setup, // Total setup time + summary.service, // Total service time + summary.waiting_time, // Total waiting time + 0, // No departure time + {}, // load + 0 // load size + }); return results; } diff --git a/pgtap/vroom/edge_cases.sql b/pgtap/vroom/edge_cases.sql index b99061269..54702c4d7 100644 --- a/pgtap/vroom/edge_cases.sql +++ b/pgtap/vroom/edge_cases.sql @@ -44,7 +44,10 @@ BEGIN PREPARE empty_matrix AS SELECT * FROM matrix WHERE start_id = -1; PREPARE vroom_sql AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -59,33 +62,38 @@ BEGIN SELECT set_eq('vroom_sql', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[30]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[30]), - (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, ARRAY[30]), - (4, 1, 1, 4, 3, 5, 1500, 50, 2250, 11850, ARRAY[40]), - (5, 1, 1, 5, 3, 3, 15650, 100, 2250, 0, ARRAY[60]), - (6, 1, 1, 6, 4, 5, 17950, 150, 2250, 225, ARRAY[50]), - (7, 1, 1, 7, 4, 3, 20425, 150, 2250, 200, ARRAY[30]), - (8, 1, 1, 8, 6, -1, 22925, 200, 0, 0, ARRAY[30]), - (9, 2, 2, 1, 1, -1, 275, 0, 0, 0, ARRAY[70]), - (10, 2, 2, 2, 5, 2, 275, 0, 10, 0, ARRAY[70]), - (11, 2, 2, 3, 2, 5, 360, 75, 250, 665, ARRAY[70]), - (12, 2, 2, 4, 2, 3, 1325, 125, 250, 1400, ARRAY[70]), - (13, 2, 2, 5, 2, 4, 2975, 125, 250, 550, ARRAY[70]), - (14, 2, 2, 6, 6, -1, 3775, 125, 0, 0, ARRAY[70]), - (15, 3, 3, 1, 1, -1, 0, 0, 0, 0, ARRAY[20]), - (16, 3, 3, 2, 5, 3, 0, 0, 0, 0, ARRAY[20]), - (17, 3, 3, 3, 2, 1, 0, 0, 250, 3625, ARRAY[20]), - (18, 3, 3, 4, 3, 4, 3875, 0, 2250, 2500, ARRAY[40]), - (19, 3, 3, 5, 4, 4, 8700, 75, 2250, 225, ARRAY[20]), - (20, 3, 3, 6, 6, -1, 11250, 150, 0, 0, ARRAY[20]), - (21, 4, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[0]), - (22, 4, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[0]), - (23, 4, 4, 3, 3, 2, 275, 25, 2250, 100, ARRAY[10]), - (24, 4, 4, 4, 3, 1, 2650, 50, 2250, 0, ARRAY[20]), - (25, 4, 4, 5, 4, 2, 4990, 140, 2250, 0, ARRAY[10]), - (26, 4, 4, 6, 4, 1, 7351, 251, 2250, 17574, ARRAY[0]), - (27, 4, 4, 7, 6, -1, 27200, 276, 0, 0, ARRAY[0]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[30]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[30]), + (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, 1500, ARRAY[30]), + (4, 1, 1, 4, 3, 5, 1500, 0, 2250, 11850, 15600, ARRAY[40]), + (5, 1, 1, 5, 3, 3, 15650, 50, 2250, 0, 17900, ARRAY[60]), + (6, 1, 1, 6, 4, 5, 17950, 50, 2250, 225, 20425, ARRAY[50]), + (7, 1, 1, 7, 4, 3, 20425, 0, 2250, 200, 22875, ARRAY[30]), + (8, 1, 1, 8, 6, -1, 22925, 50, 0, 0, 22925, ARRAY[30]), + (9, 1, 1, 0, 0, 0, 0, 200, 9250, 13175, 0, ARRAY[]::INTEGER[]), + (10, 2, 2, 1, 1, -1, 275, 0, 0, 0, 275, ARRAY[70]), + (11, 2, 2, 2, 5, 2, 275, 0, 10, 0, 285, ARRAY[70]), + (12, 2, 2, 3, 2, 5, 360, 75, 250, 665, 1275, ARRAY[70]), + (13, 2, 2, 4, 2, 3, 1325, 50, 250, 1400, 2975, ARRAY[70]), + (14, 2, 2, 5, 2, 4, 2975, 0, 250, 550, 3775, ARRAY[70]), + (15, 2, 2, 6, 6, -1, 3775, 0, 0, 0, 3775, ARRAY[70]), + (16, 2, 2, 0, 0, 0, 0, 125, 760, 2615, 0, ARRAY[]::INTEGER[]), + (17, 3, 3, 1, 1, -1, 0, 0, 0, 0, 0, ARRAY[20]), + (18, 3, 3, 2, 5, 3, 0, 0, 0, 0, 0, ARRAY[20]), + (19, 3, 3, 3, 2, 1, 0, 0, 250, 3625, 3875, ARRAY[20]), + (20, 3, 3, 4, 3, 4, 3875, 0, 2250, 2500, 8625, ARRAY[40]), + (21, 3, 3, 5, 4, 4, 8700, 75, 2250, 225, 11175, ARRAY[20]), + (22, 3, 3, 6, 6, -1, 11250, 75, 0, 0, 11250, ARRAY[20]), + (23, 3, 3, 0, 0, 0, 0, 150, 4750, 6350, 0, ARRAY[]::INTEGER[]), + (24, 4, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[0]), + (25, 4, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[0]), + (26, 4, 4, 3, 3, 2, 275, 25, 2250, 100, 2625, ARRAY[10]), + (27, 4, 4, 4, 3, 1, 2650, 25, 2250, 0, 4900, ARRAY[20]), + (28, 4, 4, 5, 4, 2, 4990, 90, 2250, 0, 7240, ARRAY[10]), + (29, 4, 4, 6, 4, 1, 7351, 111, 2250, 17574, 27175, ARRAY[0]), + (30, 4, 4, 7, 6, -1, 27200, 25, 0, 0, 27200, ARRAY[0]), + (31, 4, 4, 0, 0, 0, 0, 276, 9000, 17674, 0, ARRAY[]::INTEGER[]), + (32, 0, 0, 0, 0, 0, 0, 751, 23760, 39814, 0, ARRAY[]::INTEGER[]) $$, 'Query with the vroomdata' ); @@ -93,7 +101,10 @@ BEGIN -- tests for no jobs/shipments, no vehicles, or no matrix PREPARE no_jobs_and_shipments AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'empty_jobs', 'jobs_time_windows', 'empty_shipments', @@ -107,7 +118,10 @@ BEGIN SELECT is_empty('no_jobs_and_shipments', 'Problem with no jobs and shipments'); PREPARE no_vehicles AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -121,7 +135,10 @@ BEGIN SELECT is_empty('no_vehicles', 'Problem with no vehicles'); PREPARE no_matrix AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -138,7 +155,10 @@ BEGIN -- priority range test (jobs) PREPARE jobs_neg_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT id, location_id, service, delivery, pickup, skills, -1 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -157,7 +177,10 @@ BEGIN ); PREPARE jobs_101_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT id, location_id, service, delivery, pickup, skills, 101 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -176,7 +199,10 @@ BEGIN ); PREPARE jobs_zero_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT id, location_id, service, delivery, pickup, skills, 0 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -190,7 +216,10 @@ BEGIN SELECT lives_ok('jobs_zero_priority', 'Problem with 0 priority jobs'); PREPARE jobs_100_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT id, location_id, service, delivery, pickup, skills, 0 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -207,7 +236,10 @@ BEGIN -- priority range tests (shipments) PREPARE shipments_neg_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_id, p_service, d_location_id, d_service, @@ -227,7 +259,10 @@ BEGIN ); PREPARE shipments_101_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_id, p_service, d_location_id, d_service, @@ -247,7 +282,10 @@ BEGIN ); PREPARE shipments_zero_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_id, p_service, d_location_id, d_service, @@ -262,7 +300,10 @@ BEGIN SELECT lives_ok('shipments_zero_priority', 'Problem with 0 priority shipments'); PREPARE shipments_100_priority AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_id, p_service, d_location_id, d_service, @@ -280,7 +321,10 @@ BEGIN -- Missing id on matrix test PREPARE missing_id_on_matrix AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -299,7 +343,10 @@ BEGIN ); PREPARE missing_same_vid_on_matrix AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -313,7 +360,10 @@ BEGIN SELECT set_eq('missing_same_vid_on_matrix', 'vroom_sql', 'Cost between same vertex is always 0'); PREPARE missing_reverse_cost_on_matrix AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -333,7 +383,10 @@ BEGIN PREPARE jobs_invalid_tw AS SELECT id, 3001 AS tw_open, 3000 AS tw_close FROM jobs_time_windows; PREPARE jobs_equal_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_equal_tw', 'shipments', @@ -347,7 +400,10 @@ BEGIN SELECT lives_ok('jobs_equal_tw_problem', 'Problem with jobs having equal time windows'); PREPARE jobs_invalid_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_invalid_tw', 'shipments', @@ -372,7 +428,10 @@ BEGIN PREPARE shipments_invalid_tw AS SELECT id, kind, 3001 AS tw_open, 3000 AS tw_close FROM shipments_time_windows; PREPARE shipments_equal_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -386,7 +445,10 @@ BEGIN SELECT lives_ok('shipments_equal_tw_problem', 'Problem with shipments having equal time windows'); PREPARE shipments_invalid_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -411,7 +473,10 @@ BEGIN PREPARE breaks_invalid_tw AS SELECT id, 3001 AS tw_open, 3000 AS tw_close FROM breaks_time_windows; PREPARE breaks_equal_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -425,7 +490,10 @@ BEGIN SELECT lives_ok('breaks_equal_tw_problem', 'Problem with breaks having equal time windows'); PREPARE breaks_invalid_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -452,7 +520,10 @@ BEGIN SELECT id, start_id, end_id, capacity, skills, 3001 AS tw_open, 3000 AS tw_close, speed_factor FROM vehicles; PREPARE vehicles_equal_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -466,7 +537,10 @@ BEGIN SELECT lives_ok('vehicles_equal_tw_problem', 'Problem with vehicles having equal time windows'); PREPARE vehicles_invalid_tw_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -490,7 +564,10 @@ BEGIN PREPARE jobs_only_delivery AS SELECT id, location_id, service, delivery, skills, priority FROM jobs; PREPARE jobs_only_pickup AS SELECT id, location_id, service, pickup, skills, priority FROM jobs; PREPARE jobs_only_delivery_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs_only_delivery', 'jobs_time_windows', 'shipments', @@ -501,7 +578,10 @@ BEGIN 'matrix' ); PREPARE jobs_only_pickup_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs_only_pickup', 'jobs_time_windows', 'shipments', @@ -520,7 +600,10 @@ BEGIN PREPARE vehicles_only_start_id AS SELECT id, start_id, capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE vehicles_only_end_id AS SELECT id, end_id, capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE vehicles_only_start_id_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -531,7 +614,10 @@ BEGIN 'matrix' ); PREPARE vehicles_only_end_id_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -549,7 +635,10 @@ BEGIN PREPARE vehicles_no_index AS SELECT id, capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE vehicles_no_index_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -580,7 +669,10 @@ BEGIN SELECT id, start_id, end_id, ARRAY[10, 20]::BIGINT[] AS capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE jobs_inconsistent_delivery_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs_inconsistent_delivery', 'jobs_time_windows', 'shipments', @@ -591,7 +683,10 @@ BEGIN 'matrix' ); PREPARE jobs_inconsistent_pickup_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs_inconsistent_pickup', 'jobs_time_windows', 'shipments', @@ -602,7 +697,10 @@ BEGIN 'matrix' ); PREPARE shipments_inconsistent_amount_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments_inconsistent_amount', @@ -613,7 +711,10 @@ BEGIN 'matrix' ); PREPARE vehicles_inconsistent_capacity_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -673,7 +774,10 @@ BEGIN SELECT start_id, end_id, 4 * duration AS duration FROM matrix; PREPARE vehicles_2x_speed_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -684,7 +788,10 @@ BEGIN 'matrix_2x_distance' ); PREPARE vehicles_4x_speed_problem AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -707,7 +814,10 @@ BEGIN -- arrival, travel_time, service_time, waiting_time, load PREPARE one_job_q1 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT * FROM jobs WHERE id = 1', 'jobs_time_windows', 'empty_shipments', @@ -721,16 +831,21 @@ BEGIN SELECT set_eq('one_job_q1', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[20]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[20]), - (3, 1, 1, 3, 2, 1, 300, 0, 250, 3325, ARRAY[20]), - (4, 1, 1, 4, 6, -1, 3875, 0, 0, 0, ARRAY[20]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[20]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[20]), + (3, 1, 1, 3, 2, 1, 300, 0, 250, 3325, 3875, ARRAY[20]), + (4, 1, 1, 4, 6, -1, 3875, 0, 0, 0, 3875, ARRAY[20]), + (5, 1, 1, 0, 0, 0, 0, 0, 250, 3325, 0, ARRAY[]::INTEGER[]), + (6, 0, 0, 0, 0, 0, 0, 0, 250, 3325, 0, ARRAY[]::INTEGER[]) $$, 'Problem with only one job having id 1' ); PREPARE one_job_q2 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT * FROM jobs WHERE id = 5', 'jobs_time_windows', 'empty_shipments', @@ -744,16 +859,21 @@ BEGIN SELECT set_eq('one_job_q2', $$ VALUES - (1, 1, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[20]), - (2, 1, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[20]), - (3, 1, 4, 3, 2, 5, 300, 50, 250, 725, ARRAY[20]), - (4, 1, 4, 4, 6, -1, 1325, 100, 0, 0, ARRAY[20]) + (1, 1, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[20]), + (2, 1, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[20]), + (3, 1, 4, 3, 2, 5, 300, 50, 250, 725, 1275, ARRAY[20]), + (4, 1, 4, 4, 6, -1, 1325, 50, 0, 0, 1325, ARRAY[20]), + (5, 1, 4, 0, 0, 0, 0, 100, 250, 725, 0, ARRAY[]::INTEGER[]), + (6, 0, 0, 0, 0, 0, 0, 100, 250, 725, 0, ARRAY[]::INTEGER[]) $$, 'Problem with only one job having id 5' ); PREPARE one_shipment_q1 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'empty_jobs', 'jobs_time_windows', 'SELECT * FROM shipments WHERE id = 1', @@ -767,17 +887,22 @@ BEGIN SELECT set_eq('one_shipment_q1', $$ VALUES - (1, 1, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[0]), - (2, 1, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[0]), - (3, 1, 4, 3, 3, 1, 250, 0, 2250, 1375, ARRAY[10]), - (4, 1, 4, 4, 4, 1, 3900, 25, 2250, 21025, ARRAY[0]), - (5, 1, 4, 5, 6, -1, 27200, 50, 0, 0, ARRAY[0]) + (1, 1, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[0]), + (2, 1, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[0]), + (3, 1, 4, 3, 3, 1, 250, 0, 2250, 1375, 3875, ARRAY[10]), + (4, 1, 4, 4, 4, 1, 3900, 25, 2250, 21025, 27175, ARRAY[0]), + (5, 1, 4, 5, 6, -1, 27200, 25, 0, 0, 27200, ARRAY[0]), + (6, 1, 4, 0, 0, 0, 0, 50, 4500, 22400, 0, ARRAY[]::INTEGER[]), + (7, 0, 0, 0, 0, 0, 0, 50, 4500, 22400, 0, ARRAY[]::INTEGER[]) $$, 'Problem with only one shipment having id 1' ); PREPARE one_shipment_q2 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'empty_jobs', 'jobs_time_windows', 'SELECT * FROM shipments WHERE id = 5', @@ -791,17 +916,22 @@ BEGIN SELECT set_eq('one_shipment_q2', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[0]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[0]), - (3, 1, 1, 3, 3, 5, 350, 50, 2250, 13000, ARRAY[10]), - (4, 1, 1, 4, 4, 5, 15600, 50, 2250, 2575, ARRAY[0]), - (5, 1, 1, 5, 6, -1, 20475, 100, 0, 0, ARRAY[0]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[0]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[0]), + (3, 1, 1, 3, 3, 5, 350, 50, 2250, 13000, 15600, ARRAY[10]), + (4, 1, 1, 4, 4, 5, 15600, 0, 2250, 2575, 20425, ARRAY[0]), + (5, 1, 1, 5, 6, -1, 20475, 50, 0, 0, 20475, ARRAY[0]), + (6, 1, 1, 0, 0, 0, 0, 100, 4500, 15575, 0, ARRAY[]::INTEGER[]), + (7, 0, 0, 0, 0, 0, 0, 100, 4500, 15575, 0, ARRAY[]::INTEGER[]) $$, 'Problem with only one shipment having id 5' ); PREPARE one_job_shipment AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'SELECT * FROM jobs WHERE id = 2', 'jobs_time_windows', 'SELECT * FROM shipments WHERE id = 2', @@ -815,21 +945,27 @@ BEGIN SELECT set_eq('one_job_shipment', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[30]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[30]), - (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, ARRAY[30]), - (4, 1, 1, 4, 6, -1, 1550, 100, 0, 0, ARRAY[30]), - (5, 2, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[0]), - (6, 2, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[0]), - (7, 2, 4, 3, 3, 2, 275, 25, 2250, 100, ARRAY[10]), - (8, 2, 4, 4, 4, 2, 2736, 136, 2250, 1514, ARRAY[0]), - (9, 2, 4, 5, 6, -1, 6590, 226, 0, 0, ARRAY[0]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[30]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[30]), + (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, 1500, ARRAY[30]), + (4, 1, 1, 4, 6, -1, 1550, 50, 0, 0, 1550, ARRAY[30]), + (5, 1, 1, 0, 0, 0, 0, 100, 250, 900, 0, ARRAY[]::INTEGER[]), + (6, 2, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[0]), + (7, 2, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[0]), + (8, 2, 4, 3, 3, 2, 275, 25, 2250, 100, 2625, ARRAY[10]), + (9, 2, 4, 4, 4, 2, 2736, 111, 2250, 1514, 6500, ARRAY[0]), + (10, 2, 4, 5, 6, -1, 6590, 90, 0, 0, 6590, ARRAY[0]), + (11, 2, 4, 0, 0, 0, 0, 226, 4500, 1614, 0, ARRAY[]::INTEGER[]), + (12, 0, 0, 0, 0, 0, 0, 326, 4750, 2514, 0, ARRAY[]::INTEGER[]) $$, 'Problem with one job and one shipment having id 2' ); PREPARE exploration_level_negative AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -849,7 +985,10 @@ BEGIN ); PREPARE exploration_level_greater_5 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -869,7 +1008,10 @@ BEGIN ); PREPARE exploration_level_0 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -883,37 +1025,44 @@ BEGIN RETURN QUERY SELECT set_eq('exploration_level_0', $$ - VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[20]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[20]), - (3, 1, 1, 3, 2, 1, 300, 0, 250, 3325, ARRAY[20]), - (4, 1, 1, 4, 3, 4, 3875, 0, 2250, 2500, ARRAY[40]), - (5, 1, 1, 5, 4, 4, 8700, 75, 2250, 225, ARRAY[20]), - (6, 1, 1, 6, 3, 5, 11265, 165, 2250, 2085, ARRAY[30]), - (7, 1, 1, 7, 3, 3, 15650, 215, 2250, 0, ARRAY[50]), - (8, 1, 1, 8, 4, 5, 17950, 265, 2250, 225, ARRAY[40]), - (9, 1, 1, 9, 4, 3, 20425, 265, 2250, 200, ARRAY[20]), - (10, 1, 1, 10, 6, -1, 22925, 315, 0, 0, ARRAY[20]), - (11, 2, 2, 1, 1, -1, 275, 0, 0, 0, ARRAY[50]), - (12, 2, 2, 2, 5, 2, 275, 0, 10, 0, ARRAY[50]), - (13, 2, 2, 3, 2, 2, 335, 50, 250, 915, ARRAY[50]), - (14, 2, 2, 4, 2, 5, 1590, 140, 250, 0, ARRAY[50]), - (15, 2, 2, 5, 3, 1, 1890, 190, 2250, 0, ARRAY[60]), - (16, 2, 2, 6, 4, 1, 4165, 215, 2250, 20760, ARRAY[50]), - (17, 2, 2, 7, 6, -1, 27200, 240, 0, 0, ARRAY[50]), - (18, 3, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[50]), - (19, 3, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[50]), - (20, 3, 4, 3, 3, 2, 275, 25, 2250, 100, ARRAY[60]), - (21, 3, 4, 4, 2, 3, 2650, 50, 250, 75, ARRAY[60]), - (22, 3, 4, 5, 2, 4, 2975, 50, 250, 550, ARRAY[60]), - (23, 3, 4, 6, 4, 2, 3865, 140, 2250, 385, ARRAY[50]), - (24, 3, 4, 7, 6, -1, 6590, 230, 0, 0, ARRAY[50]) + VALUES + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[20]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[20]), + (3, 1, 1, 3, 2, 1, 300, 0, 250, 3325, 3875, ARRAY[20]), + (4, 1, 1, 4, 3, 4, 3875, 0, 2250, 2500, 8625, ARRAY[40]), + (5, 1, 1, 5, 4, 4, 8700, 75, 2250, 225, 11175, ARRAY[20]), + (6, 1, 1, 6, 3, 5, 11265, 90, 2250, 2085, 15600, ARRAY[30]), + (7, 1, 1, 7, 3, 3, 15650, 50, 2250, 0, 17900, ARRAY[50]), + (8, 1, 1, 8, 4, 5, 17950, 50, 2250, 225, 20425, ARRAY[40]), + (9, 1, 1, 9, 4, 3, 20425, 0, 2250, 200, 22875, ARRAY[20]), + (10, 1, 1, 10, 6, -1, 22925, 50, 0, 0, 22925, ARRAY[20]), + (11, 1, 1, 0, 0, 0, 0, 315, 13750, 8560, 0, ARRAY[]::INTEGER[]), + (12, 2, 2, 1, 1, -1, 275, 0, 0, 0, 275, ARRAY[50]), + (13, 2, 2, 2, 5, 2, 275, 0, 10, 0, 285, ARRAY[50]), + (14, 2, 2, 3, 2, 2, 335, 50, 250, 915, 1500, ARRAY[50]), + (15, 2, 2, 4, 2, 5, 1590, 90, 250, 0, 1840, ARRAY[50]), + (16, 2, 2, 5, 3, 1, 1890, 50, 2250, 0, 4140, ARRAY[60]), + (17, 2, 2, 6, 4, 1, 4165, 25, 2250, 20760, 27175, ARRAY[50]), + (18, 2, 2, 7, 6, -1, 27200, 25, 0, 0, 27200, ARRAY[50]), + (19, 2, 2, 0, 0, 0, 0, 240, 5010, 21675, 0, ARRAY[]::INTEGER[]), + (20, 3, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[50]), + (21, 3, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[50]), + (22, 3, 4, 3, 3, 2, 275, 25, 2250, 100, 2625, ARRAY[60]), + (23, 3, 4, 4, 2, 3, 2650, 25, 250, 75, 2975, ARRAY[60]), + (24, 3, 4, 5, 2, 4, 2975, 0, 250, 550, 3775, ARRAY[60]), + (25, 3, 4, 6, 4, 2, 3865, 90, 2250, 385, 6500, ARRAY[50]), + (26, 3, 4, 7, 6, -1, 6590, 90, 0, 0, 6590, ARRAY[50]), + (27, 3, 4, 0, 0, 0, 0, 230, 5000, 1110, 0, ARRAY[]::INTEGER[]), + (28, 0, 0, 0, 0, 0, 0, 785, 23760, 31345, 0, ARRAY[]::INTEGER[]) $$, 'Query with the vroomdata and exploration_level => 0' ); PREPARE exploration_level_5 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -929,7 +1078,10 @@ BEGIN PREPARE timeout_0 AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -944,33 +1096,39 @@ BEGIN SELECT set_eq('timeout_0', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[110]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[110]), - (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, ARRAY[110]), - (4, 1, 1, 4, 2, 5, 1590, 140, 250, 0, ARRAY[110]), - (5, 1, 1, 5, 2, 4, 1890, 190, 250, 1635, ARRAY[110]), - (6, 1, 1, 6, 2, 1, 3865, 280, 250, 0, ARRAY[110]), - (7, 1, 1, 7, 6, -1, 4115, 280, 0, 0, ARRAY[110]), - (8, 2, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[10]), - (9, 2, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[10]), - (10, 2, 4, 3, 3, 2, 275, 25, 2250, 100, ARRAY[20]), - (11, 2, 4, 4, 2, 3, 2650, 50, 250, 75, ARRAY[20]), - (12, 2, 4, 5, 3, 1, 2975, 50, 2250, 0, ARRAY[30]), - (13, 2, 4, 6, 4, 2, 5315, 140, 2250, 0, ARRAY[20]), - (14, 2, 4, 7, 3, 4, 7692, 267, 2250, 0, ARRAY[40]), - (15, 2, 4, 8, 4, 4, 10017, 342, 2250, 0, ARRAY[20]), - (16, 2, 4, 9, 3, 5, 12357, 432, 2250, 993, ARRAY[30]), - (17, 2, 4, 10, 3, 3, 15650, 482, 2250, 0, ARRAY[50]), - (18, 2, 4, 11, 4, 5, 17950, 532, 2250, 225, ARRAY[40]), - (19, 2, 4, 12, 4, 3, 20425, 532, 2250, 200, ARRAY[20]), - (20, 2, 4, 13, 4, 1, 23020, 677, 2250, 1905, ARRAY[10]), - (21, 2, 4, 14, 6, -1, 27200, 702, 0, 0, ARRAY[10]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[110]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[110]), + (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, 1500, ARRAY[110]), + (4, 1, 1, 4, 2, 5, 1590, 90, 250, 0, 1840, ARRAY[110]), + (5, 1, 1, 5, 2, 4, 1890, 50, 250, 1635, 3775, ARRAY[110]), + (6, 1, 1, 6, 2, 1, 3865, 90, 250, 0, 4115, ARRAY[110]), + (7, 1, 1, 7, 6, -1, 4115, 0, 0, 0, 4115, ARRAY[110]), + (8, 1, 1, 0, 0, 0, 0, 280, 1000, 2535, 0, ARRAY[]::INTEGER[]), + (9, 2, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[10]), + (10, 2, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[10]), + (11, 2, 4, 3, 3, 2, 275, 25, 2250, 100, 2625, ARRAY[20]), + (12, 2, 4, 4, 2, 3, 2650, 25, 250, 75, 2975, ARRAY[20]), + (13, 2, 4, 5, 3, 1, 2975, 0, 2250, 0, 5225, ARRAY[30]), + (14, 2, 4, 6, 4, 2, 5315, 90, 2250, 0, 7565, ARRAY[20]), + (15, 2, 4, 7, 3, 4, 7692, 127, 2250, 0, 9942, ARRAY[40]), + (16, 2, 4, 8, 4, 4, 10017, 75, 2250, 0, 12267, ARRAY[20]), + (17, 2, 4, 9, 3, 5, 12357, 90, 2250, 993, 15600, ARRAY[30]), + (18, 2, 4, 10, 3, 3, 15650, 50, 2250, 0, 17900, ARRAY[50]), + (19, 2, 4, 11, 4, 5, 17950, 50, 2250, 225, 20425, ARRAY[40]), + (20, 2, 4, 12, 4, 3, 20425, 0, 2250, 200, 22875, ARRAY[20]), + (21, 2, 4, 13, 4, 1, 23020, 145, 2250, 1905, 27175, ARRAY[10]), + (22, 2, 4, 14, 6, -1, 27200, 25, 0, 0, 27200, ARRAY[10]), + (23, 2, 4, 0, 0, 0, 0, 702, 22750, 3498, 0, ARRAY[]::INTEGER[]), + (24, 0, 0, 0, 0, 0, 0, 982, 23750, 6033, 0, ARRAY[]::INTEGER[]) $$, 'Query with the vroomdata and timeout => 0' ); PREPARE timeout_negative AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -994,7 +1152,10 @@ BEGIN SELECT id, start_id, end_id, capacity, skills, tw_open, tw_close, speed_factor, 1 AS max_tasks FROM vehicles; PREPARE problem_negative_tasks AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1013,7 +1174,10 @@ BEGIN ); PREPARE problem_0_tasks AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1024,10 +1188,34 @@ BEGIN 'matrix' ); RETURN QUERY - SELECT is_empty('problem_0_tasks', 'Problem with max_tasks as 0'); + SELECT set_eq('problem_0_tasks', + $$ + VALUES + (1, 1, -1, 1, 4, 5, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (2, 1, -1, 2, 3, 5, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (3, 1, -1, 3, 2, 1, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (4, 1, -1, 4, 2, 2, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (5, 1, -1, 5, 2, 3, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (6, 1, -1, 6, 2, 4, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (7, 1, -1, 7, 2, 5, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (8, 1, -1, 8, 3, 1, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (9, 1, -1, 9, 4, 1, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (10, 1, -1, 10, 3, 2, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (11, 1, -1, 11, 4, 2, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (12, 1, -1, 12, 3, 3, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (13, 1, -1, 13, 4, 3, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (14, 1, -1, 14, 3, 4, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (15, 1, -1, 15, 4, 4, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]) + $$, + 'Problem with max_tasks as 0' + ); PREPARE problem_1_task AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1041,33 +1229,52 @@ BEGIN SELECT set_eq('problem_1_task', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[30]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[30]), - (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, ARRAY[30]), - (4, 1, 1, 4, 6, -1, 1550, 100, 0, 0, ARRAY[30]), - (5, 2, 2, 1, 1, -1, 275, 0, 0, 0, ARRAY[10]), - (6, 2, 2, 2, 5, 2, 275, 0, 10, 0, ARRAY[10]), - (7, 2, 2, 3, 2, 3, 375, 90, 250, 2350, ARRAY[10]), - (8, 2, 2, 4, 6, -1, 2975, 90, 0, 0, ARRAY[10]), - (9, 3, 3, 1, 1, -1, 0, 0, 0, 0, ARRAY[20]), - (10, 3, 3, 2, 5, 3, 0, 0, 0, 0, ARRAY[20]), - (11, 3, 3, 3, 2, 1, 0, 0, 250, 3625, ARRAY[20]), - (12, 3, 3, 4, 6, -1, 3875, 0, 0, 0, ARRAY[20]), - (13, 4, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[40]), - (14, 4, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[40]), - (15, 4, 4, 3, 2, 4, 250, 0, 250, 3275, ARRAY[40]), - (16, 4, 4, 4, 6, -1, 3775, 0, 0, 0, ARRAY[40]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[30]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[30]), + (3, 1, 1, 3, 2, 2, 350, 50, 250, 900, 1500, ARRAY[30]), + (4, 1, 1, 4, 6, -1, 1550, 50, 0, 0, 1550, ARRAY[30]), + (5, 1, 1, 0, 0, 0, 0, 100, 250, 900, 0, ARRAY[]::INTEGER[]), + (6, 2, 2, 1, 1, -1, 275, 0, 0, 0, 275, ARRAY[10]), + (7, 2, 2, 2, 5, 2, 275, 0, 10, 0, 285, ARRAY[10]), + (8, 2, 2, 3, 2, 3, 375, 90, 250, 2350, 2975, ARRAY[10]), + (9, 2, 2, 4, 6, -1, 2975, 0, 0, 0, 2975, ARRAY[10]), + (10, 2, 2, 0, 0, 0, 0, 90, 260, 2350, 0, ARRAY[]::INTEGER[]), + (11, 3, 3, 1, 1, -1, 0, 0, 0, 0, 0, ARRAY[20]), + (12, 3, 3, 2, 5, 3, 0, 0, 0, 0, 0, ARRAY[20]), + (13, 3, 3, 3, 2, 1, 0, 0, 250, 3625, 3875, ARRAY[20]), + (14, 3, 3, 4, 6, -1, 3875, 0, 0, 0, 3875, ARRAY[20]), + (15, 3, 3, 0, 0, 0, 0, 0, 250, 3625, 0, ARRAY[]::INTEGER[]), + (16, 4, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[40]), + (17, 4, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[40]), + (18, 4, 4, 3, 2, 4, 250, 0, 250, 3275, 3775, ARRAY[40]), + (19, 4, 4, 4, 6, -1, 3775, 0, 0, 0, 3775, ARRAY[40]), + (20, 4, 4, 0, 0, 0, 0, 0, 250, 3275, 0, ARRAY[]::INTEGER[]), + (21, 5, -1, 1, 4, 5, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (22, 5, -1, 2, 3, 5, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (23, 5, -1, 3, 2, 5, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (24, 5, -1, 4, 3, 1, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (25, 5, -1, 5, 4, 1, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (26, 5, -1, 6, 3, 2, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (27, 5, -1, 7, 4, 2, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (28, 5, -1, 8, 3, 3, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (29, 5, -1, 9, 4, 3, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (30, 5, -1, 10, 3, 4, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (31, 5, -1, 11, 4, 4, 0, 0, 0, 0, 0, ARRAY[]::INTEGER[]), + (32, 0, 0, 0, 0, 0, 0, 190, 1010, 10150, 0, ARRAY[]::INTEGER[]) $$, 'Query with max_tasks as 1' ); PREPARE empty_skills_1 AS - SELECT * FROM vrp_vroomPlain( - 'SELECT id, location_id, service, delivery, pickup, ARRAY[]::INTEGER[] AS skills, priority FROM jobs', + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( + 'SELECT id, location_id, service, delivery, pickup, ARRAY[]::INTEGER[]::INTEGER[]::INTEGER[]::INTEGER[] AS skills, priority FROM jobs', 'jobs_time_windows', - 'SELECT id, p_location_id, p_service, d_location_id, d_service, amount, ARRAY[]::INTEGER[] AS skills, priority FROM shipments', + 'SELECT id, p_location_id, p_service, d_location_id, d_service, amount, ARRAY[]::INTEGER[]::INTEGER[]::INTEGER[]::INTEGER[] AS skills, priority FROM shipments', 'shipments_time_windows', - 'SELECT id, start_id, end_id, capacity, ARRAY[]::INTEGER[] AS skills, tw_open, tw_close, speed_factor, max_tasks FROM vehicles', + 'SELECT id, start_id, end_id, capacity, ARRAY[]::INTEGER[]::INTEGER[]::INTEGER[]::INTEGER[] AS skills, tw_open, tw_close, speed_factor, max_tasks FROM vehicles', 'breaks', 'breaks_time_windows', 'matrix' @@ -1077,10 +1284,13 @@ BEGIN SELECT set_eq('empty_skills_1', 'vroom_sql', 'Test for empty skills array - 1'); PREPARE empty_skills_2 AS - SELECT * FROM vrp_vroomPlain( - 'SELECT id, location_id, service, delivery, pickup, ARRAY[]::INTEGER[] AS skills, priority FROM jobs', + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( + 'SELECT id, location_id, service, delivery, pickup, ARRAY[]::INTEGER[]::INTEGER[]::INTEGER[]::INTEGER[] AS skills, priority FROM jobs', 'jobs_time_windows', - 'SELECT id, p_location_id, p_service, d_location_id, d_service, amount, ARRAY[]::INTEGER[] AS skills, priority FROM shipments', + 'SELECT id, p_location_id, p_service, d_location_id, d_service, amount, ARRAY[]::INTEGER[]::INTEGER[]::INTEGER[]::INTEGER[] AS skills, priority FROM shipments', 'shipments_time_windows', 'vehicles', 'breaks', @@ -1092,7 +1302,10 @@ BEGIN SELECT set_eq('empty_skills_2', 'vroom_sql', 'Test for empty skills array - 2'); PREPARE problem_negative_speed_factor AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1111,7 +1324,10 @@ BEGIN ); PREPARE problem_0_speed_factor AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1131,7 +1347,10 @@ BEGIN UPDATE vehicles SET speed_factor = 5.01 WHERE id = 4; PREPARE problem_more_than_5times_speed_factor AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1151,7 +1370,10 @@ BEGIN UPDATE vehicles SET speed_factor = 1.0 WHERE id = 4; PREPARE problem_speed_factor_5times_scaled AS - SELECT * FROM vrp_vroomPlain( + SELECT + seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, departure, load + FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -1165,33 +1387,38 @@ BEGIN SELECT set_eq('problem_speed_factor_5times_scaled', $$ VALUES - (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, ARRAY[30]), - (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, ARRAY[30]), - (3, 1, 1, 3, 2, 2, 310, 10, 250, 940, ARRAY[30]), - (4, 1, 1, 4, 3, 5, 1500, 10, 2250, 11850, ARRAY[40]), - (5, 1, 1, 5, 3, 3, 15610, 20, 2250, 0, ARRAY[60]), - (6, 1, 1, 6, 4, 5, 17870, 30, 2250, 305, ARRAY[50]), - (7, 1, 1, 7, 4, 3, 20425, 30, 2250, 200, ARRAY[30]), - (8, 1, 1, 8, 6, -1, 22885, 40, 0, 0, ARRAY[30]), - (9, 2, 2, 1, 1, -1, 275, 0, 0, 0, ARRAY[70]), - (10, 2, 2, 2, 5, 2, 275, 0, 10, 0, ARRAY[70]), - (11, 2, 2, 3, 2, 5, 300, 15, 250, 725, ARRAY[70]), - (12, 2, 2, 4, 2, 3, 1285, 25, 250, 1440, ARRAY[70]), - (13, 2, 2, 5, 2, 4, 2975, 25, 250, 550, ARRAY[70]), - (14, 2, 2, 6, 6, -1, 3775, 25, 0, 0, ARRAY[70]), - (15, 3, 3, 1, 1, -1, 0, 0, 0, 0, ARRAY[20]), - (16, 3, 3, 2, 5, 3, 0, 0, 0, 0, ARRAY[20]), - (17, 3, 3, 3, 2, 1, 0, 0, 250, 3625, ARRAY[20]), - (18, 3, 3, 4, 3, 4, 3875, 0, 2250, 2500, ARRAY[40]), - (19, 3, 3, 5, 4, 4, 8640, 15, 2250, 285, ARRAY[20]), - (20, 3, 3, 6, 6, -1, 11190, 30, 0, 0, ARRAY[20]), - (21, 4, 4, 1, 1, -1, 250, 0, 0, 0, ARRAY[0]), - (22, 4, 4, 2, 5, 4, 250, 0, 0, 0, ARRAY[0]), - (23, 4, 4, 3, 3, 2, 255, 5, 2250, 120, ARRAY[10]), - (24, 4, 4, 4, 3, 1, 2630, 10, 2250, 0, ARRAY[20]), - (25, 4, 4, 5, 4, 2, 4898, 28, 2250, 0, ARRAY[10]), - (26, 4, 4, 6, 4, 1, 7170, 50, 2250, 17755, ARRAY[0]), - (27, 4, 4, 7, 6, -1, 27180, 55, 0, 0, ARRAY[0]) + (1, 1, 1, 1, 1, -1, 300, 0, 0, 0, 300, ARRAY[30]), + (2, 1, 1, 2, 5, 1, 300, 0, 0, 0, 300, ARRAY[30]), + (3, 1, 1, 3, 2, 2, 310, 10, 250, 940, 1500, ARRAY[30]), + (4, 1, 1, 4, 3, 5, 1500, 0, 2250, 11850, 15600, ARRAY[40]), + (5, 1, 1, 5, 3, 3, 15610, 10, 2250, 0, 17860, ARRAY[60]), + (6, 1, 1, 6, 4, 5, 17870, 10, 2250, 305, 20425, ARRAY[50]), + (7, 1, 1, 7, 4, 3, 20425, 0, 2250, 200, 22875, ARRAY[30]), + (8, 1, 1, 8, 6, -1, 22885, 10, 0, 0, 22885, ARRAY[30]), + (9, 1, 1, 0, 0, 0, 0, 40, 9250, 13295, 0, ARRAY[]::INTEGER[]), + (10, 2, 2, 1, 1, -1, 275, 0, 0, 0, 275, ARRAY[70]), + (11, 2, 2, 2, 5, 2, 275, 0, 10, 0, 285, ARRAY[70]), + (12, 2, 2, 3, 2, 5, 300, 15, 250, 725, 1275, ARRAY[70]), + (13, 2, 2, 4, 2, 3, 1285, 10, 250, 1440, 2975, ARRAY[70]), + (14, 2, 2, 5, 2, 4, 2975, 0, 250, 550, 3775, ARRAY[70]), + (15, 2, 2, 6, 6, -1, 3775, 0, 0, 0, 3775, ARRAY[70]), + (16, 2, 2, 0, 0, 0, 0, 25, 760, 2715, 0, ARRAY[]::INTEGER[]), + (17, 3, 3, 1, 1, -1, 0, 0, 0, 0, 0, ARRAY[20]), + (18, 3, 3, 2, 5, 3, 0, 0, 0, 0, 0, ARRAY[20]), + (19, 3, 3, 3, 2, 1, 0, 0, 250, 3625, 3875, ARRAY[20]), + (20, 3, 3, 4, 3, 4, 3875, 0, 2250, 2500, 8625, ARRAY[40]), + (21, 3, 3, 5, 4, 4, 8640, 15, 2250, 285, 11175, ARRAY[20]), + (22, 3, 3, 6, 6, -1, 11190, 15, 0, 0, 11190, ARRAY[20]), + (23, 3, 3, 0, 0, 0, 0, 30, 4750, 6410, 0, ARRAY[]::INTEGER[]), + (24, 4, 4, 1, 1, -1, 250, 0, 0, 0, 250, ARRAY[0]), + (25, 4, 4, 2, 5, 4, 250, 0, 0, 0, 250, ARRAY[0]), + (26, 4, 4, 3, 3, 2, 255, 5, 2250, 120, 2625, ARRAY[10]), + (27, 4, 4, 4, 3, 1, 2630, 5, 2250, 0, 4880, ARRAY[20]), + (28, 4, 4, 5, 4, 2, 4898, 18, 2250, 0, 7148, ARRAY[10]), + (29, 4, 4, 6, 4, 1, 7170, 22, 2250, 17755, 27175, ARRAY[0]), + (30, 4, 4, 7, 6, -1, 27180, 5, 0, 0, 27180, ARRAY[0]), + (31, 4, 4, 0, 0, 0, 0, 55, 9000, 17875, 0, ARRAY[]::INTEGER[]), + (32, 0, 0, 0, 0, 0, 0, 150, 23760, 40295, 0, ARRAY[]::INTEGER[]) $$, 'Query with speed factor scaled five times' ); diff --git a/pgtap/vroom/types_check.sql b/pgtap/vroom/types_check.sql index ea851f8bc..83c578a22 100644 --- a/pgtap/vroom/types_check.sql +++ b/pgtap/vroom/types_check.sql @@ -26,8 +26,8 @@ BEGIN RETURN QUERY SELECT bag_has( $$SELECT proargnames from pg_proc where proname = 'vrp_vroomplain'$$, - $$SELECT '{"","","","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","step_seq","step_type",' - '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + $$SELECT '{"","","","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","vehicle_data","step_seq","step_type",' + '"task_id","location_id","task_data","arrival","travel_time","setup_time","service_time","waiting_time","departure","load"}'::TEXT[]$$ ); -- parameter types @@ -35,7 +35,7 @@ BEGIN SELECT set_eq( $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomplain'$$, $$VALUES - ('{25,25,25,25,25,25,25,25,23,23,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) + ('{25,25,25,25,25,25,25,25,23,23,20,20,20,3802,20,23,20,20,3802,23,23,23,23,23,23,1016}'::OID[]) $$ ); @@ -52,8 +52,8 @@ BEGIN RETURN QUERY SELECT bag_has( $$SELECT proargnames from pg_proc where proname = 'vrp_vroom'$$, - $$SELECT '{"","","","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","step_seq","step_type",' - '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + $$SELECT '{"","","","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","vehicle_data","step_seq","step_type",' + '"task_id","location_id","task_data","arrival","travel_time","setup_time","service_time","waiting_time","departure","load"}'::TEXT[]$$ ); -- parameter types @@ -61,7 +61,7 @@ BEGIN SELECT set_eq( $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroom'$$, $$VALUES - ('{25,25,25,25,25,25,25,25,23,1186,20,20,20,20,23,20,1114,1186,1186,1186,1016}'::OID[]) + ('{25,25,25,25,25,25,25,25,23,1186,20,20,20,3802,20,23,20,20,3802,1114,1186,1186,1186,1186,1114,1016}'::OID[]) $$ ); @@ -78,8 +78,8 @@ BEGIN RETURN QUERY SELECT bag_has( $$SELECT proargnames from pg_proc where proname = 'vrp_vroomjobsplain'$$, - $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","step_seq","step_type",' - '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","vehicle_data","step_seq","step_type",' + '"task_id","location_id","task_data","arrival","travel_time","setup_time","service_time","waiting_time","departure","load"}'::TEXT[]$$ ); -- parameter types @@ -87,7 +87,7 @@ BEGIN SELECT set_eq( $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomjobsplain'$$, $$VALUES - ('{25,25,25,25,25,25,23,23,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) + ('{25,25,25,25,25,25,23,23,20,20,20,3802,20,23,20,20,3802,23,23,23,23,23,23,1016}'::OID[]) $$ ); @@ -104,8 +104,8 @@ BEGIN RETURN QUERY SELECT bag_has( $$SELECT proargnames from pg_proc where proname = 'vrp_vroomjobs'$$, - $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","step_seq","step_type",' - '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","vehicle_data","step_seq","step_type",' + '"task_id","location_id","task_data","arrival","travel_time","setup_time","service_time","waiting_time","departure","load"}'::TEXT[]$$ ); -- parameter types @@ -113,7 +113,7 @@ BEGIN SELECT set_eq( $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomjobs'$$, $$VALUES - ('{25,25,25,25,25,25,23,1186,20,20,20,20,23,20,1114,1186,1186,1186,1016}'::OID[]) + ('{25,25,25,25,25,25,23,1186,20,20,20,3802,20,23,20,20,3802,1114,1186,1186,1186,1186,1114,1016}'::OID[]) $$ ); @@ -130,8 +130,8 @@ BEGIN RETURN QUERY SELECT bag_has( $$SELECT proargnames from pg_proc where proname = 'vrp_vroomshipmentsplain'$$, - $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","step_seq","step_type",' - '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","vehicle_data","step_seq","step_type",' + '"task_id","location_id","task_data","arrival","travel_time","setup_time","service_time","waiting_time","departure","load"}'::TEXT[]$$ ); -- parameter types @@ -139,7 +139,7 @@ BEGIN SELECT set_eq( $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomshipmentsplain'$$, $$VALUES - ('{25,25,25,25,25,25,23,23,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) + ('{25,25,25,25,25,25,23,23,20,20,20,3802,20,23,20,20,3802,23,23,23,23,23,23,1016}'::OID[]) $$ ); @@ -156,8 +156,8 @@ BEGIN RETURN QUERY SELECT bag_has( $$SELECT proargnames from pg_proc where proname = 'vrp_vroomshipments'$$, - $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","step_seq","step_type",' - '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + $$SELECT '{"","","","","","","exploration_level","timeout","seq","vehicle_seq","vehicle_id","vehicle_data","step_seq","step_type",' + '"task_id","location_id","task_data","arrival","travel_time","setup_time","service_time","waiting_time","departure","load"}'::TEXT[]$$ ); -- parameter types @@ -165,7 +165,7 @@ BEGIN SELECT set_eq( $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomshipments'$$, $$VALUES - ('{25,25,25,25,25,25,23,1186,20,20,20,20,23,20,1114,1186,1186,1186,1016}'::OID[]) + ('{25,25,25,25,25,25,23,1186,20,20,20,3802,20,23,20,20,3802,1114,1186,1186,1186,1186,1114,1016}'::OID[]) $$ ); END; diff --git a/pgtap/vroom/vroom-plain-eq-timestamp.test.sql b/pgtap/vroom/vroom-plain-eq-timestamp.test.sql index 02afcc1a5..16eedba77 100644 --- a/pgtap/vroom/vroom-plain-eq-timestamp.test.sql +++ b/pgtap/vroom/vroom-plain-eq-timestamp.test.sql @@ -41,10 +41,10 @@ DECLARE 'exploration_level => 5, timeout => $$-00:00:01$$::INTERVAL)'; returnPlain_sql TEXT := 'SELECT * FROM vrp_vroomPlain('; - return_sql TEXT := 'SELECT seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, ' || - 'EXTRACT (EPOCH FROM arrival) AS arrival, EXTRACT (EPOCH FROM travel_time) AS travel_time, ' || + return_sql TEXT := 'SELECT seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, location_id, task_data, ' || + 'EXTRACT (EPOCH FROM arrival) AS arrival, EXTRACT (EPOCH FROM travel_time) AS travel_time, EXTRACT (EPOCH FROM setup_time) AS setup_time, ' || 'EXTRACT (EPOCH FROM service_time) AS service_time, EXTRACT (EPOCH FROM waiting_time) AS waiting_time, ' || - 'load FROM vrp_vroom('; + 'EXTRACT (EPOCH FROM departure) AS departure, load FROM vrp_vroom('; vroom_sql TEXT; vroomPlain_sql TEXT; diff --git a/sql/vroom/_vrp_vroom.sql b/sql/vroom/_vrp_vroom.sql index 27e9949c0..ea286ed83 100644 --- a/sql/vroom/_vrp_vroom.sql +++ b/sql/vroom/_vrp_vroom.sql @@ -46,13 +46,18 @@ CREATE FUNCTION _vrp_vroom( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data TEXT, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data TEXT, OUT arrival INTEGER, OUT travel_time INTEGER, + OUT setup_time INTEGER, OUT service_time INTEGER, OUT waiting_time INTEGER, + OUT departure INTEGER, OUT load BIGINT[]) RETURNS SETOF RECORD AS 'MODULE_PATHNAME' diff --git a/sql/vroom/vrp_vroom.sql b/sql/vroom/vrp_vroom.sql index 78069541e..e8ad4eec0 100644 --- a/sql/vroom/vrp_vroom.sql +++ b/sql/vroom/vrp_vroom.sql @@ -38,8 +38,8 @@ signature start Matrix SQL [, exploration_level] [, timeout]) -- Experimental on v0.2 RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) signature end @@ -54,8 +54,8 @@ default signature start Matrix SQL) RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) default signature end @@ -108,8 +108,8 @@ Returns set of .. code-block:: none - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, load) =================== ================= ================================================= Column Type Description @@ -119,14 +119,24 @@ Column Type Description **vehicle_seq** ``BIGINT`` Sequential value starting from **1** for current vehicles. The :math:`n^{th}` vehicle in the solution. + - ``0``: Summary row for the complete problem + **vehicle_id** ``BIGINT`` Current vehicle identifier. + - ``-1``: Vehicle denoting all the unallocated tasks. + - ``0``: Summary row for the complete problem + +**vehicle_data** ``JSONB`` Metadata information of the vehicle + **step_seq** ``BIGINT`` Sequential value starting from **1** for the stops made by the current vehicle. The :math:`m^{th}` stop of the current vehicle. + - ``0``: Summary row + **step_type** ``INTEGER`` Kind of the step location the vehicle is at: + - ``0``: Summary row - ``1``: Starting location - ``2``: Job location - ``3``: Pickup location @@ -136,19 +146,40 @@ Column Type Description **task_id** ``BIGINT`` Identifier of the task performed at this step. + - ``0``: Summary row - ``-1``: If the step is starting/ending location. +**location_id** ``BIGINT`` Identifier of the task location. + + - ``0``: Summary row + +**task_data** ``JSONB`` Metadata information of the task + **arrival** |timestamp| Estimated time of arrival at this step. -**travel_time** |interval| Cumulated travel time upon arrival at this step. +**travel_time** |interval| Travel time from previous ``step_seq`` to current ``step_seq``. + + - ``0``: When ``step_type = 1`` + +**setup_time** |interval| Setup time at this step. **service_time** |interval| Service time at this step. **waiting_time** |interval| Waiting time upon arrival at this step. +**departure** |timestamp| Estimated time of arrival at this step. + + - :math:`arrival + service\_time + waiting\_time`. + **load** ``BIGINT`` Vehicle load after step completion (with capacity constraints) =================== ================= ================================================= +**Note**: + +- Unallocated tasks are mentioned at the end with :code:`vehicle_id = -1`. +- The last step of every vehicle denotes the summary row, where the columns ``travel_time``, ``service_time`` and ``waiting_time`` denote the total time for the corresponding vehicle, +- The last row denotes the summary for the complete problem, where the columns ``travel_time``, ``service_time`` and ``waiting_time`` denote the total time for the complete problem, + result end */ @@ -169,13 +200,18 @@ CREATE FUNCTION vrp_vroom( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data JSONB, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data JSONB, OUT arrival TIMESTAMP, OUT travel_time INTERVAL, + OUT setup_time INTERVAL, OUT service_time INTERVAL, OUT waiting_time INTERVAL, + OUT departure TIMESTAMP, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ @@ -190,13 +226,18 @@ BEGIN A.seq, A.vehicle_seq, A.vehicle_id, + A.vehicle_data::JSONB, A.step_seq, A.step_type, A.task_id, + A.location_id, + A.task_data::JSONB, (to_timestamp(A.arrival) at time zone 'UTC')::TIMESTAMP, make_interval(secs => A.travel_time), + make_interval(secs => A.setup_time), make_interval(secs => A.service_time), make_interval(secs => A.waiting_time), + (to_timestamp(A.departure) at time zone 'UTC')::TIMESTAMP, A.load FROM _vrp_vroom(_pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), _pgr_get_statement($4), _pgr_get_statement($5), _pgr_get_statement($6), diff --git a/sql/vroom/vrp_vroomJobs.sql b/sql/vroom/vrp_vroomJobs.sql index 3ce77f84d..573a36f90 100644 --- a/sql/vroom/vrp_vroomJobs.sql +++ b/sql/vroom/vrp_vroomJobs.sql @@ -37,8 +37,8 @@ signature start Matrix SQL [, exploration_level] [, timeout]) -- Experimental on v0.2 RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) signature end @@ -52,8 +52,8 @@ default signature start Matrix SQL) RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) default signature end @@ -93,13 +93,18 @@ CREATE FUNCTION vrp_vroomJobs( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data JSONB, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data JSONB, OUT arrival TIMESTAMP, OUT travel_time INTERVAL, + OUT setup_time INTERVAL, OUT service_time INTERVAL, OUT waiting_time INTERVAL, + OUT departure TIMESTAMP, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ @@ -114,13 +119,18 @@ BEGIN A.seq, A.vehicle_seq, A.vehicle_id, + A.vehicle_data::JSONB, A.step_seq, A.step_type, A.task_id, + A.location_id, + A.task_data::JSONB, (to_timestamp(A.arrival) at time zone 'UTC')::TIMESTAMP, make_interval(secs => A.travel_time), + make_interval(secs => A.setup_time), make_interval(secs => A.service_time), make_interval(secs => A.waiting_time), + (to_timestamp(A.departure) at time zone 'UTC')::TIMESTAMP, A.load FROM _vrp_vroom(_pgr_get_statement($1), _pgr_get_statement($2), NULL, NULL, _pgr_get_statement($3), _pgr_get_statement($4), diff --git a/sql/vroom/vrp_vroomJobsPlain.sql b/sql/vroom/vrp_vroomJobsPlain.sql index 6d9d97d1b..4d29e476e 100644 --- a/sql/vroom/vrp_vroomJobsPlain.sql +++ b/sql/vroom/vrp_vroomJobsPlain.sql @@ -37,8 +37,8 @@ signature start Matrix SQL [, exploration_level] [, timeout]) -- Experimental on v0.2 RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) signature end @@ -52,8 +52,8 @@ default signature start Matrix SQL) RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) default signature end */ @@ -73,13 +73,18 @@ CREATE FUNCTION vrp_vroomJobsPlain( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data JSONB, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data JSONB, OUT arrival INTEGER, OUT travel_time INTEGER, + OUT setup_time INTEGER, OUT service_time INTEGER, OUT waiting_time INTEGER, + OUT departure INTEGER, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ @@ -90,11 +95,27 @@ BEGIN END IF; RETURN QUERY - SELECT * + SELECT + A.seq, + A.vehicle_seq, + A.vehicle_id, + A.vehicle_data::JSONB, + A.step_seq, + A.step_type, + A.task_id, + A.location_id, + A.task_data::JSONB, + A.arrival, + A.travel_time, + A.setup_time, + A.service_time, + A.waiting_time, + A.departure, + A.load FROM _vrp_vroom(_pgr_get_statement($1), _pgr_get_statement($2), NULL, NULL, _pgr_get_statement($3), _pgr_get_statement($4), _pgr_get_statement($5), _pgr_get_statement($6), - exploration_level, timeout, 1::SMALLINT, true); + exploration_level, timeout, 1::SMALLINT, true) A; END; $BODY$ LANGUAGE plpgsql VOLATILE; diff --git a/sql/vroom/vrp_vroomPlain.sql b/sql/vroom/vrp_vroomPlain.sql index a452371a7..9baf23712 100644 --- a/sql/vroom/vrp_vroomPlain.sql +++ b/sql/vroom/vrp_vroomPlain.sql @@ -38,8 +38,8 @@ signature start Matrix SQL [, exploration_level] [, timeout]) -- Experimental on v0.2 RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) signature end @@ -54,8 +54,8 @@ default signature start Matrix SQL) RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) default signature end @@ -97,13 +97,18 @@ CREATE FUNCTION vrp_vroomPlain( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data JSONB, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data JSONB, OUT arrival INTEGER, OUT travel_time INTEGER, + OUT setup_time INTEGER, OUT service_time INTEGER, OUT waiting_time INTEGER, + OUT departure INTEGER, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ @@ -114,11 +119,27 @@ BEGIN END IF; RETURN QUERY - SELECT * + SELECT + A.seq, + A.vehicle_seq, + A.vehicle_id, + A.vehicle_data::JSONB, + A.step_seq, + A.step_type, + A.task_id, + A.location_id, + A.task_data::JSONB, + A.arrival, + A.travel_time, + A.setup_time, + A.service_time, + A.waiting_time, + A.departure, + A.load FROM _vrp_vroom(_pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), _pgr_get_statement($4), _pgr_get_statement($5), _pgr_get_statement($6), _pgr_get_statement($7), _pgr_get_statement($8), exploration_level, - timeout, 0::SMALLINT, true); + timeout, 0::SMALLINT, true) A; END; $BODY$ LANGUAGE plpgsql VOLATILE; diff --git a/sql/vroom/vrp_vroomShipments.sql b/sql/vroom/vrp_vroomShipments.sql index dd75a0b80..17ab933a7 100644 --- a/sql/vroom/vrp_vroomShipments.sql +++ b/sql/vroom/vrp_vroomShipments.sql @@ -37,8 +37,8 @@ signature start Matrix SQL [, exploration_level] [, timeout]) -- Experimental on v0.2 RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) signature end @@ -52,8 +52,8 @@ default signature start Matrix SQL) RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) default signature end @@ -93,13 +93,18 @@ CREATE FUNCTION vrp_vroomShipments( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data JSONB, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data JSONB, OUT arrival TIMESTAMP, OUT travel_time INTERVAL, + OUT setup_time INTERVAL, OUT service_time INTERVAL, OUT waiting_time INTERVAL, + OUT departure TIMESTAMP, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ @@ -114,13 +119,18 @@ BEGIN A.seq, A.vehicle_seq, A.vehicle_id, + A.vehicle_data::JSONB, A.step_seq, A.step_type, A.task_id, + A.location_id, + A.task_data::JSONB, (to_timestamp(A.arrival) at time zone 'UTC')::TIMESTAMP, make_interval(secs => A.travel_time), + make_interval(secs => A.setup_time), make_interval(secs => A.service_time), make_interval(secs => A.waiting_time), + (to_timestamp(A.departure) at time zone 'UTC')::TIMESTAMP, A.load FROM _vrp_vroom(NULL, NULL, _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), diff --git a/sql/vroom/vrp_vroomShipmentsPlain.sql b/sql/vroom/vrp_vroomShipmentsPlain.sql index 1fd813bbf..126296127 100644 --- a/sql/vroom/vrp_vroomShipmentsPlain.sql +++ b/sql/vroom/vrp_vroomShipmentsPlain.sql @@ -37,8 +37,8 @@ signature start Matrix SQL [, exploration_level] [, timeout]) -- Experimental on v0.2 RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) signature end @@ -52,8 +52,8 @@ default signature start Matrix SQL) RETURNS SET OF - (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, - arrival, travel_time, service_time, waiting_time, load) + (seq, vehicle_seq, vehicle_id, vehicle_data, step_seq, step_type, task_id, + task_data, arrival, travel_time, service_time, waiting_time, departure, load) default signature end */ @@ -73,13 +73,18 @@ CREATE FUNCTION vrp_vroomShipmentsPlain( OUT seq BIGINT, OUT vehicle_seq BIGINT, OUT vehicle_id BIGINT, + OUT vehicle_data JSONB, OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, + OUT location_id BIGINT, + OUT task_data JSONB, OUT arrival INTEGER, OUT travel_time INTEGER, + OUT setup_time INTEGER, OUT service_time INTEGER, OUT waiting_time INTEGER, + OUT departure INTEGER, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ @@ -90,12 +95,28 @@ BEGIN END IF; RETURN QUERY - SELECT * + SELECT + A.seq, + A.vehicle_seq, + A.vehicle_id, + A.vehicle_data::JSONB, + A.step_seq, + A.step_type, + A.task_id, + A.location_id, + A.task_data::JSONB, + A.arrival, + A.travel_time, + A.setup_time, + A.service_time, + A.waiting_time, + A.departure, + A.load FROM _vrp_vroom(NULL, NULL, _pgr_get_statement($1), _pgr_get_statement($2), _pgr_get_statement($3), _pgr_get_statement($4), _pgr_get_statement($5), _pgr_get_statement($6), exploration_level, - timeout, 2::SMALLINT, true); + timeout, 2::SMALLINT, true) A; END; $BODY$ LANGUAGE plpgsql VOLATILE; diff --git a/src/common/get_check_data.c b/src/common/get_check_data.c index e984131c2..c7b4c52e8 100644 --- a/src/common/get_check_data.c +++ b/src/common/get_check_data.c @@ -69,6 +69,14 @@ check_text_type(Column_info_t info) { } } +static +void +check_jsonb_type(Column_info_t info) { + if (!(info.type == JSONBOID)) { + elog(ERROR, "Unexpected Column '%s' type. Expected JSONB %ld", info.name, info.type); + } +} + static void check_integer_type(Column_info_t info) { @@ -566,13 +574,13 @@ get_Id(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Id opt_value) { * @returns The value found * @returns opt_value when the column does not exist * - * exceptions when the value is negative - * @pre for non-negative values only + * exceptions when the value is not positive + * @pre for positive values only */ Idx get_Idx(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Idx opt_value) { Id value = get_Id(tuple, tupdesc, info, 0); - if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name); + if (value <= 0) elog(ERROR, "Unexpected Negative value or Zero in column %s", info.name); return column_found(info.colNumber)? (Idx) value : opt_value; } @@ -643,14 +651,14 @@ get_PositiveAmount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, PAm * @returns The value found * @returns opt_value when the column does not exist * - * exceptions when the value is negative - * @pre for non-negative values only + * exceptions when the value is not positive + * @pre for positive values only */ MatrixIndex get_MatrixIndex(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, MatrixIndex opt_value) { if (column_found(info.colNumber)) { int64_t value = spi_getBigInt(tuple, tupdesc, info); - if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name); + if (value <= 0) elog(ERROR, "Unexpected Negative value or Zero in column %s", info.name); return (MatrixIndex) value; } return opt_value; @@ -823,9 +831,6 @@ spi_getCoordinate(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Coor char* spi_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) { char *val = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber)); - if (!val) { - elog(ERROR, "Unexpected Null value in column %s", info.name); - } return val; } @@ -915,6 +920,9 @@ void pgr_fetch_column_info( case TEXT: check_text_type(info[i]); break; + case JSONB: + check_jsonb_type(info[i]); + break; case CHAR1: check_char_type(info[i]); break; diff --git a/src/common/vroom/breaks_input.c b/src/common/vroom/breaks_input.c index 7e7c61acb..bc53cbf1b 100644 --- a/src/common/vroom/breaks_input.c +++ b/src/common/vroom/breaks_input.c @@ -35,17 +35,19 @@ A ``SELECT`` statement that returns the following columns: :: - id, vehicle_id [, service] + id, vehicle_id [, service, data] ==================== ========================= =========== ================================================ Column Type Default Description ==================== ========================= =========== ================================================ -**id** ``ANY-INTEGER`` Non-negative unique identifier of the break. +**id** ``ANY-INTEGER`` Positive unique identifier of the break. (unique for the same vehicle). -**vehicle_id** ``ANY-INTEGER`` Non-negative unique identifier of the vehicle. +**vehicle_id** ``ANY-INTEGER`` Positive unique identifier of the vehicle. **service** |interval| |interval0| The break duration. + +**data** ``JSONB`` '{}'::JSONB Any metadata information of the break. ==================== ========================= =========== ================================================ .. vrp_vroom end @@ -66,6 +68,9 @@ void fetch_breaks( vroom_break->service = (Duration)get_PositiveTInterval(tuple, tupdesc, info[2], 0); } + vroom_break->data = column_found(info[3].colNumber) + ? spi_getText(tuple, tupdesc, info[3]) + : strdup("{}"); } @@ -157,7 +162,7 @@ get_vroom_breaks( Vroom_break_t **rows, size_t *total_rows, bool is_plain) { - int kColumnCount = 3; + int kColumnCount = 4; Column_info_t info[kColumnCount]; for (int i = 0; i < kColumnCount; ++i) { @@ -170,15 +175,18 @@ get_vroom_breaks( info[0].name = "id"; info[1].name = "vehicle_id"; info[2].name = "service"; + info[3].name = "data"; info[2].eType = INTEGER; // service + info[3].eType = JSONB; // data if (!is_plain) { info[2].eType = INTERVAL; // service } - /* service is not mandatory */ + /* service and data are not mandatory */ info[2].strict = false; + info[3].strict = false; db_get_breaks(sql, rows, total_rows, info, kColumnCount, is_plain); } diff --git a/src/common/vroom/jobs_input.c b/src/common/vroom/jobs_input.c index 00ca57a49..431676c57 100644 --- a/src/common/vroom/jobs_input.c +++ b/src/common/vroom/jobs_input.c @@ -36,15 +36,15 @@ A ``SELECT`` statement that returns the following columns: :: id, location_id - [, setup, service, delivery, pickup, skills, priority] + [, setup, service, delivery, pickup, skills, priority, data] ==================== ========================= =========== ================================================ Column Type Default Description ==================== ========================= =========== ================================================ -**id** ``ANY-INTEGER`` Non-negative unique identifier of the job. +**id** ``ANY-INTEGER`` Positive unique identifier of the job. -**location_id** ``ANY-INTEGER`` Non-negative identifier of the job location. +**location_id** ``ANY-INTEGER`` Positive identifier of the job location. **setup** |interval| |interval0| Job setup duration. @@ -70,6 +70,8 @@ Column Type Default Description **priority** ``INTEGER`` 0 Priority level of the job - Ranges from ``[0, 100]`` + +**data** ``JSONB`` '{}'::JSONB Any metadata information of the job. ==================== ========================= =========== ================================================ Where: @@ -119,6 +121,10 @@ void fetch_jobs( : NULL; job->priority = get_Priority(tuple, tupdesc, info[7], 0); + + job->data = column_found(info[8].colNumber) + ? spi_getText(tuple, tupdesc, info[8]) + : strdup("{}"); } @@ -209,7 +215,7 @@ get_vroom_jobs( Vroom_job_t **rows, size_t *total_rows, bool is_plain) { - int kColumnCount = 8; + int kColumnCount = 9; Column_info_t info[kColumnCount]; for (int i = 0; i < kColumnCount; ++i) { @@ -227,6 +233,7 @@ get_vroom_jobs( info[5].name = "pickup"; info[6].name = "skills"; info[7].name = "priority"; + info[8].name = "data"; info[2].eType = INTEGER; // setup info[3].eType = INTEGER; // service @@ -234,6 +241,7 @@ get_vroom_jobs( info[5].eType = ANY_INTEGER_ARRAY; // pickup info[6].eType = INTEGER_ARRAY; // skills info[7].eType = INTEGER; // priority + info[8].eType = JSONB; // data if (!is_plain) { info[2].eType = INTERVAL; // setup diff --git a/src/common/vroom/shipments_input.c b/src/common/vroom/shipments_input.c index d050fce4b..700e66e2c 100644 --- a/src/common/vroom/shipments_input.c +++ b/src/common/vroom/shipments_input.c @@ -35,22 +35,22 @@ A ``SELECT`` statement that returns the following columns: :: - id, p_location_id [, p_service], d_location_id [, d_service] - [, amount, skills, priority] + id, p_location_id [, p_setup, p_service], d_location_id [, d_setup, d_service] + [, amount, skills, priority, p_data, d_data] ====================== ========================= =========== ================================================ Column Type Default Description ====================== ========================= =========== ================================================ -**id** ``ANY-INTEGER`` Non-negative unique identifier of the shipment. +**id** ``ANY-INTEGER`` Positive unique identifier of the shipment. -**p_location_id** ``ANY-INTEGER`` Non-negative identifier of the pickup location. +**p_location_id** ``ANY-INTEGER`` Positive identifier of the pickup location. **p_setup** |interval| |interval0| Pickup setup duration. **p_service** |interval| |interval0| Pickup service duration. -**d_location_id** ``ANY-INTEGER`` Non-negative identifier of the delivery location. +**d_location_id** ``ANY-INTEGER`` Positive identifier of the delivery location. **d_setup** |interval| |interval0| Delivery setup duration. @@ -70,6 +70,9 @@ Column Type Default Description - Ranges from ``[0, 100]`` +**p_data** ``JSONB`` '{}'::JSONB Any metadata information of the pickup shipment. + +**d_data** ``JSONB`` '{}'::JSONB Any metadata information of the delivery shipment. ====================== ========================= =========== ================================================ Where: @@ -118,6 +121,13 @@ void fetch_shipments( : NULL; shipment->priority = get_Priority(tuple, tupdesc, info[9], 0); + + shipment->p_data = column_found(info[10].colNumber) + ? spi_getText(tuple, tupdesc, info[10]) + : strdup("{}"); + shipment->d_data = column_found(info[11].colNumber) + ? spi_getText(tuple, tupdesc, info[11]) + : strdup("{}"); } @@ -208,7 +218,7 @@ get_vroom_shipments( Vroom_shipment_t **rows, size_t *total_rows, bool is_plain) { - int kColumnCount = 10; + int kColumnCount = 12; Column_info_t info[kColumnCount]; for (int i = 0; i < kColumnCount; ++i) { @@ -233,6 +243,8 @@ get_vroom_shipments( info[7].name = "amount"; info[8].name = "skills"; info[9].name = "priority"; + info[10].name = "p_data"; + info[11].name = "d_data"; info[2].eType = INTEGER; // p_setup info[3].eType = INTEGER; // p_service @@ -241,6 +253,8 @@ get_vroom_shipments( info[7].eType = ANY_INTEGER_ARRAY; // amount info[8].eType = INTEGER_ARRAY; // skills info[9].eType = INTEGER; // priority + info[10].eType = JSONB; // p_data + info[11].eType = JSONB; // d_data if (!is_plain) { info[2].eType = INTERVAL; // p_setup diff --git a/src/common/vroom/time_windows_input.c b/src/common/vroom/time_windows_input.c index 50cf8a7e2..eba90acfa 100644 --- a/src/common/vroom/time_windows_input.c +++ b/src/common/vroom/time_windows_input.c @@ -40,7 +40,7 @@ A ``SELECT`` statement that returns the following columns: ==================== ====================================== ===================================================== Column Type Description ==================== ====================================== ===================================================== -**id** ``ANY-INTEGER`` Non-negative unique identifier of the job, +**id** ``ANY-INTEGER`` Positive unique identifier of the job, pickup/delivery shipment, or break. **kind** ``CHAR`` **Only required for shipments time windows**. diff --git a/src/common/vroom/vehicles_input.c b/src/common/vroom/vehicles_input.c index cf267b5e4..dd6affbf1 100644 --- a/src/common/vroom/vehicles_input.c +++ b/src/common/vroom/vehicles_input.c @@ -36,17 +36,17 @@ A ``SELECT`` statement that returns the following columns: :: id, start_id, end_id - [, capacity, skills, tw_open, tw_close, speed_factor, max_tasks] + [, capacity, skills, tw_open, tw_close, speed_factor, max_tasks, data] ====================== ======================== =================== ================================================ Column Type Default Description ====================== ======================== =================== ================================================ -**id** ``ANY-INTEGER`` Non-negative unique identifier of the vehicle. +**id** ``ANY-INTEGER`` Positive unique identifier of the vehicle. -**start_id** ``ANY-INTEGER`` Non-negative identifier of the vehicle start location. +**start_id** ``ANY-INTEGER`` Positive identifier of the vehicle start location. -**end_id** ``ANY-INTEGER`` Non-negative identifier of the vehicle end location. +**end_id** ``ANY-INTEGER`` Positive identifier of the vehicle end location. **capacity** ``ARRAY[ANY-INTEGER]`` Empty Array Array of non-negative integers describing multidimensional quantities such as @@ -70,6 +70,8 @@ Column Type Default Description **max_tasks** ``INTEGER`` :math:`2147483647` Maximum number of tasks in a route for the vehicle. - A job, pickup, or delivery is counted as a single task. + +**data** ``JSONB`` '{}'::JSONB Any metadata information of the vehicle. ====================== ======================== =================== ================================================ **Note**: @@ -137,6 +139,10 @@ void fetch_vehicles( vehicle->max_tasks = column_found(info[8].colNumber) ? spi_getMaxTasks(tuple, tupdesc, info[8]) : INT_MAX; // 2147483647 + + vehicle->data = column_found(info[9].colNumber) + ? spi_getText(tuple, tupdesc, info[9]) + : strdup("{}"); } @@ -233,7 +239,7 @@ get_vroom_vehicles( Vroom_vehicle_t **rows, size_t *total_rows, bool is_plain) { - int kColumnCount = 9; + int kColumnCount = 10; Column_info_t info[kColumnCount]; for (int i = 0; i < kColumnCount; ++i) { @@ -252,6 +258,7 @@ get_vroom_vehicles( info[6].name = "tw_close"; info[7].name = "speed_factor"; info[8].name = "max_tasks"; + info[9].name = "data"; info[3].eType = ANY_INTEGER_ARRAY; // capacity info[4].eType = INTEGER_ARRAY; // skills @@ -259,6 +266,7 @@ get_vroom_vehicles( info[6].eType = INTEGER; // tw_close info[7].eType = ANY_NUMERICAL; // speed_factor info[8].eType = INTEGER; // max_tasks + info[9].eType = JSONB; // data if (!is_plain) { info[5].eType = TIMESTAMP; // tw_open diff --git a/src/cpp_common/base_matrix.cpp b/src/cpp_common/base_matrix.cpp index a9fe367cd..504b1e895 100644 --- a/src/cpp_common/base_matrix.cpp +++ b/src/cpp_common/base_matrix.cpp @@ -177,6 +177,47 @@ Base_Matrix::get_index(Id id) const { return static_cast(pos - m_ids.begin()); } +/** Given the internal index, returns the original node identifier + * + * @param [in] id + * @returns the original node identifier + * + @dot + digraph G { + graph [ranksep=".05"]; + node[fontsize=10, nodesep=0.2]; + start [shape=Mdiamond]; + n0 [label="Base_Matrix::get_original_id",shape=rect, color=green]; + n1 [label="Go to the index in the identifiers vector",shape=rect]; + n2 [label="Return the original id found",shape=rect]; + start -> n0 -> n1 -> n2 -> end; + end [shape=Mdiamond]; + error [shape=Mdiamond,color=red] + a [label="assertion",color=red]; + a -> error [color=red,label="fail",fontcolor=red]; + } + @enddot + */ +Id +Base_Matrix::get_original_id(Idx index) const { + /* + * Go to the index in the identifiers vector + */ + + if (index >= m_ids.size()) { + std::ostringstream msg; + msg << *this << "\nOut of range" << index; + pgassertwm(false, msg.str()); + throw std::make_pair(std::string("(INTERNAL) Base_Matrix: The given index is out of range"), msg.str()); + } + pgassert(index < m_ids.size()); + + /* + * return the original id found + */ + return static_cast(m_ids[index]); +} + /** * @param [in] data_costs The set of costs * @param [in] size_matrix The size of the set of costs diff --git a/src/vroom/vroom.c b/src/vroom/vroom.c index a1adef61c..9d3b242e7 100644 --- a/src/vroom/vroom.c +++ b/src/vroom/vroom.c @@ -367,23 +367,7 @@ PGDLLEXPORT Datum _vrp_vroom(PG_FUNCTION_ARGS) { int16 typlen; size_t call_cntr = funcctx->call_cntr; - /*********************************************************************** - * - * OUT seq BIGINT, - * OUT vehicles_seq BIGINT, - * OUT vehicles_id BIGINT, - * OUT step_seq BIGINT, - * OUT step_type INTEGER, - * OUT task_id BIGINT, - * OUT arrival INTEGER, - * OUT duration INTEGER, - * OUT service_time INTEGER, - * OUT waiting_time INTEGER, - * OUT load BIGINT - * - **********************************************************************/ - - size_t num = 11; + size_t num = 16; values = palloc(num * sizeof(Datum)); nulls = palloc(num * sizeof(bool)); @@ -423,19 +407,24 @@ PGDLLEXPORT Datum _vrp_vroom(PG_FUNCTION_ARGS) { int attdim ) */ - TupleDescInitEntry(tuple_desc, (AttrNumber) 11, "load", INT8ARRAYOID, -1, 0); + TupleDescInitEntry(tuple_desc, (AttrNumber) 16, "load", INT8ARRAYOID, -1, 0); values[0] = Int64GetDatum(funcctx->call_cntr + 1); - values[1] = Int32GetDatum(result_tuples[call_cntr].vehicle_seq); - values[2] = Int32GetDatum(result_tuples[call_cntr].vehicle_id); - values[3] = Int32GetDatum(result_tuples[call_cntr].step_seq); - values[4] = Int32GetDatum(result_tuples[call_cntr].step_type); - values[5] = Int32GetDatum(result_tuples[call_cntr].task_id); - values[6] = Int32GetDatum(result_tuples[call_cntr].arrival_time); - values[7] = Int32GetDatum(result_tuples[call_cntr].travel_time); - values[8] = Int32GetDatum(result_tuples[call_cntr].service_time); - values[9] = Int32GetDatum(result_tuples[call_cntr].waiting_time); - values[10] = PointerGetDatum(arrayType); + values[1] = Int64GetDatum(result_tuples[call_cntr].vehicle_seq); + values[2] = Int64GetDatum(result_tuples[call_cntr].vehicle_id); + values[3] = CStringGetTextDatum(result_tuples[call_cntr].vehicle_data); + values[4] = Int64GetDatum(result_tuples[call_cntr].step_seq); + values[5] = Int32GetDatum(result_tuples[call_cntr].step_type); + values[6] = Int64GetDatum(result_tuples[call_cntr].task_id); + values[7] = Int64GetDatum(result_tuples[call_cntr].location_id); + values[8] = CStringGetTextDatum(result_tuples[call_cntr].task_data); + values[9] = Int32GetDatum(result_tuples[call_cntr].arrival_time); + values[10] = Int32GetDatum(result_tuples[call_cntr].travel_time); + values[11] = Int32GetDatum(result_tuples[call_cntr].setup_time); + values[12] = Int32GetDatum(result_tuples[call_cntr].service_time); + values[13] = Int32GetDatum(result_tuples[call_cntr].waiting_time); + values[14] = Int32GetDatum(result_tuples[call_cntr].departure_time); + values[15] = PointerGetDatum(arrayType); /**********************************************************************/ diff --git a/tools/scripts/notes2news.pl b/tools/scripts/notes2news.pl index 2021320a7..3daf82922 100755 --- a/tools/scripts/notes2news.pl +++ b/tools/scripts/notes2news.pl @@ -26,10 +26,11 @@ sub Usage { } # convert urls to markdown - $line =~ s/`([^<]+)<([^>]+)>`_/\[$1\]($2)/g; + $line =~ s/`([^<]+?)\s*<([^>]+)>`__/\[$1\]($2)/g; + $line =~ s/`([^<]+?)\s*<([^>]+)>`_/\[$1\]($2)/g; # convert rubric to bold - $line =~ s/^\.\. rubric::\s*(.+)$/*$1*/; + $line =~ s/^\.\. rubric::\s*(.+)$/**$1**/; print $ofh $line; }