diff --git a/doc/vrp_basic/pgr_vrpOneDepot.rst b/doc/vrp_basic/pgr_vrpOneDepot.rst index 568365a0f84..96dd40c158f 100644 --- a/doc/vrp_basic/pgr_vrpOneDepot.rst +++ b/doc/vrp_basic/pgr_vrpOneDepot.rst @@ -29,6 +29,11 @@ Example: .. literalinclude:: doc-pgr_vrpOneDepot.queries +.. rubric:: Current Result + +.. literalinclude:: oneDepotWrapper.queries + + .. rubric:: Data .. literalinclude:: ../../tools/testers/vrpOneDepot.data diff --git a/sql/vrp_basic/_pgr_vrpOneDepot.sql b/sql/vrp_basic/_pgr_vrpOneDepot.sql index f5b297e1251..d7f574ded53 100644 --- a/sql/vrp_basic/_pgr_vrpOneDepot.sql +++ b/sql/vrp_basic/_pgr_vrpOneDepot.sql @@ -29,10 +29,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. CREATE OR REPLACE FUNCTION _pgr_vrpOneDepot( - customers_sql TEXT, - vehicles_sql TEXT, + TEXT, -- customers_sql + TEXT, -- vehicles_sql TEXT, -- matrix_sql - depot_id INTEGER, + INTEGER, -- depot_id OUT seq INTEGER, OUT vehicle_seq INTEGER, @@ -58,25 +58,25 @@ final_sql TEXT; BEGIN orders_sql = $$WITH - vrp_orders AS ($$ || customers_sql || $$ ), + vrp_orders AS ($$ || $1 || $$ ), pickups AS ( SELECT id, x AS p_x, y AS p_y, open_time AS p_open, close_time AS p_close, service_time AS p_service FROM vrp_orders - WHERE id = $$ || depot_id || $$ + WHERE id = $$ || $4 || $$ ) SELECT vrp_orders.id AS id, order_unit AS demand, pickups.id AS p_node_id, p_x, p_y, p_open, p_close, p_service, vrp_orders.id AS d_node_id, x AS d_x, y AS d_y, open_time AS d_open, close_time AS d_close, service_time AS d_service FROM vrp_orders, pickups - WHERE vrp_orders.id != $$ || depot_id; + WHERE vrp_orders.id != $$ || $4; trucks_sql = $$ WITH - vrp_orders AS ($$ || customers_sql || $$ ), - vrp_vehicles AS ($$ || vehicles_sql || $$ ), + vrp_orders AS ($$ || $1 || $$ ), + vrp_vehicles AS ($$ || $2 || $$ ), starts AS ( SELECT id AS start_node_id, x AS start_x, y AS start_y, open_time AS start_open, close_time AS start_close, service_time AS start_service FROM vrp_orders - WHERE id = $$ || depot_id || $$ + WHERE id = $$ || $4 || $$ ) SELECT vehicle_id AS id, capacity, starts.* FROM vrp_vehicles, starts; $$; @@ -98,3 +98,4 @@ BEGIN END; $BODY$ LANGUAGE plpgsql VOLATILE STRICT; +