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

Improve computational performance of build_osm_network #845

Merged
merged 29 commits into from
Dec 23, 2024

Conversation

davide-f
Copy link
Member

@davide-f davide-f commented Aug 25, 2023

Closes #806

and contributes to #445

Changes proposed in this Pull Request

This PR merges #807 #808 and #799

It completely revise the algorithm of set_lines_ids, set_substation_ids and fix_overpassing_nodes

Speedup increase is x100 for US with half the RAM consumption of the previous implementation.
PR coauthored with @mnm-matin

Checklist

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.yaml)
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

@davide-f davide-f marked this pull request as draft August 25, 2023 18:59
@davide-f
Copy link
Member Author

davide-f commented Aug 26, 2023

@mnm-matin Performances of this PR on US leads to a x100 speed increase and to halve the RAM requirements.

Results are not exactly matching, mainly because the DBSCAN algorithm clusters together more nodes with the same tolerance hence leading to more lines to be dropped because starting and ending in the same node.
Maybe that is acceptable.

I think it is worth testing for a smaller country than US for the performances, then this PR would be ready I think.
@mnm-matin with your consent, I'd close the other PRs that are open on this topic and that are merged here.

Update:

  • for NG, results perfectly match
  • for ZA, some discrepancies apply mainly due to DBSCAN: for dense regions, a large number of buses gets clustered, hence with a setting of 5km tolerance, buses in a diameter of 15km may get merged. I think it can be acceptable

@davide-f
Copy link
Member Author

davide-f commented Aug 27, 2023

By incorporating the other PRs on #650 and #829, the overall workflow for US takes less than 4h with a total memory compatible with a medium laptop :)

I'll be now testing the continent-wise analysis to test how pypsa-earth behaves with each country

@davide-f davide-f marked this pull request as ready for review December 18, 2023 22:43
@davide-f davide-f closed this Feb 16, 2024
@ollie-bell
Copy link
Contributor

@davide-f would you not recommend using the changes in this PR? Not sure why it was closed.

@davide-f davide-f marked this pull request as draft July 27, 2024 21:40
@GbotemiB
Copy link
Contributor

GbotemiB commented Aug 2, 2024

Hi all, I am currently using this PR to work on the US model run.

- start [Fri Aug  2 16:13:17 2024]
- stop [Fri Aug  2 16:16:49 2024]

My laptop runs MBP M1 32gb ram. It completed the build_osm_network process in about 5mins which is super fast. I have been running the US model now for days.

@davide-f davide-f marked this pull request as ready for review August 14, 2024 09:35
@yerbol-akhmetov
Copy link
Collaborator

Hi, @davide-f. This is a very great lifesaving PR. It would be fantastic if it can be merged.

@davide-f
Copy link
Member Author

This PR, after all the recent changes, achieves an objective value of 2.51e+9 on the tutorial that compares well to 2.54e+9 in https://github.com/pypsa-meets-earth/pypsa-earth/actions/runs/12447612841/job/34751281672

Difference is acceptable for me

@davide-f davide-f merged commit 876e7d9 into pypsa-meets-earth:main Dec 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Improve performances of set_lines_ids with cKDTree
5 participants