Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom cost routing #1

Merged
merged 24 commits into from
Jan 16, 2024
Merged

Custom cost routing #1

merged 24 commits into from
Jan 16, 2024

Conversation

roopehub
Copy link
Collaborator

@roopehub roopehub commented Nov 9, 2023

Created the foundation for custom cost routing. Modified existing code to handle (optional) osmid's in the results and to take in account (optional) custom costs and CustomCostTransportNetwork. Added new subclass of TransportNetwork for enabling and handling the custom cost logic to be added to the network and used during routing. Added tests for custom cost routing logic and components.

More details can be found from commit messages.

These additions rely on the custom cost logic modified r5 version (https://github.com/DigitalGeographyLab/r5_gp2).

…, added osmid helsinki double and zero test datas
…m costs and custom cost routing, some minor conditionals to the existing 'base' classes, added file for custom cost related conversions
@roopehub roopehub self-assigned this Nov 9, 2023
@roopehub roopehub marked this pull request as draft November 13, 2023 15:00
@roopehub
Copy link
Collaborator Author

some rather major changes coming still to this PR soon

…mainly adding osmids and checking them differently to prevent crashing when they are absent
…mes, sensitivities and custom_cost_dicts, removed custom cost related code from parent TransportNetwork.py, made conversions work with current changes, added checking for r5 version for support of custom costs
@roopehub
Copy link
Collaborator Author

fixes and improvements added in previous commits

@roopehub roopehub marked this pull request as ready for review November 15, 2023 10:25
@christophfink
Copy link

christophfink commented Nov 22, 2023

Should we close this one in favour of DigitalGeographyLab/r5#27 ?

Edit: of course not, but I’ll open this pull request for https://github.com/DigitalGeographyLab/r5py, instead

Edit 2: nevermind, I’m tired and should go home :-D

@christophfink
Copy link

christophfink commented Nov 23, 2023

Bit confused with the PR, as GitHub shows file changes that are not there in the repo, if I compare the branches on the command line (e.g., the changes to docs/user-guide/user-manual/travel-time-matrices.md)

$ git diff --compact-summary upstream/main
 src/r5py/__init__.py                                                  |      2 +
 src/r5py/r5/__init__.py                                               |      2 +
 src/r5py/r5/base_travel_time_matrix_computer.py                       |      5 +-
 src/r5py/r5/custom_cost_transport_network.py (new)                    |    243 +
 src/r5py/r5/direct_leg.py                                             |      7 +
 src/r5py/r5/transport_network.py                                      |     34 +-
 src/r5py/r5/travel_time_matrix_computer.py                            |      5 +
 src/r5py/r5/trip_leg.py                                               |      5 +-
 src/r5py/r5/trip_planner.py                                           |      9 +-
 src/r5py/util/__init__.py                                             |      5 +-
 src/r5py/util/custom_cost_conversions.py (new)                        |    129 +
 src/r5py/util/exceptions.py                                           |      8 +
 tests/conftest.py                                                     |    203 +
 tests/data/test_osm_data_custom_cost_kantakaupunki.csv (new)          | 299562 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/data/test_osm_data_negative_custom_cost_kantakaupunki.csv (new) | 299561 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/data/test_osm_data_zeros_kantakaupunki.csv (new)                |  69332 ++++++++++++++++++++++++++++++++++++++++
 tests/test_custom_cost_transport_network.py (new)                     |    482 +
 tests/test_detailed_itineraries_computer.py                           |      6 +
 tests/test_trip.py                                                    |      2 +
 tests/test_trip_leg.py                                                |      2 +
 20 files changed, 669586 insertions(+), 18 deletions(-)

https://github.com/DigitalGeographyLab/r5py_gp2/compare/main..custom-cost-routing

Give me a bit more time to investigate this

@christophfink
Copy link

christophfink commented Nov 23, 2023

@roopehub: While I figure out what’s up with GitHub’s diff, could you maybe change the tests to run on a subset of the data, only? Having 15 MiB of test data added is quite a lot

@roopehub
Copy link
Collaborator Author

And yes for the test data size. I agree that is should be smaller so going to make it smaller. I could cut the test pbf network to smaller one and make sure that the OD coordinates are inside that. The difficulty is that every edge needs to have the custom cost value added (if the routing goes that way) otherwise the R5 routing will thrown an error. That's why the huge test files having all the edges for the network. This is debatable, we also could allow no values for edges but this could make it possible to run CustomCost routing without custom cost values -> so "normal" routing. Therefore I would suggest to always init a value for each edge, and if no value is found, add 0. But I guess all edges should have some values e.g. for greenery or noise or emissions? Whats your take @christophfink?

@roopehub
Copy link
Collaborator Author

actually inspired from this conversation, I will add a optional flag which will allow nulls for edges to R5 java code. This will still require custom cost dict which is not empty.

christophfink and others added 10 commits December 18, 2023 10:16
* typo in docs [skip-ci]

* a few minor tweaks

* Use r5py’s patched build of r5 7.0, by default

* Mention that Java version requirements have changed

* force column types before pandas.concat()

* adapt tests to use SAVE_SHAPE==True custom R5

* tests (missing from previous commit)

* linted

* require Java>=21 for tests

* updated r5 jar url + hash also in tests

* workaround for Java==21 not in Ubuntu-22.04, remember to revert

* we’re not allowed to change system files on RTD VMs ;)

