diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index a5e723bdeb..0ec5f5386a 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -911,7 +911,6 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, } } - // Reserves { fs::path reserves = study.folderInput / "reserves" / area.id.to() / "reserves.ini"; @@ -1041,7 +1040,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, study.usedByTheSolver); fs::path reservesHydro = study.folderInput / "hydro" / "common" / area.id.to() / "reserves.ini"; - area.hydro.loadReserveParticipations(area, reservesHydro); + if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast) + { + area.hydro.loadReserveParticipations(area, reservesHydro); + } } // Wind @@ -1075,7 +1077,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, area.thermal.list.enableMustrunForEveryone(); } fs::path reservesThermal = study.folderInput / "thermal" / "clusters" / area.id.to() / "reserves.ini"; - area.thermal.list.loadReserveParticipations(area, reservesThermal); + if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast) + { + area.thermal.list.loadReserveParticipations(area, reservesThermal); + } } // Short term storage @@ -1089,7 +1094,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, fs::path reservesPath = study.folderInput / "st-storage" / "clusters" / area.id.to() / "reserves.ini"; - area.shortTermStorage.loadReserveParticipations(area, reservesPath); + if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast) + { + area.shortTermStorage.loadReserveParticipations(area, reservesPath); + } } // 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/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/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/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 607c7610a1..4ffa2b4a16 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.); + nbLTStorageReserveParticipations, 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 d0a385796d..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]->allCapacityReservations.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__