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

Refactor variables to use TulipaVariable #925

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

abelsiqueira
Copy link
Member

Create field lookup to allow changing the variables without
having to redefine the whole model creation

Related to #923

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.76%. Comparing base (a286c75) to head (d4c426d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #925      +/-   ##
==========================================
+ Coverage   97.85%   98.76%   +0.90%     
==========================================
  Files          29       30       +1     
  Lines        1214     1210       -4     
==========================================
+ Hits         1188     1195       +7     
+ Misses         26       15      -11     

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


🚨 Try these New Features:

@abelsiqueira abelsiqueira added the benchmark PR only - Run benchmark on PR label Nov 8, 2024
Copy link
Contributor

github-actions bot commented Nov 8, 2024

Benchmark Results

a286c75... d4c426d... a286c75.../d4c426d86e13ec...
energy_problem/create_model 48.1 ± 1.4 s 46.5 ± 2.2 s 1.03
energy_problem/input_and_constructor 10.1 ± 0.84 s 10.4 ± 0.33 s 0.964
time_to_load 3.98 ± 0.13 s 3.87 ± 0.046 s 1.03
a286c75... d4c426d... a286c75.../d4c426d86e13ec...
energy_problem/create_model 0.66 G allocs: 22.6 GB 0.66 G allocs: 22.6 GB 1
energy_problem/input_and_constructor 0.0327 G allocs: 1.38 GB 0.0327 G allocs: 1.38 GB 1
time_to_load 0.157 k allocs: 11.1 kB 0.157 k allocs: 11.1 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).

@abelsiqueira
Copy link
Member Author

@datejada @gnawin I translated most investment variables into SQL, but I can't do the same for assets_decommission_compact_method. If you have an idea, it would be helpful.

The main issue is that the variable apparently is not a subset of the rows of assets_data, so I don't have a good intuition on how to start.

@abelsiqueira abelsiqueira force-pushed the 923-variable-refactor-with-lookup-trick branch from ce6a64c to d00dcd1 Compare November 12, 2024 09:52
src/variables/create.jl Outdated Show resolved Hide resolved
@abelsiqueira abelsiqueira marked this pull request as ready for review November 12, 2024 12:09
# NOTE: To add another column from assets_data, it has to be added on the two inner SELECT
# statements (not the year_data one)
variables[:assets_decommission_compact_method] = TulipaVariable(
DuckDB.query(
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @abelsiqueira, @gnawin and I reviewed this query and it is almost there. So, two things:

  1. We tested it in the multi-year investment data, and it works. However, we want to cover another edge case outside that use case (so, in issue Create a meaningful year data for the Norse Case #684 I added that to the list to improve it). If we change the input to have the asset = ccgt in year = 2030 and commission_year = 2030 with investable = false, then it should not appear in the result of this query. As it is, it seems. Ni and I tried to fix it but couldn't (sorry about that). If we cover that case, then this change is okay.
  2. For the indices of the decommission variables, we don't need the investable column (we need the investment integer for creating the variable). So, we were wondering, why do you keep it? Maybe we are missing something. If we don't need it, then we should take it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Can we add that to the actual tests? Otherwise there is guarantee that it works as expected.
    I also don't see the relation between this new data row and the compact formulation. There are other rows that result in investable = false in the query, so investable is not taken into account

  2. I was just using for checking that things propagate

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 @abelsiqueira, thanks for the PR. We have a comment on the decommission variable indices. Please let us know if you need to discuss it, and we can comment on Teams.

Create field lookup to allow changing the variables without
having to redefine the whole model creation

Related to #923
@abelsiqueira abelsiqueira force-pushed the 923-variable-refactor-with-lookup-trick branch from 69b58b9 to 2e224a4 Compare November 25, 2024 14:29
src/variables/create.jl Outdated 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.

LGTM. Thanks!

@abelsiqueira abelsiqueira merged commit 38c20d4 into main Nov 25, 2024
6 of 7 checks passed
@abelsiqueira abelsiqueira deleted the 923-variable-refactor-with-lookup-trick branch November 25, 2024 15:25
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.

3 participants