From e7e0398707bf8713ebdf76b5c9d89b8526c3eb85 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:55:47 +0530 Subject: [PATCH 01/13] [vroom][sql] Change vroom -> vroomPlain --- sql/sigs/vrprouting--0.2.sig | 6 +- sql/vroom/CMakeLists.txt | 6 +- sql/vroom/vrp_vroomJobsPlain.sql | 117 ++++++++++++++++++ sql/vroom/vrp_vroomPlain.sql | 170 ++++++++++++++++++++++++++ sql/vroom/vrp_vroomShipmentsPlain.sql | 119 ++++++++++++++++++ 5 files changed, 412 insertions(+), 6 deletions(-) create mode 100644 sql/vroom/vrp_vroomJobsPlain.sql create mode 100644 sql/vroom/vrp_vroomPlain.sql create mode 100644 sql/vroom/vrp_vroomShipmentsPlain.sql diff --git a/sql/sigs/vrprouting--0.2.sig b/sql/sigs/vrprouting--0.2.sig index 0d35746a9..7ba00d929 100644 --- a/sql/sigs/vrprouting--0.2.sig +++ b/sql/sigs/vrprouting--0.2.sig @@ -32,7 +32,7 @@ _vrp_vehiclesattime(text,timestamp without time zone,boolean) vrp_version() vrp_viewrouteraw(text,text,text,text,bigint,double precision) vrp_viewroute(text,text,text,text,bigint,double precision) -vrp_vroomjobs(text,text,text,text,text,text) -vrp_vroomshipments(text,text,text,text,text,text) -vrp_vroom(text,text,text,text,text,text,text,text) +vrp_vroomjobsplain(text,text,text,text,text,text) +vrp_vroomplain(text,text,text,text,text,text,text,text) +vrp_vroomshipmentsplain(text,text,text,text,text,text) _vrp_vroom(text,text,text,text,text,text,text,text,smallint) diff --git a/sql/vroom/CMakeLists.txt b/sql/vroom/CMakeLists.txt index d50610ef3..ce3887953 100644 --- a/sql/vroom/CMakeLists.txt +++ b/sql/vroom/CMakeLists.txt @@ -1,8 +1,8 @@ SET(LOCAL_FILES _vrp_vroom.sql - vrp_vroom.sql - vrp_vroomJobs.sql - vrp_vroomShipments.sql + vrp_vroomPlain.sql + vrp_vroomJobsPlain.sql + vrp_vroomShipmentsPlain.sql ) foreach (f ${LOCAL_FILES}) diff --git a/sql/vroom/vrp_vroomJobsPlain.sql b/sql/vroom/vrp_vroomJobsPlain.sql new file mode 100644 index 000000000..cf6e00806 --- /dev/null +++ b/sql/vroom/vrp_vroomJobsPlain.sql @@ -0,0 +1,117 @@ +/*PGR-GNU***************************************************************** +File: vrp_vroomJobsPlain.sql + +Copyright (c) 2021 pgRouting developers +Mail: project@pgrouting.org + +Function's developer: +Copyright (c) 2021 Ashish Kumar +Mail: ashishkr23438@gmail.com + +------ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + ********************************************************************PGR-GNU*/ + +/* +signature start + +.. code-block:: none + + vrp_vroomJobsPlain( + Jobs SQL, Jobs Time Windows SQL, + Vehicles SQL, Breaks SQL, Breaks Time Windows SQL, + Matrix SQL) -- 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) + +signature end + +parameters start + +============================== =========== ========================================================= +Parameter Type Description +============================== =========== ========================================================= +**Jobs SQL** ``TEXT`` `Jobs SQL`_ query describing the single-location + pickup and/or delivery tasks. +**Jobs Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots + for job service start. +**Vehicles SQL** ``TEXT`` `Vehicles SQL`_ query describing the available vehicles. +**Breaks SQL** ``TEXT`` `Breaks SQL`_ query describing the driver breaks. +**Breaks Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots for + break start. +**Matrix SQL** ``TEXT`` `Time Matrix SQL`_ query containing the distance or + travel times between the locations. +============================== =========== ========================================================= + +parameters end + +*/ + +-- v0.2 +CREATE FUNCTION vrp_vroomJobsPlain( + TEXT, -- jobs_sql (required) + TEXT, -- jobs_time_windows_sql (required) + TEXT, -- vehicles_sql (required) + TEXT, -- breaks_sql (required) + TEXT, -- breaks_time_windows_sql (required) + TEXT, -- matrix_sql (required) + + OUT seq BIGINT, + OUT vehicle_seq BIGINT, + OUT vehicle_id BIGINT, + OUT step_seq BIGINT, + OUT step_type INTEGER, + OUT task_id BIGINT, + OUT arrival INTEGER, + OUT travel_time INTEGER, + OUT service_time INTEGER, + OUT waiting_time INTEGER, + OUT load BIGINT[]) +RETURNS SETOF RECORD AS +$BODY$ + SELECT * + 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), 1::SMALLINT); +$BODY$ +LANGUAGE SQL VOLATILE; + + +-- COMMENTS + +COMMENT ON FUNCTION vrp_vroomJobsPlain(TEXT, TEXT, TEXT, TEXT, TEXT, TEXT) +IS 'vrp_vroomJobsPlain + - EXPERIMENTAL + - Parameters: + - Jobs SQL with columns: + id, location_index [, service, delivery, pickup, skills, priority, time_windows] + - Jobs Time Windows SQL with columns: + id, tw_open, tw_close + - Vehicles SQL with columns: + id, start_index, end_index + [, service, delivery, pickup, skills, priority, time_window, breaks_sql, steps_sql] + - Breaks SQL with columns: + id [, service] + - Breaks Time Windows SQL with columns: + id, tw_open, tw_close + - Matrix SQL with columns: + start_vid, end_vid, agg_cost + - Documentation: + - ${PROJECT_DOC_LINK}/vrp_vroomJobsPlain.html +'; diff --git a/sql/vroom/vrp_vroomPlain.sql b/sql/vroom/vrp_vroomPlain.sql new file mode 100644 index 000000000..ec70943ed --- /dev/null +++ b/sql/vroom/vrp_vroomPlain.sql @@ -0,0 +1,170 @@ +/*PGR-GNU***************************************************************** +File: vrp_vroomPlain.sql + +Copyright (c) 2021 pgRouting developers +Mail: project@pgrouting.org + +Function's developer: +Copyright (c) 2021 Ashish Kumar +Mail: ashishkr23438@gmail.com + +------ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + ********************************************************************PGR-GNU*/ + +/* +signature start + +.. code-block:: none + + vrp_vroomPlain( + Jobs SQL, Jobs Time Windows SQL, + Shipments SQL, Shipments Time Windows SQL, + Vehicles SQL, Breaks SQL, Breaks Time Windows SQL, + Matrix SQL) -- 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) + +signature end + +parameters start + +============================== =========== ========================================================= +Parameter Type Description +============================== =========== ========================================================= +**Jobs SQL** ``TEXT`` `Jobs SQL`_ query describing the single-location + pickup and/or delivery tasks. +**Jobs Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots + for job service start. +**Shipments SQL** ``TEXT`` `Shipments SQL`_ query describing pickup and delivery + tasks that should happen within same route. +**Shipments Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots + for pickup and delivery service start. +**Vehicles SQL** ``TEXT`` `Vehicles SQL`_ query describing the available vehicles. +**Breaks SQL** ``TEXT`` `Breaks SQL`_ query describing the driver breaks. +**Breaks Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots for + break start. +**Matrix SQL** ``TEXT`` `Time Matrix SQL`_ query containing the distance or + travel times between the locations. +============================== =========== ========================================================= + +parameters end + +result start + +=================== ============= ================================================= +Column Type Description +=================== ============= ================================================= +**seq** ``BIGINT`` Sequential value starting from **1**. + +**vehicle_seq** ``BIGINT`` Sequential value starting from **1** for current vehicles. + The :math:`n^{th}` vehicle in the solution. + +**vehicle_id** ``BIGINT`` Current vehicle identifier. + +**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. + +**step_type** ``INTEGER`` Kind of the step location the vehicle is at: + + - ``1``: Starting location + - ``2``: Job location + - ``3``: Pickup location + - ``4``: Delivery location + - ``5``: Break location + - ``6``: Ending location + +**task_id** ``BIGINT`` Identifier of the task performed at this step. + + - ``-1``: If the step is starting/ending location. + +**arrival** ``INTEGER`` Estimated time of arrival at this step, in seconds. + +**travel_time** ``INTEGER`` Cumulated travel time upon arrival at this step, in seconds + +**service_time** ``INTEGER`` Service time at this step, in seconds + +**waiting_time** ``INTEGER`` Waiting time upon arrival at this step, in seconds. + +**load** ``BIGINT`` Vehicle load after step completion (with capacity constraints) +=================== ============= ================================================= + +result end +*/ + +-- v0.2 +CREATE FUNCTION vrp_vroomPlain( + TEXT, -- jobs_sql (required) + TEXT, -- jobs_time_windows_sql (required) + TEXT, -- shipments_sql (required) + TEXT, -- shipments_time_windows_sql (required) + TEXT, -- vehicles_sql (required) + TEXT, -- breaks_sql (required) + TEXT, -- breaks_time_windows_sql (required) + TEXT, -- matrix_sql (required) + + OUT seq BIGINT, + OUT vehicle_seq BIGINT, + OUT vehicle_id BIGINT, + OUT step_seq BIGINT, + OUT step_type INTEGER, + OUT task_id BIGINT, + OUT arrival INTEGER, + OUT travel_time INTEGER, + OUT service_time INTEGER, + OUT waiting_time INTEGER, + OUT load BIGINT[]) +RETURNS SETOF RECORD AS +$BODY$ + SELECT * + 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), 0::SMALLINT); +$BODY$ +LANGUAGE SQL VOLATILE; + + +-- COMMENTS + +COMMENT ON FUNCTION vrp_vroomPlain(TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT) +IS 'vrp_vroomPlain + - EXPERIMENTAL + - Parameters: + - Jobs SQL with columns: + id, location_index [, service, delivery, pickup, skills, priority, time_windows] + - Jobs Time Windows SQL with columns: + id, tw_open, tw_close + - Shipments SQL with columns: + p_id, p_location_index [, p_service, p_time_windows], + d_id, d_location_index [, d_service, d_time_windows] [, amount, skills, priority] + - Shipments Time Windows SQL with columns: + id, kind, tw_open, tw_close + - Vehicles SQL with columns: + id, start_index, end_index + [, service, delivery, pickup, skills, priority, time_window, breaks_sql, steps_sql] + - Breaks SQL with columns: + id [, service] + - Breaks Time Windows SQL with columns: + id, tw_open, tw_close + - Matrix SQL with columns: + start_vid, end_vid, agg_cost + - Documentation: + - ${PROJECT_DOC_LINK}/vrp_vroomPlain.html +'; diff --git a/sql/vroom/vrp_vroomShipmentsPlain.sql b/sql/vroom/vrp_vroomShipmentsPlain.sql new file mode 100644 index 000000000..9b2e1f8da --- /dev/null +++ b/sql/vroom/vrp_vroomShipmentsPlain.sql @@ -0,0 +1,119 @@ +/*PGR-GNU***************************************************************** +File: vrp_vroomShipmentsPlain.sql + +Copyright (c) 2021 pgRouting developers +Mail: project@pgrouting.org + +Function's developer: +Copyright (c) 2021 Ashish Kumar +Mail: ashishkr23438@gmail.com + +------ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + ********************************************************************PGR-GNU*/ + +/* +signature start + +.. code-block:: none + + vrp_vroomShipmentsPlain( + Shipments SQL, Shipments Time Windows SQL, + Vehicles SQL, Breaks SQL, Breaks Time Windows SQL, + Matrix SQL) -- 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) + +signature end + +parameters start + +============================== =========== ========================================================= +Parameter Type Description +============================== =========== ========================================================= +**Shipments SQL** ``TEXT`` `Shipments SQL`_ query describing pickup and delivery + tasks that should happen within same route. +**Shipments Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots + for pickup and delivery service start. +**Vehicles SQL** ``TEXT`` `Vehicles SQL`_ query describing the available vehicles. +**Breaks SQL** ``TEXT`` `Breaks SQL`_ query describing the driver breaks. +**Breaks Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots for + break start. +**Matrix SQL** ``TEXT`` `Time Matrix SQL`_ query containing the distance or + travel times between the locations. +============================== =========== ========================================================= + +parameters end + +*/ + +-- v0.2 +CREATE FUNCTION vrp_vroomShipmentsPlain( + TEXT, -- shipments_sql (required) + TEXT, -- shipments_time_windows_sql (required) + TEXT, -- vehicles_sql (required) + TEXT, -- breaks_sql (required) + TEXT, -- breaks_time_windows_sql (required) + TEXT, -- matrix_sql (required) + + OUT seq BIGINT, + OUT vehicle_seq BIGINT, + OUT vehicle_id BIGINT, + OUT step_seq BIGINT, + OUT step_type INTEGER, + OUT task_id BIGINT, + OUT arrival INTEGER, + OUT travel_time INTEGER, + OUT service_time INTEGER, + OUT waiting_time INTEGER, + OUT load BIGINT[]) +RETURNS SETOF RECORD AS +$BODY$ + SELECT * + 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), 2::SMALLINT); +$BODY$ +LANGUAGE SQL VOLATILE; + + +-- COMMENTS + +COMMENT ON FUNCTION vrp_vroomShipmentsPlain(TEXT, TEXT, TEXT, TEXT, TEXT, TEXT) +IS 'vrp_vroomShipmentsPlain + - EXPERIMENTAL + - Parameters: + - Shipments SQL with columns: + p_id, p_location_index [, p_service, p_time_windows], + d_id, d_location_index [, d_service, d_time_windows] [, amount, skills, priority] + - Shipments Time Windows SQL with columns: + id, kind, tw_open, tw_close + - Vehicles SQL with columns: + id, start_index, end_index + [, service, delivery, pickup, skills, priority, time_window, breaks_sql, steps_sql] + - Breaks SQL with columns: + id [, service] + - Breaks Time Windows SQL with columns: + id, tw_open, tw_close + - Matrix SQL with columns: + start_vid, end_vid, agg_cost + - Documentation: + - ${PROJECT_DOC_LINK}/vrp_vroomShipmentsPlain.html +'; From 7328b0e3ca6db5f50a31b7ec1f04d8eabf5742e0 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:56:19 +0530 Subject: [PATCH 02/13] [vroom][pgtap] Change vroom -> vroomPlain --- pgtap/vroom/edge_cases.sql | 78 ++++++++++---------- pgtap/vroom/inner_query.sql | 14 ++-- pgtap/vroom/no_crash_test.sql | 6 +- pgtap/vroom/types_check.sql | 36 ++++----- pgtap/vroom/vroomJobs-eq-vroom.test.sql | 16 ++-- pgtap/vroom/vroomShipments-eq-vroom.test.sql | 16 ++-- 6 files changed, 83 insertions(+), 83 deletions(-) diff --git a/pgtap/vroom/edge_cases.sql b/pgtap/vroom/edge_cases.sql index 39bb24f3f..8a3af4711 100644 --- a/pgtap/vroom/edge_cases.sql +++ b/pgtap/vroom/edge_cases.sql @@ -44,7 +44,7 @@ BEGIN PREPARE empty_matrix AS SELECT * FROM matrix WHERE start_vid = -1; PREPARE vroom_sql AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -59,7 +59,7 @@ BEGIN -- tests for no jobs/shipments, no vehicles, or no matrix PREPARE no_jobs_and_shipments AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'empty_jobs', 'jobs_time_windows', 'empty_shipments', @@ -73,7 +73,7 @@ BEGIN SELECT is_empty('no_jobs_and_shipments', 'Problem with no jobs and shipments'); PREPARE no_vehicles AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -87,7 +87,7 @@ BEGIN SELECT is_empty('no_vehicles', 'Problem with no vehicles'); PREPARE no_matrix AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -104,7 +104,7 @@ BEGIN -- priority range test (jobs) PREPARE jobs_neg_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT id, location_index, service, delivery, pickup, skills, -1 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -123,7 +123,7 @@ BEGIN ); PREPARE jobs_101_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT id, location_index, service, delivery, pickup, skills, 101 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -142,7 +142,7 @@ BEGIN ); PREPARE jobs_zero_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT id, location_index, service, delivery, pickup, skills, 0 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -156,7 +156,7 @@ BEGIN SELECT lives_ok('jobs_zero_priority', 'Problem with 0 priority jobs'); PREPARE jobs_100_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT id, location_index, service, delivery, pickup, skills, 0 AS priority FROM jobs', 'jobs_time_windows', 'shipments', @@ -173,7 +173,7 @@ BEGIN -- priority range tests (shipments) PREPARE shipments_neg_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_index, p_service, d_location_index, d_service, @@ -193,7 +193,7 @@ BEGIN ); PREPARE shipments_101_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_index, p_service, d_location_index, d_service, @@ -213,7 +213,7 @@ BEGIN ); PREPARE shipments_zero_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_index, p_service, d_location_index, d_service, @@ -228,7 +228,7 @@ BEGIN SELECT lives_ok('shipments_zero_priority', 'Problem with 0 priority shipments'); PREPARE shipments_100_priority AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'SELECT id, p_location_index, p_service, d_location_index, d_service, @@ -246,7 +246,7 @@ BEGIN -- Missing id on matrix test PREPARE missing_id_on_matrix AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -265,7 +265,7 @@ BEGIN ); PREPARE missing_same_vid_on_matrix AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -279,7 +279,7 @@ 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_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -299,7 +299,7 @@ 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_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_equal_tw', 'shipments', @@ -313,7 +313,7 @@ BEGIN SELECT lives_ok('jobs_equal_tw_problem', 'Problem with jobs having equal time windows'); PREPARE jobs_invalid_tw_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_invalid_tw', 'shipments', @@ -338,7 +338,7 @@ 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_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -352,7 +352,7 @@ BEGIN SELECT lives_ok('shipments_equal_tw_problem', 'Problem with shipments having equal time windows'); PREPARE shipments_invalid_tw_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -377,7 +377,7 @@ 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_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -391,7 +391,7 @@ BEGIN SELECT lives_ok('breaks_equal_tw_problem', 'Problem with breaks having equal time windows'); PREPARE breaks_invalid_tw_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -418,7 +418,7 @@ BEGIN SELECT id, start_index, end_index, capacity, skills, 3001 AS tw_open, 3000 AS tw_close, speed_factor FROM vehicles; PREPARE vehicles_equal_tw_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -432,7 +432,7 @@ BEGIN SELECT lives_ok('vehicles_equal_tw_problem', 'Problem with vehicles having equal time windows'); PREPARE vehicles_invalid_tw_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -456,7 +456,7 @@ BEGIN PREPARE jobs_only_delivery AS SELECT id, location_index, service, delivery, skills, priority FROM jobs; PREPARE jobs_only_pickup AS SELECT id, location_index, service, pickup, skills, priority FROM jobs; PREPARE jobs_only_delivery_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs_only_delivery', 'jobs_time_windows', 'shipments', @@ -467,7 +467,7 @@ BEGIN 'matrix' ); PREPARE jobs_only_pickup_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs_only_pickup', 'jobs_time_windows', 'shipments', @@ -486,7 +486,7 @@ BEGIN PREPARE vehicles_only_start_index AS SELECT id, start_index, capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE vehicles_only_end_index AS SELECT id, end_index, capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE vehicles_only_start_index_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -497,7 +497,7 @@ BEGIN 'matrix' ); PREPARE vehicles_only_end_index_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -515,7 +515,7 @@ 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_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -546,7 +546,7 @@ BEGIN SELECT id, start_index, end_index, ARRAY[10, 20]::BIGINT[] AS capacity, skills, tw_open, tw_close, speed_factor FROM vehicles; PREPARE jobs_inconsistent_delivery_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs_inconsistent_delivery', 'jobs_time_windows', 'shipments', @@ -557,7 +557,7 @@ BEGIN 'matrix' ); PREPARE jobs_inconsistent_pickup_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs_inconsistent_pickup', 'jobs_time_windows', 'shipments', @@ -568,7 +568,7 @@ BEGIN 'matrix' ); PREPARE shipments_inconsistent_amount_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments_inconsistent_amount', @@ -579,7 +579,7 @@ BEGIN 'matrix' ); PREPARE vehicles_inconsistent_capacity_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -639,7 +639,7 @@ BEGIN SELECT start_vid, end_vid, 4 * agg_cost AS agg_cost FROM matrix; PREPARE vehicles_2x_speed_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -650,7 +650,7 @@ BEGIN 'matrix_2x_distance' ); PREPARE vehicles_4x_speed_problem AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'jobs', 'jobs_time_windows', 'shipments', @@ -673,7 +673,7 @@ BEGIN -- arrival, travel_time, service_time, waiting_time, load PREPARE one_job_q1 AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT * FROM jobs WHERE id = 1', 'jobs_time_windows', 'empty_shipments', @@ -696,7 +696,7 @@ BEGIN ); PREPARE one_job_q2 AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT * FROM jobs WHERE id = 5', 'jobs_time_windows', 'empty_shipments', @@ -719,7 +719,7 @@ BEGIN ); PREPARE one_shipment_q1 AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'empty_jobs', 'jobs_time_windows', 'SELECT * FROM shipments WHERE id = 1', @@ -743,7 +743,7 @@ BEGIN ); PREPARE one_shipment_q2 AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'empty_jobs', 'jobs_time_windows', 'SELECT * FROM shipments WHERE id = 5', @@ -767,7 +767,7 @@ BEGIN ); PREPARE one_job_shipment AS - SELECT * FROM vrp_vroom( + SELECT * FROM vrp_vroomPlain( 'SELECT * FROM jobs WHERE id = 2', 'jobs_time_windows', 'SELECT * FROM shipments WHERE id = 2', diff --git a/pgtap/vroom/inner_query.sql b/pgtap/vroom/inner_query.sql index a94be6995..3e4d335d4 100644 --- a/pgtap/vroom/inner_query.sql +++ b/pgtap/vroom/inner_query.sql @@ -4,7 +4,7 @@ SET search_path TO 'vroom', 'public'; SELECT CASE WHEN min_version('0.2.0') THEN plan (564) ELSE plan(1) END; /* -SELECT * FROM vrp_vroom( +SELECT * FROM vrp_vroomPlain( $$SELECT id, location_index, service, delivery, pickup, skills, priority FROM jobs$$, $$SELECT id, tw_open, tw_close FROM jobs_time_windows$$, $$SELECT id, p_location_index, p_service, d_location_index, d_service, amount, skills, priority FROM shipments$$, @@ -255,9 +255,9 @@ BEGIN RETURN; END IF; - -- vrp_vroom + -- vrp_vroomPlain - fn := 'vrp_vroom'; + fn := 'vrp_vroomPlain'; start_sql := ''; rest_sql := ', $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || @@ -308,9 +308,9 @@ BEGIN RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql); - -- vrp_vroomJobs + -- vrp_vroomJobsPlain - fn := 'vrp_vroomJobs'; + fn := 'vrp_vroomJobsPlain'; start_sql := ''; rest_sql := ', $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; @@ -344,9 +344,9 @@ BEGIN RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql); - -- vrp_vroomShipments + -- vrp_vroomShipmentsPlain - fn := 'vrp_vroomShipments'; + fn := 'vrp_vroomShipmentsPlain'; start_sql := ''; rest_sql := ', $$SELECT * FROM shipments_time_windows$$, $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; diff --git a/pgtap/vroom/no_crash_test.sql b/pgtap/vroom/no_crash_test.sql index f9e779b5a..5ee488c79 100644 --- a/pgtap/vroom/no_crash_test.sql +++ b/pgtap/vroom/no_crash_test.sql @@ -77,7 +77,7 @@ BEGIN ]::TEXT[]; non_empty_args = ARRAY[0, 1, 2, 3, 4, 6, 7]::INTEGER[]; - RETURN query SELECT * FROM no_crash_test('vrp_vroom', params, subs, error_messages, non_empty_args); + RETURN query SELECT * FROM no_crash_test('vrp_vroomPlain', params, subs, error_messages, non_empty_args); params = ARRAY[ '$$jobs$$', @@ -105,7 +105,7 @@ BEGIN ]::TEXT[]; non_empty_args = ARRAY[0, 2, 4, 5]::INTEGER[]; - RETURN query SELECT * FROM no_crash_test('vrp_vroomJobs', params, subs, error_messages, non_empty_args); + RETURN query SELECT * FROM no_crash_test('vrp_vroomJobsPlain', params, subs, error_messages, non_empty_args); params = ARRAY[ '$$shipments$$', @@ -133,7 +133,7 @@ BEGIN ]::TEXT[]; non_empty_args = ARRAY[0, 2, 4, 5]::INTEGER[]; - RETURN query SELECT * FROM no_crash_test('vrp_vroomShipments'::TEXT, params, subs, error_messages, non_empty_args); + RETURN query SELECT * FROM no_crash_test('vrp_vroomShipmentsPlain'::TEXT, params, subs, error_messages, non_empty_args); END $BODY$ diff --git a/pgtap/vroom/types_check.sql b/pgtap/vroom/types_check.sql index 336e22672..7236c4efd 100644 --- a/pgtap/vroom/types_check.sql +++ b/pgtap/vroom/types_check.sql @@ -14,18 +14,18 @@ BEGIN RETURN; END IF; - -- vrp_vroom + -- vrp_vroomPlain RETURN QUERY - SELECT has_function('vrp_vroom'); + SELECT has_function('vrp_vroomplain'); RETURN QUERY - SELECT has_function('vrp_vroom', ARRAY['text', 'text', 'text', 'text', 'text', 'text', 'text', 'text']); + SELECT has_function('vrp_vroomplain', ARRAY['text', 'text', 'text', 'text', 'text', 'text', 'text', 'text']); RETURN QUERY - SELECT function_returns('vrp_vroom', ARRAY['text', 'text', 'text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); + SELECT function_returns('vrp_vroomplain', ARRAY['text', 'text', 'text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); -- parameter names RETURN QUERY SELECT bag_has( - $$SELECT proargnames from pg_proc where proname = 'vrp_vroom'$$, + $$SELECT proargnames from pg_proc where proname = 'vrp_vroomplain'$$, $$SELECT '{"","","","","","","","","seq","vehicle_seq","vehicle_id","step_seq","step_type",' '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ ); @@ -33,25 +33,25 @@ BEGIN -- parameter types RETURN QUERY SELECT set_eq( - $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroom'$$, + $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomplain'$$, $$VALUES ('{25,25,25,25,25,25,25,25,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) $$ ); - -- vrp_vroomJobs + -- vrp_vroomJobsPlain RETURN QUERY - SELECT has_function('vrp_vroomjobs'); + SELECT has_function('vrp_vroomjobsplain'); RETURN QUERY - SELECT has_function('vrp_vroomjobs', ARRAY['text', 'text', 'text', 'text', 'text', 'text']); + SELECT has_function('vrp_vroomjobsplain', ARRAY['text', 'text', 'text', 'text', 'text', 'text']); RETURN QUERY - SELECT function_returns('vrp_vroomjobs', ARRAY['text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); + SELECT function_returns('vrp_vroomjobsplain', ARRAY['text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); -- parameter names RETURN QUERY SELECT bag_has( - $$SELECT proargnames from pg_proc where proname = 'vrp_vroomjobs'$$, + $$SELECT proargnames from pg_proc where proname = 'vrp_vroomjobsplain'$$, $$SELECT '{"","","","","","","seq","vehicle_seq","vehicle_id","step_seq","step_type",' '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ ); @@ -59,25 +59,25 @@ BEGIN -- parameter types RETURN QUERY SELECT set_eq( - $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomjobs'$$, + $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomjobsplain'$$, $$VALUES ('{25,25,25,25,25,25,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) $$ ); - -- vrp_vroomShipments + -- vrp_vroomShipmentsPlain RETURN QUERY - SELECT has_function('vrp_vroomshipments'); + SELECT has_function('vrp_vroomshipmentsplain'); RETURN QUERY - SELECT has_function('vrp_vroomshipments', ARRAY['text', 'text', 'text', 'text', 'text', 'text']); + SELECT has_function('vrp_vroomshipmentsplain', ARRAY['text', 'text', 'text', 'text', 'text', 'text']); RETURN QUERY - SELECT function_returns('vrp_vroomshipments', ARRAY['text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); + SELECT function_returns('vrp_vroomshipmentsplain', ARRAY['text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); -- parameter names RETURN QUERY SELECT bag_has( - $$SELECT proargnames from pg_proc where proname = 'vrp_vroomshipments'$$, + $$SELECT proargnames from pg_proc where proname = 'vrp_vroomshipmentsplain'$$, $$SELECT '{"","","","","","","seq","vehicle_seq","vehicle_id","step_seq","step_type",' '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ ); @@ -85,7 +85,7 @@ BEGIN -- parameter types RETURN QUERY SELECT set_eq( - $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomshipments'$$, + $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomshipmentsplain'$$, $$VALUES ('{25,25,25,25,25,25,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) $$ diff --git a/pgtap/vroom/vroomJobs-eq-vroom.test.sql b/pgtap/vroom/vroomJobs-eq-vroom.test.sql index 9d83e2b78..0e77c3e1a 100644 --- a/pgtap/vroom/vroomJobs-eq-vroom.test.sql +++ b/pgtap/vroom/vroomJobs-eq-vroom.test.sql @@ -28,8 +28,8 @@ BEGIN FOR i in 1..array_length(ids, 1) LOOP FOR j in (i+1)..array_length(ids, 1) LOOP jobs_sql := '$$SELECT * FROM jobs WHERE id in (' || i || ', ' || j || ')$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomJobs_sql := 'SELECT * FROM vrp_vroomJobs(' || jobs_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomJobs_sql := 'SELECT * FROM vrp_vroomJobsPlain(' || jobs_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomJobs_sql); END LOOP; END LOOP; @@ -39,8 +39,8 @@ BEGIN FOR j in (i+1)..array_length(ids, 1) LOOP FOR k in (j+1)..array_length(ids, 1) LOOP jobs_sql := '$$SELECT * FROM jobs WHERE id in (' || i || ', ' || j || ', ' || k || ')$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomJobs_sql := 'SELECT * FROM vrp_vroomJobs(' || jobs_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomJobs_sql := 'SELECT * FROM vrp_vroomJobsPlain(' || jobs_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomJobs_sql); END LOOP; END LOOP; @@ -48,14 +48,14 @@ BEGIN -- All the five jobs jobs_sql := '$$SELECT * FROM jobs$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomJobs_sql := 'SELECT * FROM vrp_vroomJobs(' || jobs_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomJobs_sql := 'SELECT * FROM vrp_vroomJobsPlain(' || jobs_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomJobs_sql); -- No jobs jobs_sql := '$$SELECT * FROM jobs WHERE id = -1$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomJobs_sql := 'SELECT * FROM vrp_vroomJobs(' || jobs_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomJobs_sql := 'SELECT * FROM vrp_vroomJobsPlain(' || jobs_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomJobs_sql); END $BODY$ diff --git a/pgtap/vroom/vroomShipments-eq-vroom.test.sql b/pgtap/vroom/vroomShipments-eq-vroom.test.sql index fe16d68a7..f801f69e9 100644 --- a/pgtap/vroom/vroomShipments-eq-vroom.test.sql +++ b/pgtap/vroom/vroomShipments-eq-vroom.test.sql @@ -28,8 +28,8 @@ BEGIN FOR i in 1..array_length(ids, 1) LOOP FOR j in (i+1)..array_length(ids, 1) LOOP shipments_sql := '$$SELECT * FROM shipments WHERE id in (' || i || ', ' || j || ')$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomShipments_sql := 'SELECT * FROM vrp_vroomShipments(' || shipments_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomShipments_sql := 'SELECT * FROM vrp_vroomShipmentsPlain(' || shipments_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomShipments_sql); END LOOP; END LOOP; @@ -39,8 +39,8 @@ BEGIN FOR j in (i+1)..array_length(ids, 1) LOOP FOR k in (j+1)..array_length(ids, 1) LOOP shipments_sql := '$$SELECT * FROM shipments WHERE id in (' || i || ', ' || j || ', ' || k || ')$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomShipments_sql := 'SELECT * FROM vrp_vroomShipments(' || shipments_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomShipments_sql := 'SELECT * FROM vrp_vroomShipmentsPlain(' || shipments_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomShipments_sql); END LOOP; END LOOP; @@ -48,14 +48,14 @@ BEGIN -- All the five shipments shipments_sql := '$$SELECT * FROM shipments$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomShipments_sql := 'SELECT * FROM vrp_vroomShipments(' || shipments_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomShipments_sql := 'SELECT * FROM vrp_vroomShipmentsPlain(' || shipments_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomShipments_sql); -- No shipments shipments_sql := '$$SELECT * FROM shipments WHERE id = -1$$, ' || empty_time_windows; - vroom_sql := 'SELECT * FROM vrp_vroom(' || jobs_sql || shipments_sql || rest_sql; - vroomShipments_sql := 'SELECT * FROM vrp_vroomShipments(' || shipments_sql || rest_sql; + vroom_sql := 'SELECT * FROM vrp_vroomPlain(' || jobs_sql || shipments_sql || rest_sql; + vroomShipments_sql := 'SELECT * FROM vrp_vroomShipmentsPlain(' || shipments_sql || rest_sql; RETURN query SELECT set_eq(vroom_sql, vroomShipments_sql); END $BODY$ From 9bb5d1c8fffebda42c931c9778bbd605aa455236 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:56:41 +0530 Subject: [PATCH 03/13] [vroom][doc] Change vroom -> vroomPlain --- doc/conf.py.in | 12 +-- doc/general/vroom-category.rst | 6 +- doc/vroom/CMakeLists.txt | 6 +- doc/vroom/vrp_vroomJobsPlain.rst | 108 ++++++++++++++++++++++++ doc/vroom/vrp_vroomPlain.rst | 116 ++++++++++++++++++++++++++ doc/vroom/vrp_vroomShipmentsPlain.rst | 109 ++++++++++++++++++++++++ 6 files changed, 345 insertions(+), 12 deletions(-) create mode 100644 doc/vroom/vrp_vroomJobsPlain.rst create mode 100644 doc/vroom/vrp_vroomPlain.rst create mode 100644 doc/vroom/vrp_vroomShipmentsPlain.rst diff --git a/doc/conf.py.in b/doc/conf.py.in index 46401c0e0..f9002a3f7 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -319,12 +319,12 @@ linkcheck_ignore = [ "https://vrp.pgrouting.org/latest/en/pgr-category.html", "https://vrp.pgrouting.org/v0/en/vroom-category.html", "https://vrp.pgrouting.org/latest/en/vroom-category.html", - "https://vrp.pgrouting.org/v0/en/vrp_vroom.html", - "https://vrp.pgrouting.org/latest/en/vrp_vroom.html", - "https://vrp.pgrouting.org/v0/en/vrp_vroomJobs.html", - "https://vrp.pgrouting.org/latest/en/vrp_vroomJobs.html", - "https://vrp.pgrouting.org/v0/en/vrp_vroomShipments.html", - "https://vrp.pgrouting.org/latest/en/vrp_vroomShipments.html", + "https://vrp.pgrouting.org/v0/en/vrp_vroomPlain.html", + "https://vrp.pgrouting.org/latest/en/vrp_vroomPlain.html", + "https://vrp.pgrouting.org/v0/en/vrp_vroomJobsPlain.html", + "https://vrp.pgrouting.org/latest/en/vrp_vroomJobsPlain.html", + "https://vrp.pgrouting.org/v0/en/vrp_vroomShipmentsPlain.html", + "https://vrp.pgrouting.org/latest/en/vrp_vroomShipmentsPlain.html", # (see: https://github.com/sphinx-doc/sphinx/issues/7388) r"https://github.com/pgRouting/vrprouting/", # limit only vrprouting diff --git a/doc/general/vroom-category.rst b/doc/general/vroom-category.rst index 1008291a3..353e1efb4 100644 --- a/doc/general/vroom-category.rst +++ b/doc/general/vroom-category.rst @@ -30,9 +30,9 @@ VROOM - Category (Experimental) .. toctree:: :maxdepth: 1 - vrp_vroom - vrp_vroomJobs - vrp_vroomShipments + vrp_vroomPlain + vrp_vroomJobsPlain + vrp_vroomShipmentsPlain Synopsis diff --git a/doc/vroom/CMakeLists.txt b/doc/vroom/CMakeLists.txt index d537ef8af..e8f25536d 100644 --- a/doc/vroom/CMakeLists.txt +++ b/doc/vroom/CMakeLists.txt @@ -1,8 +1,8 @@ SET(LOCAL_FILES - vrp_vroom.rst - vrp_vroomJobs.rst - vrp_vroomShipments.rst + vrp_vroomPlain.rst + vrp_vroomJobsPlain.rst + vrp_vroomShipmentsPlain.rst ) foreach (f ${LOCAL_FILES}) diff --git a/doc/vroom/vrp_vroomJobsPlain.rst b/doc/vroom/vrp_vroomJobsPlain.rst new file mode 100644 index 000000000..db7a5c73f --- /dev/null +++ b/doc/vroom/vrp_vroomJobsPlain.rst @@ -0,0 +1,108 @@ +.. + **************************************************************************** + vrpRouting Manual + Copyright(c) vrpRouting Contributors + + This documentation is licensed under a Creative Commons Attribution-Share + Alike 3.0 License: https://creativecommons.org/licenses/by-sa/3.0/ + **************************************************************************** + +| + +* `Documentation `__ → `vrpRouting v0 `__ +* Supported Versions + `Latest `__ + (`v0 `__) + + +vrp_vroomJobsPlain - Experimental +=============================================================================== + +``vrp_vroomJobsPlain`` - Vehicle Routing Problem with VROOM, involving only jobs. + +.. include:: experimental.rst + :start-after: begin-warn-expr + :end-before: end-warn-expr + +.. rubric:: Availability + +Version 0.2.0 + +* New **experimental** function + + +Description +------------------------------------------------------------------------------- + +VROOM is an open-source optimization engine that aims at providing good solutions +to various real-life vehicle routing problems (VRP) within a small computing time. +This function can be used to get the solution to a problem involving only jobs. + +.. index:: + single: vrp_vroomJobsPlain -- Experimental on v0.2 + +Signature +------------------------------------------------------------------------------- + +.. include:: ../sql/vroom/vrp_vroomJobs.sql + :start-after: signature start + :end-before: signature end + +**Example**: This example is based on the VROOM Data of the :doc:`sampledata` network: + +.. literalinclude:: doc-vrp_vroomJobsPlain.queries + :start-after: -- q1 + :end-before: -- q2 + +Parameters +------------------------------------------------------------------------------- + +.. include:: ../sql/vroom/vrp_vroomJobs.sql + :start-after: parameters start + :end-before: parameters end + +Inner Queries +------------------------------------------------------------------------------- + +Jobs SQL +............................................................................... + +.. include:: ../../src/common/vroom/jobs_input.c + :start-after: vrp_vroom start + :end-before: vrp_vroom end + +.. include:: vroom-category.rst + :start-after: inner_queries_start + :end-before: inner_queries_end + +Result Columns +------------------------------------------------------------------------------- + +.. include:: vroom-category.rst + :start-after: result_columns_start + :end-before: result_columns_end + +Additional Example +------------------------------------------------------------------------------- + +Problem involving 2 jobs, using a single vehicle, corresponding to the VROOM Documentation +`Example 2 `__. + +.. literalinclude:: doc-vrp_vroomJobsPlain.queries + :start-after: -- q2 + :end-before: -- q3 + +See Also +------------------------------------------------------------------------------- + +* :doc:`vroom-category` +* The queries use the :doc:`sampledata` network. + +.. include:: vroom-category.rst + :start-after: see_also_start + :end-before: see_also_end + +.. rubric:: Indices and tables + +* :ref:`genindex` +* :ref:`search` diff --git a/doc/vroom/vrp_vroomPlain.rst b/doc/vroom/vrp_vroomPlain.rst new file mode 100644 index 000000000..79788d290 --- /dev/null +++ b/doc/vroom/vrp_vroomPlain.rst @@ -0,0 +1,116 @@ +.. + **************************************************************************** + vrpRouting Manual + Copyright(c) vrpRouting Contributors + + This documentation is licensed under a Creative Commons Attribution-Share + Alike 3.0 License: https://creativecommons.org/licenses/by-sa/3.0/ + **************************************************************************** + +| + +* `Documentation `__ → `vrpRouting v0 `__ +* Supported Versions + `Latest `__ + (`v0 `__) + + +vrp_vroomPlain - Experimental +=============================================================================== + +``vrp_vroomPlain`` - Vehicle Routing Problem with VROOM, involving both jobs and shipments. + +.. include:: experimental.rst + :start-after: begin-warn-expr + :end-before: end-warn-expr + +.. rubric:: Availability + +Version 0.2.0 + +* New **experimental** function + + +Description +------------------------------------------------------------------------------- + +VROOM is an open-source optimization engine that aims at providing good solutions +to various real-life vehicle routing problems (VRP) within a small computing time. +This function can be used to get the solution to a problem involving both jobs and +shipments. + +.. index:: + single: vrp_vroomPlain -- Experimental on v0.2 + +Signature +------------------------------------------------------------------------------- + +.. include:: ../sql/vroom/vrp_vroom.sql + :start-after: signature start + :end-before: signature end + +**Example**: This example is based on the VROOM Data of the :doc:`sampledata` network: + +.. literalinclude:: doc-vrp_vroomPlain.queries + :start-after: -- q1 + :end-before: -- q2 + +Parameters +------------------------------------------------------------------------------- + +.. include:: ../sql/vroom/vrp_vroom.sql + :start-after: parameters start + :end-before: parameters end + +Inner Queries +------------------------------------------------------------------------------- + +Jobs SQL +............................................................................... + +.. include:: ../../src/common/vroom/jobs_input.c + :start-after: vrp_vroom start + :end-before: vrp_vroom end + +Shipments SQL +............................................................................... + +.. include:: ../../src/common/vroom/shipments_input.c + :start-after: vrp_vroom start + :end-before: vrp_vroom end + +.. include:: vroom-category.rst + :start-after: inner_queries_start + :end-before: inner_queries_end + +Result Columns +------------------------------------------------------------------------------- + +.. include:: vroom-category.rst + :start-after: result_columns_start + :end-before: result_columns_end + +Additional Example +------------------------------------------------------------------------------- + +Problem involving 2 jobs and 1 shipment, using a single vehicle, similar to the VROOM Documentation +`Example 2 `__ with a shipment. + +.. literalinclude:: doc-vrp_vroomPlain.queries + :start-after: -- q2 + :end-before: -- q3 + +See Also +------------------------------------------------------------------------------- + +* :doc:`vroom-category` +* The queries use the :doc:`sampledata` network. + +.. include:: vroom-category.rst + :start-after: see_also_start + :end-before: see_also_end + +.. rubric:: Indices and tables + +* :ref:`genindex` +* :ref:`search` diff --git a/doc/vroom/vrp_vroomShipmentsPlain.rst b/doc/vroom/vrp_vroomShipmentsPlain.rst new file mode 100644 index 000000000..093f8582e --- /dev/null +++ b/doc/vroom/vrp_vroomShipmentsPlain.rst @@ -0,0 +1,109 @@ +.. + **************************************************************************** + vrpRouting Manual + Copyright(c) vrpRouting Contributors + + This documentation is licensed under a Creative Commons Attribution-Share + Alike 3.0 License: https://creativecommons.org/licenses/by-sa/3.0/ + **************************************************************************** + +| + +* `Documentation `__ → `vrpRouting v0 `__ +* Supported Versions + `Latest `__ + (`v0 `__) + + +vrp_vroomShipmentsPlain - Experimental +=============================================================================== + +``vrp_vroomShipmentsPlain`` - Vehicle Routing Problem with VROOM, involving only shipments. + +.. include:: experimental.rst + :start-after: begin-warn-expr + :end-before: end-warn-expr + +.. rubric:: Availability + +Version 0.2.0 + +* New **experimental** function + + +Description +------------------------------------------------------------------------------- + +VROOM is an open-source optimization engine that aims at providing good solutions +to various real-life vehicle routing problems (VRP) within a small computing time. +This function can be used to get the solution to a problem involving only shipments. + +.. index:: + single: vrp_vroomShipmentsPlain -- Experimental on v0.2 + +Signature +------------------------------------------------------------------------------- + +.. include:: ../sql/vroom/vrp_vroomShipments.sql + :start-after: signature start + :end-before: signature end + +**Example**: This example is based on the VROOM Data of the :doc:`sampledata` network: + +.. literalinclude:: doc-vrp_vroomShipmentsPlain.queries + :start-after: -- q1 + :end-before: -- q2 + +Parameters +------------------------------------------------------------------------------- + +.. include:: ../sql/vroom/vrp_vroomShipments.sql + :start-after: parameters start + :end-before: parameters end + +Inner Queries +------------------------------------------------------------------------------- + +Shipments SQL +............................................................................... + +.. include:: ../../src/common/vroom/shipments_input.c + :start-after: vrp_vroom start + :end-before: vrp_vroom end + +.. include:: vroom-category.rst + :start-after: inner_queries_start + :end-before: inner_queries_end + +Result Columns +------------------------------------------------------------------------------- + +.. include:: vroom-category.rst + :start-after: result_columns_start + :end-before: result_columns_end + +Additional Example +------------------------------------------------------------------------------- + +Problem involving 1 shipment, using a single vehicle, similar to the VROOM Documentation +`Example 2 `__ without jobs +and with a shipment. + +.. literalinclude:: doc-vrp_vroomShipmentsPlain.queries + :start-after: -- q2 + :end-before: -- q3 + +See Also +------------------------------------------------------------------------------- + +* :doc:`vroom-category` +* The queries use the :doc:`sampledata` network. + +.. include:: vroom-category.rst + :start-after: see_also_start + :end-before: see_also_end + +.. rubric:: Indices and tables + +* :ref:`genindex` +* :ref:`search` From e3482c7190ec80bf5ba983704c561eb607397609 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:56:48 +0530 Subject: [PATCH 04/13] [vroom][docquery] Change vroom -> vroomPlain --- docqueries/vroom/CMakeLists.txt | 6 +- .../vroom/doc-vrp_vroomJobsPlain.result | 65 +++++++++++++ .../vroom/doc-vrp_vroomJobsPlain.test.sql | 36 ++++++++ docqueries/vroom/doc-vrp_vroomPlain.result | 91 +++++++++++++++++++ docqueries/vroom/doc-vrp_vroomPlain.test.sql | 44 +++++++++ .../vroom/doc-vrp_vroomShipmentsPlain.result | 70 ++++++++++++++ .../doc-vrp_vroomShipmentsPlain.test.sql | 36 ++++++++ docqueries/vroom/test.conf | 12 +-- 8 files changed, 351 insertions(+), 9 deletions(-) create mode 100644 docqueries/vroom/doc-vrp_vroomJobsPlain.result create mode 100644 docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql create mode 100644 docqueries/vroom/doc-vrp_vroomPlain.result create mode 100644 docqueries/vroom/doc-vrp_vroomPlain.test.sql create mode 100644 docqueries/vroom/doc-vrp_vroomShipmentsPlain.result create mode 100644 docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql diff --git a/docqueries/vroom/CMakeLists.txt b/docqueries/vroom/CMakeLists.txt index ad8f8281f..2e2c65052 100644 --- a/docqueries/vroom/CMakeLists.txt +++ b/docqueries/vroom/CMakeLists.txt @@ -1,8 +1,8 @@ # Do not use extensions SET(LOCAL_FILES - doc-vrp_vroom - doc-vrp_vroomJobs - doc-vrp_vroomShipments + doc-vrp_vroomPlain + doc-vrp_vroomJobsPlain + doc-vrp_vroomShipmentsPlain ) foreach (f ${LOCAL_FILES}) diff --git a/docqueries/vroom/doc-vrp_vroomJobsPlain.result b/docqueries/vroom/doc-vrp_vroomJobsPlain.result new file mode 100644 index 000000000..55c557aae --- /dev/null +++ b/docqueries/vroom/doc-vrp_vroomJobsPlain.result @@ -0,0 +1,65 @@ +BEGIN; +BEGIN +SET client_min_messages TO NOTICE; +SET +-- q1 +SELECT * +FROM vrp_vroomJobsPlain( + 'SELECT * FROM vroom.jobs', + 'SELECT * FROM vroom.jobs_time_windows', + 'SELECT * FROM vroom.vehicles', + 'SELECT * FROM vroom.breaks', + '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) + +-- q2 +SELECT * +FROM vrp_vroomJobsPlain( + $jobs$ + SELECT * FROM ( + VALUES (1414, 2), (1515, 3) + ) AS C(id, location_index) + $jobs$, + NULL, + $vehicles$ + SELECT * FROM ( + VALUES (1, 1, 4) + ) AS C(id, start_index, end_index) + $vehicles$, + NULL, + NULL, + $matrix$ + SELECT * FROM ( + VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299), + (2, 1, 2103), (2, 3, 2255), (2, 4, 3152), + (3, 1, 197), (3, 2, 2256), (3, 4, 1102), + (4, 1, 1299), (4, 2, 3153), (4, 3, 1102) + ) AS C(start_vid, end_vid, agg_cost) + $matrix$ +); + seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load +-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------ + 1 | 1 | 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) + +-- q3 +ROLLBACK; +ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql b/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql new file mode 100644 index 000000000..f92e18ff1 --- /dev/null +++ b/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql @@ -0,0 +1,36 @@ +\echo -- q1 +SELECT * +FROM vrp_vroomJobsPlain( + 'SELECT * FROM vroom.jobs', + 'SELECT * FROM vroom.jobs_time_windows', + 'SELECT * FROM vroom.vehicles', + 'SELECT * FROM vroom.breaks', + 'SELECT * FROM vroom.breaks_time_windows', + 'SELECT * FROM vroom.matrix' +); +\echo -- q2 +SELECT * +FROM vrp_vroomJobsPlain( + $jobs$ + SELECT * FROM ( + VALUES (1414, 2), (1515, 3) + ) AS C(id, location_index) + $jobs$, + NULL, + $vehicles$ + SELECT * FROM ( + VALUES (1, 1, 4) + ) AS C(id, start_index, end_index) + $vehicles$, + NULL, + NULL, + $matrix$ + SELECT * FROM ( + VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299), + (2, 1, 2103), (2, 3, 2255), (2, 4, 3152), + (3, 1, 197), (3, 2, 2256), (3, 4, 1102), + (4, 1, 1299), (4, 2, 3153), (4, 3, 1102) + ) AS C(start_vid, end_vid, agg_cost) + $matrix$ +); +\echo -- q3 diff --git a/docqueries/vroom/doc-vrp_vroomPlain.result b/docqueries/vroom/doc-vrp_vroomPlain.result new file mode 100644 index 000000000..d77ec48ae --- /dev/null +++ b/docqueries/vroom/doc-vrp_vroomPlain.result @@ -0,0 +1,91 @@ +BEGIN; +BEGIN +SET client_min_messages TO NOTICE; +SET +-- q1 +SELECT * +FROM vrp_vroomPlain( + 'SELECT * FROM vroom.jobs', + 'SELECT * FROM vroom.jobs_time_windows', + 'SELECT * FROM vroom.shipments', + 'SELECT * FROM vroom.shipments_time_windows', + 'SELECT * FROM vroom.vehicles', + 'SELECT * FROM vroom.breaks', + '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) + +-- q2 +SELECT * +FROM vrp_vroomPlain( + $jobs$ + SELECT * FROM ( + VALUES (1414, 2), (1515, 3) + ) AS C(id, location_index) + $jobs$, + NULL, + $shipments$ + SELECT * FROM ( + VALUES (100, 1, 4) + ) AS C(id, p_location_index, d_location_index) + $shipments$, + NULL, + $vehicles$ + SELECT * FROM ( + VALUES (1, 1, 4) + ) AS C(id, start_index, end_index) + $vehicles$, + NULL, + NULL, + $matrix$ + SELECT * FROM ( + VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299), + (2, 1, 2103), (2, 3, 2255), (2, 4, 3152), + (3, 1, 197), (3, 2, 2256), (3, 4, 1102), + (4, 1, 1299), (4, 2, 3153), (4, 3, 1102) + ) AS C(start_vid, end_vid, agg_cost) + $matrix$ +); + seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load +-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------ + 1 | 1 | 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) + +-- q3 +ROLLBACK; +ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomPlain.test.sql b/docqueries/vroom/doc-vrp_vroomPlain.test.sql new file mode 100644 index 000000000..738b4d492 --- /dev/null +++ b/docqueries/vroom/doc-vrp_vroomPlain.test.sql @@ -0,0 +1,44 @@ +\echo -- q1 +SELECT * +FROM vrp_vroomPlain( + 'SELECT * FROM vroom.jobs', + 'SELECT * FROM vroom.jobs_time_windows', + 'SELECT * FROM vroom.shipments', + 'SELECT * FROM vroom.shipments_time_windows', + 'SELECT * FROM vroom.vehicles', + 'SELECT * FROM vroom.breaks', + 'SELECT * FROM vroom.breaks_time_windows', + 'SELECT * FROM vroom.matrix' +); +\echo -- q2 +SELECT * +FROM vrp_vroomPlain( + $jobs$ + SELECT * FROM ( + VALUES (1414, 2), (1515, 3) + ) AS C(id, location_index) + $jobs$, + NULL, + $shipments$ + SELECT * FROM ( + VALUES (100, 1, 4) + ) AS C(id, p_location_index, d_location_index) + $shipments$, + NULL, + $vehicles$ + SELECT * FROM ( + VALUES (1, 1, 4) + ) AS C(id, start_index, end_index) + $vehicles$, + NULL, + NULL, + $matrix$ + SELECT * FROM ( + VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299), + (2, 1, 2103), (2, 3, 2255), (2, 4, 3152), + (3, 1, 197), (3, 2, 2256), (3, 4, 1102), + (4, 1, 1299), (4, 2, 3153), (4, 3, 1102) + ) AS C(start_vid, end_vid, agg_cost) + $matrix$ +); +\echo -- q3 diff --git a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result new file mode 100644 index 000000000..a1450cbb4 --- /dev/null +++ b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result @@ -0,0 +1,70 @@ +BEGIN; +BEGIN +SET client_min_messages TO NOTICE; +SET +-- q1 +SELECT * +FROM vrp_vroomShipmentsPlain( + 'SELECT * FROM vroom.shipments', + 'SELECT * FROM vroom.shipments_time_windows', + 'SELECT * FROM vroom.vehicles', + 'SELECT * FROM vroom.breaks', + '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) + +-- q2 +SELECT * +FROM vrp_vroomShipmentsPlain( + $shipments$ + SELECT * FROM ( + VALUES (100, 1, 4) + ) AS C(id, p_location_index, d_location_index) + $shipments$, + NULL, + $vehicles$ + SELECT * FROM ( + VALUES (1, 1, 4) + ) AS C(id, start_index, end_index) + $vehicles$, + NULL, + NULL, + $matrix$ + SELECT * FROM ( + VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299), + (2, 1, 2103), (2, 3, 2255), (2, 4, 3152), + (3, 1, 197), (3, 2, 2256), (3, 4, 1102), + (4, 1, 1299), (4, 2, 3153), (4, 3, 1102) + ) AS C(start_vid, end_vid, agg_cost) + $matrix$ +); + seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load +-----+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------ + 1 | 1 | 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) + +-- q3 +ROLLBACK; +ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql new file mode 100644 index 000000000..6e6505e01 --- /dev/null +++ b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql @@ -0,0 +1,36 @@ +\echo -- q1 +SELECT * +FROM vrp_vroomShipmentsPlain( + 'SELECT * FROM vroom.shipments', + 'SELECT * FROM vroom.shipments_time_windows', + 'SELECT * FROM vroom.vehicles', + 'SELECT * FROM vroom.breaks', + 'SELECT * FROM vroom.breaks_time_windows', + 'SELECT * FROM vroom.matrix' +); +\echo -- q2 +SELECT * +FROM vrp_vroomShipmentsPlain( + $shipments$ + SELECT * FROM ( + VALUES (100, 1, 4) + ) AS C(id, p_location_index, d_location_index) + $shipments$, + NULL, + $vehicles$ + SELECT * FROM ( + VALUES (1, 1, 4) + ) AS C(id, start_index, end_index) + $vehicles$, + NULL, + NULL, + $matrix$ + SELECT * FROM ( + VALUES (1, 2, 2104), (1, 3, 197), (1, 4, 1299), + (2, 1, 2103), (2, 3, 2255), (2, 4, 3152), + (3, 1, 197), (3, 2, 2256), (3, 4, 1102), + (4, 1, 1299), (4, 2, 3153), (4, 3, 1102) + ) AS C(start_vid, end_vid, agg_cost) + $matrix$ +); +\echo -- q3 diff --git a/docqueries/vroom/test.conf b/docqueries/vroom/test.conf index 8cd4cabd0..8db795969 100644 --- a/docqueries/vroom/test.conf +++ b/docqueries/vroom/test.conf @@ -5,14 +5,14 @@ 'comment' => 'VRP with VROOM tests.', 'data' => [ ], 'tests' => [qw( - doc-vrp_vroom - doc-vrp_vroomJobs - doc-vrp_vroomShipments + doc-vrp_vroomPlain + doc-vrp_vroomJobsPlain + doc-vrp_vroomShipmentsPlain )], 'documentation' => [qw( - doc-vrp_vroom - doc-vrp_vroomJobs - doc-vrp_vroomShipments + doc-vrp_vroomPlain + doc-vrp_vroomJobsPlain + doc-vrp_vroomShipmentsPlain )] }, From bdb79dfc63c5614b5d74e5df946cdd01d65ab815 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:58:35 +0530 Subject: [PATCH 05/13] [vroom][sql] Add vroom functions with timestamp --- sql/sigs/vrprouting--0.2.sig | 5 +- sql/vroom/CMakeLists.txt | 3 + sql/vroom/_vrp_vroom.sql | 3 +- sql/vroom/vrp_vroom.sql | 23 ++++++-- sql/vroom/vrp_vroomJobs.sql | 23 ++++++-- sql/vroom/vrp_vroomJobsPlain.sql | 39 +------------ sql/vroom/vrp_vroomPlain.sql | 84 +-------------------------- sql/vroom/vrp_vroomShipments.sql | 23 ++++++-- sql/vroom/vrp_vroomShipmentsPlain.sql | 38 +----------- 9 files changed, 63 insertions(+), 178 deletions(-) diff --git a/sql/sigs/vrprouting--0.2.sig b/sql/sigs/vrprouting--0.2.sig index 7ba00d929..18a1cca00 100644 --- a/sql/sigs/vrprouting--0.2.sig +++ b/sql/sigs/vrprouting--0.2.sig @@ -33,6 +33,9 @@ vrp_version() vrp_viewrouteraw(text,text,text,text,bigint,double precision) vrp_viewroute(text,text,text,text,bigint,double precision) vrp_vroomjobsplain(text,text,text,text,text,text) +vrp_vroomjobs(text,text,text,text,text,text) vrp_vroomplain(text,text,text,text,text,text,text,text) vrp_vroomshipmentsplain(text,text,text,text,text,text) -_vrp_vroom(text,text,text,text,text,text,text,text,smallint) +vrp_vroomshipments(text,text,text,text,text,text) +vrp_vroom(text,text,text,text,text,text,text,text) +_vrp_vroom(text,text,text,text,text,text,text,text,smallint,boolean) diff --git a/sql/vroom/CMakeLists.txt b/sql/vroom/CMakeLists.txt index ce3887953..9c629ae95 100644 --- a/sql/vroom/CMakeLists.txt +++ b/sql/vroom/CMakeLists.txt @@ -1,5 +1,8 @@ SET(LOCAL_FILES _vrp_vroom.sql + vrp_vroom.sql + vrp_vroomJobs.sql + vrp_vroomShipments.sql vrp_vroomPlain.sql vrp_vroomJobsPlain.sql vrp_vroomShipmentsPlain.sql diff --git a/sql/vroom/_vrp_vroom.sql b/sql/vroom/_vrp_vroom.sql index 2c5334393..6d3fa62b5 100644 --- a/sql/vroom/_vrp_vroom.sql +++ b/sql/vroom/_vrp_vroom.sql @@ -37,6 +37,7 @@ CREATE FUNCTION _vrp_vroom( breaks_time_windows_sql TEXT, matrix_sql TEXT, fn SMALLINT, + is_plain BOOLEAN, OUT seq BIGINT, OUT vehicle_seq BIGINT, @@ -55,5 +56,5 @@ LANGUAGE C VOLATILE; -- COMMENTS -COMMENT ON FUNCTION _vrp_vroom(TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, SMALLINT) +COMMENT ON FUNCTION _vrp_vroom(TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, SMALLINT, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/vroom/vrp_vroom.sql b/sql/vroom/vrp_vroom.sql index 8f982ae07..f9ac6929a 100644 --- a/sql/vroom/vrp_vroom.sql +++ b/sql/vroom/vrp_vroom.sql @@ -126,17 +126,28 @@ CREATE FUNCTION vrp_vroom( OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, - OUT arrival INTEGER, - OUT travel_time INTEGER, - OUT service_time INTEGER, - OUT waiting_time INTEGER, + OUT arrival TIMESTAMP, + OUT travel_time INTERVAL, + OUT service_time INTERVAL, + OUT waiting_time INTERVAL, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ - SELECT * + SELECT + seq, + vehicle_seq, + vehicle_id, + step_seq, + step_type, + task_id, + (to_timestamp(arrival) at time zone 'UTC')::TIMESTAMP, + make_interval(secs => travel_time), + make_interval(secs => service_time), + make_interval(secs => waiting_time), + 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), 0::SMALLINT); + _pgr_get_statement($7), _pgr_get_statement($8), 0::SMALLINT, false); $BODY$ LANGUAGE SQL VOLATILE; diff --git a/sql/vroom/vrp_vroomJobs.sql b/sql/vroom/vrp_vroomJobs.sql index 37b4d1efc..4c493a733 100644 --- a/sql/vroom/vrp_vroomJobs.sql +++ b/sql/vroom/vrp_vroomJobs.sql @@ -78,17 +78,28 @@ CREATE FUNCTION vrp_vroomJobs( OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, - OUT arrival INTEGER, - OUT travel_time INTEGER, - OUT service_time INTEGER, - OUT waiting_time INTEGER, + OUT arrival TIMESTAMP, + OUT travel_time INTERVAL, + OUT service_time INTERVAL, + OUT waiting_time INTERVAL, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ - SELECT * + SELECT + seq, + vehicle_seq, + vehicle_id, + step_seq, + step_type, + task_id, + (to_timestamp(arrival) at time zone 'UTC')::TIMESTAMP, + make_interval(secs => travel_time), + make_interval(secs => service_time), + make_interval(secs => waiting_time), + 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), 1::SMALLINT); + _pgr_get_statement($5), _pgr_get_statement($6), 1::SMALLINT, false); $BODY$ LANGUAGE SQL VOLATILE; diff --git a/sql/vroom/vrp_vroomJobsPlain.sql b/sql/vroom/vrp_vroomJobsPlain.sql index cf6e00806..fb6dd9061 100644 --- a/sql/vroom/vrp_vroomJobsPlain.sql +++ b/sql/vroom/vrp_vroomJobsPlain.sql @@ -26,43 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -/* -signature start - -.. code-block:: none - - vrp_vroomJobsPlain( - Jobs SQL, Jobs Time Windows SQL, - Vehicles SQL, Breaks SQL, Breaks Time Windows SQL, - Matrix SQL) -- 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) - -signature end - -parameters start - -============================== =========== ========================================================= -Parameter Type Description -============================== =========== ========================================================= -**Jobs SQL** ``TEXT`` `Jobs SQL`_ query describing the single-location - pickup and/or delivery tasks. -**Jobs Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots - for job service start. -**Vehicles SQL** ``TEXT`` `Vehicles SQL`_ query describing the available vehicles. -**Breaks SQL** ``TEXT`` `Breaks SQL`_ query describing the driver breaks. -**Breaks Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots for - break start. -**Matrix SQL** ``TEXT`` `Time Matrix SQL`_ query containing the distance or - travel times between the locations. -============================== =========== ========================================================= - -parameters end - -*/ - -- v0.2 CREATE FUNCTION vrp_vroomJobsPlain( TEXT, -- jobs_sql (required) @@ -88,7 +51,7 @@ $BODY$ SELECT * 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), 1::SMALLINT); + _pgr_get_statement($5), _pgr_get_statement($6), 1::SMALLINT, true); $BODY$ LANGUAGE SQL VOLATILE; diff --git a/sql/vroom/vrp_vroomPlain.sql b/sql/vroom/vrp_vroomPlain.sql index ec70943ed..3d533d0c5 100644 --- a/sql/vroom/vrp_vroomPlain.sql +++ b/sql/vroom/vrp_vroomPlain.sql @@ -26,88 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -/* -signature start - -.. code-block:: none - - vrp_vroomPlain( - Jobs SQL, Jobs Time Windows SQL, - Shipments SQL, Shipments Time Windows SQL, - Vehicles SQL, Breaks SQL, Breaks Time Windows SQL, - Matrix SQL) -- 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) - -signature end - -parameters start - -============================== =========== ========================================================= -Parameter Type Description -============================== =========== ========================================================= -**Jobs SQL** ``TEXT`` `Jobs SQL`_ query describing the single-location - pickup and/or delivery tasks. -**Jobs Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots - for job service start. -**Shipments SQL** ``TEXT`` `Shipments SQL`_ query describing pickup and delivery - tasks that should happen within same route. -**Shipments Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots - for pickup and delivery service start. -**Vehicles SQL** ``TEXT`` `Vehicles SQL`_ query describing the available vehicles. -**Breaks SQL** ``TEXT`` `Breaks SQL`_ query describing the driver breaks. -**Breaks Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots for - break start. -**Matrix SQL** ``TEXT`` `Time Matrix SQL`_ query containing the distance or - travel times between the locations. -============================== =========== ========================================================= - -parameters end - -result start - -=================== ============= ================================================= -Column Type Description -=================== ============= ================================================= -**seq** ``BIGINT`` Sequential value starting from **1**. - -**vehicle_seq** ``BIGINT`` Sequential value starting from **1** for current vehicles. - The :math:`n^{th}` vehicle in the solution. - -**vehicle_id** ``BIGINT`` Current vehicle identifier. - -**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. - -**step_type** ``INTEGER`` Kind of the step location the vehicle is at: - - - ``1``: Starting location - - ``2``: Job location - - ``3``: Pickup location - - ``4``: Delivery location - - ``5``: Break location - - ``6``: Ending location - -**task_id** ``BIGINT`` Identifier of the task performed at this step. - - - ``-1``: If the step is starting/ending location. - -**arrival** ``INTEGER`` Estimated time of arrival at this step, in seconds. - -**travel_time** ``INTEGER`` Cumulated travel time upon arrival at this step, in seconds - -**service_time** ``INTEGER`` Service time at this step, in seconds - -**waiting_time** ``INTEGER`` Waiting time upon arrival at this step, in seconds. - -**load** ``BIGINT`` Vehicle load after step completion (with capacity constraints) -=================== ============= ================================================= - -result end -*/ -- v0.2 CREATE FUNCTION vrp_vroomPlain( @@ -136,7 +54,7 @@ $BODY$ SELECT * 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), 0::SMALLINT); + _pgr_get_statement($7), _pgr_get_statement($8), 0::SMALLINT, true); $BODY$ LANGUAGE SQL VOLATILE; diff --git a/sql/vroom/vrp_vroomShipments.sql b/sql/vroom/vrp_vroomShipments.sql index 0d4a66bd9..6bde8157c 100644 --- a/sql/vroom/vrp_vroomShipments.sql +++ b/sql/vroom/vrp_vroomShipments.sql @@ -78,18 +78,29 @@ CREATE FUNCTION vrp_vroomShipments( OUT step_seq BIGINT, OUT step_type INTEGER, OUT task_id BIGINT, - OUT arrival INTEGER, - OUT travel_time INTEGER, - OUT service_time INTEGER, - OUT waiting_time INTEGER, + OUT arrival TIMESTAMP, + OUT travel_time INTERVAL, + OUT service_time INTERVAL, + OUT waiting_time INTERVAL, OUT load BIGINT[]) RETURNS SETOF RECORD AS $BODY$ - SELECT * + SELECT + seq, + vehicle_seq, + vehicle_id, + step_seq, + step_type, + task_id, + (to_timestamp(arrival) at time zone 'UTC')::TIMESTAMP, + make_interval(secs => travel_time), + make_interval(secs => service_time), + make_interval(secs => waiting_time), + 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), 2::SMALLINT); + _pgr_get_statement($6), 2::SMALLINT, false); $BODY$ LANGUAGE SQL VOLATILE; diff --git a/sql/vroom/vrp_vroomShipmentsPlain.sql b/sql/vroom/vrp_vroomShipmentsPlain.sql index 9b2e1f8da..de9bca901 100644 --- a/sql/vroom/vrp_vroomShipmentsPlain.sql +++ b/sql/vroom/vrp_vroomShipmentsPlain.sql @@ -26,42 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -/* -signature start - -.. code-block:: none - - vrp_vroomShipmentsPlain( - Shipments SQL, Shipments Time Windows SQL, - Vehicles SQL, Breaks SQL, Breaks Time Windows SQL, - Matrix SQL) -- 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) - -signature end - -parameters start - -============================== =========== ========================================================= -Parameter Type Description -============================== =========== ========================================================= -**Shipments SQL** ``TEXT`` `Shipments SQL`_ query describing pickup and delivery - tasks that should happen within same route. -**Shipments Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots - for pickup and delivery service start. -**Vehicles SQL** ``TEXT`` `Vehicles SQL`_ query describing the available vehicles. -**Breaks SQL** ``TEXT`` `Breaks SQL`_ query describing the driver breaks. -**Breaks Time Windows SQL** ``TEXT`` `Time Windows SQL`_ query describing valid slots for - break start. -**Matrix SQL** ``TEXT`` `Time Matrix SQL`_ query containing the distance or - travel times between the locations. -============================== =========== ========================================================= - -parameters end - -*/ -- v0.2 CREATE FUNCTION vrp_vroomShipmentsPlain( @@ -89,7 +53,7 @@ $BODY$ 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), 2::SMALLINT); + _pgr_get_statement($6), 2::SMALLINT, true); $BODY$ LANGUAGE SQL VOLATILE; From 2bbdf124a2e8faed2bf6d0f4f71435deb82b2d85 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:58:40 +0530 Subject: [PATCH 06/13] [vroom][src] Add vroom functions with timestamp --- src/common/vroom/breaks_input.c | 24 +++++++++---- src/common/vroom/jobs_input.c | 24 +++++++++---- src/common/vroom/shipments_input.c | 37 +++++++++++-------- src/common/vroom/time_windows_input.c | 51 +++++++++++++++++++++------ src/common/vroom/vehicles_input.c | 30 +++++++++++----- src/vroom/vroom.c | 21 +++++++---- 6 files changed, 135 insertions(+), 52 deletions(-) diff --git a/src/common/vroom/breaks_input.c b/src/common/vroom/breaks_input.c index 801e9deb1..ab22aa153 100644 --- a/src/common/vroom/breaks_input.c +++ b/src/common/vroom/breaks_input.c @@ -56,10 +56,16 @@ void fetch_breaks( HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, - Vroom_break_t *vroom_break) { + Vroom_break_t *vroom_break, + bool is_plain) { vroom_break->id = get_Idx(tuple, tupdesc, info[0], 0); vroom_break->vehicle_id = get_Idx(tuple, tupdesc, info[1], 0); - vroom_break->service = get_Duration(tuple, tupdesc, info[2], 0); + if (is_plain) { + vroom_break->service = get_Duration(tuple, tupdesc, info[2], 0); + } else { + vroom_break->service = + (Duration)get_PositiveTInterval(tuple, tupdesc, info[2], 0); + } } @@ -70,7 +76,8 @@ void db_get_breaks( size_t *total_breaks, Column_info_t *info, - const int column_count) { + const int column_count, + bool is_plain) { #ifdef PROFILE clock_t start_t = clock(); PGR_DBG("%s", breaks_sql); @@ -116,7 +123,7 @@ void db_get_breaks( for (t = 0; t < ntuples; t++) { HeapTuple tuple = tuptable->vals[t]; fetch_breaks(&tuple, &tupdesc, info, - &(*breaks)[total_tuples - ntuples + t]); + &(*breaks)[total_tuples - ntuples + t], is_plain); } SPI_freetuptable(tuptable); } else { @@ -148,7 +155,8 @@ void get_vroom_breaks( char *sql, Vroom_break_t **rows, - size_t *total_rows) { + size_t *total_rows, + bool is_plain) { int kColumnCount = 3; Column_info_t info[kColumnCount]; @@ -165,8 +173,12 @@ get_vroom_breaks( info[2].eType = INTEGER; // service + if (!is_plain) { + info[2].eType = INTERVAL; // service + } + /* service is not mandatory */ info[2].strict = false; - db_get_breaks(sql, rows, total_rows, info, kColumnCount); + 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 332e28e00..443e4b5ff 100644 --- a/src/common/vroom/jobs_input.c +++ b/src/common/vroom/jobs_input.c @@ -82,10 +82,16 @@ void fetch_jobs( HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, - Vroom_job_t *job) { + Vroom_job_t *job, + bool is_plain) { job->id = get_Idx(tuple, tupdesc, info[0], 0); job->location_index = get_MatrixIndex(tuple, tupdesc, info[1], 0); - job->service = get_Duration(tuple, tupdesc, info[2], 0); + + if (is_plain) { + job->service = get_Duration(tuple, tupdesc, info[2], 0); + } else { + job->service = (Duration)get_PositiveTInterval(tuple, tupdesc, info[2], 0); + } /* * The deliveries @@ -119,7 +125,8 @@ void db_get_jobs( size_t *total_jobs, Column_info_t *info, - const int column_count) { + const int column_count, + bool is_plain) { #ifdef PROFILE clock_t start_t = clock(); PGR_DBG("%s", jobs_sql); @@ -165,7 +172,7 @@ void db_get_jobs( for (t = 0; t < ntuples; t++) { HeapTuple tuple = tuptable->vals[t]; fetch_jobs(&tuple, &tupdesc, info, - &(*jobs)[total_tuples - ntuples + t]); + &(*jobs)[total_tuples - ntuples + t], is_plain); } SPI_freetuptable(tuptable); } else { @@ -196,7 +203,8 @@ void get_vroom_jobs( char *sql, Vroom_job_t **rows, - size_t *total_rows) { + size_t *total_rows, + bool is_plain) { int kColumnCount = 7; Column_info_t info[kColumnCount]; @@ -221,9 +229,13 @@ get_vroom_jobs( info[5].eType = INTEGER_ARRAY; // skills info[6].eType = INTEGER; // priority + if (!is_plain) { + info[2].eType = INTERVAL; // service + } + /* Only id and location_index are mandatory */ info[0].strict = true; info[1].strict = true; - db_get_jobs(sql, rows, total_rows, info, kColumnCount); + db_get_jobs(sql, rows, total_rows, info, kColumnCount, is_plain); } diff --git a/src/common/vroom/shipments_input.c b/src/common/vroom/shipments_input.c index 864b4dc71..9e8ab1042 100644 --- a/src/common/vroom/shipments_input.c +++ b/src/common/vroom/shipments_input.c @@ -80,20 +80,22 @@ void fetch_shipments( HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, - Vroom_shipment_t *shipment) { + Vroom_shipment_t *shipment, + bool is_plain) { shipment->id = get_Idx(tuple, tupdesc, info[0], 0); - /* - * The pickups - */ shipment->p_location_index = get_MatrixIndex(tuple, tupdesc, info[1], 0); - shipment->p_service = get_Duration(tuple, tupdesc, info[2], 0); - - /* - * The deliveries - */ shipment->d_location_index = get_MatrixIndex(tuple, tupdesc, info[3], 0); - shipment->d_service = get_Duration(tuple, tupdesc, info[4], 0); + + if (is_plain) { + shipment->p_service = get_Duration(tuple, tupdesc, info[2], 0); + shipment->d_service = get_Duration(tuple, tupdesc, info[4], 0); + } else { + shipment->p_service = + (Duration)get_PositiveTInterval(tuple, tupdesc, info[2], 0); + shipment->d_service = + (Duration)get_PositiveTInterval(tuple, tupdesc, info[4], 0); + } shipment->amount_size = 0; shipment->amount = column_found(info[5].colNumber) ? @@ -116,7 +118,8 @@ void db_get_shipments( size_t *total_shipments, Column_info_t *info, - const int column_count) { + const int column_count, + bool is_plain) { #ifdef PROFILE clock_t start_t = clock(); PGR_DBG("%s", shipments_sql); @@ -162,7 +165,7 @@ void db_get_shipments( for (t = 0; t < ntuples; t++) { HeapTuple tuple = tuptable->vals[t]; fetch_shipments(&tuple, &tupdesc, info, - &(*shipments)[total_tuples - ntuples + t]); + &(*shipments)[total_tuples - ntuples + t], is_plain); } SPI_freetuptable(tuptable); } else { @@ -193,7 +196,8 @@ void get_vroom_shipments( char *sql, Vroom_shipment_t **rows, - size_t *total_rows) { + size_t *total_rows, + bool is_plain) { int kColumnCount = 8; Column_info_t info[kColumnCount]; @@ -224,10 +228,15 @@ get_vroom_shipments( info[6].eType = INTEGER_ARRAY; // skills info[7].eType = INTEGER; // priority + if (!is_plain) { + info[2].eType = INTERVAL; // p_service + info[4].eType = INTERVAL; // d_service + } + /* id and location_index of pickup and delivery are mandatory */ info[0].strict = true; info[1].strict = true; info[3].strict = true; - db_get_shipments(sql, rows, total_rows, info, kColumnCount); + db_get_shipments(sql, rows, total_rows, info, kColumnCount, is_plain); } diff --git a/src/common/vroom/time_windows_input.c b/src/common/vroom/time_windows_input.c index b45979317..e5a94cd7a 100644 --- a/src/common/vroom/time_windows_input.c +++ b/src/common/vroom/time_windows_input.c @@ -72,7 +72,8 @@ void fetch_time_windows( TupleDesc *tupdesc, Column_info_t *info, Vroom_time_window_t *time_window, - bool is_shipment) { + bool is_shipment, + bool is_plain) { time_window->id = get_Idx(tuple, tupdesc, info[0], 0); @@ -83,11 +84,25 @@ void fetch_time_windows( errhint("Kind must be either 'p' or 'd'"))); } time_window->kind = kind; - time_window->start_time = get_Duration(tuple, tupdesc, info[2], 0); - time_window->end_time = get_Duration(tuple, tupdesc, info[3], 0); + if (is_plain) { + time_window->start_time = get_Duration(tuple, tupdesc, info[2], 0); + time_window->end_time = get_Duration(tuple, tupdesc, info[3], 0); + } else { + time_window->start_time = + (Duration)get_PositiveTTimestamp(tuple, tupdesc, info[2], 0); + time_window->end_time = + (Duration)get_PositiveTTimestamp(tuple, tupdesc, info[3], 0); + } } else { - time_window->start_time = get_Duration(tuple, tupdesc, info[1], 0); - time_window->end_time = get_Duration(tuple, tupdesc, info[2], 0); + if (is_plain) { + time_window->start_time = get_Duration(tuple, tupdesc, info[1], 0); + time_window->end_time = get_Duration(tuple, tupdesc, info[2], 0); + } else { + time_window->start_time = + (Duration)get_PositiveTTimestamp(tuple, tupdesc, info[1], 0); + time_window->end_time = + (Duration)get_PositiveTTimestamp(tuple, tupdesc, info[2], 0); + } } if (time_window->start_time > time_window->end_time) { @@ -109,7 +124,8 @@ void db_get_time_windows( Column_info_t *info, const int column_count, - bool is_shipment) { + bool is_shipment, + bool is_plain) { #ifdef PROFILE clock_t start_t = clock(); PGR_DBG("%s", time_windows_sql); @@ -155,7 +171,8 @@ void db_get_time_windows( for (t = 0; t < ntuples; t++) { HeapTuple tuple = tuptable->vals[t]; fetch_time_windows(&tuple, &tupdesc, info, - &(*time_windows)[total_tuples - ntuples + t], is_shipment); + &(*time_windows)[total_tuples - ntuples + t], + is_shipment, is_plain); } SPI_freetuptable(tuptable); } else { @@ -186,7 +203,8 @@ void get_vroom_time_windows( char *sql, Vroom_time_window_t **rows, - size_t *total_rows) { + size_t *total_rows, + bool is_plain) { int kColumnCount = 3; Column_info_t info[kColumnCount]; @@ -203,7 +221,12 @@ get_vroom_time_windows( info[0].eType = ANY_INTEGER; // id - db_get_time_windows(sql, rows, total_rows, info, kColumnCount, 0); + if (!is_plain) { + info[1].eType = TIMESTAMP; // tw_open + info[2].eType = TIMESTAMP; // tw_close + } + + db_get_time_windows(sql, rows, total_rows, info, kColumnCount, 0, is_plain); } /** @@ -215,7 +238,8 @@ void get_vroom_shipments_time_windows( char *sql, Vroom_time_window_t **rows, - size_t *total_rows) { + size_t *total_rows, + bool is_plain) { int kColumnCount = 4; Column_info_t info[kColumnCount]; @@ -234,5 +258,10 @@ get_vroom_shipments_time_windows( info[0].eType = ANY_INTEGER; // id info[1].eType = CHAR1; // kind - db_get_time_windows(sql, rows, total_rows, info, kColumnCount, 1); + if (!is_plain) { + info[2].eType = TIMESTAMP; // tw_open + info[3].eType = TIMESTAMP; // tw_close + } + + db_get_time_windows(sql, rows, total_rows, info, kColumnCount, 1, is_plain); } diff --git a/src/common/vroom/vehicles_input.c b/src/common/vroom/vehicles_input.c index 73fd69dc5..fc02d4dc9 100644 --- a/src/common/vroom/vehicles_input.c +++ b/src/common/vroom/vehicles_input.c @@ -83,7 +83,8 @@ void fetch_vehicles( HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, - Vroom_vehicle_t *vehicle) { + Vroom_vehicle_t *vehicle, + bool is_plain) { vehicle->id = get_Idx(tuple, tupdesc, info[0], 0); vehicle->start_index = get_MatrixIndex(tuple, tupdesc, info[1], -1); vehicle->end_index = get_MatrixIndex(tuple, tupdesc, info[2], -1); @@ -98,8 +99,15 @@ void fetch_vehicles( spi_getPositiveIntArr_allowEmpty(tuple, tupdesc, info[4], &vehicle->skills_size) : NULL; - vehicle->time_window_start = get_Duration(tuple, tupdesc, info[5], 0); - vehicle->time_window_end = get_Duration(tuple, tupdesc, info[6], UINT_MAX); + if (is_plain) { + vehicle->time_window_start = get_Duration(tuple, tupdesc, info[5], 0); + vehicle->time_window_end = get_Duration(tuple, tupdesc, info[6], UINT_MAX); + } else { + vehicle->time_window_start = + (Duration)get_PositiveTTimestamp(tuple, tupdesc, info[5], 0); + vehicle->time_window_end = + (Duration)get_PositiveTTimestamp(tuple, tupdesc, info[6], UINT_MAX); + } if (vehicle->time_window_start > vehicle->time_window_end) { ereport(ERROR, @@ -123,7 +131,8 @@ void db_get_vehicles( size_t *total_vehicles, Column_info_t *info, - const int column_count) { + const int column_count, + bool is_plain) { #ifdef PROFILE clock_t start_t = clock(); PGR_DBG("%s", vehicles_sql); @@ -175,7 +184,7 @@ void db_get_vehicles( for (t = 0; t < ntuples; t++) { HeapTuple tuple = tuptable->vals[t]; fetch_vehicles(&tuple, &tupdesc, info, - &(*vehicles)[total_tuples - ntuples + t]); + &(*vehicles)[total_tuples - ntuples + t], is_plain); } SPI_freetuptable(tuptable); } else { @@ -206,7 +215,8 @@ void get_vroom_vehicles( char *sql, Vroom_vehicle_t **rows, - size_t *total_rows) { + size_t *total_rows, + bool is_plain) { int kColumnCount = 8; Column_info_t info[kColumnCount]; @@ -230,14 +240,18 @@ get_vroom_vehicles( info[4].eType = INTEGER_ARRAY; // skills info[5].eType = INTEGER; // tw_open info[6].eType = INTEGER; // tw_close - info[7].eType = ANY_NUMERICAL; // speed_factor + if (!is_plain) { + info[5].eType = TIMESTAMP; // tw_open + info[6].eType = TIMESTAMP; // tw_close + } + /** * id is mandatory. * At least one out of start_index or end_index must be present, but that is checked later. */ info[0].strict = true; - db_get_vehicles(sql, rows, total_rows, info, kColumnCount); + db_get_vehicles(sql, rows, total_rows, info, kColumnCount, is_plain); } diff --git a/src/vroom/vroom.c b/src/vroom/vroom.c index b54039d4e..0d2723609 100644 --- a/src/vroom/vroom.c +++ b/src/vroom/vroom.c @@ -81,6 +81,7 @@ PG_FUNCTION_INFO_V1(_vrp_vroom); * @param breaks_tws_sql SQL query describing the time windows for break start. * @param matrix_sql SQL query describing the cells of the cost matrix * @param fn Value denoting the function used. + * @param is_plain Value denoting whether the plain/timestamp function is used. * @param result_tuples the rows in the result * @param result_count the count of rows in the result * @@ -98,6 +99,7 @@ process( char *breaks_tws_sql, char *matrix_sql, int16_t fn, + bool is_plain, Vroom_rt **result_tuples, size_t *result_count) { @@ -109,13 +111,13 @@ process( Vroom_job_t *jobs = NULL; size_t total_jobs = 0; if (jobs_sql) { - get_vroom_jobs(jobs_sql, &jobs, &total_jobs); + get_vroom_jobs(jobs_sql, &jobs, &total_jobs, is_plain); } Vroom_shipment_t *shipments = NULL; size_t total_shipments = 0; if (shipments_sql) { - get_vroom_shipments(shipments_sql, &shipments, &total_shipments); + get_vroom_shipments(shipments_sql, &shipments, &total_shipments, is_plain); } if (total_jobs == 0 && total_shipments == 0) { @@ -138,18 +140,20 @@ process( Vroom_time_window_t *jobs_tws = NULL; size_t total_jobs_tws = 0; if (jobs_tws_sql) { - get_vroom_time_windows(jobs_tws_sql, &jobs_tws, &total_jobs_tws); + get_vroom_time_windows(jobs_tws_sql, &jobs_tws, &total_jobs_tws, + is_plain); } Vroom_time_window_t *shipments_tws = NULL; size_t total_shipments_tws = 0; if (shipments_tws_sql) { - get_vroom_shipments_time_windows(shipments_tws_sql, &shipments_tws, &total_shipments_tws); + get_vroom_shipments_time_windows(shipments_tws_sql, &shipments_tws, + &total_shipments_tws, is_plain); } Vroom_vehicle_t *vehicles = NULL; size_t total_vehicles = 0; - get_vroom_vehicles(vehicles_sql, &vehicles, &total_vehicles); + get_vroom_vehicles(vehicles_sql, &vehicles, &total_vehicles, is_plain); if (total_vehicles == 0) { ereport(WARNING, (errmsg("Insufficient data found on Vehicles SQL query."), @@ -163,13 +167,14 @@ process( Vroom_break_t *breaks = NULL; size_t total_breaks = 0; if (breaks_sql) { - get_vroom_breaks(breaks_sql, &breaks, &total_breaks); + get_vroom_breaks(breaks_sql, &breaks, &total_breaks, is_plain); } Vroom_time_window_t *breaks_tws = NULL; size_t total_breaks_tws = 0; if (breaks_tws_sql) { - get_vroom_time_windows(breaks_tws_sql, &breaks_tws, &total_breaks_tws); + get_vroom_time_windows(breaks_tws_sql, &breaks_tws, &total_breaks_tws, + is_plain); } Matrix_cell_t *matrix_cells_arr = NULL; @@ -274,6 +279,7 @@ PGDLLEXPORT Datum _vrp_vroom(PG_FUNCTION_ARGS) { } int16_t fn = PG_GETARG_INT16(8); + bool is_plain = PG_GETARG_BOOL(9); // Verify that both jobs_sql and shipments_sql are not NULL if (args[0] == NULL && args[2] == NULL) { @@ -304,6 +310,7 @@ PGDLLEXPORT Datum _vrp_vroom(PG_FUNCTION_ARGS) { args[6], args[7], fn, + is_plain, &result_tuples, &result_count); From 12c2e7c9aec2cafcc4728d6e0e5f6158120c6913 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 31 Aug 2021 18:58:50 +0530 Subject: [PATCH 07/13] [vroom][include] Add vroom functions with timestamp --- include/c_common/vroom/breaks_input.h | 3 ++- include/c_common/vroom/jobs_input.h | 3 ++- include/c_common/vroom/shipments_input.h | 3 ++- include/c_common/vroom/time_windows_input.h | 6 ++++-- include/c_common/vroom/vehicles_input.h | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/c_common/vroom/breaks_input.h b/include/c_common/vroom/breaks_input.h index 9ced90937..7dec72a15 100644 --- a/include/c_common/vroom/breaks_input.h +++ b/include/c_common/vroom/breaks_input.h @@ -46,6 +46,7 @@ void get_vroom_breaks( char *breaks_sql, Vroom_break_t **breaks, - size_t *total_breaks); + size_t *total_breaks, + bool is_plain); #endif // INCLUDE_C_COMMON_VROOM_BREAKS_INPUT_H_ diff --git a/include/c_common/vroom/jobs_input.h b/include/c_common/vroom/jobs_input.h index 8cc5a51ac..9c4e33076 100644 --- a/include/c_common/vroom/jobs_input.h +++ b/include/c_common/vroom/jobs_input.h @@ -46,6 +46,7 @@ void get_vroom_jobs( char *jobs_sql, Vroom_job_t **jobs, - size_t *total_jobs); + size_t *total_jobs, + bool is_plain); #endif // INCLUDE_C_COMMON_VROOM_JOBS_INPUT_H_ diff --git a/include/c_common/vroom/shipments_input.h b/include/c_common/vroom/shipments_input.h index 22bc7fa06..7cf074e48 100644 --- a/include/c_common/vroom/shipments_input.h +++ b/include/c_common/vroom/shipments_input.h @@ -46,6 +46,7 @@ void get_vroom_shipments( char *shipments_sql, Vroom_shipment_t **shipments, - size_t *total_shipments); + size_t *total_shipments, + bool is_plain); #endif // INCLUDE_C_COMMON_VROOM_SHIPMENTS_INPUT_H_ diff --git a/include/c_common/vroom/time_windows_input.h b/include/c_common/vroom/time_windows_input.h index a252a0d43..1ffa8bc16 100644 --- a/include/c_common/vroom/time_windows_input.h +++ b/include/c_common/vroom/time_windows_input.h @@ -47,13 +47,15 @@ void get_vroom_time_windows( char *time_windows_sql, Vroom_time_window_t **time_windows, - size_t *total_time_windows); + size_t *total_time_windows, + bool is_plain); /** @brief Reads the VROOM shipments time windows */ void get_vroom_shipments_time_windows( char *time_windows_sql, Vroom_time_window_t **time_windows, - size_t *total_time_windows); + size_t *total_time_windows, + bool is_plain); #endif // INCLUDE_C_COMMON_VROOM_TIME_WINDOWS_INPUT_H_ diff --git a/include/c_common/vroom/vehicles_input.h b/include/c_common/vroom/vehicles_input.h index 298f2a7c5..851b15392 100644 --- a/include/c_common/vroom/vehicles_input.h +++ b/include/c_common/vroom/vehicles_input.h @@ -46,6 +46,7 @@ void get_vroom_vehicles( char *vehicles_sql, Vroom_vehicle_t **vehicles, - size_t *total_vehicles); + size_t *total_vehicles, + bool is_plain); #endif // INCLUDE_C_COMMON_VROOM_VEHICLES_INPUT_H_ From 703c7eccb639ef3f00b908597998ad953ec74b6a Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 3 Sep 2021 10:04:51 +0530 Subject: [PATCH 08/13] [vroom][docquery] Fixed codacy errors for \echo --- docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.result | 6 +++--- docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.test.sql | 6 +++--- .../pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.result | 4 ++-- .../pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.test.sql | 4 ++-- docqueries/pgr_pickDeliver/pickDeliver.result | 6 +++--- docqueries/pgr_pickDeliver/pickDeliver.test.sql | 6 +++--- docqueries/version/doc-full_version.result | 4 ++-- docqueries/version/doc-full_version.test.sql | 4 ++-- docqueries/version/doc-version.result | 4 ++-- docqueries/version/doc-version.test.sql | 4 ++-- docqueries/vroom/doc-vrp_vroom.result | 6 +++--- docqueries/vroom/doc-vrp_vroom.test.sql | 6 +++--- docqueries/vroom/doc-vrp_vroomJobs.result | 6 +++--- docqueries/vroom/doc-vrp_vroomJobs.test.sql | 6 +++--- docqueries/vroom/doc-vrp_vroomJobsPlain.result | 6 +++--- docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql | 6 +++--- docqueries/vroom/doc-vrp_vroomPlain.result | 6 +++--- docqueries/vroom/doc-vrp_vroomPlain.test.sql | 6 +++--- docqueries/vroom/doc-vrp_vroomShipments.result | 6 +++--- docqueries/vroom/doc-vrp_vroomShipments.test.sql | 6 +++--- docqueries/vroom/doc-vrp_vroomShipmentsPlain.result | 6 +++--- docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql | 6 +++--- 22 files changed, 60 insertions(+), 60 deletions(-) diff --git a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.result b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.result index 2aed993ed..2ae4bbc88 100644 --- a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.result +++ b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.result @@ -4,7 +4,7 @@ SET client_min_messages TO NOTICE; SET SET extra_float_digits=-3; SET ---q1 +/* --q1 */ SELECT * FROM vrp_pgr_pickDeliver( 'SELECT * FROM orders_1 ORDER BY id', 'SELECT * from vehicles_1', @@ -35,7 +35,7 @@ SELECT * FROM vrp_pgr_pickDeliver( 11 | -2 | 0 | 0 | -1 | -1 | -1 | -1 | 10 | -1 | 2 | 17 | 29 (11 rows) ---q2 +/* --q2 */ SELECT * FROM vrp_pgr_pickDeliver( $$ SELECT * FROM orders_1 ORDER BY id $$, $$ SELECT * FROM vehicles_1 ORDER BY id$$, @@ -63,6 +63,6 @@ SELECT * FROM vrp_pgr_pickDeliver( 11 | -2 | 0 | 0 | -1 | -1 | -1 | -1 | 16 | -1 | 1 | 17 | 34 (11 rows) ---q3 +/* --q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.test.sql b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.test.sql index 3d8e5b66d..3cdcf1fcb 100644 --- a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.test.sql +++ b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliver.test.sql @@ -1,5 +1,5 @@ SET extra_float_digits=-3; -\echo --q1 +/* --q1 */ SELECT * FROM vrp_pgr_pickDeliver( 'SELECT * FROM orders_1 ORDER BY id', 'SELECT * from vehicles_1', @@ -16,7 +16,7 @@ SELECT * FROM vrp_pgr_pickDeliver( FROM A, A AS B WHERE A.id != B.id' ); -\echo --q2 +/* --q2 */ SELECT * FROM vrp_pgr_pickDeliver( $$ SELECT * FROM orders_1 ORDER BY id $$, @@ -31,4 +31,4 @@ SELECT * FROM vrp_pgr_pickDeliver( $$ ); -\echo --q3 +/* --q3 */ diff --git a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.result b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.result index f5bcb5f1b..e173dc10d 100644 --- a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.result +++ b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.result @@ -4,7 +4,7 @@ SET client_min_messages TO NOTICE; SET SET extra_float_digits=-3; SET ---q1 +/* --q1 */ SELECT * FROM vrp_pgr_pickDeliverEuclidean( 'SELECT * FROM orders_1 ORDER BY id', 'SELECT * from vehicles_1' @@ -24,6 +24,6 @@ SELECT * FROM vrp_pgr_pickDeliverEuclidean( 11 | -2 | 0 | 0 | -1 | -1 | -1 | 11 | -1 | 1 | 17 | 29 (11 rows) ---q2 +/* --q2 */ ROLLBACK; ROLLBACK diff --git a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.test.sql b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.test.sql index 359a5d734..ad787385f 100644 --- a/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.test.sql +++ b/docqueries/pgr_pickDeliver/doc-pgr_pickDeliverEuclidean.test.sql @@ -1,7 +1,7 @@ SET extra_float_digits=-3; -\echo --q1 +/* --q1 */ SELECT * FROM vrp_pgr_pickDeliverEuclidean( 'SELECT * FROM orders_1 ORDER BY id', 'SELECT * from vehicles_1' ); -\echo --q2 +/* --q2 */ diff --git a/docqueries/pgr_pickDeliver/pickDeliver.result b/docqueries/pgr_pickDeliver/pickDeliver.result index 66c36af68..4716bb189 100644 --- a/docqueries/pgr_pickDeliver/pickDeliver.result +++ b/docqueries/pgr_pickDeliver/pickDeliver.result @@ -1,4 +1,4 @@ ---q1 +/* --q1 */ 1|1|1|-1|0|0|0|0|0 2|1|2|5|15.1327459504216|15.1327459504216|0|90|105.132745950422 3|1|3|3|1|106.132745950422|0|90|196.132745950422 @@ -126,7 +126,7 @@ 125|10|11|99|5|782.402110959561|0|90|872.402110959561 126|10|12|-1|33.5410196624968|905.943130622058|0|0|905.943130622058 127|-2|0|-1|879.42275822512|-1|0|9000|9879.42275822512 ---q2 +/* --q2 */ 1|1|1|1|-1|1|0|0|0|0|0|0 2|1|1|2|5|2|10|15.1327459504216|15.1327459504216|0|90|105.132745950422 3|1|1|3|3|2|20|1|106.132745950422|0|90|196.132745950422 @@ -254,4 +254,4 @@ 125|10|1|11|100|3|0|5|782.402110959561|0|90|872.402110959561 126|10|1|12|-1|6|0|33.5410196624968|905.943130622058|0|0|905.943130622058 127|-2|0|0|-1|-1|-1|879.42275822512|-1|0|9000|9879.42275822512 ---q3 +/* --q3 */ diff --git a/docqueries/pgr_pickDeliver/pickDeliver.test.sql b/docqueries/pgr_pickDeliver/pickDeliver.test.sql index 9dc7ce239..bad99832f 100644 --- a/docqueries/pgr_pickDeliver/pickDeliver.test.sql +++ b/docqueries/pgr_pickDeliver/pickDeliver.test.sql @@ -1,10 +1,10 @@ -\echo --q1 +/* --q1 */ SELECT * FROM _pgr_pickDeliver( 'select * from customer order by id', 25, 200, 1, 30); -\echo --q2 +/* --q2 */ SELECT * FROM _pgr_pickDeliverEuclidean( 'SELECT * FROM orders ORDER BY id', 'SELECT * FROM vehicles', 30); -\echo --q3 +/* --q3 */ diff --git a/docqueries/version/doc-full_version.result b/docqueries/version/doc-full_version.result index be5593924..8e8df0161 100644 --- a/docqueries/version/doc-full_version.result +++ b/docqueries/version/doc-full_version.result @@ -2,13 +2,13 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT version, library FROM vrp_full_version(); version | library -----------+------------------ 0.2.0-dev | vrprouting-0.2.0 (1 row) --- q2 +/* -- q2 */ ROLLBACK; ROLLBACK diff --git a/docqueries/version/doc-full_version.test.sql b/docqueries/version/doc-full_version.test.sql index f9f5afa1d..ba6422521 100644 --- a/docqueries/version/doc-full_version.test.sql +++ b/docqueries/version/doc-full_version.test.sql @@ -1,3 +1,3 @@ -\echo -- q1 +/* -- q1 */ SELECT version, library FROM vrp_full_version(); -\echo -- q2 +/* -- q2 */ diff --git a/docqueries/version/doc-version.result b/docqueries/version/doc-version.result index 8e56dbfb6..b498fff1c 100644 --- a/docqueries/version/doc-version.result +++ b/docqueries/version/doc-version.result @@ -2,13 +2,13 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT vrp_version(); vrp_version ------------- 0.2.0-dev (1 row) --- q2 +/* -- q2 */ ROLLBACK; ROLLBACK diff --git a/docqueries/version/doc-version.test.sql b/docqueries/version/doc-version.test.sql index f0e09b5a5..717eaeab8 100644 --- a/docqueries/version/doc-version.test.sql +++ b/docqueries/version/doc-version.test.sql @@ -2,6 +2,6 @@ -------------------------------------------------------------------------------- -- vrp_version -------------------------------------------------------------------------------- -\echo -- q1 +/* -- q1 */ SELECT vrp_version(); -\echo -- q2 +/* -- q2 */ diff --git a/docqueries/vroom/doc-vrp_vroom.result b/docqueries/vroom/doc-vrp_vroom.result index 371ee2ad9..c5f0bbb65 100644 --- a/docqueries/vroom/doc-vrp_vroom.result +++ b/docqueries/vroom/doc-vrp_vroom.result @@ -2,7 +2,7 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT * FROM vrp_vroom( 'SELECT * FROM vroom.jobs', @@ -45,7 +45,7 @@ FROM vrp_vroom( 27 | 4 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0} (27 rows) --- q2 +/* -- q2 */ SELECT * FROM vrp_vroom( $jobs$ @@ -86,6 +86,6 @@ FROM vrp_vroom( 6 | 1 | 1 | 6 | 6 | -1 | 5461 | 5461 | 0 | 0 | {} (6 rows) --- q3 +/* -- q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroom.test.sql b/docqueries/vroom/doc-vrp_vroom.test.sql index c0ce92438..7b369bb01 100644 --- a/docqueries/vroom/doc-vrp_vroom.test.sql +++ b/docqueries/vroom/doc-vrp_vroom.test.sql @@ -1,4 +1,4 @@ -\echo -- q1 +/* -- q1 */ SELECT * FROM vrp_vroom( 'SELECT * FROM vroom.jobs', @@ -10,7 +10,7 @@ FROM vrp_vroom( 'SELECT * FROM vroom.breaks_time_windows', 'SELECT * FROM vroom.matrix' ); -\echo -- q2 +/* -- q2 */ SELECT * FROM vrp_vroom( $jobs$ @@ -41,4 +41,4 @@ FROM vrp_vroom( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); -\echo -- q3 +/* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomJobs.result b/docqueries/vroom/doc-vrp_vroomJobs.result index db6a8f149..30585e686 100644 --- a/docqueries/vroom/doc-vrp_vroomJobs.result +++ b/docqueries/vroom/doc-vrp_vroomJobs.result @@ -2,7 +2,7 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT * FROM vrp_vroomJobs( 'SELECT * FROM vroom.jobs', @@ -27,7 +27,7 @@ FROM vrp_vroomJobs( 11 | 2 | 2 | 7 | 6 | -1 | 3775 | 190 | 0 | 0 | {100} (11 rows) --- q2 +/* -- q2 */ SELECT * FROM vrp_vroomJobs( $jobs$ @@ -60,6 +60,6 @@ FROM vrp_vroomJobs( 4 | 1 | 1 | 4 | 6 | -1 | 5461 | 5461 | 0 | 0 | {} (4 rows) --- q3 +/* -- q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomJobs.test.sql b/docqueries/vroom/doc-vrp_vroomJobs.test.sql index c2d39c778..2ea6f4a4a 100644 --- a/docqueries/vroom/doc-vrp_vroomJobs.test.sql +++ b/docqueries/vroom/doc-vrp_vroomJobs.test.sql @@ -1,4 +1,4 @@ -\echo -- q1 +/* -- q1 */ SELECT * FROM vrp_vroomJobs( 'SELECT * FROM vroom.jobs', @@ -8,7 +8,7 @@ FROM vrp_vroomJobs( 'SELECT * FROM vroom.breaks_time_windows', 'SELECT * FROM vroom.matrix' ); -\echo -- q2 +/* -- q2 */ SELECT * FROM vrp_vroomJobs( $jobs$ @@ -33,4 +33,4 @@ FROM vrp_vroomJobs( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); -\echo -- q3 +/* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomJobsPlain.result b/docqueries/vroom/doc-vrp_vroomJobsPlain.result index 55c557aae..d520a7371 100644 --- a/docqueries/vroom/doc-vrp_vroomJobsPlain.result +++ b/docqueries/vroom/doc-vrp_vroomJobsPlain.result @@ -2,7 +2,7 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT * FROM vrp_vroomJobsPlain( 'SELECT * FROM vroom.jobs', @@ -27,7 +27,7 @@ FROM vrp_vroomJobsPlain( 11 | 2 | 2 | 7 | 6 | -1 | 3775 | 190 | 0 | 0 | {100} (11 rows) --- q2 +/* -- q2 */ SELECT * FROM vrp_vroomJobsPlain( $jobs$ @@ -60,6 +60,6 @@ FROM vrp_vroomJobsPlain( 4 | 1 | 1 | 4 | 6 | -1 | 5461 | 5461 | 0 | 0 | {} (4 rows) --- q3 +/* -- q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql b/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql index f92e18ff1..aa82a70c4 100644 --- a/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql +++ b/docqueries/vroom/doc-vrp_vroomJobsPlain.test.sql @@ -1,4 +1,4 @@ -\echo -- q1 +/* -- q1 */ SELECT * FROM vrp_vroomJobsPlain( 'SELECT * FROM vroom.jobs', @@ -8,7 +8,7 @@ FROM vrp_vroomJobsPlain( 'SELECT * FROM vroom.breaks_time_windows', 'SELECT * FROM vroom.matrix' ); -\echo -- q2 +/* -- q2 */ SELECT * FROM vrp_vroomJobsPlain( $jobs$ @@ -33,4 +33,4 @@ FROM vrp_vroomJobsPlain( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); -\echo -- q3 +/* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomPlain.result b/docqueries/vroom/doc-vrp_vroomPlain.result index d77ec48ae..32a9adadf 100644 --- a/docqueries/vroom/doc-vrp_vroomPlain.result +++ b/docqueries/vroom/doc-vrp_vroomPlain.result @@ -2,7 +2,7 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT * FROM vrp_vroomPlain( 'SELECT * FROM vroom.jobs', @@ -45,7 +45,7 @@ FROM vrp_vroomPlain( 27 | 4 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0} (27 rows) --- q2 +/* -- q2 */ SELECT * FROM vrp_vroomPlain( $jobs$ @@ -86,6 +86,6 @@ FROM vrp_vroomPlain( 6 | 1 | 1 | 6 | 6 | -1 | 5461 | 5461 | 0 | 0 | {} (6 rows) --- q3 +/* -- q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomPlain.test.sql b/docqueries/vroom/doc-vrp_vroomPlain.test.sql index 738b4d492..11140d50e 100644 --- a/docqueries/vroom/doc-vrp_vroomPlain.test.sql +++ b/docqueries/vroom/doc-vrp_vroomPlain.test.sql @@ -1,4 +1,4 @@ -\echo -- q1 +/* -- q1 */ SELECT * FROM vrp_vroomPlain( 'SELECT * FROM vroom.jobs', @@ -10,7 +10,7 @@ FROM vrp_vroomPlain( 'SELECT * FROM vroom.breaks_time_windows', 'SELECT * FROM vroom.matrix' ); -\echo -- q2 +/* -- q2 */ SELECT * FROM vrp_vroomPlain( $jobs$ @@ -41,4 +41,4 @@ FROM vrp_vroomPlain( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); -\echo -- q3 +/* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomShipments.result b/docqueries/vroom/doc-vrp_vroomShipments.result index 625293f5e..babf4384a 100644 --- a/docqueries/vroom/doc-vrp_vroomShipments.result +++ b/docqueries/vroom/doc-vrp_vroomShipments.result @@ -2,7 +2,7 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT * FROM vrp_vroomShipments( 'SELECT * FROM vroom.shipments', @@ -32,7 +32,7 @@ FROM vrp_vroomShipments( 16 | 2 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0} (16 rows) --- q2 +/* -- q2 */ SELECT * FROM vrp_vroomShipments( $shipments$ @@ -65,6 +65,6 @@ FROM vrp_vroomShipments( 4 | 1 | 1 | 4 | 6 | -1 | 1299 | 1299 | 0 | 0 | {} (4 rows) --- q3 +/* -- q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomShipments.test.sql b/docqueries/vroom/doc-vrp_vroomShipments.test.sql index 71fc684a6..d6cae97fe 100644 --- a/docqueries/vroom/doc-vrp_vroomShipments.test.sql +++ b/docqueries/vroom/doc-vrp_vroomShipments.test.sql @@ -1,4 +1,4 @@ -\echo -- q1 +/* -- q1 */ SELECT * FROM vrp_vroomShipments( 'SELECT * FROM vroom.shipments', @@ -8,7 +8,7 @@ FROM vrp_vroomShipments( 'SELECT * FROM vroom.breaks_time_windows', 'SELECT * FROM vroom.matrix' ); -\echo -- q2 +/* -- q2 */ SELECT * FROM vrp_vroomShipments( $shipments$ @@ -33,4 +33,4 @@ FROM vrp_vroomShipments( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); -\echo -- q3 +/* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result index a1450cbb4..e6d4e89b9 100644 --- a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result +++ b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.result @@ -2,7 +2,7 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET --- q1 +/* -- q1 */ SELECT * FROM vrp_vroomShipmentsPlain( 'SELECT * FROM vroom.shipments', @@ -32,7 +32,7 @@ FROM vrp_vroomShipmentsPlain( 16 | 2 | 4 | 7 | 6 | -1 | 27200 | 276 | 0 | 0 | {0} (16 rows) --- q2 +/* -- q2 */ SELECT * FROM vrp_vroomShipmentsPlain( $shipments$ @@ -65,6 +65,6 @@ FROM vrp_vroomShipmentsPlain( 4 | 1 | 1 | 4 | 6 | -1 | 1299 | 1299 | 0 | 0 | {} (4 rows) --- q3 +/* -- q3 */ ROLLBACK; ROLLBACK diff --git a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql index 6e6505e01..ba20c6937 100644 --- a/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql +++ b/docqueries/vroom/doc-vrp_vroomShipmentsPlain.test.sql @@ -1,4 +1,4 @@ -\echo -- q1 +/* -- q1 */ SELECT * FROM vrp_vroomShipmentsPlain( 'SELECT * FROM vroom.shipments', @@ -8,7 +8,7 @@ FROM vrp_vroomShipmentsPlain( 'SELECT * FROM vroom.breaks_time_windows', 'SELECT * FROM vroom.matrix' ); -\echo -- q2 +/* -- q2 */ SELECT * FROM vrp_vroomShipmentsPlain( $shipments$ @@ -33,4 +33,4 @@ FROM vrp_vroomShipmentsPlain( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); -\echo -- q3 +/* -- q3 */ From 01c6a42af9eefe24c8d831ed12bf630159d3207b Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 3 Sep 2021 10:28:59 +0530 Subject: [PATCH 09/13] [vroom][doc] Add vroom functions with timestamps --- doc/conf.py.in | 6 ++++++ doc/general/sampledata.rst | 9 +++++++++ doc/general/vroom-category.rst | 3 +++ doc/vroom/CMakeLists.txt | 3 +++ doc/vroom/vrp_vroom.rst | 3 ++- doc/vroom/vrp_vroomJobs.rst | 3 ++- doc/vroom/vrp_vroomShipments.rst | 3 ++- 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/doc/conf.py.in b/doc/conf.py.in index f9002a3f7..ecfa919cb 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -319,6 +319,12 @@ linkcheck_ignore = [ "https://vrp.pgrouting.org/latest/en/pgr-category.html", "https://vrp.pgrouting.org/v0/en/vroom-category.html", "https://vrp.pgrouting.org/latest/en/vroom-category.html", + "https://vrp.pgrouting.org/v0/en/vrp_vroom.html", + "https://vrp.pgrouting.org/latest/en/vrp_vroom.html", + "https://vrp.pgrouting.org/v0/en/vrp_vroomJobs.html", + "https://vrp.pgrouting.org/latest/en/vrp_vroomJobs.html", + "https://vrp.pgrouting.org/v0/en/vrp_vroomShipments.html", + "https://vrp.pgrouting.org/latest/en/vrp_vroomShipments.html", "https://vrp.pgrouting.org/v0/en/vrp_vroomPlain.html", "https://vrp.pgrouting.org/latest/en/vrp_vroomPlain.html", "https://vrp.pgrouting.org/v0/en/vrp_vroomJobsPlain.html", diff --git a/doc/general/sampledata.rst b/doc/general/sampledata.rst index 48e8bcb64..64eae77c2 100644 --- a/doc/general/sampledata.rst +++ b/doc/general/sampledata.rst @@ -126,6 +126,15 @@ Matrix :start-after: -- MATRIX TABLE start :end-before: -- MATRIX TABLE end +Modified VROOM Data +------------------------------------------------------------------------------- + +The tables created using the above VROOM Data are modified for the VROOM functions +with timestamps/interval, as: + +.. literalinclude:: ../../docqueries/vroom/doc-vrp_vroom.test.sql + :start-after: -- q0 + :end-before: -- q1 Images ------------------------------------------------------------------------------- diff --git a/doc/general/vroom-category.rst b/doc/general/vroom-category.rst index 353e1efb4..247228327 100644 --- a/doc/general/vroom-category.rst +++ b/doc/general/vroom-category.rst @@ -30,6 +30,9 @@ VROOM - Category (Experimental) .. toctree:: :maxdepth: 1 + vrp_vroom + vrp_vroomJobs + vrp_vroomShipments vrp_vroomPlain vrp_vroomJobsPlain vrp_vroomShipmentsPlain diff --git a/doc/vroom/CMakeLists.txt b/doc/vroom/CMakeLists.txt index e8f25536d..c8d650c18 100644 --- a/doc/vroom/CMakeLists.txt +++ b/doc/vroom/CMakeLists.txt @@ -1,5 +1,8 @@ SET(LOCAL_FILES + vrp_vroom.rst + vrp_vroomJobs.rst + vrp_vroomShipments.rst vrp_vroomPlain.rst vrp_vroomJobsPlain.rst vrp_vroomShipmentsPlain.rst diff --git a/doc/vroom/vrp_vroom.rst b/doc/vroom/vrp_vroom.rst index 2987ee976..b02d6414b 100644 --- a/doc/vroom/vrp_vroom.rst +++ b/doc/vroom/vrp_vroom.rst @@ -49,7 +49,8 @@ Signature :start-after: signature start :end-before: signature end -**Example**: This example is based on the VROOM Data of the :doc:`sampledata` network: +**Example**: This example is based on the modified VROOM Data of the :doc:`sampledata` network. +The modification in the tables is mentioned at the end of the :doc:`sampledata`. .. literalinclude:: doc-vrp_vroom.queries :start-after: -- q1 diff --git a/doc/vroom/vrp_vroomJobs.rst b/doc/vroom/vrp_vroomJobs.rst index be67cf924..6c568a622 100644 --- a/doc/vroom/vrp_vroomJobs.rst +++ b/doc/vroom/vrp_vroomJobs.rst @@ -48,7 +48,8 @@ Signature :start-after: signature start :end-before: signature end -**Example**: This example is based on the VROOM Data of the :doc:`sampledata` network: +**Example**: This example is based on the modified VROOM Data of the :doc:`sampledata` network. +The modification in the tables is mentioned at the end of the :doc:`sampledata`. .. literalinclude:: doc-vrp_vroomJobs.queries :start-after: -- q1 diff --git a/doc/vroom/vrp_vroomShipments.rst b/doc/vroom/vrp_vroomShipments.rst index 5a504eeed..5903a0b0b 100644 --- a/doc/vroom/vrp_vroomShipments.rst +++ b/doc/vroom/vrp_vroomShipments.rst @@ -48,7 +48,8 @@ Signature :start-after: signature start :end-before: signature end -**Example**: This example is based on the VROOM Data of the :doc:`sampledata` network: +**Example**: This example is based on the modified VROOM Data of the :doc:`sampledata` network. +The modification in the tables is mentioned at the end of the :doc:`sampledata`. .. literalinclude:: doc-vrp_vroomShipments.queries :start-after: -- q1 From 07edf3789ccb5d3f93bd799bf757f55adea12381 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 3 Sep 2021 10:29:24 +0530 Subject: [PATCH 10/13] [vroom][src] Modify doc for functions with timestamps --- src/common/vroom/breaks_input.c | 4 +++- src/common/vroom/jobs_input.c | 4 +++- src/common/vroom/shipments_input.c | 8 ++++++-- src/common/vroom/time_windows_input.c | 8 ++++++-- src/common/vroom/vehicles_input.c | 8 ++++++-- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/common/vroom/breaks_input.c b/src/common/vroom/breaks_input.c index ab22aa153..14dbfd351 100644 --- a/src/common/vroom/breaks_input.c +++ b/src/common/vroom/breaks_input.c @@ -45,7 +45,9 @@ Column Type Default Description **vehicle_id** ``ANY-INTEGER`` Non-negative unique identifier of the vehicle. -**service** ``INTEGER`` 0 The break duration, in seconds +**service** ``INTERVAL`` 0 The break duration, in seconds. + + - ``INTEGER`` for plain VROOM functions. ==================== ========================= =========== ================================================ .. vrp_vroom end diff --git a/src/common/vroom/jobs_input.c b/src/common/vroom/jobs_input.c index 443e4b5ff..1516ef9f4 100644 --- a/src/common/vroom/jobs_input.c +++ b/src/common/vroom/jobs_input.c @@ -46,7 +46,9 @@ Column Type Default Description **location_index** ``ANY-INTEGER`` Non-negative identifier of the job location. -**service** ``INTEGER`` 0 Job service duration, in seconds +**service** ``INTERVAL`` 0 Job service duration, in seconds + + - ``INTEGER`` for plain VROOM functions. **delivery** ``ARRAY[ANY-INTEGER]`` Array of non-negative integers describing multidimensional quantities for delivery such diff --git a/src/common/vroom/shipments_input.c b/src/common/vroom/shipments_input.c index 9e8ab1042..40ede8f6d 100644 --- a/src/common/vroom/shipments_input.c +++ b/src/common/vroom/shipments_input.c @@ -46,11 +46,15 @@ Column Type Default Description **p_location_index** ``ANY-INTEGER`` Non-negative identifier of the pickup location. -**p_service** ``INTEGER`` 0 Pickup service duration, in seconds +**p_service** ``INTERVAL`` 0 Pickup service duration, in seconds + + - ``INTEGER`` for plain VROOM functions. **d_location_index** ``ANY-INTEGER`` Non-negative identifier of the delivery location. -**d_service** ``INTEGER`` 0 Delivery service duration, in seconds +**d_service** ``INTERVAL`` 0 Delivery service duration, in seconds + + - ``INTEGER`` for plain VROOM functions. **amount** ``ARRAY[ANY-INTEGER]`` Array of non-negative integers describing multidimensional quantities such as number diff --git a/src/common/vroom/time_windows_input.c b/src/common/vroom/time_windows_input.c index e5a94cd7a..86311d16d 100644 --- a/src/common/vroom/time_windows_input.c +++ b/src/common/vroom/time_windows_input.c @@ -49,9 +49,13 @@ Column Type Description - Pickup shipment, or - Delivery shipment. -**tw_open** ``INTEGER`` Time window opening time. +**tw_open** ``TIMESTAMP`` Time window opening time. -**tw_close** ``INTEGER`` Time window closing time. + - ``INTEGER`` for plain VROOM functions. + +**tw_close** ``TIMESTAMP`` Time window closing time. + + - ``INTEGER`` for plain VROOM functions. ==================== ====================================== ===================================================== **Note**: diff --git a/src/common/vroom/vehicles_input.c b/src/common/vroom/vehicles_input.c index fc02d4dc9..c63f1a6d7 100644 --- a/src/common/vroom/vehicles_input.c +++ b/src/common/vroom/vehicles_input.c @@ -58,9 +58,13 @@ Column Type Description **skills** ``ARRAY[INTEGER]`` Array of non-negative integers defining mandatory skills. -**tw_open** ``INTEGER`` Time window opening time. +**tw_open** ``TIMESTAMP`` Time window opening time. -**tw_close** ``INTEGER`` Time window closing time. + - ``INTEGER`` for plain VROOM functions. + +**tw_close** ``TIMESTAMP`` Time window closing time. + + - ``INTEGER`` for plain VROOM functions. **speed_factor** ``ANY-NUMERICAL`` Vehicle travel time multiplier. ====================== ================================= ================================================ From a3b30dc417227fc88d532454cd2f4a94d981071c Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 3 Sep 2021 10:29:31 +0530 Subject: [PATCH 11/13] [vroom][sql] Modify doc for functions with timestamps --- sql/vroom/vrp_vroom.sql | 65 +++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/sql/vroom/vrp_vroom.sql b/sql/vroom/vrp_vroom.sql index f9ac6929a..bcd6597b6 100644 --- a/sql/vroom/vrp_vroom.sql +++ b/sql/vroom/vrp_vroom.sql @@ -68,43 +68,58 @@ parameters end result start -=================== ============= ================================================= -Column Type Description -=================== ============= ================================================= -**seq** ``BIGINT`` Sequential value starting from **1**. +Returns set of -**vehicle_seq** ``BIGINT`` Sequential value starting from **1** for current vehicles. - The :math:`n^{th}` vehicle in the solution. +.. code-block:: none + + (seq, vehicle_seq, vehicle_id, step_seq, step_type, task_id, + arrival, travel_time, service_time, waiting_time, load) + +=================== ================= ================================================= +Column Type Description +=================== ================= ================================================= +**seq** ``BIGINT`` Sequential value starting from **1**. + +**vehicle_seq** ``BIGINT`` Sequential value starting from **1** for current vehicles. + The :math:`n^{th}` vehicle in the solution. + +**vehicle_id** ``BIGINT`` Current vehicle identifier. + +**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. + +**step_type** ``INTEGER`` Kind of the step location the vehicle is at: + + - ``1``: Starting location + - ``2``: Job location + - ``3``: Pickup location + - ``4``: Delivery location + - ``5``: Break location + - ``6``: Ending location -**vehicle_id** ``BIGINT`` Current vehicle identifier. +**task_id** ``BIGINT`` Identifier of the task performed at this step. -**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. + - ``-1``: If the step is starting/ending location. -**step_type** ``INTEGER`` Kind of the step location the vehicle is at: +**arrival** ``TIMESTAMP`` Estimated time of arrival at this step, in seconds. - - ``1``: Starting location - - ``2``: Job location - - ``3``: Pickup location - - ``4``: Delivery location - - ``5``: Break location - - ``6``: Ending location + - ``INTEGER`` for plain VROOM functions. -**task_id** ``BIGINT`` Identifier of the task performed at this step. +**travel_time** ``INTERVAL`` Cumulated travel time upon arrival at this step, in seconds - - ``-1``: If the step is starting/ending location. + - ``INTEGER`` for plain VROOM functions. -**arrival** ``INTEGER`` Estimated time of arrival at this step, in seconds. +**service_time** ``INTERVAL`` Service time at this step, in seconds -**travel_time** ``INTEGER`` Cumulated travel time upon arrival at this step, in seconds + - ``INTEGER`` for plain VROOM functions. -**service_time** ``INTEGER`` Service time at this step, in seconds +**waiting_time** ``INTERVAL`` Waiting time upon arrival at this step, in seconds. -**waiting_time** ``INTEGER`` Waiting time upon arrival at this step, in seconds. + - ``INTEGER`` for plain VROOM functions. -**load** ``BIGINT`` Vehicle load after step completion (with capacity constraints) -=================== ============= ================================================= +**load** ``BIGINT`` Vehicle load after step completion (with capacity constraints) +=================== ================= ================================================= result end */ From f9feeee9e911e0b28bbcfb1b13f9956917153c87 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 3 Sep 2021 10:30:09 +0530 Subject: [PATCH 12/13] [vroom][docquery] Add docqueries for functions with timestamps --- docqueries/vroom/CMakeLists.txt | 3 + docqueries/vroom/doc-vrp_vroom.result | 99 ++++++++++++------- docqueries/vroom/doc-vrp_vroom.test.sql | 13 +++ docqueries/vroom/doc-vrp_vroomJobs.result | 63 ++++++++---- docqueries/vroom/doc-vrp_vroomJobs.test.sql | 13 +++ .../vroom/doc-vrp_vroomShipments.result | 73 +++++++++----- .../vroom/doc-vrp_vroomShipments.test.sql | 13 +++ docqueries/vroom/test.conf | 6 ++ 8 files changed, 203 insertions(+), 80 deletions(-) diff --git a/docqueries/vroom/CMakeLists.txt b/docqueries/vroom/CMakeLists.txt index 2e2c65052..a28beba0e 100644 --- a/docqueries/vroom/CMakeLists.txt +++ b/docqueries/vroom/CMakeLists.txt @@ -1,5 +1,8 @@ # Do not use extensions SET(LOCAL_FILES + doc-vrp_vroom + doc-vrp_vroomJobs + doc-vrp_vroomShipments doc-vrp_vroomPlain doc-vrp_vroomJobsPlain doc-vrp_vroomShipmentsPlain diff --git a/docqueries/vroom/doc-vrp_vroom.result b/docqueries/vroom/doc-vrp_vroom.result index c5f0bbb65..85468ee55 100644 --- a/docqueries/vroom/doc-vrp_vroom.result +++ b/docqueries/vroom/doc-vrp_vroom.result @@ -2,6 +2,31 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET +/* -- q0 */ +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE /* -- q1 */ SELECT * FROM vrp_vroom( @@ -14,35 +39,35 @@ 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 | 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} + 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) /* -- q2 */ @@ -76,14 +101,14 @@ FROM vrp_vroom( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); - seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load ------+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------ - 1 | 1 | 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 | {} + 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) /* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroom.test.sql b/docqueries/vroom/doc-vrp_vroom.test.sql index 7b369bb01..dc9494d3b 100644 --- a/docqueries/vroom/doc-vrp_vroom.test.sql +++ b/docqueries/vroom/doc-vrp_vroom.test.sql @@ -1,3 +1,16 @@ +/* -- q0 */ +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; /* -- q1 */ SELECT * FROM vrp_vroom( diff --git a/docqueries/vroom/doc-vrp_vroomJobs.result b/docqueries/vroom/doc-vrp_vroomJobs.result index 30585e686..990086503 100644 --- a/docqueries/vroom/doc-vrp_vroomJobs.result +++ b/docqueries/vroom/doc-vrp_vroomJobs.result @@ -2,6 +2,31 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET +/* -- q0 */ +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE /* -- q1 */ SELECT * FROM vrp_vroomJobs( @@ -12,19 +37,19 @@ 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 | 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} + 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) /* -- q2 */ @@ -52,12 +77,12 @@ FROM vrp_vroomJobs( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); - seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load ------+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------ - 1 | 1 | 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 | {} + 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) /* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomJobs.test.sql b/docqueries/vroom/doc-vrp_vroomJobs.test.sql index 2ea6f4a4a..5974cb279 100644 --- a/docqueries/vroom/doc-vrp_vroomJobs.test.sql +++ b/docqueries/vroom/doc-vrp_vroomJobs.test.sql @@ -1,3 +1,16 @@ +/* -- q0 */ +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; /* -- q1 */ SELECT * FROM vrp_vroomJobs( diff --git a/docqueries/vroom/doc-vrp_vroomShipments.result b/docqueries/vroom/doc-vrp_vroomShipments.result index babf4384a..9b180bc5b 100644 --- a/docqueries/vroom/doc-vrp_vroomShipments.result +++ b/docqueries/vroom/doc-vrp_vroomShipments.result @@ -2,6 +2,31 @@ BEGIN; BEGIN SET client_min_messages TO NOTICE; SET +/* -- q0 */ +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE /* -- q1 */ SELECT * FROM vrp_vroomShipments( @@ -12,24 +37,24 @@ 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 | 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} + 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) /* -- q2 */ @@ -57,12 +82,12 @@ FROM vrp_vroomShipments( ) AS C(start_vid, end_vid, agg_cost) $matrix$ ); - seq | vehicle_seq | vehicle_id | step_seq | step_type | task_id | arrival | travel_time | service_time | waiting_time | load ------+-------------+------------+----------+-----------+---------+---------+-------------+--------------+--------------+------ - 1 | 1 | 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 | {} + 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) /* -- q3 */ diff --git a/docqueries/vroom/doc-vrp_vroomShipments.test.sql b/docqueries/vroom/doc-vrp_vroomShipments.test.sql index d6cae97fe..d7ad0754f 100644 --- a/docqueries/vroom/doc-vrp_vroomShipments.test.sql +++ b/docqueries/vroom/doc-vrp_vroomShipments.test.sql @@ -1,3 +1,16 @@ +/* -- q0 */ +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; /* -- q1 */ SELECT * FROM vrp_vroomShipments( diff --git a/docqueries/vroom/test.conf b/docqueries/vroom/test.conf index 8db795969..7f7210a44 100644 --- a/docqueries/vroom/test.conf +++ b/docqueries/vroom/test.conf @@ -5,11 +5,17 @@ 'comment' => 'VRP with VROOM tests.', 'data' => [ ], 'tests' => [qw( + doc-vrp_vroom + doc-vrp_vroomJobs + doc-vrp_vroomShipments doc-vrp_vroomPlain doc-vrp_vroomJobsPlain doc-vrp_vroomShipmentsPlain )], 'documentation' => [qw( + doc-vrp_vroom + doc-vrp_vroomJobs + doc-vrp_vroomShipments doc-vrp_vroomPlain doc-vrp_vroomJobsPlain doc-vrp_vroomShipmentsPlain From 31747c7f2b63d5132689956bc781abcec4923691 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 3 Sep 2021 10:30:22 +0530 Subject: [PATCH 13/13] [vroom][pgtap] Add tests for functions with timestamps --- pgtap/vroom/inner_query.sql | 176 +++++++++++++----- pgtap/vroom/no_crash_test.sql | 62 ++++-- pgtap/vroom/types_check.sql | 80 +++++++- pgtap/vroom/vroom-plain-eq-timestamp.test.sql | 115 ++++++++++++ 4 files changed, 369 insertions(+), 64 deletions(-) create mode 100644 pgtap/vroom/vroom-plain-eq-timestamp.test.sql diff --git a/pgtap/vroom/inner_query.sql b/pgtap/vroom/inner_query.sql index 3e4d335d4..d0a33a2de 100644 --- a/pgtap/vroom/inner_query.sql +++ b/pgtap/vroom/inner_query.sql @@ -1,7 +1,7 @@ BEGIN; SET search_path TO 'vroom', 'public'; -SELECT CASE WHEN min_version('0.2.0') THEN plan (564) ELSE plan(1) END; +SELECT CASE WHEN min_version('0.2.0') THEN plan (1099) ELSE plan(1) END; /* SELECT * FROM vrp_vroomPlain( @@ -114,14 +114,39 @@ RETURNS SETOF TEXT AS $BODY$ DECLARE accept TEXT[] := ARRAY['CHAR']; - reject TEXT[] := ARRAY['VARCHAR', 'TEXT']::TEXT[]; + reject TEXT[] := ARRAY['VARCHAR', 'TEXT']; BEGIN RETURN query SELECT test_value(fn, inner_query_table, start_sql, rest_sql, params, parameter, accept, reject); END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_jobs(fn TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION test_Interval(fn TEXT, inner_query_table TEXT, start_sql TEXT, rest_sql TEXT, params TEXT[], parameter TEXT) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + accept TEXT[] := ARRAY['INTERVAL']; + reject TEXT[] := ARRAY['TIMESTAMP', 'DATE', 'TIME', 'INTEGER']; +BEGIN + RETURN query SELECT test_value(fn, inner_query_table, start_sql, rest_sql, params, parameter, accept, reject); +END; +$BODY$ LANGUAGE plpgsql; + + +CREATE OR REPLACE FUNCTION test_Timestamp(fn TEXT, inner_query_table TEXT, start_sql TEXT, rest_sql TEXT, params TEXT[], parameter TEXT) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + accept TEXT[] := ARRAY['TIMESTAMP']; + reject TEXT[] := ARRAY['INTERVAL', 'DATE', 'TIME', 'INTEGER']; +BEGIN + RETURN query SELECT test_value(fn, inner_query_table, start_sql, rest_sql, params, parameter, accept, reject); +END; +$BODY$ LANGUAGE plpgsql; + + + +CREATE OR REPLACE FUNCTION inner_query_jobs(fn TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -130,17 +155,21 @@ DECLARE BEGIN RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'id'); RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'location_index'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'service'); RETURN QUERY SELECT test_anyArrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'delivery'); RETURN QUERY SELECT test_anyArrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'pickup'); RETURN QUERY SELECT test_arrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'skills'); RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'priority'); + IF is_plain = TRUE THEN + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'service'); + ELSE + RETURN QUERY SELECT test_Interval(fn, inner_query_table, start_sql, rest_sql, params, 'service'); + END IF; END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_shipments(fn TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION inner_query_shipments(fn TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -150,17 +179,22 @@ BEGIN RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'id'); RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'p_location_index'); RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'd_location_index'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'p_service'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'd_service'); RETURN QUERY SELECT test_anyArrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'amount'); RETURN QUERY SELECT test_arrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'skills'); RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'priority'); + IF is_plain = TRUE THEN + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'p_service'); + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'd_service'); + ELSE + RETURN QUERY SELECT test_Interval(fn, inner_query_table, start_sql, rest_sql, params, 'p_service'); + RETURN QUERY SELECT test_Interval(fn, inner_query_table, start_sql, rest_sql, params, 'd_service'); + END IF; END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_vehicles(fn TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION inner_query_vehicles(fn TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -172,15 +206,20 @@ BEGIN RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'end_index'); RETURN QUERY SELECT test_anyArrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'capacity'); RETURN QUERY SELECT test_arrayInteger(fn, inner_query_table, start_sql, rest_sql, params, 'skills'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); RETURN QUERY SELECT test_anyNumerical(fn, inner_query_table, start_sql, rest_sql, params, 'speed_factor'); + IF is_plain = TRUE THEN + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + ELSE + RETURN QUERY SELECT test_Timestamp(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); + RETURN QUERY SELECT test_Timestamp(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + END IF; END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_matrix(fn TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION inner_query_matrix(fn TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -195,7 +234,7 @@ $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_breaks(fn TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION inner_query_breaks(fn TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -204,27 +243,36 @@ DECLARE BEGIN RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'id'); RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'vehicle_id'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'service'); + IF is_plain = TRUE THEN + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'service'); + ELSE + RETURN QUERY SELECT test_Interval(fn, inner_query_table, start_sql, rest_sql, params, 'service'); + END IF; END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_time_windows(fn TEXT, inner_query_table TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION inner_query_time_windows(fn TEXT, inner_query_table TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE params TEXT[] := ARRAY['id', 'tw_open', 'tw_close']; BEGIN RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'id'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + IF is_plain = TRUE THEN + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + ELSE + RETURN QUERY SELECT test_Timestamp(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); + RETURN QUERY SELECT test_Timestamp(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + END IF; END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query_shipments_time_windows(fn TEXT, inner_query_table TEXT, start_sql TEXT, rest_sql TEXT) +CREATE OR REPLACE FUNCTION inner_query_shipments_time_windows(fn TEXT, inner_query_table TEXT, start_sql TEXT, rest_sql TEXT, is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -232,14 +280,19 @@ DECLARE BEGIN RETURN QUERY SELECT test_anyInteger(fn, inner_query_table, start_sql, rest_sql, params, 'id'); RETURN QUERY SELECT test_Char(fn, inner_query_table, start_sql, rest_sql, params, 'kind'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); - RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + IF is_plain = TRUE THEN + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); + RETURN QUERY SELECT test_Integer(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + ELSE + RETURN QUERY SELECT test_Timestamp(fn, inner_query_table, start_sql, rest_sql, params, 'tw_open'); + RETURN QUERY SELECT test_Timestamp(fn, inner_query_table, start_sql, rest_sql, params, 'tw_close'); + END IF; END; $BODY$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION inner_query() +CREATE OR REPLACE FUNCTION inner_query(is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -255,134 +308,163 @@ BEGIN RETURN; END IF; - -- vrp_vroomPlain + -- vrp_vroom - fn := 'vrp_vroomPlain'; + IF is_plain = TRUE THEN + fn := 'vrp_vroomPlain'; + ELSE + fn := 'vrp_vroom'; + END IF; start_sql := ''; rest_sql := ', $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_jobs(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_jobs(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, '; rest_sql := ', $$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; inner_query_table := 'jobs_time_windows'; - RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, '; rest_sql := ', $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_shipments(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_shipments(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, '; rest_sql := ', $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; inner_query_table := 'shipments_time_windows'; - RETURN QUERY SELECT inner_query_shipments_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_shipments_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, ' || '$$SELECT * FROM shipments_time_windows$$, '; rest_sql := ', $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_vehicles(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_vehicles(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, ' || '$$SELECT * FROM shipments_time_windows$$, $$SELECT * FROM vehicles$$, '; rest_sql := ', $$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_breaks(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_breaks(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, ' || '$$SELECT * FROM shipments_time_windows$$, $$SELECT * FROM vehicles$$, ' || '$$SELECT * FROM breaks$$, '; rest_sql := ', $$SELECT * FROM matrix$$)'; inner_query_table := 'breaks_time_windows'; - RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM shipments$$, ' || '$$SELECT * FROM shipments_time_windows$$, $$SELECT * FROM vehicles$$, ' || '$$SELECT * FROM breaks$$, $$SELECT * FROM breaks_time_windows$$, '; rest_sql := ')'; - RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql, is_plain); - -- vrp_vroomJobsPlain + -- vrp_vroomJobs - fn := 'vrp_vroomJobsPlain'; + IF is_plain = TRUE THEN + fn := 'vrp_vroomJobsPlain'; + ELSE + fn := 'vrp_vroomJobs'; + END IF; start_sql := ''; rest_sql := ', $$SELECT * FROM jobs_time_windows$$, $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_jobs(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_jobs(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, '; rest_sql := ', $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; inner_query_table := 'jobs_time_windows'; - RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, '; rest_sql := ', $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_vehicles(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_vehicles(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, ' || '$$SELECT * FROM vehicles$$, '; rest_sql := ', $$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_breaks(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_breaks(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, '; rest_sql := ', $$SELECT * FROM matrix$$)'; inner_query_table := 'breaks_time_windows'; - RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM jobs$$, $$SELECT * FROM jobs_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, $$SELECT * FROM breaks_time_windows$$, '; rest_sql := ')'; - RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql, is_plain); - -- vrp_vroomShipmentsPlain + -- vrp_vroomShipments - fn := 'vrp_vroomShipmentsPlain'; + IF is_plain = TRUE THEN + fn := 'vrp_vroomShipmentsPlain'; + ELSE + fn := 'vrp_vroomShipments'; + END IF; start_sql := ''; rest_sql := ', $$SELECT * FROM shipments_time_windows$$, $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_shipments(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_shipments(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM shipments$$, '; rest_sql := ', $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, ' || '$$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; inner_query_table := 'shipments_time_windows'; - RETURN QUERY SELECT inner_query_shipments_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_shipments_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, '; rest_sql := ', $$SELECT * FROM breaks$$, $$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_vehicles(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_vehicles(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, '; rest_sql := ', $$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; - RETURN QUERY SELECT inner_query_breaks(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_breaks(fn, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, '; rest_sql := ', $$SELECT * FROM matrix$$)'; inner_query_table := 'breaks_time_windows'; - RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_time_windows(fn, inner_query_table, start_sql, rest_sql, is_plain); start_sql := '$$SELECT * FROM shipments$$, $$SELECT * FROM shipments_time_windows$$, ' || '$$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$, $$SELECT * FROM breaks_time_windows$$, '; rest_sql := ')'; - RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql); + RETURN QUERY SELECT inner_query_matrix(fn, start_sql, rest_sql, is_plain); + END; $BODY$ LANGUAGE plpgsql; -SELECT inner_query(); +SELECT inner_query(is_plain => TRUE); + +-- Adjust the column types to the expected types for vroom functions with timestamps/interval +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; + +SELECT inner_query(is_plain => FALSE); SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/vroom/no_crash_test.sql b/pgtap/vroom/no_crash_test.sql index 5ee488c79..c8db335e2 100644 --- a/pgtap/vroom/no_crash_test.sql +++ b/pgtap/vroom/no_crash_test.sql @@ -2,18 +2,9 @@ BEGIN; SET search_path TO 'vroom', 'public'; SET client_min_messages TO ERROR; -SELECT CASE WHEN min_version('0.2.0') THEN plan (46) ELSE plan(1) END; - -PREPARE jobs AS SELECT * FROM jobs; -PREPARE jobs_time_windows AS SELECT * FROM jobs_time_windows; -PREPARE shipments AS SELECT * FROM shipments; -PREPARE shipments_time_windows AS SELECT * FROM shipments_time_windows; -PREPARE vehicles AS SELECT * FROM vehicles; -PREPARE breaks AS SELECT * FROM breaks; -PREPARE breaks_time_windows AS SELECT * FROM breaks_time_windows; -PREPARE matrix AS SELECT * FROM matrix; - -CREATE OR REPLACE FUNCTION no_crash() +SELECT CASE WHEN min_version('0.2.0') THEN plan (92) ELSE plan(1) END; + +CREATE OR REPLACE FUNCTION no_crash(is_plain BOOLEAN) RETURNS SETOF TEXT AS $BODY$ DECLARE @@ -28,6 +19,15 @@ BEGIN RETURN; END IF; + PREPARE jobs AS SELECT * FROM jobs; + PREPARE jobs_time_windows AS SELECT * FROM jobs_time_windows; + PREPARE shipments AS SELECT * FROM shipments; + PREPARE shipments_time_windows AS SELECT * FROM shipments_time_windows; + PREPARE vehicles AS SELECT * FROM vehicles; + PREPARE breaks AS SELECT * FROM breaks; + PREPARE breaks_time_windows AS SELECT * FROM breaks_time_windows; + PREPARE matrix AS SELECT * FROM matrix; + RETURN QUERY SELECT isnt_empty('jobs', 'Should be not empty to tests be meaningful'); RETURN QUERY @@ -77,7 +77,11 @@ BEGIN ]::TEXT[]; non_empty_args = ARRAY[0, 1, 2, 3, 4, 6, 7]::INTEGER[]; - RETURN query SELECT * FROM no_crash_test('vrp_vroomPlain', params, subs, error_messages, non_empty_args); + IF is_plain = TRUE THEN + RETURN query SELECT * FROM no_crash_test('vrp_vroomPlain', params, subs, error_messages, non_empty_args); + ELSE + RETURN query SELECT * FROM no_crash_test('vrp_vroom', params, subs, error_messages, non_empty_args); + END IF; params = ARRAY[ '$$jobs$$', @@ -105,7 +109,11 @@ BEGIN ]::TEXT[]; non_empty_args = ARRAY[0, 2, 4, 5]::INTEGER[]; - RETURN query SELECT * FROM no_crash_test('vrp_vroomJobsPlain', params, subs, error_messages, non_empty_args); + IF is_plain = TRUE THEN + RETURN query SELECT * FROM no_crash_test('vrp_vroomJobsPlain', params, subs, error_messages, non_empty_args); + ELSE + RETURN query SELECT * FROM no_crash_test('vrp_vroomJobs', params, subs, error_messages, non_empty_args); + END IF; params = ARRAY[ '$$shipments$$', @@ -133,13 +141,35 @@ BEGIN ]::TEXT[]; non_empty_args = ARRAY[0, 2, 4, 5]::INTEGER[]; - RETURN query SELECT * FROM no_crash_test('vrp_vroomShipmentsPlain'::TEXT, params, subs, error_messages, non_empty_args); + IF is_plain = TRUE THEN + RETURN query SELECT * FROM no_crash_test('vrp_vroomShipmentsPlain', params, subs, error_messages, non_empty_args); + ELSE + RETURN query SELECT * FROM no_crash_test('vrp_vroomShipments', params, subs, error_messages, non_empty_args); + END IF; + + DEALLOCATE ALL; END $BODY$ LANGUAGE plpgsql VOLATILE; -SELECT * FROM no_crash(); +SELECT * FROM no_crash(is_plain => TRUE); + +-- Adjust the column types to the expected types for vroom functions with timestamps/interval +ALTER TABLE vroom.jobs ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.shipments ALTER COLUMN p_service TYPE INTERVAL USING make_interval(secs => p_service); +ALTER TABLE vroom.shipments ALTER COLUMN d_service TYPE INTERVAL USING make_interval(secs => d_service); +ALTER TABLE vroom.vehicles ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.vehicles ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks ALTER COLUMN service TYPE INTERVAL USING make_interval(secs => service); +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.jobs_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.shipments_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_open TYPE TIMESTAMP USING (to_timestamp(tw_open + 1630573200) at time zone 'UTC')::TIMESTAMP; +ALTER TABLE vroom.breaks_time_windows ALTER COLUMN tw_close TYPE TIMESTAMP USING (to_timestamp(tw_close + 1630573200) at time zone 'UTC')::TIMESTAMP; + +SELECT * FROM no_crash(is_plain => FALSE); ROLLBACK; diff --git a/pgtap/vroom/types_check.sql b/pgtap/vroom/types_check.sql index 7236c4efd..ee296c513 100644 --- a/pgtap/vroom/types_check.sql +++ b/pgtap/vroom/types_check.sql @@ -1,7 +1,7 @@ BEGIN; SET search_path TO 'vroom', 'public'; -SELECT CASE WHEN min_version('0.2.0') THEN plan (15) ELSE plan(1) END; +SELECT CASE WHEN min_version('0.2.0') THEN plan (30) ELSE plan(1) END; CREATE OR REPLACE FUNCTION types_check() RETURNS SETOF TEXT AS @@ -40,6 +40,32 @@ BEGIN ); + -- vrp_vroom + RETURN QUERY + SELECT has_function('vrp_vroom'); + RETURN QUERY + SELECT has_function('vrp_vroom', ARRAY['text', 'text', 'text', 'text', 'text', 'text', 'text', 'text']); + RETURN QUERY + SELECT function_returns('vrp_vroom', ARRAY['text', 'text', 'text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); + + -- parameter names + RETURN QUERY + SELECT bag_has( + $$SELECT proargnames from pg_proc where proname = 'vrp_vroom'$$, + $$SELECT '{"","","","","","","","","seq","vehicle_seq","vehicle_id","step_seq","step_type",' + '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + ); + + -- parameter types + RETURN QUERY + SELECT set_eq( + $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroom'$$, + $$VALUES + ('{25,25,25,25,25,25,25,25,20,20,20,20,23,20,1114,1186,1186,1186,1016}'::OID[]) + $$ + ); + + -- vrp_vroomJobsPlain RETURN QUERY SELECT has_function('vrp_vroomjobsplain'); @@ -66,6 +92,32 @@ BEGIN ); + -- vrp_vroomJobs + RETURN QUERY + SELECT has_function('vrp_vroomjobs'); + RETURN QUERY + SELECT has_function('vrp_vroomjobs', ARRAY['text', 'text', 'text', 'text', 'text', 'text']); + RETURN QUERY + SELECT function_returns('vrp_vroomjobs', ARRAY['text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); + + -- parameter names + RETURN QUERY + SELECT bag_has( + $$SELECT proargnames from pg_proc where proname = 'vrp_vroomjobs'$$, + $$SELECT '{"","","","","","","seq","vehicle_seq","vehicle_id","step_seq","step_type",' + '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + ); + + -- parameter types + RETURN QUERY + SELECT set_eq( + $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomjobs'$$, + $$VALUES + ('{25,25,25,25,25,25,20,20,20,20,23,20,1114,1186,1186,1186,1016}'::OID[]) + $$ + ); + + -- vrp_vroomShipmentsPlain RETURN QUERY SELECT has_function('vrp_vroomshipmentsplain'); @@ -90,6 +142,32 @@ BEGIN ('{25,25,25,25,25,25,20,20,20,20,23,20,23,23,23,23,1016}'::OID[]) $$ ); + + + -- vrp_vroomShipments + RETURN QUERY + SELECT has_function('vrp_vroomshipments'); + RETURN QUERY + SELECT has_function('vrp_vroomshipments', ARRAY['text', 'text', 'text', 'text', 'text', 'text']); + RETURN QUERY + SELECT function_returns('vrp_vroomshipments', ARRAY['text', 'text', 'text', 'text', 'text', 'text'], 'setof record'); + + -- parameter names + RETURN QUERY + SELECT bag_has( + $$SELECT proargnames from pg_proc where proname = 'vrp_vroomshipments'$$, + $$SELECT '{"","","","","","","seq","vehicle_seq","vehicle_id","step_seq","step_type",' + '"task_id","arrival","travel_time","service_time","waiting_time","load"}'::TEXT[]$$ + ); + + -- parameter types + RETURN QUERY + SELECT set_eq( + $$SELECT proallargtypes from pg_proc where proname = 'vrp_vroomshipments'$$, + $$VALUES + ('{25,25,25,25,25,25,20,20,20,20,23,20,1114,1186,1186,1186,1016}'::OID[]) + $$ + ); END; $BODY$ LANGUAGE plpgsql; diff --git a/pgtap/vroom/vroom-plain-eq-timestamp.test.sql b/pgtap/vroom/vroom-plain-eq-timestamp.test.sql new file mode 100644 index 000000000..6c9cdcc01 --- /dev/null +++ b/pgtap/vroom/vroom-plain-eq-timestamp.test.sql @@ -0,0 +1,115 @@ +BEGIN; +SET search_path TO 'vroom', 'public'; +SET client_min_messages TO ERROR; + +SELECT CASE WHEN min_version('0.2.0') THEN plan (22) ELSE plan(1) END; + +CREATE or REPLACE FUNCTION vroom_plain_eq_timestamp() +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + ids BIGINT[] := ARRAY[1, 2, 3, 4, 5]; + + jobsPlain TEXT := '$$SELECT * FROM jobs'; + jobsPlain_sql TEXT; + jobs TEXT := '$$SELECT id, location_index, make_interval(secs => service) AS service, delivery, pickup, skills, priority FROM jobs'; + jobs_sql TEXT; + + shipmentsPlain TEXT := '$$SELECT * FROM shipments'; + shipmentsPlain_sql TEXT; + shipments TEXT := '$$SELECT id, p_location_index, make_interval(secs => p_service) AS p_service, ' || + 'd_location_index, make_interval(secs => d_service) AS d_service, amount, skills, priority FROM shipments'; + shipments_sql TEXT; + + jobsPlain_time_windows TEXT := '$$SELECT * FROM jobs_time_windows$$'; + jobs_time_windows TEXT := '$$SELECT id, (to_timestamp(tw_open) at time zone ''UTC'')::TIMESTAMP AS tw_open, ' || + '(to_timestamp(tw_close) at time zone ''UTC'')::TIMESTAMP AS tw_close FROM jobs_time_windows$$'; + + shipmentsPlain_time_windows TEXT := '$$SELECT * FROM shipments_time_windows$$'; + shipments_time_windows TEXT := '$$SELECT id, kind, (to_timestamp(tw_open) at time zone ''UTC'')::TIMESTAMP AS tw_open, ' || + '(to_timestamp(tw_close) at time zone ''UTC'')::TIMESTAMP AS tw_close FROM shipments_time_windows$$'; + + restPlain_sql TEXT := ', $$SELECT * FROM vehicles$$, $$SELECT * FROM breaks$$' || + ', $$SELECT * FROM breaks_time_windows$$, $$SELECT * FROM matrix$$)'; + + rest_sql TEXT := ', $$SELECT id, start_index, end_index, capacity, skills, (to_timestamp(tw_open) at time zone ''UTC'')::TIMESTAMP AS tw_open' || + ', (to_timestamp(tw_close) at time zone ''UTC'')::TIMESTAMP AS tw_close, speed_factor FROM vehicles$$' || + ', $$SELECT id, vehicle_id, make_interval(secs => service) AS service FROM breaks$$' || + ', $$SELECT id, (to_timestamp(tw_open) at time zone ''UTC'')::TIMESTAMP AS tw_open' || + ', (to_timestamp(tw_close) at time zone ''UTC'')::TIMESTAMP AS tw_close FROM breaks_time_windows$$, ' || + '$$SELECT * FROM matrix$$)'; + + 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, ' || + 'EXTRACT (EPOCH FROM service_time) AS service_time, EXTRACT (EPOCH FROM waiting_time) AS waiting_time, ' || + 'load FROM vrp_vroom('; + + vroom_sql TEXT; + vroomPlain_sql TEXT; + id_filter TEXT; +data TEXT; +BEGIN + IF NOT min_version('0.2.0') THEN + RETURN QUERY + SELECT skip(1, 'Function is new on 0.2.0'); + RETURN; + END IF; + + -- Two jobs and shipments + FOR i in 1..array_length(ids, 1) LOOP + FOR j in (i+1)..array_length(ids, 1) LOOP + id_filter := ' WHERE id in (' || i || ', ' || j || ')$$, '; + jobs_sql := jobs || id_filter || jobs_time_windows; + shipments_sql := shipments || id_filter || shipments_time_windows; + vroom_sql := return_sql || jobs_sql || ', ' || shipments_sql || rest_sql; + jobsPlain_sql := jobsPlain || id_filter || jobsPlain_time_windows; + shipmentsPlain_sql := shipmentsPlain || id_filter || shipmentsPlain_time_windows; + vroomPlain_sql := returnPlain_sql || jobsPlain_sql || ', ' || shipmentsPlain_sql || restPlain_sql; + RETURN query SELECT set_eq(vroom_sql, vroomPlain_sql); + END LOOP; + END LOOP; + + -- Three jobs and shipments + FOR i in 1..array_length(ids, 1) LOOP + FOR j in (i+1)..array_length(ids, 1) LOOP + FOR k in (j+1)..array_length(ids, 1) LOOP + id_filter := ' WHERE id in (' || i || ', ' || j || ', ' || k || ')$$, '; + jobs_sql := jobs || id_filter || jobs_time_windows; + shipments_sql := shipments || id_filter || shipments_time_windows; + vroom_sql := return_sql || jobs_sql || ', ' || shipments_sql || rest_sql; + jobsPlain_sql := jobsPlain || id_filter || jobsPlain_time_windows; + shipmentsPlain_sql := shipmentsPlain || id_filter || shipmentsPlain_time_windows; + vroomPlain_sql := returnPlain_sql || jobsPlain_sql || ', ' || shipmentsPlain_sql || restPlain_sql; + RETURN query SELECT set_eq(vroom_sql, vroomPlain_sql); + END LOOP; + END LOOP; + END LOOP; + + -- All the five jobs and shipments + id_filter := '$$, '; + jobs_sql := jobs || id_filter || jobs_time_windows; + shipments_sql := shipments || id_filter || shipments_time_windows; + vroom_sql := return_sql || jobs_sql || ', ' || shipments_sql || rest_sql; + jobsPlain_sql := jobsPlain || id_filter || jobsPlain_time_windows; + shipmentsPlain_sql := shipmentsPlain || id_filter || shipmentsPlain_time_windows; + vroomPlain_sql := returnPlain_sql || jobsPlain_sql || ', ' || shipmentsPlain_sql || restPlain_sql; + RETURN query SELECT set_eq(vroom_sql, vroomPlain_sql); + + -- No jobs or shipments + id_filter := ' WHERE id in (-1)$$, '; + jobs_sql := jobs || id_filter || jobs_time_windows; + shipments_sql := shipments || id_filter || shipments_time_windows; + vroom_sql := return_sql || jobs_sql || ', ' || shipments_sql || rest_sql; + jobsPlain_sql := jobsPlain || id_filter || jobsPlain_time_windows; + shipmentsPlain_sql := shipmentsPlain || id_filter || shipmentsPlain_time_windows; + vroomPlain_sql := returnPlain_sql || jobsPlain_sql || ', ' || shipmentsPlain_sql || restPlain_sql; + RETURN query SELECT set_eq(vroom_sql, vroomPlain_sql); +END +$BODY$ +language plpgsql; + +SELECT vroom_plain_eq_timestamp(); + +SELECT * FROM finish(); +ROLLBACK;