Skip to content

GSoC 2023 Implement pgr_withPointsKSP and Add Overloads

Abhinav Jain edited this page Jul 23, 2023 · 21 revisions

Table of Contents

Proposal

Brief Description

The project aims implement pgr_withPointsKSP and all its overloads.
Yen's algorithm computes single-source K-shortest loopless paths for a graph with non-negative edge cost. It employs any shortest path algorithm to find the best path, then proceeds to find K − 1 deviations of the best path.
Sometimes the applications work “on the fly” starting from a location that is not a vertex in the graph. Those locations, in pgRouting, are called points of interest.So this function will modify the graph to include these points of interest and, using Yen’s Algorithm finds K shortest paths.

State of the Project Before GSoC

Currently, the pgRouting repository implements the pgr_withPointsKSP function with only single signature (one to one).

Current Signature

pgr_withPointsKSP(Edges SQL, Points SQL start vid, end vid, K, [options])
options: [directed, heap_paths, driving_side, details]
RETURNS SET OF (seq, path_id, path_seq, node, edge, cost, agg_cost)
OR EMPTY SET

However, it is not an official pgRouting function but its available for users.

Benefits to the Community

  • Adding all overloads will refrain users from writing and executing multiple queries.
  • Proposed Signatures :-
pgr_yen_withPoints(Edges SQL, Points SQL, start vid, end vid, K,[options])
pgr_yen_withPoints(Edges SQL, Points SQL, start vid, end vids, K,[options])
pgr_yen_withPoints(Edges SQL, Points SQL, start vids, end vid, K,[options])
pgr_yen_withPoints(Edges SQL, Points SQL, start vids, end vids,K,[options])
pgr_yen_withPoints(Edges SQL, Points SQL, Combinations SQL, K,[options])
options: [directed, heap_paths, driving_side, details])
RETURNS SET OF (seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)
OR EMTPY SET
  • The proposed function will return the same set of columns for all overloads, reducing users' and developers’ developing time.
  • The function will help users to calculate the K Shortest Paths not only between two vertices but also between the points (such as restaurants, supermarkets, etc.) closer to the particular edge and combinations of two.
  • Why the name is to be changed:
    • using the algorithm's author name, which will generalize better with the users and will help them to look up for the function in documentation easily.
    • Postgres does not allow two functions with the same set of input parameters but with different output columns
    • Adding these algorithms to pgRouting will result in more functionalities in pgRouting which will help the current and future users and developers to use and integrate with other algorithms.

Deliverables

  • pgr_withPointsKSP => pgr_yen_WithPoints
  • Have pgr_yen_WithPoints with all overloads:
    • one to one
    • one to many
    • many to one
    • many to many
    • combinations
  • driving_side CHAR: Value in [r,R,L,l] indicating if the driving side is:
    • r,R for right driving side
    • l,L for left driving side
    • Any other value (including NULL) will be considered as r
  • Return columns on all overloads: seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost
  • pgTap test equivalence with pgr_withPoints when K = 1 and the points are actual vertices on the graph
  • Documentation of the new function
  • Documentation on how to migrate to the new function

Detailed Proposal

Detailed Proposal in PDF format

Participants

Title GitHub Handle Name
1st Mentor @krashish8 Ashish Kumar
2nd Mentor @cvvergara Vicky Vergara
Student Software Developer @Abhinj Abhinav Jain

Weekly Report And Plan

Community Bonding Period (May 4 - May 28)

-Introduce myself to the community, interact with mentors, and actively get involved in the discussion. -Setting up the Development Environment -Develop a better understanding of PostgreSQL, PostGIS and how they interact with pgRouting. -Set up the wiki page to keep track of weekly progress.

###Report

First Coding Period (May 29 - July 9)

Week 1 (May 29 - Jun 4)

  • Create new one-to-one renamed function
  • Reuse and duplicate Code wherever possible
  • Deeply study pgr_withPointsKSP

Week 1 Report

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • Created a branch where i will be working.
  • Tasks in the issue #289
  • Understand the working of the function and its calls.
  • Added my name in contributor's list and Made a PR.

Plans for the next week:-

  • Will try to replicate what vicky did in this for pgr_kspWithPoints.
  • Start standardizing columns of the function

Am I blocked on anything?

  • No, Currently I am not blocked to anything.

Week 2 (Jun 5 - Jun 11)

  • Create a basic skeleton for C, C++, SQL, and pgTap Tests

Week 2 Report

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • Watch Twitch about the simplification of bdAstar.
  • Tried to simplify the withPoints_ksp function similar to dijkstra but getting errors in github actions.

Plans for the next week:-

  • Will resolve the issues facing during week 2.
  • Standardise the output columns.

Am I blocked on anything?

  • No, Currently I am not blocked to anything.

Week 3 (Jun 12 - Jun 18)

  • Create C++ containers for passing SQL data to C++ containers for data processing
  • Refine the code

Week 3 Report

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • Had a meeting with mentors and identified a new function signature, which can be found #300
  • Standardised the output columns of withPointsKSP

Plans for the next week:-

  • I will start testing my implemented function and backward compatibility

Am I blocked on anything?

  • As my sister's wedding draws near, my focus and dedication will be centered around this occasion. However, rest assured that I am committed to reclaiming and fulfilling my work obligations in the forthcoming weeks.

Week 4 (Jun 19 - Jun 25)

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • Removed unused code
  • Worked on Backward compatibility

Plans for the next week:-

  • Catch up on my week 4 work.
  • Fix pgtap cases.

Am I blocked on anything?

  • Sister's Wedding

Week 5 (Jun 26 - Jul 2)

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • Bug fixes in output columns
  • Some testing with doc queries

Plans for the next week:-

  • Catch up on my week 5 work.
  • Will start working on documentation.
  • pgtap test cases

Am I blocked on anything? I currently do not have any blocking issues and can proceed with my tasks smoothly.

Week 6 (Jul 3 - Jul 9)

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • added more docqueries
  • worked on feedback provided by vicky

Plans for the next week:-

  • Catch up on my week 6 work.
  • Have to more work on feed provided by vicky

Am I blocked on anything? I currently do not have any blocking issues and can proceed with my tasks smoothly.

First Evaluation Period(July 10 - July 14)

  • Submit a working pgr_yen_withPoints function with its documentation without pgTap tests

Second Coding Period(July 14 - Aug 27)

Week 7 (Jul 14 - Jul 16)

Report Mail - [SoC], [pgRouting-dev]

What did I get done this week?

  • Discussed the meaning of driving side with mentors and other GSoC students.
  • Updated old Code for backward compatibility
  • Updated Docqueries for newer function
  • Changed SQL functions to v4

Plans for the next week:-

  • Work on feedback.
  • Fixing pgTap cases and docqueries

Week 8 (Jul 23 - Jul 30)

  • Testing against OpenStreetMap data
  • Internal tests for “pgr_yen_withPoints”
  • No server crash test
  • pgTap Unit tests

Week 9 (Jul 31 - Aug 6)

  • Write meaningful pgTap tests for the function, equivalence with Dijkstra when k = 1 and for all edge cases and functionalities

Week 10 (Aug 7 - Aug 13)

  • Fix bugs in the unit test
  • Create queries for documentation using pgRouting sample data

Week 11 (Aug 14 - Aug 20)

  • Verify Documentation
  • Migration Documentation work

Week 12 (Aug 21 - Aug 27)

  • Verify documentation and migration documentation works Prepare final submission along with full documentation.

Final Evaluation Period(Aug 28 - Sep 4)

  • Prepare PR to main repository
  • Prepare final report

Log of Pull Requests

Final Report

Clone this wiki locally