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 Final reservoir level implementation - cr25 #1564

Conversation

Milos-RTEi
Copy link
Collaborator

@Milos-RTEi Milos-RTEi commented Aug 17, 2023

This PR solves an issue and adds info logs on branch [fix/hydro-final-levels-cr25--try-fixes].

// if the user specifies the final reservoir level, but does not specifies initial reservoir level
// or uses wrong hydro options
// we should inform the user that the final reservoir level wont be reached
void FinalLevelInflowsModifier::logInfoFinLvlNotApplicable(uint year)
Copy link
Contributor

Choose a reason for hiding this comment

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

To me, there is some inconsistencies here :

  • We log that the problem is not applicable, ok, but we don't skip or stop anything because of it. If the problem is not applicable, normally we should prevent something from happening, right ?
  • Applicable is already taken by another property (see method isApplicable). We should distinguish the different form of applicability, or it starts to be unclear

Copy link
Collaborator Author

@Milos-RTEi Milos-RTEi Sep 6, 2023

Choose a reason for hiding this comment

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

These info logs are as Florian suggested for crazy users.
For example, final_level is set to 55% but initila_level is left at rand.
In this case, we log out that for the specified MC-year and area, the final reservoir level won't be implemented (will be skipped). But we continue on implementation for the next year/area.
Logic won't be implemented for this year/area because "isApplicable_" is going to be false for that year/area.
This behavior should be distinguished from the one when some of the pre-checks fail and we break the simulation immediately.
So we have situations where we exit Antares asap, or we skip the year/area and throw an info log.

@@ -169,7 +182,7 @@ bool FinalLevelInflowsModifier::isApplicable(uint year)
{
// If isApplicable_.size() == 0, then instance was not properly initialized
// and is not applicable.
return isActive() && isApplicable_.size() && isApplicable_.at(year);
return isApplicable_.size() && isApplicable_.at(year);
Copy link
Member

Choose a reason for hiding this comment

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

Both versions are correct, though using empty makes it a bit more clear

Suggested change
return isApplicable_.size() && isApplicable_.at(year);
return !isApplicable_.empty() && isApplicable_.at(year);

Comment on lines +64 to +65
if (study.parameters.yearsFilter.at(year))
CheckFinalReservoirLevelsForYear(study, year);
Copy link
Member

Choose a reason for hiding this comment

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

Checking only active years is good I think

Comment on lines 58 to 59
std::vector<bool> yearFilter(2, true);
study->parameters.yearsFilter = yearFilter;
Copy link
Member

Choose a reason for hiding this comment

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

Slightly simpler

Suggested change
std::vector<bool> yearFilter(2, true);
study->parameters.yearsFilter = yearFilter;
study->parameters.yearsFilter.assign(2, true);

Comment on lines 156 to 160
if (isValidLevel(finalReservoirLevel_)
&& (!hydro_.reservoirManagement || hydro_.useWaterValue
|| !isValidLevel(initialReservoirLevel_)))
logs.info() << "Final reservoir level not applicable! Year:" << year + 1
<< ", Area:" << areaName_;
Copy link
Member

Choose a reason for hiding this comment

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

Please tell the user why the final level is not applicable, so that they can change their input data accordingly.

@flomnes flomnes added this to the v8.8.0 milestone Sep 14, 2023
…final-level-cr25-add-info

# Conflicts:
#	src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp
#	src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

79.5% 79.5% Coverage
0.0% 0.0% Duplication

@flomnes flomnes merged commit ddd1fdc into fix/hydro-final-levels-cr25--try-fixes Sep 28, 2023
7 checks passed
@flomnes flomnes deleted the fix/hydro-final-level-cr25-add-info branch September 28, 2023 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Technical design
Development

Successfully merging this pull request may close these issues.

3 participants