Skip to content

Conversation

@vesameskanen
Copy link
Contributor

@vesameskanen vesameskanen commented Jan 4, 2023

Summary

Street graph pruning uses distance and transport mode based heuristics to decide which sub graphs should be pruned.

Pruning should remove quite large disconnected sub graphs because they cause great damage to routing (see the new document page included in the PR). However, small real geographic islands which may have ferry connections should be always retained.

New processing steps may slow down graph building a bit. Helsinki region graph build changed from 150 seconds to 200 seconds. Distance heuristics can be turned off using build-config settings.

Unit tests

Adaptive pruning is tested with an OSM snippet which contains a small network of 3 separated graphs.

Documentation

New document page with examples added to docs folder

It is very useful to see the complexity of the removed island
- Size thresholds depend on distance
- Consider ferry transport mode
With default parameters, aggressive adaptive pruning would erase relevant parts from the small test data set
Default settings may prune too small OSM test data sets.
@vesameskanen vesameskanen requested a review from a team as a code owner January 4, 2023 13:50
@vesameskanen vesameskanen added the !Improvement A functional improvement or micro feature label Jan 4, 2023
@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Base: 61.64% // Head: 61.63% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (2eacbdb) compared to base (8416bdd).
Patch coverage: 59.24% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #4688      +/-   ##
=============================================
- Coverage      61.64%   61.63%   -0.01%     
- Complexity     12637    12665      +28     
=============================================
  Files           1611     1612       +1     
  Lines          64360    64539     +179     
  Branches        6978     7002      +24     
=============================================
+ Hits           39677    39781     +104     
- Misses         22447    22520      +73     
- Partials        2236     2238       +2     
Impacted Files Coverage Δ
...rg/opentripplanner/graph_builder/GraphBuilder.java 0.00% <0.00%> (ø)
...anner/graph_builder/issue/api/DataImportIssue.java 20.00% <0.00%> (-5.00%) ⬇️
...h_builder/issue/report/DataImportIssuesToHTML.java 0.00% <0.00%> (ø)
...anner/graph_builder/issues/AreaTooComplicated.java 0.00% <0.00%> (ø)
...tripplanner/graph_builder/issues/HopSpeedFast.java 66.66% <0.00%> (-8.34%) ⬇️
...tripplanner/graph_builder/issues/HopSpeedSlow.java 66.66% <0.00%> (-8.34%) ⬇️
...nner/graph_builder/issues/InterliningTeleport.java 71.42% <0.00%> (-11.91%) ⬇️
...planner/graph_builder/issues/PrunedStopIsland.java 0.00% <0.00%> (ø)
...builder/issues/PublicTransportRelationSkipped.java 60.00% <0.00%> (-15.00%) ⬇️
...r/graph_builder/issues/TooManyAreasInRelation.java 60.00% <0.00%> (-15.00%) ⬇️
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

As soon as there are more than 10 issues of a kind, sorting becomes an invaluable feature.
In graph pruning, number of issues is counted in thousands.
Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the thorough documentation page. Could you add it to mkdocs.yml so that it shows up in the menu?

Also, since we now have 4 parameters to control the pruning, should we have our own config object for it?

// build-config.json
{
  "islandPruning": {
      "adaptivePruningDistance": 250,
     ... ...
  }
}

@leonardehrenfried
Copy link
Member

leonardehrenfried commented Jan 9, 2023

Also, could you add example values in https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/test/resources/standalone/config/build-config.json ?

That way they will end up in the documentation as well.

@hannesj hannesj requested a review from optionsome January 10, 2023 10:23
vesameskanen and others added 5 commits January 11, 2023 09:02
- Create only one issue per sub graph about unlinked stops. Rename the issue to reflect the change.
- Include relevant details about pruning changes and traverse mode so that issue can be understood
Co-authored-by: Leonard Ehrenfried <[email protected]>
Co-authored-by: Leonard Ehrenfried <[email protected]>
Co-authored-by: Leonard Ehrenfried <[email protected]>
@leonardehrenfried leonardehrenfried added the +Config Change This PR might require the configuration to be updated. label Jan 16, 2023
@leonardehrenfried
Copy link
Member

