From 62f6abe51b1e7c357c9204cadea4cb7c921d8484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Wed, 27 Sep 2023 11:53:10 +0200 Subject: [PATCH] Use 50% as a default value for ST-storage property initiallevel (#1632) * Use 0 as a default value for ST-storage property initiallevel * Use 50% for default values, add logs * Document default value --- docs/reference-guide/13-file-format.md | 5 ++++ .../parts/short-term-storage/properties.cpp | 27 ++++++------------- .../parts/short-term-storage/properties.h | 4 ++- .../opt_gestion_des_bornes_cas_lineaire.cpp | 4 +-- .../simulation/sim_calcul_economique.cpp | 1 + .../sim_structure_probleme_economique.h | 3 ++- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/docs/reference-guide/13-file-format.md b/docs/reference-guide/13-file-format.md index 116ebfde11..24b4d64abb 100644 --- a/docs/reference-guide/13-file-format.md +++ b/docs/reference-guide/13-file-format.md @@ -1,5 +1,10 @@ # Study format changes This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts. +## v8.7.1 +### Input +### Short-term storage +If no value is specified for `initiallevel`, then a default value of 50% is used. Note that this value is used only if `initialleveloptim=false`, and that `false` is the default value for `initialleveloptim`. + ## v8.7.0 ### Input #### Scenarized RHS for binding constraints diff --git a/src/libs/antares/study/parts/short-term-storage/properties.cpp b/src/libs/antares/study/parts/short-term-storage/properties.cpp index 1c5e58bee3..058a8b5f3a 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.cpp +++ b/src/libs/antares/study/parts/short-term-storage/properties.cpp @@ -99,7 +99,7 @@ bool Properties::loadKey(const IniFile::Property* p) return p->value.to(this->name); if (p->key == "initiallevel") - return valueForOptional(this->initialLevel); + return p->value.to(this->initialLevel); if (p->key == "initialleveloptim") return p->value.to(this->initialLevelOptim); @@ -206,29 +206,18 @@ bool Properties::validate() efficiencyFactor = 1; } - // reset initialLevel value to show we're optimising it - if (initialLevelOptim) + if (initialLevel < 0) { - logs.info() << "Optimizing initial level"; - initialLevel.reset(); - } + initialLevel = initiallevelDefault; + logs.warning() << "initiallevel for cluster: " << name << " should be positive, value has been set to " << initialLevel; - if (!initialLevelOptim && !initialLevel.has_value()) - logs.error() << "Initial level not optimized and no value provided, aborting"; + } - if (initialLevel.has_value()) + if (initialLevel > 1) { - if (initialLevel < 0) - { - logs.warning() << "initiallevel for cluster: " << name << " should be positive"; - initialLevel = 0; - } + initialLevel = initiallevelDefault; + logs.warning() << "initiallevel for cluster: " << name << " should be inferior to 1, value has been set to " << initialLevel; - if (initialLevel > 1) - { - logs.warning() << "initiallevel for cluster: " << name << " should be inferior to 1"; - initialLevel = 1; - } } return true; diff --git a/src/libs/antares/study/parts/short-term-storage/properties.h b/src/libs/antares/study/parts/short-term-storage/properties.h index 73c81b0a4e..58e79b1241 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.h +++ b/src/libs/antares/study/parts/short-term-storage/properties.h @@ -63,7 +63,7 @@ class Properties // Not optional Reservoir capacity in MWh, >= 0 std::optional reservoirCapacity; // Initial level, <= 1 - std::optional initialLevel; + double initialLevel = initiallevelDefault; // Bool to optimise or not initial level bool initialLevelOptim = false; // Efficiency factor between 0 and 1 @@ -74,5 +74,7 @@ class Properties std::string name; static const std::map ST_STORAGE_PROPERTY_GROUP_ENUM; +private: + static constexpr double initiallevelDefault = .5; }; } // namespace Antares::Data::ShortTermStorage diff --git a/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp b/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp index c26a2fbdca..f0c8eff8fe 100644 --- a/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp +++ b/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp @@ -190,10 +190,10 @@ static void setBoundsForShortTermStorage(PROBLEME_HEBDO* problemeHebdo, // 3. Levels int varLevel = CorrespondanceVarNativesVarOptim.SIM_ShortTermStorage .LevelVariable[clusterGlobalIndex]; - if (pdtHebdo == DernierPdtDeLIntervalle - 1 && storage.initialLevel.has_value()) + if (pdtHebdo == DernierPdtDeLIntervalle - 1 && !storage.initialLevelOptim) { Xmin[varLevel] = Xmax[varLevel] - = storage.reservoirCapacity * storage.initialLevel.value(); + = storage.reservoirCapacity * storage.initialLevel; } else { diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 75bba4aa43..29c5bb4005 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -62,6 +62,7 @@ static void importShortTermStorages( toInsert.injectionNominalCapacity = st->properties.injectionNominalCapacity.value(); toInsert.withdrawalNominalCapacity = st->properties.withdrawalNominalCapacity.value(); toInsert.initialLevel = st->properties.initialLevel; + toInsert.initialLevelOptim = st->properties.initialLevelOptim; toInsert.name = st->properties.name; toInsert.series = st->series; diff --git a/src/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/sim_structure_probleme_economique.h index 2721839f00..5a94273a9b 100644 --- a/src/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/sim_structure_probleme_economique.h @@ -173,7 +173,8 @@ struct PROPERTIES double injectionNominalCapacity; double withdrawalNominalCapacity; double efficiency; - std::optional initialLevel; + double initialLevel; + bool initialLevelOptim; std::shared_ptr series;