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

Optimize memory usage in homogeneous_DUO_update via in-place update #144

Closed
wants to merge 1 commit into from

Conversation

EwoutH
Copy link
Contributor

@EwoutH EwoutH commented Sep 24, 2024

This commit resolves a memory consumption issue in the homogeneous_DUO_update method by replacing the previous array reallocation with an in-place update using np.place. The old implementation created new NumPy arrays in each update cycle, leading to unnecessary memory overhead.

With the in-place update, total memory usage was reduced from 1189 MB to 471 MB.

Changes

  • Switched to np.place for in-place updates of s.route_pref.
  • Removed unnecessary temporary array creation to reduce memory footprint.

Part of #143.

This commit resolves a memory consumption issue in the `homogeneous_DUO_update` method by replacing the previous array reallocation with an in-place update using `np.place`. The old implementation created new NumPy arrays in each update cycle, leading to unnecessary memory overhead.

With the in-place update, total memory usage was reduced from 1189 MB to 471 MB.

Changes:
- Switched to `np.place` for in-place updates of `s.route_pref`.
- Removed unnecessary temporary array creation to reduce memory footprint.
@EwoutH EwoutH marked this pull request as ready for review September 24, 2024 14:32
@EwoutH
Copy link
Contributor Author

EwoutH commented Sep 24, 2024

@toruseo The failure values look very small, could it be that just some rounding error and the tolerances are a bit tight?

@toruseo
Copy link
Owner

toruseo commented Sep 24, 2024

The diff is not small. I guess (I dont fully understand the vectorizatoin technique used here) the modification broke the route choice logic.

@EwoutH
Copy link
Contributor Author

EwoutH commented Sep 25, 2024

Yes, took a look again, you’re right.

I will try a few other approaches, and also investigate dist_record. Could it be that s.route_pref is copied somewhere and/or pointed to from other entities?

@toruseo
Copy link
Owner

toruseo commented Oct 3, 2024

Closing, as better one is implemented by #146

@toruseo toruseo closed this Oct 3, 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