From 1c943574622ef168b57e34d5f5382d396edf1758 Mon Sep 17 00:00:00 2001 From: h-fournier Date: Wed, 30 Oct 2024 09:56:45 +0100 Subject: [PATCH 1/7] fix to pass the CI tests --- src/solver/simulation/sim_alloc_probleme_hebdo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 7d8a3d8b6c..607c7610a1 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -248,10 +248,10 @@ void SIM_AllocationProblemePasDeTemps(PROBLEME_HEBDO& problem, study.runtime.thermalPlantTotalCount * study.runtime.capacityReservationCount, -1); problem.CorrespondanceCntNativesCntOptim[k] .NumeroDeContrainteDesContraintesDePuissanceMinDuPalier.assign( - study.runtime.thermalPlantTotalCount, 0); + study.runtime.thermalPlantTotalCount, -1); problem.CorrespondanceCntNativesCntOptim[k] .NumeroDeContrainteDesContraintesDePuissanceMaxDuPalier.assign( - study.runtime.thermalPlantTotalCount, 0); + study.runtime.thermalPlantTotalCount, -1); problem.CorrespondanceCntNativesCntOptim[k] .NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation.assign( From 6b4a1c1d85c814aa298787d62bdf197d83113828 Mon Sep 17 00:00:00 2001 From: h-fournier Date: Wed, 30 Oct 2024 12:20:25 +0100 Subject: [PATCH 2/7] Fix load area --- src/libs/antares/study/area/list.cpp | 92 ++----------------- .../antares/study/parts/common/cluster_list.h | 2 +- .../antares/study/parts/hydro/container.h | 2 +- .../study/parts/common/cluster_list.cpp | 2 +- .../antares/study/parts/hydro/container.cpp | 2 +- 5 files changed, 12 insertions(+), 88 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 64a33cea07..a5e723bdeb 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -911,85 +911,11 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, } } - // Reserves - { - buffer.clear() << study.folderInput << SEP << "reserves" << SEP << area.id << SEP - << "reserves.ini"; - if (ini.open(buffer, false)) - { - ini.each( - [&](const IniFile::Section& section) - { - if (area.allCapacityReservations.contains(section.name)) - { - logs.warning() << area.name << ": reserve name already exists for reserve " - << section.name; - } - else - { - CapacityReservation tmpCapacityReservation; - std::string file_name = AllCapacityReservations::toFilename(section.name); - int type = -1; - for (auto* p = section.firstProperty; p; p = p->next) - { - CString<30, false> tmp; - tmp = p->key; - tmp.toLower(); - - if (tmp == "failure-cost") - { - if (!p->value.to(tmpCapacityReservation.failureCost)) - { - logs.warning() - << area.name << ": invalid failure cost for reserve " - << section.name; - } - } - else if (tmp == "spillage-cost") - { - if (!p->value.to(tmpCapacityReservation.spillageCost)) - { - logs.warning() - << area.name << ": invalid spillage cost for reserve " - << section.name; - } - } - else if (tmp == "type") - { - if (p->value == "up") - type = 0; - else if (p->value == "down") - type = 1; - else - logs.warning() - << area.name << ": invalid type for reserve " << section.name; - } - else - logs.warning() - << area.name << ": invalid key " << tmp << " in file " << buffer; - } - fs::path filePath = study.folderInput / "reserves" / area.id.to() - / (file_name + ".txt"); - ret = tmpCapacityReservation.need.loadFromFile(filePath, false) && ret; - if (type == 0) - area.allCapacityReservations.areaCapacityReservationsUp.emplace( - section.name, tmpCapacityReservation); - else if (type == 1) - area.allCapacityReservations.areaCapacityReservationsDown.emplace( - section.name, tmpCapacityReservation); - else - logs.warning() - << area.name << ": invalid type for reserve " << section.name; - } - }); - } - } // Reserves { - buffer.clear() << study.folderInput << SEP << "reserves" << SEP << area.id << SEP - << "reserves.ini"; - if (ini.open(buffer, false)) + fs::path reserves = study.folderInput / "reserves" / area.id.to() / "reserves.ini"; + if (ini.open(reserves, false)) { ini.each( [&](const IniFile::Section& section) @@ -1114,9 +1040,8 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, studyVersion, study.usedByTheSolver); - buffer.clear() << study.folderInput << SEP << "hydro" << SEP << "common" << SEP << area.id - << SEP << "reserves.ini"; - ret = area.hydro.loadReserveParticipations(area, buffer) && ret; + fs::path reservesHydro = study.folderInput / "hydro" / "common" / area.id.to() / "reserves.ini"; + area.hydro.loadReserveParticipations(area, reservesHydro); } // Wind @@ -1148,10 +1073,9 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, if (study.usedByTheSolver && study.parameters.mode == SimulationMode::Adequacy) { area.thermal.list.enableMustrunForEveryone(); - } - buffer.clear() << study.folderInput << SEP << "thermal" << SEP << "clusters" << SEP - << area.id << SEP << "reserves.ini"; - ret = area.thermal.list.loadReserveParticipations(area, buffer) && ret; + } + fs::path reservesThermal = study.folderInput / "thermal" / "clusters" / area.id.to() / "reserves.ini"; + area.thermal.list.loadReserveParticipations(area, reservesThermal); } // Short term storage @@ -1165,7 +1089,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, fs::path reservesPath = study.folderInput / "st-storage" / "clusters" / area.id.to() / "reserves.ini"; - ret = area.shortTermStorage.loadReserveParticipations(area, reservesPath) && ret; + area.shortTermStorage.loadReserveParticipations(area, reservesPath); } // Renewable cluster list diff --git a/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h b/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h index 8973e02e43..5a193d327a 100644 --- a/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h +++ b/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h @@ -175,7 +175,7 @@ class ClusterList /// @param area Reference to area /// @param file File to read the reserve participations entries /// @return false if the file opening failed, true otherwise - bool loadReserveParticipations(Area& area, const AnyString& folder); + bool loadReserveParticipations(Area& area, const std::filesystem::path& file); bool saveDataSeriesToFolder(const AnyString& folder) const; 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 08d86d4b73..9e2b299c08 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 @@ -165,7 +165,7 @@ class PartHydro uint count() const; - bool loadReserveParticipations(Area& area, const AnyString& file); + bool loadReserveParticipations(Area& area, const std::filesystem::path& file); void addReserveParticipation(const std::string& reserveName, const LTStorageClusterReserveParticipation& participation); diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index 5f91f34c6b..801bfe11ad 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -377,7 +377,7 @@ bool ClusterList::loadDataSeriesFromFolder(Study& s, const std::filesy } template -bool ClusterList::loadReserveParticipations(Area& area, const AnyString& file) +bool ClusterList::loadReserveParticipations(Area& area, const std::filesystem::path& file) { IniFile ini; if (!ini.open(file, false)) diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index e6be5311ea..9beb274b18 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -761,7 +761,7 @@ bool PartHydro::CheckDailyMaxEnergy(const AnyString& areaName) return ret; } -bool PartHydro::loadReserveParticipations(Area& area, const AnyString& file) +bool PartHydro::loadReserveParticipations(Area& area, const std::filesystem::path& file) { IniFile ini; if (!ini.open(file, false)) From 0c9eca85011d30b7404ab4d79e1be72dddc8c15c Mon Sep 17 00:00:00 2001 From: CAMUS Benjamin Date: Wed, 6 Nov 2024 16:53:28 +0100 Subject: [PATCH 3/7] fix bug occuring when not all the thermal clusters are participating to a reserve --- src/solver/optimisation/constraints/POutBounds.cpp | 12 ++++++++---- .../constraints/POutCapacityThreasholds.cpp | 2 +- src/solver/optimisation/opt_rename_problem.cpp | 3 +-- src/solver/simulation/sim_alloc_probleme_hebdo.cpp | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/solver/optimisation/constraints/POutBounds.cpp b/src/solver/optimisation/constraints/POutBounds.cpp index c99d25543d..ab57356a83 100644 --- a/src/solver/optimisation/constraints/POutBounds.cpp +++ b/src/solver/optimisation/constraints/POutBounds.cpp @@ -103,16 +103,20 @@ void POutBounds::add(int pays, int cluster, int pdt) return counter; }; + int nbTermsUp = countReservesParticipations( + data.areaReserves[pays].areaCapacityReservationsUp); + int nbTermsDown = countReservesParticipations( + data.areaReserves[pays].areaCapacityReservationsDown); + int nbTermsToAdd = countReservesParticipations( data.areaReserves[pays].areaCapacityReservationsUp) + countReservesParticipations( data.areaReserves[pays].areaCapacityReservationsDown); + builder.data.NbTermesContraintesPourLesReserves + += (nbTermsUp + 1) * (nbTermsUp > 0) + (nbTermsDown + 1) * (nbTermsDown > 0); - - builder.data.NbTermesContraintesPourLesReserves += 2 * (nbTermsToAdd + 1); - - builder.data.nombreDeContraintes += 2; + builder.data.nombreDeContraintes += (nbTermsUp > 0) + (nbTermsDown > 0); } } diff --git a/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp b/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp index ac1def9ff3..c1c801f204 100644 --- a/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp +++ b/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp @@ -107,7 +107,7 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) data.areaReserves[pays].areaCapacityReservationsDown); builder.data.NbTermesContraintesPourLesReserves - += (nbTermsUp + 1) * (nbTermsUp > 0) + (nbTermsDown + 1) * (nbTermsDown > 0); + += (nbTermsUp + 2) * (nbTermsUp > 0) + (nbTermsDown + 2) * (nbTermsDown > 0); builder.data.nombreDeContraintes += (nbTermsUp > 0) + (nbTermsDown > 0); } diff --git a/src/solver/optimisation/opt_rename_problem.cpp b/src/solver/optimisation/opt_rename_problem.cpp index f11aa9098b..d541c9c0ef 100644 --- a/src/solver/optimisation/opt_rename_problem.cpp +++ b/src/solver/optimisation/opt_rename_problem.cpp @@ -279,8 +279,7 @@ void VariableNamer::NumberOfOffUnitsParticipatingToReserve(unsigned int variable const std::string& clusterName, const std::string& reserveName) { - SetThermalClusterReserveElementName( - variable, "NumberOfOffUnitsParticipatingToReserve", clusterName); + SetThermalClusterAndReserveElementName(variable, "NumberOfOffUnitsParticipatingToReserve", clusterName, reserveName); } void VariableNamer::NumberStoppingDispatchableUnits(unsigned int variable, diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 7d8a3d8b6c..607c7610a1 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -248,10 +248,10 @@ void SIM_AllocationProblemePasDeTemps(PROBLEME_HEBDO& problem, study.runtime.thermalPlantTotalCount * study.runtime.capacityReservationCount, -1); problem.CorrespondanceCntNativesCntOptim[k] .NumeroDeContrainteDesContraintesDePuissanceMinDuPalier.assign( - study.runtime.thermalPlantTotalCount, 0); + study.runtime.thermalPlantTotalCount, -1); problem.CorrespondanceCntNativesCntOptim[k] .NumeroDeContrainteDesContraintesDePuissanceMaxDuPalier.assign( - study.runtime.thermalPlantTotalCount, 0); + study.runtime.thermalPlantTotalCount, -1); problem.CorrespondanceCntNativesCntOptim[k] .NumeroDeContrainteDesContraintesSTStorageClusterMaxWithdrawParticipation.assign( From d031b91773acbde77ee9a9bcae0757f0dc045550 Mon Sep 17 00:00:00 2001 From: CAMUS Benjamin Date: Wed, 6 Nov 2024 18:10:26 +0100 Subject: [PATCH 4/7] remove duplicate code caused by merge error --- src/libs/antares/study/area/list.cpp | 74 ---------------------------- 1 file changed, 74 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 64a33cea07..0f4af06576 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -985,80 +985,6 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, } } - // Reserves - { - buffer.clear() << study.folderInput << SEP << "reserves" << SEP << area.id << SEP - << "reserves.ini"; - if (ini.open(buffer, false)) - { - ini.each( - [&](const IniFile::Section& section) - { - if (area.allCapacityReservations.contains(section.name)) - { - logs.warning() << area.name << ": reserve name already exists for reserve " - << section.name; - } - else - { - CapacityReservation tmpCapacityReservation; - std::string file_name = AllCapacityReservations::toFilename(section.name); - int type = -1; - for (auto* p = section.firstProperty; p; p = p->next) - { - CString<30, false> tmp; - tmp = p->key; - tmp.toLower(); - - if (tmp == "failure-cost") - { - if (!p->value.to(tmpCapacityReservation.failureCost)) - { - logs.warning() - << area.name << ": invalid failure cost for reserve " - << section.name; - } - } - else if (tmp == "spillage-cost") - { - if (!p->value.to(tmpCapacityReservation.spillageCost)) - { - logs.warning() - << area.name << ": invalid spillage cost for reserve " - << section.name; - } - } - else if (tmp == "type") - { - if (p->value == "up") - type = 0; - else if (p->value == "down") - type = 1; - else - logs.warning() - << area.name << ": invalid type for reserve " << section.name; - } - else - logs.warning() - << area.name << ": invalid key " << tmp << " in file " << buffer; - } - fs::path filePath = study.folderInput / "reserves" / area.id.to() - / (file_name + ".txt"); - ret = tmpCapacityReservation.need.loadFromFile(filePath, false) && ret; - if (type == 0) - area.allCapacityReservations.areaCapacityReservationsUp.emplace( - section.name, tmpCapacityReservation); - else if (type == 1) - area.allCapacityReservations.areaCapacityReservationsDown.emplace( - section.name, tmpCapacityReservation); - else - logs.warning() - << area.name << ": invalid type for reserve " << section.name; - } - }); - } - } - // Solar { if (area.solar.prepro) // Prepro From 5de985309536a900ed3987768e072a7b21d461a0 Mon Sep 17 00:00:00 2001 From: sylvmara Date: Thu, 7 Nov 2024 12:35:54 +0100 Subject: [PATCH 5/7] Work in progress : fixed bugs on loading empty reserves and on hydro not participating to reserves TODO : investigate on a possible bug in case of holes in the bimap --- src/libs/antares/study/area/list.cpp | 15 ++++++++++++--- .../study/include/antares/study/area/area.h | 6 ++++++ .../economy/reserveParticipationByLTStorage.h | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 0f4af06576..b7c52c2143 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -1042,7 +1042,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, buffer.clear() << study.folderInput << SEP << "hydro" << SEP << "common" << SEP << area.id << SEP << "reserves.ini"; - ret = area.hydro.loadReserveParticipations(area, buffer) && ret; + if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast) + { + ret = area.hydro.loadReserveParticipations(area, buffer) && ret; + } } // Wind @@ -1077,7 +1080,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, } buffer.clear() << study.folderInput << SEP << "thermal" << SEP << "clusters" << SEP << area.id << SEP << "reserves.ini"; - ret = area.thermal.list.loadReserveParticipations(area, buffer) && ret; + if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast) + { + ret = area.thermal.list.loadReserveParticipations(area, buffer) && ret; + } } // Short term storage @@ -1091,7 +1097,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, fs::path reservesPath = study.folderInput / "st-storage" / "clusters" / area.id.to() / "reserves.ini"; - ret = area.shortTermStorage.loadReserveParticipations(area, reservesPath) && ret; + if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast) + { + ret = area.shortTermStorage.loadReserveParticipations(area, reservesPath) && ret; + } } // Renewable cluster list 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 5af75fca47..81cb81c006 100644 --- a/src/libs/antares/study/include/antares/study/area/area.h +++ b/src/libs/antares/study/include/antares/study/area/area.h @@ -85,6 +85,12 @@ class BiMap } return -1; // Return -1 if value is not found } + + // Function to return the size of the bimap + int size() + { + return key_to_value.size(); + } }; namespace Antares diff --git a/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h b/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h index d0a385796d..a263c68abd 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h +++ b/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h @@ -70,7 +70,7 @@ class ReserveParticipationByLTStorage pSize = 0; for (int areaIndex = 0; areaIndex < study->areas.size(); areaIndex++) { - pSize += study->areas[areaIndex]->allCapacityReservations.size(); + pSize += study->areas[areaIndex]->reserveParticipationLTStorageIndexMap.size(); } if (pSize) { From 98fab55221ba33fe68b3b87c4d5f6221a17eff06 Mon Sep 17 00:00:00 2001 From: sylvmara Date: Wed, 13 Nov 2024 17:01:33 +0100 Subject: [PATCH 6/7] Correcting bug in cases of multiple hydro reserves --- src/solver/simulation/sim_alloc_probleme_hebdo.cpp | 3 +-- .../solver/variable/economy/reserveParticipationByLTStorage.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 607c7610a1..ee36491dbe 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -519,8 +519,7 @@ void SIM_AllocateAreas(PROBLEME_HEBDO& problem, problem.ResultatsHoraires[k].Reserves[j].ValeursHorairesInternalExcessReserve.assign( nbReserves, 0.); problem.ResultatsHoraires[k].HydroUsage[j].reserveParticipationOfCluster.assign( - 1, // For the moment only one hydro cluster per area - 0.); + nbReserves, 0.); } // Short term storage results const unsigned long nbShortTermStorage = study.areas.byIndex[k]->shortTermStorage.count(); diff --git a/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h b/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h index a263c68abd..bf7e14a412 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h +++ b/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationByLTStorage.h @@ -70,7 +70,7 @@ class ReserveParticipationByLTStorage pSize = 0; for (int areaIndex = 0; areaIndex < study->areas.size(); areaIndex++) { - pSize += study->areas[areaIndex]->reserveParticipationLTStorageIndexMap.size(); + pSize += study->areas[areaIndex]->hydro.reserveParticipationsCount(); } if (pSize) { @@ -224,4 +224,4 @@ void localBuildAnnualSurveyReport(SurveyResults& results, } // namespace Solver } // namespace Antares -#endif // __SOLVER_VARIABLE_ECONOMY_ReserveParticipationByLTStorage_H__ \ No newline at end of file +#endif // __SOLVER_VARIABLE_ECONOMY_ReserveParticipationByLTStorage_H__ From 65d2843a5bcd48df05211de2abe924baaca9a710 Mon Sep 17 00:00:00 2001 From: sylvmara Date: Thu, 14 Nov 2024 11:54:54 +0100 Subject: [PATCH 7/7] Correcting constraint implemented but not counted when no cluster are participating to a reserve (esp constraint 24 : ReserveSatisfaction) --- .../constraints/ReserveSatisfaction.cpp | 130 +++++++++--------- .../simulation/sim_alloc_probleme_hebdo.cpp | 2 +- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/solver/optimisation/constraints/ReserveSatisfaction.cpp b/src/solver/optimisation/constraints/ReserveSatisfaction.cpp index e53b3a5567..74ede7e6ec 100644 --- a/src/solver/optimisation/constraints/ReserveSatisfaction.cpp +++ b/src/solver/optimisation/constraints/ReserveSatisfaction.cpp @@ -5,84 +5,84 @@ void ReserveSatisfaction::add(int pays, int reserve, int pdt, bool isUpReserve) CAPACITY_RESERVATION capacityReservation = isUpReserve ? data.areaReserves[pays].areaCapacityReservationsUp[reserve] : data.areaReserves[pays].areaCapacityReservationsDown[reserve]; - - if (!data.Simulation) + int nbTermes = capacityReservation.AllThermalReservesParticipation.size() + + capacityReservation.AllSTStorageReservesParticipation.size() + + capacityReservation.AllLTStorageReservesParticipation.size(); + if (nbTermes) { - // 24 + if (!data.Simulation) + { + // 24 - // Sum(P_θ) + Sum(P_B) + Sum(P_H) = S + J^+ -J^- - // P_θ : Participation power from thermal cluster θ to the reserve res - // P_B : Participation power from Short Term Storage cluster B to the reserve res - // P_H : Participation power from Long Term Storage to the reserve res - // S : Internal reserve res need for the area (second membre) - // J^+ : Amount of internal excess reserve for the reserve res - // J^- : Amount of internal unsatisfied reserve for the reserve res + // Sum(P_θ) + Sum(P_B) + Sum(P_H) = S + J^+ -J^- + // P_θ : Participation power from thermal cluster θ to the reserve res + // P_B : Participation power from Short Term Storage cluster B to the reserve res + // P_H : Participation power from Long Term Storage to the reserve res + // S : Internal reserve res need for the area (second membre) + // J^+ : Amount of internal excess reserve for the reserve res + // J^- : Amount of internal unsatisfied reserve for the reserve res - builder.updateHourWithinWeek(pdt); - // Thermal clusters reserve participation - for (auto& [clusterId, reserveParticipation] : capacityReservation.AllThermalReservesParticipation) - { - builder.ThermalClusterReserveParticipation( - reserveParticipation.globalIndexClusterParticipation, - 1); - } + builder.updateHourWithinWeek(pdt); - // Short Term Storage clusters reserve participation - for (auto& [clusterId, reserveParticipation] : capacityReservation.AllSTStorageReservesParticipation) - { - if (isUpReserve) - { - builder.STStorageClusterReserveUpParticipation( - reserveParticipation.globalIndexClusterParticipation, - 1); - } - else + // Thermal clusters reserve participation + for (auto& [clusterId, reserveParticipation] : capacityReservation.AllThermalReservesParticipation) { - builder.STStorageClusterReserveDownParticipation( - reserveParticipation.globalIndexClusterParticipation, - 1); + builder.ThermalClusterReserveParticipation( + reserveParticipation.globalIndexClusterParticipation, + 1); } - } - // Long Term Storage clusters reserve participation - for (auto& reserveParticipation: capacityReservation.AllLTStorageReservesParticipation) - { - if (isUpReserve) + // Short Term Storage clusters reserve participation + for (auto& [clusterId, reserveParticipation] : capacityReservation.AllSTStorageReservesParticipation) { - builder.LTStorageClusterReserveUpParticipation( - reserveParticipation.globalIndexClusterParticipation, - 1); + if (isUpReserve) + { + builder.STStorageClusterReserveUpParticipation( + reserveParticipation.globalIndexClusterParticipation, + 1); + } + else + { + builder.STStorageClusterReserveDownParticipation( + reserveParticipation.globalIndexClusterParticipation, + 1); + } } - else + + // Long Term Storage clusters reserve participation + for (auto& reserveParticipation : capacityReservation.AllLTStorageReservesParticipation) { - builder.LTStorageClusterReserveDownParticipation( - reserveParticipation.globalIndexClusterParticipation, - 1); + if (isUpReserve) + { + builder.LTStorageClusterReserveUpParticipation( + reserveParticipation.globalIndexClusterParticipation, + 1); + } + else + { + builder.LTStorageClusterReserveDownParticipation( + reserveParticipation.globalIndexClusterParticipation, + 1); + } } - } - builder.InternalUnsatisfiedReserve(capacityReservation.globalReserveIndex, 1) - .InternalExcessReserve(capacityReservation.globalReserveIndex, -1) - .equalTo(); - data.CorrespondanceCntNativesCntOptim[pdt] - .NumeroDeContrainteDesContraintesDeBesoinEnReserves[capacityReservation - .globalReserveIndex] - = builder.data.nombreDeContraintes; - ConstraintNamer namer(builder.data.NomDesContraintes); - const int hourInTheYear = builder.data.weekInTheYear * 168 + pdt; - namer.UpdateTimeStep(hourInTheYear); - namer.UpdateArea(builder.data.NomsDesPays[pays]); - namer.ReserveSatisfaction(builder.data.nombreDeContraintes, - capacityReservation.reserveName); - builder.build(); - } - else - { - int nbTermes = capacityReservation.AllThermalReservesParticipation.size() - + capacityReservation.AllSTStorageReservesParticipation.size() - + capacityReservation.AllLTStorageReservesParticipation.size(); - if (nbTermes) + builder.InternalUnsatisfiedReserve(capacityReservation.globalReserveIndex, 1) + .InternalExcessReserve(capacityReservation.globalReserveIndex, -1) + .equalTo(); + data.CorrespondanceCntNativesCntOptim[pdt] + .NumeroDeContrainteDesContraintesDeBesoinEnReserves[capacityReservation + .globalReserveIndex] + = builder.data.nombreDeContraintes; + ConstraintNamer namer(builder.data.NomDesContraintes); + const int hourInTheYear = builder.data.weekInTheYear * 168 + pdt; + namer.UpdateTimeStep(hourInTheYear); + namer.UpdateArea(builder.data.NomsDesPays[pays]); + namer.ReserveSatisfaction(builder.data.nombreDeContraintes, + capacityReservation.reserveName); + builder.build(); + } + else { builder.data.NbTermesContraintesPourLesReserves += 2 + nbTermes; builder.data.nombreDeContraintes += 1; diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index ee36491dbe..4ffa2b4a16 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -519,7 +519,7 @@ void SIM_AllocateAreas(PROBLEME_HEBDO& problem, problem.ResultatsHoraires[k].Reserves[j].ValeursHorairesInternalExcessReserve.assign( nbReserves, 0.); problem.ResultatsHoraires[k].HydroUsage[j].reserveParticipationOfCluster.assign( - nbReserves, 0.); + nbLTStorageReserveParticipations, 0.); } // Short term storage results const unsigned long nbShortTermStorage = study.areas.byIndex[k]->shortTermStorage.count();