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

Update UC and ramping constraints with accumulated units #804

Conversation

datejada
Copy link
Member

@datejada datejada commented Sep 18, 2024

Pull request details

Describe the changes made in this pull request

Generalization of the accumulated units for all assets (including the ones that are not investable). This generalization simplifies the code in the capacity, unit commitment, and ramping constraints.

List of related issues or pull requests

Closes #790

Collaboration confirmation

As a contributor I confirm

  • I read and followed the instructions in README.dev.md
  • [NA] The documentation is up to date with the changes introduced in this Pull Request (or NA)
  • Tests are passing
  • Lint is passing

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0fe4d8f) to head (053daaf).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #804   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines          964       963    -1     
=========================================
- Hits           964       963    -1     

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

@datejada datejada marked this pull request as draft September 18, 2024 08:05
@datejada
Copy link
Member Author

@abelsiqueira I am a bit puzzled by the result of the Codecov because:

  1. locally it is 100%
  2. If that line is missed, then the next ones would have been missed too

Any ideas or suggestions?

@abelsiqueira
Copy link
Member

It's the same issue we had in the other PR. We moved the if-else to the outside (a few lines above).

@datejada
Copy link
Member Author

It's the same issue we had in the other PR. We moved the if-else to the outside (a few lines above).

Can we get rid of the lookup during the refactoring? If the answer is yes, I can continue my changes with that strategy for now. But, if the answer is no, then I am willing to sacrifice the Codecov in favour of readability

Comment on lines 1038 to 1051
y ∈ Y,
a ∈ decommissionable_assets_using_simple_method∪decommissionable_assets_using_compact_method,
],
accumulated_units[y ∈ Y, a ∈ A],
if a in decommissionable_assets_using_simple_method
accumulated_units_simple_method[y, a]
else
elseif a in decommissionable_assets_using_compact_method
sum(
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
a,
y,
v,
)]] for v in V_all if (a, y, v) in accumulated_set_using_compact_method
)
else
sum(values(graph[a].initial_units[y]))
end
)
Copy link
Member

Choose a reason for hiding this comment

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

My earlier comment was to transform this into the following where each condition has its own expression.

Suggested change
y Y,
a decommissionable_assets_using_simple_methoddecommissionable_assets_using_compact_method,
],
accumulated_units[y Y, a A],
if a in decommissionable_assets_using_simple_method
accumulated_units_simple_method[y, a]
else
elseif a in decommissionable_assets_using_compact_method
sum(
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
a,
y,
v,
)]] for v in V_all if (a, y, v) in accumulated_set_using_compact_method
)
else
sum(values(graph[a].initial_units[y]))
end
)
accumulated_units = model[:accumulated_units] = [
if a in decommissionable_assets_using_simple_method
@expression(model,
accumulated_units_simple_method[y, a]
)
elseif a in decommissionable_assets_using_compact_method
@expression(model,
sum(
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
a,
y,
v,
)]] for v in V_all if (a, y, v) in accumulated_set_using_compact_method
)
)
else
@expression(model,
sum(values(graph[a].initial_units[y]))
)
end
for y Y, a A
]

@abelsiqueira
Copy link
Member

I made a comment in the code trying to clarify what I meant

@datejada
Copy link
Member Author

datejada commented Sep 18, 2024

I made a comment in the code trying to clarify what I meant

Thanks, I got that, but then to access it I need a lookup, making the code less readable only to make the codecov happy :/

I mean, with that strategy, I can't any longer access the parameter accumulated_units[row.year, row.asset] but accumulated_units[accumulated_units_lookup[(row.year, row.asset)]] and it looks odd, only because the online codecov does not get that line...

@datejada datejada marked this pull request as ready for review September 18, 2024 10:35
@datejada
Copy link
Member Author

@abelsiqueira commit 053daaf has the suggested changes. Let's continue with the lookup, but I will add to the refactor issue #701 this check to discuss it later

@datejada
Copy link
Member Author

datejada commented Sep 18, 2024

And for some reason, the Codecov is not running again; haha it doesn't like that I complained about it

@abelsiqueira
Copy link
Member

Thanks for clarifying. I'm fine with decreasing codecov's requirement. There are settings that we can set to say ">90%" means passing, or something. We should discuss it later.

@datejada
Copy link
Member Author

datejada commented Sep 18, 2024

@abelsiqueira I am unsure why the codecov is not running with the updates. I tried to trigger it in #805, but it didn't work either :/

So, here is the local coverage report, if that helps

image

@abelsiqueira
Copy link
Member

I did nothing, I think codecov was just tired. Nobody complained anywhere I searched, so no way to know for sure.

@datejada
Copy link
Member Author

Great! So it is ready for review again 😊 @abelsiqueira

Copy link
Member

@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.

Thanks, LGTM

@datejada datejada merged commit 771b3b4 into TulipaEnergy:main Sep 19, 2024
12 checks passed
@datejada datejada deleted the 790-update-uc-ramps-constraints-with-multi-year branch September 19, 2024 08:01
@gnawin
Copy link
Member

gnawin commented Sep 19, 2024

@datejada @abelsiqueira I agree that the code now is less readable to make codecov happy. We did the same for the compact method. If we decrease the codecov requirement, lots of places can be cleaner.

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.

Update ramping constraints to consider multi-year investment methods
3 participants