From 6c2dfebada80cd3f137fbe2ee7acd2d99c16f90a Mon Sep 17 00:00:00 2001 From: h-fournier Date: Wed, 27 Nov 2024 17:22:10 +0100 Subject: [PATCH] Intern Review NSA --- src/format-code.sh | 24 + .../study/include/antares/study/area/area.h | 12 +- .../antares/study/parts/hydro/container.h | 6 +- .../parts/short-term-storage/properties.h | 3 + src/solver/optimisation/CMakeLists.txt | 2 +- .../opt_construction_variables_reserves.cpp | 811 +++++++++--------- .../opt_gestion_des_bornes_reserves.cpp | 402 +++++++++ ...gestion_des_bornes_reserves_thermiques.cpp | 345 -------- .../opt_gestion_des_couts_reserves.cpp | 227 +++-- .../opt_gestion_second_membre_reserves.cpp | 624 ++++++++------ .../sim_structure_probleme_economique.h | 36 +- .../simulation/sim_calcul_economique.cpp | 5 + .../include/antares/solver/variable/info.h | 14 +- .../include/antares/solver/variable/state.h | 50 +- 14 files changed, 1370 insertions(+), 1191 deletions(-) create mode 100644 src/solver/optimisation/opt_gestion_des_bornes_reserves.cpp delete mode 100644 src/solver/optimisation/opt_gestion_des_bornes_reserves_thermiques.cpp diff --git a/src/format-code.sh b/src/format-code.sh index e69de29bb2..abac85a423 100755 --- a/src/format-code.sh +++ b/src/format-code.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ $# -eq 0 ] +then + # No arguments: format all + SOURCE_DIRS="analyzer/ libs/ solver/ tools/ config/ tests/ packaging/" + SOURCE_FILES=$(find $SOURCE_DIRS -regextype egrep -regex ".*/*\.(c|cxx|cpp|cc|h|hxx|hpp)$" ! -path '*/antlr-interface/*') +else + # Format files provided as arguments + SOURCE_FILES="$@" +fi + +# Remove ^M, etc. +if ! [ -x "$(command -v dos2unix)" ]; then + echo 'Warning: dos2unix is not installed. Skipping' >&2 +else + echo "$SOURCE_FILES" | xargs dos2unix +fi + +if ! [ -x "$(command -v clang-format)" ]; then + echo 'Warning: clang-format is not installed. Skipping' >&2 +else + echo "$SOURCE_FILES" | xargs clang-format -i --verbose +fi diff --git a/src/libs/antares/study/include/antares/study/area/area.h b/src/libs/antares/study/include/antares/study/area/area.h index 81cb81c006..d62bba0e19 100644 --- a/src/libs/antares/study/include/antares/study/area/area.h +++ b/src/libs/antares/study/include/antares/study/area/area.h @@ -43,10 +43,9 @@ template class BiMap { -private: // Maps for both directions: key-to-value and value-to-key - std::map key_to_value; // Map from key (int) to value (T) - std::map value_to_key; // Map from value (T) to key (int) + std::map key_to_value; //!< Map from key (int) to value (T) + std::map value_to_key; //!< Map from value (T) to key (int) public: // Function to insert a key-value pair @@ -65,12 +64,11 @@ class BiMap } // Function to get the value from the key - T get(int key) const + const T& get(int key) const { - auto it = key_to_value.find(key); - if (it != key_to_value.end()) + if (key_to_value.count(key)) { - return it->second; // Return the associated value if the key exists + return key_to_value.at(key); // Return the associated value if the key exists } throw std::out_of_range("This index is not in the BiMap"); } diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/container.h b/src/libs/antares/study/include/antares/study/parts/hydro/container.h index 9e2b299c08..1cfdcb86f3 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/container.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/container.h @@ -172,13 +172,13 @@ class PartHydro std::optional reserveParticipationAt(const Area* area, unsigned int index) const; - //! \brief Returns max turbining power for a reserve if participating, -1 otherwise + //! Returns max turbining power for a reserve if participating, -1 otherwise float reserveMaxTurbining(Data::ReserveName name); - //! \brief Returns max pumping power for a reserve if participating, -1 otherwise + //! Returns max pumping power for a reserve if participating, -1 otherwise float reserveMaxPumping(Data::ReserveName name); - //! \brief Returns participating cost for a reserve if participating, -1 otherwise + //! Returns participating cost for a reserve if participating, -1 otherwise float reserveCost(Data::ReserveName name); diff --git a/src/libs/antares/study/include/antares/study/parts/short-term-storage/properties.h b/src/libs/antares/study/include/antares/study/parts/short-term-storage/properties.h index 6e11541e30..51b0568fc8 100644 --- a/src/libs/antares/study/include/antares/study/parts/short-term-storage/properties.h +++ b/src/libs/antares/study/include/antares/study/parts/short-term-storage/properties.h @@ -77,6 +77,9 @@ class Properties /// cluster name std::string name; + /// Cluster gloval index (across areas) + int clusterGlobalIndex; + /// Enabled ? bool enabled = true; diff --git a/src/solver/optimisation/CMakeLists.txt b/src/solver/optimisation/CMakeLists.txt index c6c9c4cdcb..fdcd1db947 100644 --- a/src/solver/optimisation/CMakeLists.txt +++ b/src/solver/optimisation/CMakeLists.txt @@ -30,7 +30,7 @@ set(RTESOLVER_OPT opt_gestion_des_couts_cas_quadratique.cpp opt_construction_variables_couts_demarrages.cpp opt_gestion_des_bornes_couts_demarrage.cpp - opt_gestion_des_bornes_reserves_thermiques.cpp + opt_gestion_des_bornes_reserves.cpp opt_gestion_des_couts_couts_demarrage.cpp opt_gestion_des_couts_reserves.cpp opt_gestion_second_membre_couts_demarrage.cpp diff --git a/src/solver/optimisation/opt_construction_variables_reserves.cpp b/src/solver/optimisation/opt_construction_variables_reserves.cpp index 4bb183d9a8..763e69fde9 100644 --- a/src/solver/optimisation/opt_construction_variables_reserves.cpp +++ b/src/solver/optimisation/opt_construction_variables_reserves.cpp @@ -19,30 +19,380 @@ ** along with Antares_Simulator. If not, see . */ -#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" +#include #include "antares/solver/optimisation/opt_fonctions.h" #include "antares/solver/optimisation/opt_rename_problem.h" - -#include +#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireReserves( PROBLEME_HEBDO* problemeHebdo, bool Simulation) { - const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre; + VariableNamer variableNamer(problemeHebdo->ProblemeAResoudre->NomDesVariables); + int NombreDePasDeTempsPourUneOptimisation = problemeHebdo + ->NombreDePasDeTempsPourUneOptimisation; + + struct ReserveVariablesInitializer + { + PROBLEME_HEBDO* problemeHebdo; + bool Simulation; + const std::unique_ptr& ProblemeAResoudre; + int& NombreDeVariables; + VariableNamer& variableNamer; + VariableManagement::VariableManager variableManager; + + ReserveVariablesInitializer(PROBLEME_HEBDO* hebdo, bool sim, VariableNamer& namer): + problemeHebdo(hebdo), + Simulation(sim), + ProblemeAResoudre(hebdo->ProblemeAResoudre), + NombreDeVariables(ProblemeAResoudre->NombreDeVariables), + variableNamer(namer), + variableManager(VariableManagerFromProblemHebdo(hebdo)) + { + } + + // Init variables for a reserve + void initReserve(int pdt, const int reserveIndex, const std::string& reserveName) + { + if (Simulation) + { + NombreDeVariables += 2; + } + else + { + // For Unsatisfied Reserves + variableManager.InternalUnsatisfiedReserve(reserveIndex, pdt) = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.InternalUnsatisfiedReserve(NombreDeVariables, reserveName); + NombreDeVariables++; + + // For Excess Reserves + variableManager.InternalExcessReserve(reserveIndex, pdt) = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.InternalExcessReserve(NombreDeVariables, reserveName); + NombreDeVariables++; + } + } + + // Init variables for a Thermal cluster participation to a reserve up + void initThermalReserveUpParticipation( + int pdt, + const RESERVE_PARTICIPATION_THERMAL& clusterReserveParticipation, + const std::string& reserveName) + { + const auto& clusterName = clusterReserveParticipation.clusterName; + if (Simulation) + { + NombreDeVariables += 4; + } + else + { + // For running units in cluster + variableManager.RunningThermalClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfRunningUnitsToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; - int NombreDePasDeTempsPourUneOptimisation - = problemeHebdo->NombreDePasDeTempsPourUneOptimisation; - int& NombreDeVariables = ProblemeAResoudre->NombreDeVariables; - VariableNamer variableNamer(ProblemeAResoudre->NomDesVariables); - auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo); + // For off units in cluster + variableManager.OffThermalClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfOffUnitsToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + variableManager.NumberOfOffUnitsParticipatingToReserve( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + ProblemeAResoudre->VariablesEntieres[NombreDeVariables] + = problemeHebdo->OptimisationAvecVariablesEntieres; + variableNamer.NumberOfOffUnitsParticipatingToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For all units in cluster + variableManager.ThermalClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ThermalClusterReserveParticipation(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + } + } + + // Init variables for a Thermal cluster participation to a reserve down + void initThermalReserveDownParticipation( + int pdt, + const RESERVE_PARTICIPATION_THERMAL& clusterReserveParticipation, + const std::string& reserveName) + { + const auto& clusterName = clusterReserveParticipation.clusterName; + if (Simulation) + { + NombreDeVariables += 2; + } + else + { + // For running units in cluster + variableManager.RunningThermalClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfRunningUnitsToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For all units in cluster (off units can not participate to down reserves) + variableManager.ThermalClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ThermalClusterReserveParticipation(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + } + } + + // Init variables for a ShortTerm cluster participation to a reserve up + void initSTStorageReserveUpParticipation( + int pdt, + const RESERVE_PARTICIPATION_STSTORAGE& clusterReserveParticipation, + const std::string& reserveName) + { + const auto& clusterName = clusterReserveParticipation.clusterName; + if (Simulation) + { + NombreDeVariables += 3; + } + else + { + // For Turbining participation to the reserves + variableManager.STStorageTurbiningClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfSTStorageTurbiningToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Pumping participation to the reserves + variableManager.STStoragePumpingClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfSTStoragePumpingToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Short Term Storage participation to the up reserves + variableManager.STStorageClusterReserveUpParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfSTStorageToUpReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + } + } + // Init variables for a ShortTerm cluster participation to a reserve down + void initSTStorageReserveDownParticipation( + int pdt, + const RESERVE_PARTICIPATION_STSTORAGE& clusterReserveParticipation, + const std::string& reserveName) + { + const auto& clusterName = clusterReserveParticipation.clusterName; + if (Simulation) + { + NombreDeVariables += 3; + } + else + { + // For Turbining participation to the reserves + variableManager.STStorageTurbiningClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfSTStorageTurbiningToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Pumping participation to the reserves + variableManager.STStoragePumpingClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfSTStoragePumpingToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Short Term Storage participation to the Down reserves + variableManager.STStorageClusterReserveDownParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfSTStorageToDownReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + } + } + + // Init variables for a LongTerm cluster participation to a reserve up + void initLTStorageReserveUpParticipation( + int pdt, + const RESERVE_PARTICIPATION_LTSTORAGE& clusterReserveParticipation, + const std::string& reserveName) + { + const auto& clusterName = clusterReserveParticipation.clusterName; + if (Simulation) + { + NombreDeVariables += 3; + } + else + { + // For Turbining participation to the reserves + variableManager.LTStorageTurbiningClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfLTStorageTurbiningToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Pumping participation to the reserves + variableManager.LTStoragePumpingClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfLTStoragePumpingToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Long Term Storage participation to the up reserves + variableManager.LTStorageClusterReserveUpParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfLTStorageToUpReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + } + } + + // Init variables for a LongTerm cluster participation to a reserve down + void initLTStorageReserveDownParticipation( + int pdt, + const RESERVE_PARTICIPATION_LTSTORAGE& clusterReserveParticipation, + const std::string& reserveName) + { + const auto& clusterName = clusterReserveParticipation.clusterName; + if (Simulation) + { + NombreDeVariables += 3; + } + else + { + // For Turbining participation to the reserves + variableManager.LTStorageTurbiningClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfLTStorageTurbiningToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Pumping participation to the reserves + variableManager.LTStoragePumpingClusterReserveParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfLTStoragePumpingToReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + + // For Long Term Storage participation to the Down reserves + variableManager.LTStorageClusterReserveDownParticipation( + clusterReserveParticipation.globalIndexClusterParticipation, + pdt) + = NombreDeVariables; + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] + = VARIABLE_BORNEE_DES_DEUX_COTES; + variableNamer.ParticipationOfLTStorageToDownReserve(NombreDeVariables, + clusterName, + reserveName); + NombreDeVariables++; + } + } + }; + + ReserveVariablesInitializer reserveVariablesInitializer(problemeHebdo, + Simulation, + variableNamer); for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++) { variableNamer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt); - auto& CorrespondanceVarNativesVarOptim - = problemeHebdo->CorrespondanceVarNativesVarOptim[pdt]; + auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim[pdt]; for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) { @@ -52,439 +402,78 @@ void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireReserves( int reserveIndex = 0; // For Up Reserves - for (auto& areaReserveUp : areaReserves.areaCapacityReservationsUp) + for (auto& areaReserveUp: areaReserves.areaCapacityReservationsUp) { - reserveIndex = areaReserveUp.globalReserveIndex; - if (Simulation) - { - NombreDeVariables += 2; - } - else - { - // For Unsatisfied Reserves - variableManager.InternalUnsatisfiedReserve(reserveIndex, pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.InternalUnsatisfiedReserve(NombreDeVariables, - areaReserveUp.reserveName); - NombreDeVariables++; - - // For Excess Reserves - variableManager.InternalExcessReserve(reserveIndex, pdt) = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.InternalExcessReserve(NombreDeVariables, + reserveVariablesInitializer.initReserve(pdt, + areaReserveUp.globalReserveIndex, areaReserveUp.reserveName); - NombreDeVariables++; - } // Thermal Clusters - for (auto& [clusterId, clusterReserveParticipation] : + for (auto& [clusterId, clusterReserveParticipation]: areaReserveUp.AllThermalReservesParticipation) { - const auto& clusterName = clusterReserveParticipation.clusterName; - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For running units in cluster - variableManager.RunningThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfRunningUnitsToReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } - if (Simulation) - { - NombreDeVariables += 2; - } - else - { - // For off units in cluster - variableManager.OffThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfOffUnitsToReserve(NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - - variableManager.NumberOfOffUnitsParticipatingToReserve( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - ProblemeAResoudre->VariablesEntieres[NombreDeVariables] - = problemeHebdo->OptimisationAvecVariablesEntieres; - variableNamer.NumberOfOffUnitsParticipatingToReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For all units in cluster - variableManager.ThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ThermalClusterReserveParticipation(NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } + reserveVariablesInitializer.initThermalReserveUpParticipation( + pdt, + clusterReserveParticipation, + areaReserveUp.reserveName); } // Short Term Storage Clusters - for (auto& [clusterId, clusterReserveParticipation] : - areaReserveUp.AllSTStorageReservesParticipation) + for (auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllSTStorageReservesParticipation) { - const auto& clusterName = clusterReserveParticipation.clusterName; - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Turbining participation to the reserves - variableManager.STStorageTurbiningClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfSTStorageTurbiningToReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Pumping participation to the reserves - variableManager.STStoragePumpingClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfSTStoragePumpingToReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Short Term Storage participation to the up reserves - variableManager.STStorageClusterReserveUpParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfSTStorageToUpReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } + reserveVariablesInitializer.initSTStorageReserveUpParticipation( + pdt, + clusterReserveParticipation, + areaReserveUp.reserveName); } - //Long Term Storage Clusters - for (auto& clusterReserveParticipation : - areaReserveUp.AllLTStorageReservesParticipation) + // Long Term Storage Clusters + for (auto& clusterReserveParticipation: + areaReserveUp.AllLTStorageReservesParticipation) { - const auto& clusterName = clusterReserveParticipation.clusterName; - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Turbining participation to the reserves - variableManager.LTStorageTurbiningClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfLTStorageTurbiningToReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Pumping participation to the reserves - variableManager.LTStoragePumpingClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfLTStoragePumpingToReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Long Term Storage participation to the up reserves - variableManager.LTStorageClusterReserveUpParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfLTStorageToUpReserve( - NombreDeVariables, - clusterName, - areaReserveUp.reserveName); - NombreDeVariables++; - } + reserveVariablesInitializer.initLTStorageReserveUpParticipation( + pdt, + clusterReserveParticipation, + areaReserveUp.reserveName); } } // For Down Reserves - for (auto& areaReserveDown : areaReserves.areaCapacityReservationsDown) + for (auto& areaReserveDown: areaReserves.areaCapacityReservationsDown) { - reserveIndex = areaReserveDown.globalReserveIndex; - if (Simulation) - { - NombreDeVariables += 2; - } - else - { - // For Unsatisfied Reserves - variableManager.InternalUnsatisfiedReserve(reserveIndex, pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.InternalUnsatisfiedReserve(NombreDeVariables, - areaReserveDown.reserveName); - NombreDeVariables++; - - // For Excess Reserves - variableManager.InternalExcessReserve(reserveIndex, pdt) = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.InternalExcessReserve(NombreDeVariables, + reserveVariablesInitializer.initReserve(pdt, + areaReserveDown.globalReserveIndex, areaReserveDown.reserveName); - NombreDeVariables++; - } // Thermal Clusters - for (auto& [clusterId, clusterReserveParticipation] : + for (auto& [clusterId, clusterReserveParticipation]: areaReserveDown.AllThermalReservesParticipation) { - const auto& clusterName = clusterReserveParticipation.clusterName; - if (Simulation) - { - NombreDeVariables += 2; - } - else - { - // For running units in cluster - variableManager.RunningThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfRunningUnitsToReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - - // For all units in cluster (off units can not participate to down - // reserves) - variableManager.ThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ThermalClusterReserveParticipation(NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } + reserveVariablesInitializer.initThermalReserveDownParticipation( + pdt, + clusterReserveParticipation, + areaReserveDown.reserveName); } // Short Term Storage Clusters - for (auto& [clusterId, clusterReserveParticipation] : + for (auto& [clusterId, clusterReserveParticipation]: areaReserveDown.AllSTStorageReservesParticipation) { - const auto& clusterName = clusterReserveParticipation.clusterName; - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Turbining participation to the reserves - variableManager.STStorageTurbiningClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfSTStorageTurbiningToReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Pumping participation to the reserves - variableManager.STStoragePumpingClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfSTStoragePumpingToReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Short Term Storage participation to the Down reserves - variableManager.STStorageClusterReserveDownParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfSTStorageToDownReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } + reserveVariablesInitializer.initSTStorageReserveDownParticipation( + pdt, + clusterReserveParticipation, + areaReserveDown.reserveName); } // Long Term Storage Clusters - for (auto& clusterReserveParticipation : + for (auto& clusterReserveParticipation: areaReserveDown.AllLTStorageReservesParticipation) { - const auto& clusterName = clusterReserveParticipation.clusterName; - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Turbining participation to the reserves - variableManager.LTStorageTurbiningClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfLTStorageTurbiningToReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Pumping participation to the reserves - variableManager.LTStoragePumpingClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfLTStoragePumpingToReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } - - if (Simulation) - { - NombreDeVariables++; - } - else - { - // For Long Term Storage participation to the Down reserves - variableManager.LTStorageClusterReserveDownParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdt) - = NombreDeVariables; - ProblemeAResoudre->TypeDeVariable[NombreDeVariables] - = VARIABLE_BORNEE_DES_DEUX_COTES; - variableNamer.ParticipationOfLTStorageToDownReserve( - NombreDeVariables, - clusterName, - areaReserveDown.reserveName); - NombreDeVariables++; - } + reserveVariablesInitializer.initLTStorageReserveDownParticipation( + pdt, + clusterReserveParticipation, + areaReserveDown.reserveName); } } } diff --git a/src/solver/optimisation/opt_gestion_des_bornes_reserves.cpp b/src/solver/optimisation/opt_gestion_des_bornes_reserves.cpp new file mode 100644 index 0000000000..00b3bf1569 --- /dev/null +++ b/src/solver/optimisation/opt_gestion_des_bornes_reserves.cpp @@ -0,0 +1,402 @@ +/* +** Copyright 2007-2024, RTE (https://www.rte-france.com) +** See AUTHORS.txt +** SPDX-License-Identifier: MPL-2.0 +** This file is part of Antares-Simulator, +** Adequacy and Performance assessment for interconnected energy networks. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the Mozilla Public Licence 2.0 as published by +** the Mozilla Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** Mozilla Public Licence 2.0 for more details. +** +** You should have received a copy of the Mozilla Public Licence 2.0 +** along with Antares_Simulator. If not, see . +*/ + +#include "antares/solver/optimisation/opt_fonctions.h" +#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" +#include "antares/solver/simulation/sim_structure_donnees.h" +#include "antares/solver/simulation/sim_structure_probleme_economique.h" +#include "antares/solver/simulation/simulation.h" + +#include "variables/VariableManagement.h" +#include "variables/VariableManagerUtils.h" + +using namespace Yuni; + +void OPT_InitialiserLesBornesDesVariablesDuProblemeLineaireReservesThermiques( + PROBLEME_HEBDO* problemeHebdo, + const int PremierPdtDeLIntervalle, + const int DernierPdtDeLIntervalle) +{ + struct ReserveVariablesBoundsSetter + { + PROBLEME_HEBDO* problemeHebdo; + const std::unique_ptr& ProblemeAResoudre; + std::vector& Xmin; + std::vector& Xmax; + std::vector& AdresseOuPlacerLaValeurDesVariablesOptimisees; + int pdtJour, pdtHebdo, pays; + + ReserveVariablesBoundsSetter(PROBLEME_HEBDO* hebdo): + problemeHebdo(hebdo), + ProblemeAResoudre(hebdo->ProblemeAResoudre), + Xmin(ProblemeAResoudre->Xmin), + Xmax(ProblemeAResoudre->Xmax), + AdresseOuPlacerLaValeurDesVariablesOptimisees( + ProblemeAResoudre->AdresseOuPlacerLaValeurDesVariablesOptimisees), + pdtJour(0), + pdtHebdo(0), + pays(0) + { + } + + void setPdtJour(int pdt) + { + pdtJour = pdt; + } + + void setPdtHebdo(int pdt) + { + pdtHebdo = pdt; + } + + void setPays(int p) + { + pays = p; + } + + // Set variables bounds for a reserve + void setReserveBounds(int reserveIdInArea, int reserveId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim.internalUnsatisfiedReserveIndex[reserveId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .Reserves[pdtHebdo] + .ValeursHorairesInternalUnsatisfied[reserveIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + + var = CorrespondanceVarNativesVarOptim.internalExcessReserveIndex[reserveId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .Reserves[pdtHebdo] + .ValeursHorairesInternalExcessReserve[reserveIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + + // Set variables bounds for a Thermal cluster participation to a reserve up + void setThermalReserveUpParticipationBounds(int clusterParticipationIdInArea, + int clusterParticipationId, + int clusterIdInArea, + int clusterId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim + .runningThermalClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .ProductionThermique[pdtHebdo] + .ParticipationReservesDuPalierOn[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + + var = CorrespondanceVarNativesVarOptim + .offThermalClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .ProductionThermique[pdtHebdo] + .ParticipationReservesDuPalierOff[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + + var = CorrespondanceVarNativesVarOptim + .nbOffGroupUnitsParticipatingToReservesInThermalClusterIndex + [clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = problemeHebdo->PaliersThermiquesDuPays[pays] + .TailleUnitaireDUnGroupeDuPalierThermique[clusterId]; + adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .ProductionThermique[pdtHebdo] + .NombreDeGroupesEteintDuPalierQuiParticipentAuxReserves[clusterIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + + var = CorrespondanceVarNativesVarOptim + .thermalClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .ProductionThermique[pdtHebdo] + .ParticipationReservesDuPalier[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + + // Set variables bounds for a Thermal cluster participation to a reserve down + void setThermalReserveDownParticipationBounds(int clusterParticipationIdInArea, + int clusterParticipationId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim + .runningThermalClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .ProductionThermique[pdtHebdo] + .ParticipationReservesDuPalierOn[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + + var = CorrespondanceVarNativesVarOptim + .thermalClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .ProductionThermique[pdtHebdo] + .ParticipationReservesDuPalier[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + + // Set variables bounds for a ShortTerm cluster participation to a reserve up + void setSTStorageReserveUpParticipationBounds(int clusterParticipationIdInArea, + int clusterParticipationId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim + .STStorageTurbiningClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .ShortTermStorage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .STStoragePumpingClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .ShortTermStorage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .STStorageClusterReserveUpParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .ShortTermStorage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + + // Set variables bounds for a ShortTerm cluster participation to a reserve down + void setSTStorageReserveDownParticipationBounds(int clusterParticipationIdInArea, + int clusterParticipationId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim + .STStorageTurbiningClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .ShortTermStorage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .STStoragePumpingClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .ShortTermStorage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .STStorageClusterReserveDownParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .ShortTermStorage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + + // Set variables bounds for a LongTerm cluster participation to a reserve up + void setLTStorageReserveUpParticipationBounds(int clusterParticipationIdInArea, + int clusterParticipationId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim + .LTStorageTurbiningClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .HydroUsage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .LTStoragePumpingClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .HydroUsage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .LTStorageClusterReserveUpParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .HydroUsage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + + // Set variables bounds for a LongTerm cluster participation to a reserve down + void setLTStorageReserveDownParticipationBounds(int clusterParticipationIdInArea, + int clusterParticipationId) + { + const auto& CorrespondanceVarNativesVarOptim = problemeHebdo + ->CorrespondanceVarNativesVarOptim + [pdtJour]; + int var = CorrespondanceVarNativesVarOptim + .LTStorageTurbiningClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays] + .HydroUsage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .LTStoragePumpingClusterReserveParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .HydroUsage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; + + var = CorrespondanceVarNativesVarOptim + .LTStorageClusterReserveDownParticipationIndex[clusterParticipationId]; + Xmin[var] = 0; + Xmax[var] = LINFINI_ANTARES; + adresseDuResultat = &(problemeHebdo->ResultatsHoraires[pays] + .HydroUsage[pdtHebdo] + .reserveParticipationOfCluster[clusterParticipationIdInArea]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } + }; + + ReserveVariablesBoundsSetter reserveVariablesBoundsSetter(problemeHebdo); + + for (int pdtHebdo = PremierPdtDeLIntervalle, pdtJour = 0; pdtHebdo < DernierPdtDeLIntervalle; + pdtHebdo++, pdtJour++) + { + reserveVariablesBoundsSetter.setPdtJour(pdtJour); + reserveVariablesBoundsSetter.setPdtHebdo(pdtHebdo); + + for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) + { + reserveVariablesBoundsSetter.setPays(pays); + const auto& areaReserves = problemeHebdo->allReserves[pays]; + + for (const auto& areaReserveUp: areaReserves.areaCapacityReservationsUp) + { + reserveVariablesBoundsSetter.setReserveBounds(areaReserveUp.areaReserveIndex, + areaReserveUp.globalReserveIndex); + + // Thermal Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllThermalReservesParticipation) + { + reserveVariablesBoundsSetter.setThermalReserveUpParticipationBounds( + clusterReserveParticipation.areaIndexClusterParticipation, + clusterReserveParticipation.globalIndexClusterParticipation, + clusterReserveParticipation.clusterIdInArea, + clusterId); + } + + // Short Term Storage Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllSTStorageReservesParticipation) + { + reserveVariablesBoundsSetter.setSTStorageReserveUpParticipationBounds( + clusterReserveParticipation.areaIndexClusterParticipation, + clusterReserveParticipation.globalIndexClusterParticipation); + } + + // Long Term Storage Cluster + for (const auto& clusterReserveParticipation: + areaReserveUp.AllLTStorageReservesParticipation) + { + reserveVariablesBoundsSetter.setLTStorageReserveUpParticipationBounds( + clusterReserveParticipation.areaIndexClusterParticipation, + clusterReserveParticipation.globalIndexClusterParticipation); + } + } + for (const auto& areaReserveDown: areaReserves.areaCapacityReservationsDown) + { + reserveVariablesBoundsSetter.setReserveBounds(areaReserveDown.areaReserveIndex, + areaReserveDown.globalReserveIndex); + + // Thermal Clusters + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveDown.AllThermalReservesParticipation) + { + reserveVariablesBoundsSetter.setThermalReserveDownParticipationBounds( + clusterReserveParticipation.areaIndexClusterParticipation, + clusterReserveParticipation.globalIndexClusterParticipation); + } + + // Short Term Storage Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveDown.AllSTStorageReservesParticipation) + { + reserveVariablesBoundsSetter.setSTStorageReserveDownParticipationBounds( + clusterReserveParticipation.areaIndexClusterParticipation, + clusterReserveParticipation.globalIndexClusterParticipation); + } + + // Long Term Storage Cluster + for (const auto& clusterReserveParticipation: + areaReserveDown.AllLTStorageReservesParticipation) + { + reserveVariablesBoundsSetter.setLTStorageReserveDownParticipationBounds( + clusterReserveParticipation.areaIndexClusterParticipation, + clusterReserveParticipation.globalIndexClusterParticipation); + } + } + } + } +} diff --git a/src/solver/optimisation/opt_gestion_des_bornes_reserves_thermiques.cpp b/src/solver/optimisation/opt_gestion_des_bornes_reserves_thermiques.cpp deleted file mode 100644 index e13f0ceb94..0000000000 --- a/src/solver/optimisation/opt_gestion_des_bornes_reserves_thermiques.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" - -#include "variables/VariableManagement.h" -#include "variables/VariableManagerUtils.h" -#include "antares/solver/simulation/simulation.h" -#include "antares/solver/simulation/sim_structure_donnees.h" -#include "antares/solver/simulation/sim_structure_probleme_economique.h" -#include "antares/solver/optimisation/opt_fonctions.h" - -using namespace Yuni; - -void OPT_InitialiserLesBornesDesVariablesDuProblemeLineaireReservesThermiques( - PROBLEME_HEBDO* problemeHebdo, - const int PremierPdtDeLIntervalle, - const int DernierPdtDeLIntervalle) -{ - const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre; - std::vector& Xmin = ProblemeAResoudre->Xmin; - std::vector& Xmax = ProblemeAResoudre->Xmax; - - std::vector& AdresseOuPlacerLaValeurDesVariablesOptimisees - = ProblemeAResoudre->AdresseOuPlacerLaValeurDesVariablesOptimisees; - - for (int pdtHebdo = PremierPdtDeLIntervalle, pdtJour = 0; pdtHebdo < DernierPdtDeLIntervalle; - pdtHebdo++, pdtJour++) - { - const CORRESPONDANCES_DES_VARIABLES& CorrespondanceVarNativesVarOptim - = problemeHebdo->CorrespondanceVarNativesVarOptim[pdtJour]; - - for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) - { - auto areaReserves = problemeHebdo->allReserves[pays]; - - for (const auto& areaReserveUp : areaReserves.areaCapacityReservationsUp) - { - int var = CorrespondanceVarNativesVarOptim - .internalUnsatisfiedReserveIndex[areaReserveUp.globalReserveIndex]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat1 - = &(problemeHebdo->ResultatsHoraires[pays] - .Reserves[pdtHebdo] - .ValeursHorairesInternalUnsatisfied[areaReserveUp.areaReserveIndex]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat1; - - var = CorrespondanceVarNativesVarOptim - .internalExcessReserveIndex[areaReserveUp.globalReserveIndex]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat2 - = &(problemeHebdo->ResultatsHoraires[pays] - .Reserves[pdtHebdo] - .ValeursHorairesInternalExcessReserve[areaReserveUp.areaReserveIndex]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat2; - - // Thermal Cluster - for (const auto& [clusterId, clusterReserveParticipation] : - areaReserveUp.AllThermalReservesParticipation) - { - var = CorrespondanceVarNativesVarOptim - .runningThermalClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ProductionThermique[pdtHebdo] - .ParticipationReservesDuPalierOn[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - - var = CorrespondanceVarNativesVarOptim - .offThermalClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ProductionThermique[pdtHebdo] - .ParticipationReservesDuPalierOff[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - - var = CorrespondanceVarNativesVarOptim - .nbOffGroupUnitsParticipatingToReservesInThermalClusterIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = problemeHebdo->PaliersThermiquesDuPays[pays].TailleUnitaireDUnGroupeDuPalierThermique[clusterId]; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ProductionThermique[pdtHebdo] - .NombreDeGroupesEteintDuPalierQuiParticipentAuxReserves - [clusterReserveParticipation.clusterIdInArea]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - - var = CorrespondanceVarNativesVarOptim.thermalClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ProductionThermique[pdtHebdo] - .ParticipationReservesDuPalier[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - } - - // Short Term Storage Cluster - for (const auto& [clusterId, clusterReserveParticipation] : - areaReserveUp.AllSTStorageReservesParticipation) - { - var = CorrespondanceVarNativesVarOptim - .STStorageTurbiningClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ShortTermStorage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .STStoragePumpingClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ShortTermStorage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .STStorageClusterReserveUpParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ShortTermStorage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - } - - // Long Term Storage Cluster - for (const auto& clusterReserveParticipation: - areaReserveUp.AllLTStorageReservesParticipation) - { - var = CorrespondanceVarNativesVarOptim - .LTStorageTurbiningClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .HydroUsage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .LTStoragePumpingClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .HydroUsage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .LTStorageClusterReserveUpParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .HydroUsage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - } - } - for (const auto& areaReserveDown : areaReserves.areaCapacityReservationsDown) - { - int var = CorrespondanceVarNativesVarOptim - .internalUnsatisfiedReserveIndex[areaReserveDown.globalReserveIndex]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat1 - = &(problemeHebdo->ResultatsHoraires[pays] - .Reserves[pdtHebdo] - .ValeursHorairesInternalUnsatisfied[areaReserveDown.areaReserveIndex]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat1; - - var = CorrespondanceVarNativesVarOptim - .internalExcessReserveIndex[areaReserveDown.globalReserveIndex]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat2 - = &(problemeHebdo->ResultatsHoraires[pays] - .Reserves[pdtHebdo] - .ValeursHorairesInternalExcessReserve[areaReserveDown.areaReserveIndex]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat2; - - // Thermal Clusters - for (const auto& [clusterId, clusterReserveParticipation] : - areaReserveDown.AllThermalReservesParticipation) - { - var = CorrespondanceVarNativesVarOptim - .runningThermalClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat3 = &( - problemeHebdo->ResultatsHoraires[pays] - .ProductionThermique[pdtHebdo] - .ParticipationReservesDuPalierOn[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat3; - - var = CorrespondanceVarNativesVarOptim.thermalClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat4 = &( - problemeHebdo->ResultatsHoraires[pays] - .ProductionThermique[pdtHebdo] - .ParticipationReservesDuPalier[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat4; - } - - // Short Term Storage Cluster - for (const auto& [clusterId, clusterReserveParticipation] : - areaReserveDown.AllSTStorageReservesParticipation) - { - var = CorrespondanceVarNativesVarOptim - .STStorageTurbiningClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ShortTermStorage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .STStoragePumpingClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ShortTermStorage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .STStorageClusterReserveDownParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .ShortTermStorage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - } - - // Long Term Storage Cluster - for (const auto& clusterReserveParticipation: - areaReserveDown.AllLTStorageReservesParticipation) - { - var = CorrespondanceVarNativesVarOptim - .LTStorageTurbiningClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - double* adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .HydroUsage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .LTStoragePumpingClusterReserveParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .HydroUsage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr; - - var = CorrespondanceVarNativesVarOptim - .LTStorageClusterReserveDownParticipationIndex - [clusterReserveParticipation.globalIndexClusterParticipation]; - Xmin[var] = 0; - Xmax[var] = LINFINI_ANTARES; - adresseDuResultat = &( - problemeHebdo->ResultatsHoraires[pays] - .HydroUsage[pdtHebdo] - .reserveParticipationOfCluster[clusterReserveParticipation - .areaIndexClusterParticipation]); - AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; - } - } - } - } -} diff --git a/src/solver/optimisation/opt_gestion_des_couts_reserves.cpp b/src/solver/optimisation/opt_gestion_des_couts_reserves.cpp index 521bd2d231..57aafe20ae 100644 --- a/src/solver/optimisation/opt_gestion_des_couts_reserves.cpp +++ b/src/solver/optimisation/opt_gestion_des_couts_reserves.cpp @@ -19,132 +19,185 @@ ** along with Antares_Simulator. If not, see . */ +#include "antares/solver/optimisation/opt_fonctions.h" #include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" - -#include "variables/VariableManagerUtils.h" -#include "antares/solver/simulation/simulation.h" #include "antares/solver/simulation/sim_structure_donnees.h" +#include "antares/solver/simulation/simulation.h" -#include "antares/solver/optimisation/opt_fonctions.h" +#include "variables/VariableManagerUtils.h" void OPT_InitialiserLesCoutsLineaireReserves(PROBLEME_HEBDO* problemeHebdo, - const int PremierPdtDeLIntervalle, - const int DernierPdtDeLIntervalle) + const int PremierPdtDeLIntervalle, + const int DernierPdtDeLIntervalle) { - const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre; - std::vector& CoutLineaire = ProblemeAResoudre->CoutLineaire; - auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo); + struct ReserveCostsInitializer + { + PROBLEME_HEBDO* problemeHebdo; + const std::unique_ptr& ProblemeAResoudre; + VariableManagement::VariableManager variableManager; + std::vector& CoutLineaire; + int pdtHebdo; + + ReserveCostsInitializer(PROBLEME_HEBDO* hebdo): + problemeHebdo(hebdo), + ProblemeAResoudre(hebdo->ProblemeAResoudre), + variableManager(VariableManagerFromProblemHebdo(hebdo)), + CoutLineaire(hebdo->ProblemeAResoudre->CoutLineaire), + pdtHebdo(0) + { + } + + void setPdtHebdo(int pdt) + { + pdtHebdo = pdt; + } + + // Init costs for a reserve + void initReserveCosts(const CAPACITY_RESERVATION& reserve) + { + int var = variableManager.InternalExcessReserve(reserve.globalReserveIndex, pdtHebdo); + if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables) + { + CoutLineaire[var] = reserve.spillageCost; + } + + var = variableManager.InternalUnsatisfiedReserve(reserve.globalReserveIndex, pdtHebdo); + if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables) + { + CoutLineaire[var] = reserve.failureCost; + } + } + + // Init costs for a Thermal cluster participation to a reserve up + void initThermalReserveUpParticipationCosts( + const RESERVE_PARTICIPATION_THERMAL& reserveParticipation) + { + int var = variableManager.RunningThermalClusterReserveParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCost; + var = variableManager.OffThermalClusterReserveParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCostOff; + } + + // Init costs for a Thermal cluster participation to a reserve down + void initThermalReserveDownParticipationCosts( + const RESERVE_PARTICIPATION_THERMAL& reserveParticipation) + { + int var = variableManager.RunningThermalClusterReserveParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCost; + } - for (int pdtHebdo = PremierPdtDeLIntervalle; pdtHebdo < DernierPdtDeLIntervalle; - pdtHebdo++) + // Init costs for a ShortTerm cluster participation to a reserve up + void initSTStorageReserveUpParticipationCosts( + const RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation) + { + int var = variableManager.STStorageClusterReserveUpParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCost; + } + + // Init costs for a ShortTerm cluster participation to a reserve down + void initSTStorageReserveDownParticipationCosts( + const RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation) + { + int var = variableManager.STStorageClusterReserveDownParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCost; + } + + // Init costs for a LongTerm cluster participation to a reserve up + void initLTStorageReserveUpParticipationCosts( + const RESERVE_PARTICIPATION_LTSTORAGE& reserveParticipation) + { + int var = variableManager.LTStorageClusterReserveUpParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCost; + } + + // Init costs for a LongTerm cluster participation to a reserve down + void initLTStorageReserveDownParticipationCosts( + const RESERVE_PARTICIPATION_LTSTORAGE& reserveParticipation) + { + int var = variableManager.LTStorageClusterReserveDownParticipation( + reserveParticipation.globalIndexClusterParticipation, + pdtHebdo); + CoutLineaire[var] = reserveParticipation.participationCost; + } + }; + + ReserveCostsInitializer reserveCostsInitializer(problemeHebdo); + + for (int pdtHebdo = PremierPdtDeLIntervalle; pdtHebdo < DernierPdtDeLIntervalle; pdtHebdo++) { + reserveCostsInitializer.setPdtHebdo(pdtHebdo); for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) { - auto reservesDuPays = problemeHebdo->allReserves[pays]; + auto areaReserves = problemeHebdo->allReserves[pays]; int var; - for (int index = 0; index < reservesDuPays.areaCapacityReservationsUp.size(); index++) + for (auto& areaReserveUp: areaReserves.areaCapacityReservationsUp) { + reserveCostsInitializer.initReserveCosts(areaReserveUp); + // Thermal clusters - for (const auto& [clusterId, clusterReserveParticipation] : - reservesDuPays.areaCapacityReservationsUp[index] - .AllThermalReservesParticipation) + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllThermalReservesParticipation) { - var = variableManager.RunningThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCost; - var = variableManager.OffThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCostOff; + reserveCostsInitializer.initThermalReserveUpParticipationCosts( + clusterReserveParticipation); } // Short Term Storage clusters - for (const auto& [clusterId, clusterReserveParticipation] : - reservesDuPays.areaCapacityReservationsUp[index] - .AllSTStorageReservesParticipation) + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllSTStorageReservesParticipation) { - var = variableManager.STStorageClusterReserveUpParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCost; + reserveCostsInitializer.initSTStorageReserveUpParticipationCosts( + clusterReserveParticipation); } // Long Term Storage clusters for (const auto& clusterReserveParticipation: - reservesDuPays.areaCapacityReservationsUp[index] - .AllLTStorageReservesParticipation) + areaReserveUp.AllLTStorageReservesParticipation) { - var = variableManager.LTStorageClusterReserveUpParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCost; - } - - var = variableManager.InternalExcessReserve( - reservesDuPays.areaCapacityReservationsUp[index].globalReserveIndex, pdtHebdo); - if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables) - { - CoutLineaire[var] = reservesDuPays.areaCapacityReservationsUp[index].spillageCost; - } - - var = variableManager.InternalUnsatisfiedReserve( - reservesDuPays.areaCapacityReservationsUp[index].globalReserveIndex, pdtHebdo); - if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables) - { - CoutLineaire[var] = reservesDuPays.areaCapacityReservationsUp[index].failureCost; + reserveCostsInitializer.initLTStorageReserveUpParticipationCosts( + clusterReserveParticipation); } } - for (int index = 0; index < reservesDuPays.areaCapacityReservationsDown.size(); index++) + for (auto& areaReserveDown: areaReserves.areaCapacityReservationsDown) { + reserveCostsInitializer.initReserveCosts(areaReserveDown); + // Thermal clusters - for (const auto& [clusterId, clusterReserveParticipation] : - reservesDuPays.areaCapacityReservationsDown[index] - .AllThermalReservesParticipation) + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveDown.AllThermalReservesParticipation) { - var = variableManager.RunningThermalClusterReserveParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCost; + reserveCostsInitializer.initThermalReserveDownParticipationCosts( + clusterReserveParticipation); } // Short Term Storage clusters - for (const auto& [clusterId, clusterReserveParticipation] : - reservesDuPays.areaCapacityReservationsDown[index] - .AllSTStorageReservesParticipation) + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveDown.AllSTStorageReservesParticipation) { - var = variableManager.STStorageClusterReserveDownParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCost; + reserveCostsInitializer.initSTStorageReserveDownParticipationCosts( + clusterReserveParticipation); } // Long Term Storage clusters for (const auto& clusterReserveParticipation: - reservesDuPays.areaCapacityReservationsDown[index] - .AllLTStorageReservesParticipation) - { - var = variableManager.LTStorageClusterReserveDownParticipation( - clusterReserveParticipation.globalIndexClusterParticipation, - pdtHebdo); - CoutLineaire[var] = clusterReserveParticipation.participationCost; - } - - var = variableManager.InternalExcessReserve( - reservesDuPays.areaCapacityReservationsDown[index].globalReserveIndex, pdtHebdo); - if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables) - { - CoutLineaire[var] - = reservesDuPays.areaCapacityReservationsDown[index].spillageCost; - } - - var = variableManager.InternalUnsatisfiedReserve( - reservesDuPays.areaCapacityReservationsDown[index].globalReserveIndex, pdtHebdo); - if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables) + areaReserveDown.AllLTStorageReservesParticipation) { - CoutLineaire[var] = reservesDuPays.areaCapacityReservationsDown[index].failureCost; + reserveCostsInitializer.initLTStorageReserveDownParticipationCosts( + clusterReserveParticipation); } } } diff --git a/src/solver/optimisation/opt_gestion_second_membre_reserves.cpp b/src/solver/optimisation/opt_gestion_second_membre_reserves.cpp index dc5143b9c7..6534f428ab 100644 --- a/src/solver/optimisation/opt_gestion_second_membre_reserves.cpp +++ b/src/solver/optimisation/opt_gestion_second_membre_reserves.cpp @@ -19,14 +19,11 @@ ** along with Antares_Simulator. If not, see . */ +#include +#include "antares/solver/optimisation/opt_fonctions.h" #include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" - #include "antares/solver/simulation/sim_structure_donnees.h" -#include "antares/solver/optimisation/opt_fonctions.h" - -#include - using namespace Antares; using namespace Antares::Data; using namespace Yuni; @@ -41,304 +38,373 @@ void OPT_InitialiserLeSecondMembreDuProblemeLineaireReserves(PROBLEME_HEBDO* pro std::vector& AdresseOuPlacerLaValeurDesCoutsMarginaux = ProblemeAResoudre->AdresseOuPlacerLaValeurDesCoutsMarginaux; - auto& areaReserves = problemeHebdo->allReserves; + struct ReserveVariablesRightSidesSetter + { + PROBLEME_HEBDO* problemeHebdo; + const std::unique_ptr& ProblemeAResoudre; + std::vector& SecondMembre; + std::vector& AdresseOuPlacerLaValeurDesCoutsMarginaux; + int pdtJour, pdtGlobal, pays; + + ReserveVariablesRightSidesSetter(PROBLEME_HEBDO* hebdo): + problemeHebdo(hebdo), + ProblemeAResoudre(hebdo->ProblemeAResoudre), + SecondMembre(ProblemeAResoudre->SecondMembre), + AdresseOuPlacerLaValeurDesCoutsMarginaux( + ProblemeAResoudre->AdresseOuPlacerLaValeurDesCoutsMarginaux), + pdtJour(0), + pdtGlobal(0), + pays(0) + { + } + + void setPdtJour(int pdt) + { + pdtJour = pdt; + } + + void setPdtGlobal(int pdt) + { + pdtGlobal = pdt; + } + + void setPays(int p) + { + pays = p; + } + + // Set the rigth sides of equations for a reserve + void setReserveRightSides(const CAPACITY_RESERVATION& reserve) + { + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesDeBesoinEnReserves[reserve + .globalReserveIndex]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserve.need.at(pdtGlobal); + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Common setter for the thermal clusters + void setThermalReserveParticipationRightSides( + const RESERVE_PARTICIPATION_THERMAL& reserveParticipation) + { + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesDePuissanceMinDuPalier[reserveParticipation + .clusterIdInArea]; + if (cnt >= 0) + { + SecondMembre[cnt] = problemeHebdo->PaliersThermiquesDuPays[pays] + .PuissanceDisponibleEtCout[reserveParticipation + .clusterIdInArea] + .PuissanceMinDuPalierThermiqueRef[pdtJour]; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesDePuissanceMaxDuPalier[reserveParticipation + .clusterIdInArea]; + if (cnt >= 0) + { + SecondMembre[cnt] = problemeHebdo->PaliersThermiquesDuPays[pays] + .PuissanceDisponibleEtCout[reserveParticipation + .clusterIdInArea] + .PuissanceDisponibleDuPalierThermiqueRef[pdtJour]; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Set the rigth sides of equations for a Thermal cluster participation to a reserve up + void setThermalReserveUpParticipationRightSides( + const RESERVE_PARTICIPATION_THERMAL& reserveParticipation) + { + setThermalReserveParticipationRightSides(reserveParticipation); + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .nbOffGroupUnitsParticipatingToReservesInThermalClusterConstraintIndex + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = problemeHebdo->PaliersThermiquesDuPays[pays] + .PuissanceDisponibleEtCout[reserveParticipation + .clusterIdInArea] + .NombreMaxDeGroupesEnMarcheDuPalierThermique[pdtJour]; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Set the rigth sides of equations for a Thermal cluster participation to a reserve down + void setThermalReserveDownParticipationRightSides( + const RESERVE_PARTICIPATION_THERMAL& reserveParticipation) + { + setThermalReserveParticipationRightSides(reserveParticipation); + } + + // Common setter for the ShortTerm Storage clusters + void setSTStorageReserveParticipationRightSides( + const RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation) + { + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt + = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMax + [reserveParticipation.clusterId]; + + auto& cluster = problemeHebdo->ShortTermStorage[pays][reserveParticipation.clusterId]; + if (cnt >= 0) + { + SecondMembre[cnt] = cluster.series.get()->maxWithdrawalModulation[pdtJour] + * cluster.withdrawalNominalCapacity; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } - for (int pdtJour = 0, pdtHebdo = PremierPdtDeLIntervalle; pdtHebdo < DernierPdtDeLIntervalle; + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMin + [reserveParticipation.clusterId]; + if (cnt >= 0) + { + SecondMembre[cnt] = cluster.series.get()->lowerRuleCurve[pdtJour] + * cluster.withdrawalNominalCapacity; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterPumpingCapacityThreasholds + [reserveParticipation.clusterId]; + if (cnt >= 0) + { + SecondMembre[cnt] = cluster.series.get()->maxInjectionModulation[pdtJour] + * cluster.injectionNominalCapacity; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Set the rigth sides of equations for a ShortTerm cluster participation to a reserve up + void setSTStorageReserveUpParticipationRightSides( + const RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation) + { + setSTStorageReserveParticipationRightSides(reserveParticipation); + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxTurbining; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterMaxInjectionParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxPumping; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Set the rigth sides of equations for a ShortTerm cluster participation to a reserve down + void setSTStorageReserveDownParticipationRightSides( + const RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation) + { + setSTStorageReserveParticipationRightSides(reserveParticipation); + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxTurbining; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesSTStorageClusterMaxInjectionParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxPumping; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Common setter for the LongTerm Storage clusters + void setLTStorageReserveParticipationRightSides() + { + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + auto& hydroCluster = problemeHebdo->CaracteristiquesHydrauliques[pays]; + int globalClusterIdx = hydroCluster.GlobalHydroIndex; + + int cnt + = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMax + [globalClusterIdx]; + if (cnt >= 0) + { + SecondMembre[cnt] = hydroCluster.ContrainteDePmaxHydrauliqueHoraire[pdtJour]; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMin + [globalClusterIdx]; + if (cnt >= 0) + { + SecondMembre[cnt] = hydroCluster.MingenHoraire[pdtJour]; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterPumpingCapacityThreasholds + [globalClusterIdx]; + if (cnt >= 0) + { + SecondMembre[cnt] = hydroCluster.ContrainteDePmaxPompageHoraire[pdtJour]; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Set the rigth sides of equations for a LongTerm cluster participation to a reserve up + void setLTStorageReserveUpParticipationRightSides( + const RESERVE_PARTICIPATION_LTSTORAGE& reserveParticipation) + { + setLTStorageReserveParticipationRightSides(); + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterMaxWithdrawParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxTurbining; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterMaxInjectionParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxPumping; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + + // Set the rigth sides of equations for a LongTerm cluster participation to a reserve down + void setLTStorageReserveDownParticipationRightSides( + const RESERVE_PARTICIPATION_LTSTORAGE& reserveParticipation) + { + setLTStorageReserveParticipationRightSides(); + const auto& CorrespondanceCntNativesCntOptim = problemeHebdo + ->CorrespondanceCntNativesCntOptim + [pdtJour]; + int cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterMaxWithdrawParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxTurbining; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + cnt = CorrespondanceCntNativesCntOptim + .NumeroDeContrainteDesContraintesLTStorageClusterMaxInjectionParticipation + [reserveParticipation.globalIndexClusterParticipation]; + if (cnt >= 0) + { + SecondMembre[cnt] = reserveParticipation.maxPumping; + AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; + } + } + }; + + ReserveVariablesRightSidesSetter reserveVariablesRightSidesSetter(problemeHebdo); + + for (int pdtHebdo = PremierPdtDeLIntervalle, pdtJour = 0; pdtHebdo < DernierPdtDeLIntervalle; pdtHebdo++, pdtJour++) { - const CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim - = problemeHebdo->CorrespondanceCntNativesCntOptim[pdtJour]; + int pdtGlobal = problemeHebdo->weekInTheYear * problemeHebdo->NombreDePasDeTempsDUneJournee + * problemeHebdo->NombreDeJours + + pdtJour; + + reserveVariablesRightSidesSetter.setPdtJour(pdtJour); + reserveVariablesRightSidesSetter.setPdtGlobal(pdtGlobal); for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) { - int pdtGlobal = problemeHebdo->weekInTheYear - * problemeHebdo->NombreDePasDeTempsDUneJournee - * problemeHebdo->NombreDeJours - + pdtJour; + reserveVariablesRightSidesSetter.setPays(pays); + const auto& areaReserves = problemeHebdo->allReserves[pays]; - // Thermal clusters + // Up Reserves Right Sides + for (const auto& areaReserveUp: areaReserves.areaCapacityReservationsUp) { - auto& areaReservesUp - = areaReserves[pays].areaCapacityReservationsUp; - for (const auto& areaReserveUp : areaReservesUp) + reserveVariablesRightSidesSetter.setReserveRightSides(areaReserveUp); + + // Thermal Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllThermalReservesParticipation) { - int cnt = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesDeBesoinEnReserves - [areaReserveUp.globalReserveIndex]; - if (cnt >= 0) - { - SecondMembre[cnt] = areaReserveUp.need.at(pdtGlobal); - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - - for (const auto& [clusterId, reserveParticipation]: - areaReserveUp.AllThermalReservesParticipation) - { - int cnt1 - = CorrespondanceCntNativesCntOptim - .nbOffGroupUnitsParticipatingToReservesInThermalClusterConstraintIndex - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt1 >= 0) - { - SecondMembre[cnt1] = problemeHebdo->PaliersThermiquesDuPays[pays] - .PuissanceDisponibleEtCout[reserveParticipation - .clusterIdInArea] - .NombreMaxDeGroupesEnMarcheDuPalierThermique - [pdtJour]; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt1] = nullptr; - } - } + reserveVariablesRightSidesSetter.setThermalReserveUpParticipationRightSides( + clusterReserveParticipation); } - auto& areaReservesDown - = areaReserves[pays].areaCapacityReservationsDown; - for (const auto& areaReserveDown : areaReservesDown) + // Short Term Storage Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveUp.AllSTStorageReservesParticipation) { - int cnt = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesDeBesoinEnReserves - [areaReserveDown.globalReserveIndex]; - if (cnt >= 0) - { - SecondMembre[cnt] = areaReserveDown.need.at(pdtGlobal); - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } + reserveVariablesRightSidesSetter.setSTStorageReserveUpParticipationRightSides( + clusterReserveParticipation); } - for (uint32_t cluster = 0; - cluster - < problemeHebdo->PaliersThermiquesDuPays[pays].NombreDePaliersThermiques; - cluster++) + // Long Term Storage Cluster + for (const auto& clusterReserveParticipation: + areaReserveUp.AllLTStorageReservesParticipation) { - int globalClusterIdx - = problemeHebdo->PaliersThermiquesDuPays[pays] - .NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; - int cnt1 - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesDePuissanceMinDuPalier[globalClusterIdx]; - if (cnt1 >= 0) - { - SecondMembre[cnt1] = problemeHebdo->PaliersThermiquesDuPays[pays] - .PuissanceDisponibleEtCout[cluster] - .PuissanceMinDuPalierThermiqueRef[pdtJour]; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt1] = nullptr; - } - - int cnt2 - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesDePuissanceMaxDuPalier[globalClusterIdx]; - if (cnt2 >= 0) - { - SecondMembre[cnt2] = problemeHebdo->PaliersThermiquesDuPays[pays] - .PuissanceDisponibleEtCout[cluster] - .PuissanceDisponibleDuPalierThermiqueRef[pdtJour]; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt2] = nullptr; - } + reserveVariablesRightSidesSetter.setLTStorageReserveUpParticipationRightSides( + clusterReserveParticipation); } } - - // Short Term Storage clusters + for (const auto& areaReserveDown: areaReserves.areaCapacityReservationsDown) { - auto& areaReservesUp - = areaReserves[pays].areaCapacityReservationsUp; - for (const auto& areaReserveUp : areaReservesUp) - { - for (const auto& [clusterId, reserveParticipation] : - areaReserveUp.AllSTStorageReservesParticipation) - { - int cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxTurbining; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterMaxInjectionParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxPumping; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - } - } - auto& areaReservesDown - = areaReserves[pays].areaCapacityReservationsDown; - for (const auto& areaReserveDown : areaReservesDown) + reserveVariablesRightSidesSetter.setReserveRightSides(areaReserveDown); + + // Thermal Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveDown.AllThermalReservesParticipation) { - for (const auto& [clusterId, reserveParticipation] : - areaReserveDown.AllSTStorageReservesParticipation) - { - int cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxTurbining; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterMaxInjectionParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxPumping; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - } + reserveVariablesRightSidesSetter.setThermalReserveDownParticipationRightSides( + clusterReserveParticipation); } - for (const auto& cluster : problemeHebdo->ShortTermStorage[pays]) + + // Short Term Storage Cluster + for (const auto& [clusterId, clusterReserveParticipation]: + areaReserveDown.AllSTStorageReservesParticipation) { - int globalClusterIdx = cluster.clusterGlobalIndex; - int cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMax - [globalClusterIdx]; - if (cnt >= 0) - { - SecondMembre[cnt] = cluster.series.get()->maxWithdrawalModulation[pdtJour] - * cluster.withdrawalNominalCapacity; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - - cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMin - [globalClusterIdx]; - if (cnt >= 0) - { - SecondMembre[cnt] = cluster.series.get()->lowerRuleCurve[pdtJour] - * cluster.withdrawalNominalCapacity; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - - cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesSTStorageClusterPumpingCapacityThreasholds - [globalClusterIdx]; - if (cnt >= 0) - { - SecondMembre[cnt] = cluster.series.get()->maxInjectionModulation[pdtJour] - * cluster.injectionNominalCapacity; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } + reserveVariablesRightSidesSetter.setSTStorageReserveDownParticipationRightSides( + clusterReserveParticipation); } - } - // Long Term Storage clusters - { - for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) + // Long Term Storage Cluster + for (const auto& clusterReserveParticipation: + areaReserveDown.AllLTStorageReservesParticipation) { - auto& areaReservesUp = areaReserves[pays].areaCapacityReservationsUp; - for (const auto& areaReserveUp : areaReservesUp) - { - for (const auto& reserveParticipation : - areaReserveUp.AllLTStorageReservesParticipation) - { - int cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterMaxWithdrawParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxTurbining; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterMaxInjectionParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxPumping; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - } - } - auto& areaReservesDown = areaReserves[pays].areaCapacityReservationsDown; - for (const auto& areaReserveDown : areaReservesDown) - { - for (const auto& reserveParticipation : - areaReserveDown.AllLTStorageReservesParticipation) - { - int cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterMaxWithdrawParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxTurbining; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - cnt - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterMaxInjectionParticipation - [reserveParticipation.globalIndexClusterParticipation]; - if (cnt >= 0) - { - SecondMembre[cnt] = reserveParticipation.maxPumping; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt] = nullptr; - } - } - } - - // Checks if LTStorage cluster are participating to reserves - auto isClusterParticipatingToReserves = - [](std::vector& reserves) - { - auto hasReserveParticipations = [](CAPACITY_RESERVATION& res) - { return res.AllLTStorageReservesParticipation.size() > 0; }; - return std::any_of(reserves.begin(), - reserves.end(), - hasReserveParticipations); - }; - - if (isClusterParticipatingToReserves( - problemeHebdo->allReserves[pays].areaCapacityReservationsDown) - || isClusterParticipatingToReserves( - problemeHebdo->allReserves[pays].areaCapacityReservationsUp)) - { - auto& hydroCluster = problemeHebdo->CaracteristiquesHydrauliques[pays]; - - int globalClusterIdx = hydroCluster.GlobalHydroIndex; - int cnt1 - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMax - [globalClusterIdx]; - if (cnt1 >= 0) - { - SecondMembre[cnt1] = hydroCluster - .ContrainteDePmaxHydrauliqueHoraire[pdtJour]; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt1] = nullptr; - } - - int cnt2 - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMin - [globalClusterIdx]; - if (cnt2 >= 0) - { - SecondMembre[cnt2] = hydroCluster - .MingenHoraire[pdtJour]; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt2] = nullptr; - } - - int cnt3 - = CorrespondanceCntNativesCntOptim - .NumeroDeContrainteDesContraintesLTStorageClusterPumpingCapacityThreasholds - [globalClusterIdx]; - if (cnt3 >= 0) - { - SecondMembre[cnt3] = hydroCluster - .ContrainteDePmaxPompageHoraire[pdtJour]; - AdresseOuPlacerLaValeurDesCoutsMarginaux[cnt3] = nullptr; - } - } + reserveVariablesRightSidesSetter.setLTStorageReserveDownParticipationRightSides( + clusterReserveParticipation); } } } diff --git a/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h index c883c8d026..6338e24ca1 100644 --- a/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h @@ -86,7 +86,6 @@ struct CORRESPONDANCES_DES_VARIABLES std::vector WithdrawalVariable; std::vector LevelVariable; } SIM_ShortTermStorage; - }; struct CORRESPONDANCES_DES_CONTRAINTES @@ -116,14 +115,18 @@ struct CORRESPONDANCES_DES_CONTRAINTES std::vector NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation; std::vector NumeroDeContrainteDesContraintesSTStorageClusterMaxInjectionParticipation; - std::vector NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMax; - std::vector NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMin; + std::vector + NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMax; + std::vector + NumeroDeContrainteDesContraintesSTStorageClusterTurbiningCapacityThreasholdsMin; std::vector NumeroDeContrainteDesContraintesSTStorageClusterPumpingCapacityThreasholds; std::vector NumeroDeContrainteDesContraintesLTStorageClusterMaxWithdrawParticipation; std::vector NumeroDeContrainteDesContraintesLTStorageClusterMaxInjectionParticipation; - std::vector NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMax; - std::vector NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMin; + std::vector + NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMax; + std::vector + NumeroDeContrainteDesContraintesLTStorageClusterTurbiningCapacityThreasholdsMin; std::vector NumeroDeContrainteDesContraintesLTStorageClusterPumpingCapacityThreasholds; std::vector NumeroDeContrainteDesNiveauxPays; @@ -218,9 +221,9 @@ using AREA_INPUT = std::vector<::ShortTermStorage::PROPERTIES>; // index is loca struct RESULTS { // Index is the number of the STS in the area - std::vector level; // MWh - std::vector injection; // MWh - std::vector withdrawal; // MWh + std::vector level; // MWh + std::vector injection; // MWh + std::vector withdrawal; // MWh std::vector reserveParticipationOfCluster; // MWh }; } // namespace ShortTermStorage @@ -296,24 +299,25 @@ struct RESERVE_PARTICIPATION_BASE int areaIndexClusterParticipation; std::string clusterName; int clusterIdInArea; + int clusterId; virtual ~RESERVE_PARTICIPATION_BASE() = default; }; -struct RESERVE_PARTICIPATION_THERMAL : public RESERVE_PARTICIPATION_BASE +struct RESERVE_PARTICIPATION_THERMAL: public RESERVE_PARTICIPATION_BASE { float maxPower; float maxPowerOff; float participationCostOff; }; -struct RESERVE_PARTICIPATION_STSTORAGE : public RESERVE_PARTICIPATION_BASE +struct RESERVE_PARTICIPATION_STSTORAGE: public RESERVE_PARTICIPATION_BASE { float maxTurbining; float maxPumping; }; -struct RESERVE_PARTICIPATION_LTSTORAGE : public RESERVE_PARTICIPATION_BASE +struct RESERVE_PARTICIPATION_LTSTORAGE: public RESERVE_PARTICIPATION_BASE { float maxTurbining; float maxPumping; @@ -322,9 +326,10 @@ struct RESERVE_PARTICIPATION_LTSTORAGE : public RESERVE_PARTICIPATION_BASE struct CAPACITY_RESERVATION { std::map AllThermalReservesParticipation; - std::map AllSTStorageReservesParticipation; + std::map + AllSTStorageReservesParticipation; std::vector AllLTStorageReservesParticipation; - std::vector need; //!< Vector size is number of hours in year + std::vector need; //!< Vector size is number of hours in year float failureCost = 0; float spillageCost = 0; std::string reserveName; @@ -508,7 +513,6 @@ class computeTimeStepLevel } }; - struct RESERVES { std::vector ValeursHorairesInternalUnsatisfied; @@ -525,11 +529,9 @@ struct RESULTATS_HORAIRES std::vector ValeursHorairesDeDefaillanceNegative; - - std::vector CoutsMarginauxHoraires; std::vector ProductionThermique; // index is pdtHebdo - std::vector HydroUsage; // index is pdtHebdo + std::vector HydroUsage; // index is pdtHebdo std::vector Reserves; std::vector<::ShortTermStorage::RESULTS> ShortTermStorage; diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index d9f7c12b70..9d86271367 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -122,6 +122,7 @@ static void importShortTermStorages( toInsert.initialLevel = st.properties.initialLevel; toInsert.initialLevelOptim = st.properties.initialLevelOptim; toInsert.name = st.properties.name; + toInsert.clusterGlobalIndex = clusterGlobalIndex; toInsert.series = st.series; @@ -143,6 +144,7 @@ static void importShortTermStorages( reserveParticipation.participationCost = cluster.reserveCost(reserveName); reserveParticipation.clusterName = cluster.id; reserveParticipation.clusterIdInArea = idx; + reserveParticipation.clusterId = cluster.properties.clusterGlobalIndex; reserveParticipation.globalIndexClusterParticipation = globalSTStorageClusterParticipationIndex; reserveParticipation.areaIndexClusterParticipation = areaClusterParticipationIndex; @@ -168,6 +170,7 @@ static void importShortTermStorages( reserveParticipation.participationCost = cluster.reserveCost(reserveName); reserveParticipation.clusterName = cluster.id; reserveParticipation.clusterIdInArea = idx; + reserveParticipation.clusterId = cluster.properties.clusterGlobalIndex; reserveParticipation.globalIndexClusterParticipation = globalSTStorageClusterParticipationIndex; reserveParticipation.areaIndexClusterParticipation = areaClusterParticipationIndex; @@ -511,6 +514,7 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, reserveName); reserveParticipation.clusterName = cluster->name(); reserveParticipation.clusterIdInArea = cluster->index; + reserveParticipation.clusterId = NombrePaliers + cluster->index; reserveParticipation.globalIndexClusterParticipation = globalThermalClusterParticipationIndex; reserveParticipation.areaIndexClusterParticipation @@ -535,6 +539,7 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, reserveParticipation.participationCost = cluster->reserveCost(reserveName); reserveParticipation.clusterName = cluster->name(); reserveParticipation.clusterIdInArea = cluster->index; + reserveParticipation.clusterId = NombrePaliers + cluster->index; reserveParticipation.globalIndexClusterParticipation = globalThermalClusterParticipationIndex; reserveParticipation.areaIndexClusterParticipation diff --git a/src/solver/variable/include/antares/solver/variable/info.h b/src/solver/variable/include/antares/solver/variable/info.h index 26419b9468..7a2fb4017b 100644 --- a/src/solver/variable/include/antares/solver/variable/info.h +++ b/src/solver/variable/include/antares/solver/variable/info.h @@ -22,13 +22,13 @@ #define __SOLVER_VARIABLE_INFO_H__ #include -#include "./economy/vCardReserveParticipationByDispatchableOnUnitsPlant.h" -#include "./economy/vCardReserveParticipationByDispatchableOffUnitsPlant.h" -#include "./economy/vCardReserveParticipationBySTStorage.h" -#include "./economy/vCardReserveParticipationByLTStorage.h" -#include "./economy/vCardReserveParticipationBySTStorageGroup.h" -#include "./economy/vCardReserveParticipationByThermalGroup.h" -#include "./economy/vCardReserveParticipationUnsuppliedSpilled.h" +#include "economy/vCardReserveParticipationByDispatchableOnUnitsPlant.h" +#include "economy/vCardReserveParticipationByDispatchableOffUnitsPlant.h" +#include "economy/vCardReserveParticipationBySTStorage.h" +#include "economy/vCardReserveParticipationByLTStorage.h" +#include "economy/vCardReserveParticipationBySTStorageGroup.h" +#include "economy/vCardReserveParticipationByThermalGroup.h" +#include "economy/vCardReserveParticipationUnsuppliedSpilled.h" #include "antares/solver/variable/surveyresults.h" #include "antares/study/fwd.h" diff --git a/src/solver/variable/include/antares/solver/variable/state.h b/src/solver/variable/include/antares/solver/variable/state.h index 60fc6615a3..133bcca697 100644 --- a/src/solver/variable/include/antares/solver/variable/state.h +++ b/src/solver/variable/include/antares/solver/variable/state.h @@ -71,7 +71,8 @@ struct ReserveParticipationPerGroupForYear { //! Reserve Participation for all thermal group types (nuclear / coal / ...) for the whole //! year per reserve - std::map> thermalGroupsReserveParticipation; + std::map> + thermalGroupsReserveParticipation; //! Reserve Participation for all thermal Short Term storages types (PSP / Battery / ...) //! for the whole year per reserve @@ -79,7 +80,6 @@ struct ReserveParticipationPerGroupForYear shortTermStorageGroupsReserveParticipation; }; - class State { public: @@ -107,14 +107,14 @@ class State */ void initFromThermalClusterIndex(const unsigned int areaWideIndex); - /*! - ** \brief Initialize some variable according a short term storage cluster index - ** - ** We assume here that the variables related to an area - ** are properly initialized. - ** - ** \param areaWideIndex Index of the short term storage cluster for the current area - */ + /*! + ** \brief Initialize some variable according a short term storage cluster index + ** + ** We assume here that the variables related to an area + ** are properly initialized. + ** + ** \param areaWideIndex Index of the short term storage cluster for the current area + */ void initFromShortTermStorageClusterIndex(const unsigned int areaWideIndex); /*! @@ -139,21 +139,8 @@ class State void yearEndBuildFromThermalClusterIndex(const unsigned int areaWideIndex); void calculateReserveParticipationCosts(); - - void initFromHydroStorage(); - - //std::map hydroReserveParticipationForYear[Variable::maxHoursInAYear]; - //double hydroReserveParticipationCostForYear[Variable::maxHoursInAYear]; - - // void initFromHydroStorage(); - - // void processReserve(const CAPACITY_RESERVATION& reserve, bool isUpReserve); - - //int getAreaIndexReserveParticipationFromReserveAndLTStorage( - // Data::ReserveName reserveName, - // Data::ClusterName clusterName); - + void initFromHydroStorage(); private: /*! @@ -171,7 +158,6 @@ class State const std::array& ON_opt, const Data::ThermalCluster* currentCluster); - std::array computeEconomicallyOptimalNbClustersONforEachHour( const uint& maxDurationON, const std::array& ON_min, @@ -216,8 +202,6 @@ class State //! The current Short Term Storage cluster Data::ShortTermStorage::STStorageCluster* STStorageCluster; - - //! The current renewable cluster Data::RenewableCluster* renewableCluster; //! The Scratchpad for the current area @@ -246,7 +230,6 @@ class State std::vector reserveParticipationPerGroupForYear{ HOURS_PER_YEAR}; - struct DetailledParticipation { double totalParticipation = 0; @@ -257,7 +240,7 @@ class State { totalParticipation += participation; } - + void addOffParticipation(double participation) { offUnitsParticipation += participation; @@ -277,12 +260,12 @@ class State //! Reserve Participation for each STStorage cluster per reserve std::vector>> - reserveParticipationPerSTStorageClusterForYear{ HOURS_PER_YEAR }; + reserveParticipationPerSTStorageClusterForYear{HOURS_PER_YEAR}; //! Reserve Participation for each LTStorage cluster per reserve std::vector>> - reserveParticipationPerLTStorageClusterForYear{ HOURS_PER_YEAR }; - + reserveParticipationPerLTStorageClusterForYear{HOURS_PER_YEAR}; + //! Reserve Participation cost for the whole year double reserveParticipationCostForYear[HOURS_PER_YEAR]; @@ -303,8 +286,7 @@ class State double STStorageClusterReserveParticipationCostForYear[HOURS_PER_YEAR]; //! Reserves participation cost of the Long Term Storage for the whole year - double LTStorageClusterReserveParticipationCostForYear[HOURS_PER_YEAR]; - + double LTStorageClusterReserveParticipationCostForYear[HOURS_PER_YEAR]; double renewableClusterProduction;