From 4ffcfd0cf848cd2eb756ec08dfa40853da57b13c Mon Sep 17 00:00:00 2001 From: Milos-RTEi Date: Thu, 17 Aug 2023 19:30:46 +0200 Subject: [PATCH 1/7] fix - isApplicable --- .../antares/study/parts/hydro/finallevelinflowsmodifyer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp index 568d6b067d..3348b0e3a1 100644 --- a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp +++ b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp @@ -169,7 +169,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); } } // namespace Antares::Data From e191e5abd5090697f3174b950990798901313a0a Mon Sep 17 00:00:00 2001 From: Milos-RTEi Date: Thu, 17 Aug 2023 20:09:55 +0200 Subject: [PATCH 2/7] add logs if fin-lvl not applicable --- .../study/parts/hydro/finallevelinflowsmodifyer.cpp | 13 +++++++++++++ .../study/parts/hydro/finallevelinflowsmodifyer.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp index 3348b0e3a1..41f3f76682 100644 --- a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp +++ b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp @@ -46,6 +46,7 @@ FinalLevelInflowsModifier::FinalLevelInflowsModifier(const PartHydro& hydro, bool FinalLevelInflowsModifier::CheckInfeasibility(uint year) { ComputeDelta(year); + logInfoFinLvlNotApplicable(year); if (!isActive()) return true; @@ -147,6 +148,18 @@ bool FinalLevelInflowsModifier::isActive() isValidLevel(initialReservoirLevel_); } +// 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) +{ + if (isValidLevel(finalReservoirLevel_) + && (!hydro_.reservoirManagement || hydro_.useWaterValue + || !isValidLevel(initialReservoirLevel_))) + logs.info() << "Final reservoir level not applicable! Year:" << year + 1 + << ", Area:" << areaName_; +} + bool FinalLevelInflowsModifier::makeChecks(uint year) { // Simulation must end on day 365 and reservoir level must be initiated in January diff --git a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h index ecd29ea2de..fd8136cbe3 100644 --- a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h +++ b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h @@ -61,6 +61,7 @@ class FinalLevelInflowsModifier private: bool isActive(); + void logInfoFinLvlNotApplicable(uint year); void ComputeDelta(uint year); bool makeChecks(uint year); void storeDeltaLevels(uint year); From d38d482de0c9594d3e5c26c533c15e162eb18de0 Mon Sep 17 00:00:00 2001 From: Milos-RTEi Date: Fri, 8 Sep 2023 12:57:33 +0200 Subject: [PATCH 3/7] fix - only check active years --- .../simulation/hydro-final-reservoir-level-functions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/solver/simulation/hydro-final-reservoir-level-functions.cpp b/src/solver/simulation/hydro-final-reservoir-level-functions.cpp index 09735e0990..8fada405e0 100644 --- a/src/solver/simulation/hydro-final-reservoir-level-functions.cpp +++ b/src/solver/simulation/hydro-final-reservoir-level-functions.cpp @@ -56,12 +56,13 @@ void CheckFinalReservoirLevelsForYear(const Data::Study& study, uint year) void CheckFinalReservoirLevelsConfiguration(const Data::Study& study) { initializeFinalLevelData(study); - + uint nbYears = study.parameters.nbYears; for (uint year = 0; year != nbYears; ++year) { - CheckFinalReservoirLevelsForYear(study, year); + if (study.parameters.yearsFilter.at(year)) + CheckFinalReservoirLevelsForYear(study, year); } } From 0c373702511ef7cdd8f7f0abad0b38a8e2eb077b Mon Sep 17 00:00:00 2001 From: Milos-RTEi Date: Fri, 8 Sep 2023 13:51:47 +0200 Subject: [PATCH 4/7] fix - failed unit test yearFilter --- .../simulation/test-hydro-final-reservoir-level-functions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp b/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp index f926eaeb23..4c6022a5fd 100644 --- a/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp +++ b/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp @@ -55,6 +55,9 @@ struct Fixture // ------------------------------------------------------- uint areasCount = study->areas.size(); + std::vector yearFilter(2, true); + study->parameters.yearsFilter = yearFilter; + study->scenarioInitialHydroLevels.resize(nbYears, areasCount); study->scenarioFinalHydroLevels.resize(nbYears, areasCount); From 41dd16db9a1fcfabe86294f455fe665f3619c19e Mon Sep 17 00:00:00 2001 From: Milos-RTEi Date: Wed, 13 Sep 2023 12:10:02 +0200 Subject: [PATCH 5/7] refactor unit test --- .../simulation/test-hydro-final-reservoir-level-functions.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp b/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp index 4c6022a5fd..0ab05cd51d 100644 --- a/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp +++ b/src/tests/src/solver/simulation/test-hydro-final-reservoir-level-functions.cpp @@ -55,8 +55,7 @@ struct Fixture // ------------------------------------------------------- uint areasCount = study->areas.size(); - std::vector yearFilter(2, true); - study->parameters.yearsFilter = yearFilter; + study->parameters.yearsFilter.assign(2, true); study->scenarioInitialHydroLevels.resize(nbYears, areasCount); study->scenarioFinalHydroLevels.resize(nbYears, areasCount); From 94648ef034309d762134b88367d3d73e22e7358c Mon Sep 17 00:00:00 2001 From: Milos-RTEi Date: Wed, 13 Sep 2023 12:10:22 +0200 Subject: [PATCH 6/7] improve info log + refactor --- .../antares/study/parts/hydro/finallevelinflowsmodifyer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp index 41f3f76682..89918db5bf 100644 --- a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp +++ b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.cpp @@ -157,7 +157,9 @@ void FinalLevelInflowsModifier::logInfoFinLvlNotApplicable(uint year) && (!hydro_.reservoirManagement || hydro_.useWaterValue || !isValidLevel(initialReservoirLevel_))) logs.info() << "Final reservoir level not applicable! Year:" << year + 1 - << ", Area:" << areaName_; + << ", Area:" << areaName_ + << ". Check: Reservoir management = Yes, Use water values = No and proper initial " + "reservoir level is provided "; } bool FinalLevelInflowsModifier::makeChecks(uint year) @@ -182,7 +184,7 @@ bool FinalLevelInflowsModifier::isApplicable(uint year) { // If isApplicable_.size() == 0, then instance was not properly initialized // and is not applicable. - return isApplicable_.size() && isApplicable_.at(year); + return !isApplicable_.empty() && isApplicable_.at(year); } } // namespace Antares::Data From 950a0a2d8fc614bc799887afe368f0ba19abc1bb Mon Sep 17 00:00:00 2001 From: Guillaume PIERRE Date: Thu, 14 Sep 2023 18:09:47 +0200 Subject: [PATCH 7/7] CR-25 - add-info : correction after merge from develop --- src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h index 0c9f3e3708..492c313448 100644 --- a/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h +++ b/src/libs/antares/study/parts/hydro/finallevelinflowsmodifyer.h @@ -59,6 +59,7 @@ class FinalLevelInflowsModifier private: bool isActive(); + void logInfoFinLvlNotApplicable(uint year); void ComputeDelta(unsigned int year); bool makeChecks(unsigned int year); void storeDeltaLevels(unsigned int year);