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

Speed up parsing distances matrix #68

Merged
merged 3 commits into from
Feb 7, 2023
Merged

Speed up parsing distances matrix #68

merged 3 commits into from
Feb 7, 2023

Conversation

leonlan
Copy link
Member

@leonlan leonlan commented Feb 7, 2023

Closes #57. In particular:

  • Computing the pairwise Euclidean distance matrix is much faster.
  • Computing the full distances matrix from the lower row matrix is 2x faster.

@leonlan
Copy link
Member Author

leonlan commented Feb 7, 2023

Much faster now!

In [3]: %timeit vrplib.read_instance(f"tmp/X-n1001-k43.txt")
27.2 ms ± 754 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Base: 96.61% // Head: 96.53% // Decreases project coverage by -0.08% ⚠️

Coverage data is based on head (18b0f27) compared to base (f8aacbf).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 18b0f27 differs from pull request most recent head 75abca3. Consider uploading reports for the commit 75abca3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #68      +/-   ##
==========================================
- Coverage   96.61%   96.53%   -0.08%     
==========================================
  Files          16       16              
  Lines         236      231       -5     
==========================================
- Hits          228      223       -5     
  Misses          8        8              
Impacted Files Coverage Δ
vrplib/parse/parse_distances.py 90.00% <100.00%> (-0.91%) ⬇️

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.

@leonlan
Copy link
Member Author

leonlan commented Feb 7, 2023

%timeit vrplib.read_instance(f"tmp/Loggi-n1001-k31.txt")
121 ms ± 2.31 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

Also slightly faster. There is still room for speeding up stuff (e.g. infer_type for parsing the edge weight section is quite redundant), but these running times are quite reasonable.

@leonlan leonlan changed the title Vectorize computation of Euclidean matrix Speed up parsing distances matrix Feb 7, 2023
@leonlan leonlan merged commit 6e90956 into master Feb 7, 2023
@leonlan leonlan deleted the speed-up-euclidean branch February 7, 2023 21:15
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.

Speed-up parsing
1 participant