Can you click "re-request review" when you have found the logic bug?

Copy link
Member

@optionsome optionsome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw some lines in the GraphIsland reports that were like Pruned WALK subgraph area splitter at (24.62297726728413, 60.16452804217827, NaN) containing vertex '{area splitter at (24.62297726728413, 60.16452804217827, NaN) lat,lng=60.16452804217827,24.62297726728413}' at (24.622977, 60.164528) of 288 street vertices and 0 stops. Edge changes: 809 to nothru, 0 to no traversal, 0 erased. What is that "third" NaN coordinate value?

/**
* search radius as meters when looking for island neighbours
*/
private double adaptivePruningDistance;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really need to be double? Couldn't it just be int?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing, should we defined the unit in the parameter name or not?

Copy link
Contributor Author

@vesameskanen vesameskanen Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I considered both these questions, and was not sure what to choose. Distance is natively a decimal value, although one meter accuracy is surely enough.
I'm not sure if adding unit is good or bad, e.g. 'adaptivePruningDistanceMeters'. Is there a standard convention or a decision about such one already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in the dev meeting and came to the conclusion that this should be int, not double. Name can stay as is. The javadoc should be on a getter method, not on the field.

@optionsome
Copy link
Member

We discussed this pr today in the developer meeting and @leonardehrenfried pointed out that it would make sense to convert the issue classes (at least the ones heavily edited here) as records so less code is needed and they fit the use case pretty well.

Also, do not let islands overlap by nothru edges as this can generate islands,
which are almost identical (only a few unique normal edges, lots of shared nothru edges).
Almost identical islands make issue report harder to use.
Instance methods are now in use, so there is no need to pass constant data around as long
complicated function parameter lists.
After pruning changes, one footway=highway island no longer got car nothru restriction.
This appears acceptable as the mentioned way does not have CAR traverse mode at all.
Car nothru makes no sense for such a way.
- Code now tracks if processed edges actually change. Logged statistics reflect more accurately street graph changes.
- Example vertex for graph island issue is taken from an edge which changed in pruning, giving a more useful link to OSM data.
@vesameskanen
Copy link
Contributor Author

Conversion of issue classes to simpler records will be done in another PR.

@leonardehrenfried
Copy link
Member

Can you resolve the conflicts?

@vesameskanen
Copy link
Contributor Author

Conflicts resolved.

public static final String FMT = "Area %s is too complicated (%s > %s )";
public static final String FMT = "Area %s is too complicated (%s > %s)";
public static final String HTMLFMT =
"Area <a href='http://www.openstreetmap.org/%s'>'%s'</a> is too complicated (%s > %s)";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each OSM element has a method to generate an OSM link:

return String.format("https://www.openstreetmap.org/node/%d", getId());

However, you can change that in your follow-up PR which also converts the records.

)
);
OSMWithTags osm = group.getSomeOSMObject();
String id = (osm instanceof OSMWay) ? "way/" + osm.getId() : "relation/" + osm.getId();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your follow up you can also replace his with getOpenstreetmapLink.

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The things I picked up on we can fix in a follow-up PR.

@vesameskanen vesameskanen merged commit efd91d7 into opentripplanner:dev-2.x Jan 19, 2023
@vesameskanen vesameskanen deleted the adaptive-pruning branch January 19, 2023 09:53
t2gran pushed a commit that referenced this pull request Jan 19, 2023
@leonardehrenfried
Copy link
Member

The documentation is now on https://docs.opentripplanner.org/en/dev-2.x/IslandPruning/

However, I think it didn't come out how you wanted it as the newlines look pretty broken.

@vesameskanen
Copy link
Contributor Author

True, image captions show up different from github's presentation of the .md file. I will fix them
using another approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Config Change This PR might require the configuration to be updated. !Improvement A functional improvement or micro feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants