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

Option to disable name creation #936

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Conversation

joaquimg
Copy link
Contributor

This option is very useful if model building becomes a bottleneck.

I tested with the case: https://github.com/jump-dev/open-energy-modeling-benchmarks/tree/main/TulipaEnergyModel/cases/1_EU_investment_simple

And considered a 744-hour window.

After running:

@time for i in 1:5
    @time TEM.create_model!(energy_problem, enable_names = true)
end
@time for i in 1:5
    @time TEM.create_model!(energy_problem, enable_names = false)
end
  6.068038 seconds (51.89 M allocations: 2.070 GiB, 14.97% gc time)
  6.543459 seconds (51.89 M allocations: 2.070 GiB, 15.97% gc time)
  6.146185 seconds (51.89 M allocations: 2.070 GiB, 31.12% gc time)
  4.789449 seconds (51.89 M allocations: 2.070 GiB, 21.78% gc time)
  5.377641 seconds (51.89 M allocations: 2.070 GiB, 28.66% gc time)
 28.927705 seconds (259.45 M allocations: 10.349 GiB, 22.30% gc time)
  3.624356 seconds (41.80 M allocations: 1.707 GiB, 22.72% gc time)
  4.070576 seconds (41.80 M allocations: 1.707 GiB, 28.73% gc time)
  3.930987 seconds (41.80 M allocations: 1.707 GiB, 21.55% gc time)
  4.170375 seconds (41.80 M allocations: 1.707 GiB, 27.58% gc time)
  3.802902 seconds (41.80 M allocations: 1.707 GiB, 21.91% gc time)
 19.601341 seconds (208.98 M allocations: 8.534 GiB, 24.61% gc time)

Which is a 30% speedup.

I can imagine some names are important for model interaction.
The more complicated version with names would be to generate names after the build, and only on the need basis.
A simpler version would be to only enable names of specific variables and constraints that are more frequently used.
The latter can be done by calling the JuMP function right before and right after each group of constraints / variables.

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.17%. Comparing base (72889d1) to head (ae4e92f).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #936      +/-   ##
==========================================
- Coverage   99.17%   96.17%   -3.00%     
==========================================
  Files          29       30       +1     
  Lines        1209     1203       -6     
==========================================
- Hits         1199     1157      -42     
- Misses         10       46      +36     

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

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.

Hi @joaquimg, Thank you for the PR and the feedback. This is a great improvement in the time it takes to build the model.

@datejada datejada merged commit 0b6b646 into TulipaEnergy:main Nov 27, 2024
6 of 7 checks passed
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