* use a fixed version of jre instead of ubuntu-22.04’s default (that’s too old)

* change the wording of the SAVE_SHAPES warning

* typed no-data values for detailed trips, updated test comparison data

* linted

* catch also empty linestrings in TripLeg.__repr__()

* compiled R5 with Java 17 (class file version 61)

* use existing jre for rtd

* update r5 jar hash in tests

* use openjdk 17

* investigate java env on rtd [skip-ci]

* investigate java env on rtd [skip-ci]

* investigate java env on rtd [skip-ci]

* revert to original rtd config

* detailed itineraries works with our own r5

* RTD: conda + local installaion

* use mambaforge

* require openjdk>=21

* update jar checksums

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* debugging RTD

* set JAVA_HOME if running within conda env (and it is not set)

* linted

* debug RTD env vars

* debugging RTD

* fixed CONDA_PREFIX and JAVA_HOME for conda on RTD

* Move env var handling to separate file, add PROJ_LIB
* typo in docs [skip-ci]

* a few minor tweaks

* Use r5py’s patched build of r5 7.0, by default

* Mention that Java version requirements have changed

* force column types before pandas.concat()

* adapt tests to use SAVE_SHAPE==True custom R5

* tests (missing from previous commit)

* linted

* require Java>=21 for tests

* updated r5 jar url + hash also in tests

* workaround for Java==21 not in Ubuntu-22.04, remember to revert

* we’re not allowed to change system files on RTD VMs ;)

* use a fixed version of jre instead of ubuntu-22.04’s default (that’s too old)

* change the wording of the SAVE_SHAPES warning

* typed no-data values for detailed trips, updated test comparison data

* linted

* catch also empty linestrings in TripLeg.__repr__()

* compiled R5 with Java 17 (class file version 61)

* use existing jre for rtd

* update r5 jar hash in tests

* use openjdk 17

* investigate java env on rtd [skip-ci]

* investigate java env on rtd [skip-ci]

* investigate java env on rtd [skip-ci]

* revert to original rtd config

* detailed itineraries works with our own r5

* RTD: conda + local installaion

* use mambaforge

* require openjdk>=21

* update jar checksums

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* RTD debugging, [ci-skip]

* debugging RTD

* set JAVA_HOME if running within conda env (and it is not set)

* linted

* debug RTD env vars

* debugging RTD

* fixed CONDA_PREFIX and JAVA_HOME for conda on RTD

* Move env var handling to separate file, add PROJ_LIB
…ing of type CustomCostTransportNetwork for it's always TransportNetwork
@christophfink christophfink merged commit 885cc2a into main Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants