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

Remove need for representative_periods and graph in add_expression_terms_rep_period_constraints #987

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

abelsiqueira
Copy link
Member

@abelsiqueira abelsiqueira commented Jan 7, 2025

Remove graph and representative_periods from add_expression_terms_rep_period_constraints.
Refactor the function to use the DuckDB tables instead of the DataFrames.

This now uses DuckDB to compute the groups and the intersection. The type instability made the code a bit slower so to improve, we have to manually specify the types of some outputs with ::Type. This made the code faster than it was before!

Related issues

Part of #942

Checklist

  • I am following the contributing guidelines
  • Tests are passing
  • Lint workflow is passing
  • Docs were updated and workflow is passing

@abelsiqueira abelsiqueira added the benchmark PR only - Run benchmark on PR label Jan 7, 2025
Copy link
Contributor

github-actions bot commented Jan 7, 2025

Benchmark Results

59d9e96... 7581848... 59d9e96.../7581848a2e217d...
energy_problem/create_model 44 ± 2.9 s 36.1 ± 1.4 s 1.22
energy_problem/input_and_constructor 18.8 ± 0.27 s 18.7 ± 0.11 s 1
time_to_load 3.96 ± 0.014 s 3.97 ± 0.022 s 0.998
59d9e96... 7581848... 59d9e96.../7581848a2e217d...
energy_problem/create_model 0.563 G allocs: 22.9 GB 0.328 G allocs: 16.5 GB 1.39
energy_problem/input_and_constructor 0.0675 G allocs: 2.37 GB 0.0675 G allocs: 2.37 GB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.43%. Comparing base (59d9e96) to head (7581848).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #987      +/-   ##
==========================================
+ Coverage   95.37%   95.43%   +0.06%     
==========================================
  Files          29       29              
  Lines        1124     1140      +16     
==========================================
+ Hits         1072     1088      +16     
  Misses         52       52              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abelsiqueira abelsiqueira force-pushed the 942-clean-add-flow-expression-to-cons branch from 42af70a to 073dad7 Compare January 7, 2025 15:54
@abelsiqueira abelsiqueira force-pushed the 942-clean-add-flow-expression-to-cons branch from ca58367 to 2a22cf7 Compare January 8, 2025 10:50
@abelsiqueira abelsiqueira marked this pull request as ready for review January 8, 2025 12:52
@abelsiqueira abelsiqueira requested a review from datejada January 8, 2025 12:52
src/model-preparation.jl Outdated Show resolved Hide resolved
src/model-preparation.jl Outdated Show resolved Hide resolved
@datejada
Copy link
Member

datejada commented Jan 8, 2025

Thanks @abelsiqueira, I have a couple of comments that are for my understanding of the changes rather than improvements. The SQL is understandable and readable. The best is that it is fast and uses less memory.

Move implementation details to the docstring.
Add a comment for each step in the corresponding section
Copy link
Member Author

@abelsiqueira abelsiqueira left a comment

Choose a reason for hiding this comment

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

Hi @datejada, thanks for the review and comments. Let me know if my replies answer your questions. I will push updates and re-request a review 👍

src/model-preparation.jl Outdated Show resolved Hide resolved
src/model-preparation.jl Outdated Show resolved Hide resolved
src/model-preparation.jl Show resolved Hide resolved
src/model-preparation.jl Show resolved Hide resolved
src/model-preparation.jl Show resolved Hide resolved
Copy link
Member

@datejada datejada left a comment

Choose a reason for hiding this comment

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

@abelsiqueira Thanks for the reply to the comments and the changes. I learnt more about SQL and type stability 😄

@datejada datejada merged commit 9f7908c into main Jan 9, 2025
6 of 7 checks passed
@datejada datejada deleted the 942-clean-add-flow-expression-to-cons branch January 9, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark PR only - Run benchmark on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants