diff --git a/src/solver/optimisation/constraints/PMaxReserve.cpp b/src/solver/optimisation/constraints/PMaxReserve.cpp index c3ab59e3c6..37d0557983 100644 --- a/src/solver/optimisation/constraints/PMaxReserve.cpp +++ b/src/solver/optimisation/constraints/PMaxReserve.cpp @@ -20,10 +20,10 @@ void PMaxReserve::add(int pays, int reserve, int cluster, int pdt, bool isUpRese = capacityReservation.AllReservesParticipation[cluster]; int globalClusterIdx = data.thermalClusters[pays] - .NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipation.clusterIdInArea]; builder.updateHourWithinWeek(pdt) - .RunningClusterReserveParticipation(globalClusterIdx, 1.0) + .RunningClusterReserveParticipation(reserveParticipation.indexClusterParticipation, 1.0) .NumberOfDispatchableUnits(globalClusterIdx, -reserveParticipation.maxPower) .lessThan(); diff --git a/src/solver/optimisation/constraints/POutBounds.cpp b/src/solver/optimisation/constraints/POutBounds.cpp index fcde27cd91..7fc0b9c739 100644 --- a/src/solver/optimisation/constraints/POutBounds.cpp +++ b/src/solver/optimisation/constraints/POutBounds.cpp @@ -9,6 +9,9 @@ void POutBounds::add(int pays, int cluster, int pdt) .NumeroDeContrainteDesContraintesDePuissanceMaxDuPalier[cluster] = -1; + int globalClusterIdx + = data.thermalClusters[pays].NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; + if (!data.Simulation) { // 17 ter @@ -20,8 +23,6 @@ void POutBounds::add(int pays, int cluster, int pdt) // P_down : Minimal power output demanded from cluster θ // P_up : Maximal power output from cluster θ - int globalClusterIdx - = data.thermalClusters[pays].NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; // 17 ter (1) : Sum(P^on_re-) - P <= - P_down { @@ -33,8 +34,14 @@ void POutBounds::add(int pays, int cluster, int pdt) for (const auto& reserveParticipations : capacityReservation.AllReservesParticipation) { - if (reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) - builder.RunningClusterReserveParticipation(globalClusterIdx, 1); + if ((reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + && (data.thermalClusters[pays] + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipations + .clusterIdInArea] + == globalClusterIdx)) + { + builder.RunningClusterReserveParticipation(reserveParticipations.indexClusterParticipation, 1); + } } } @@ -67,8 +74,12 @@ void POutBounds::add(int pays, int cluster, int pdt) for (const auto& reserveParticipations : capacityReservation.AllReservesParticipation) { - if (reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) - builder.RunningClusterReserveParticipation(globalClusterIdx, 1); + if ((reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + && (data.thermalClusters[pays] + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipations + .clusterIdInArea] + == globalClusterIdx)) + builder.RunningClusterReserveParticipation(reserveParticipations.indexClusterParticipation, 1); } } @@ -95,7 +106,10 @@ void POutBounds::add(int pays, int cluster, int pdt) { // Lambda that count the number of reserves that the cluster is participating to auto countReservesFromCluster - = [cluster](const std::vector& reservations) + = [cluster](const std::vector& reservations, + int globalClusterIdx, + int pays, + ReserveData data) { int counter = 0; for (const auto& capacityReservation : reservations) @@ -103,7 +117,11 @@ void POutBounds::add(int pays, int cluster, int pdt) for (const auto& reserveParticipations : capacityReservation.AllReservesParticipation) { - if (reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + if ((reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + && (data.thermalClusters[pays] + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipations + .clusterIdInArea] + == globalClusterIdx)) counter++; } } @@ -112,9 +130,9 @@ void POutBounds::add(int pays, int cluster, int pdt) int nbConstraintsToAdd = countReservesFromCluster( - data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsUp) + data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsUp, globalClusterIdx, pays, data) + countReservesFromCluster( - data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsDown); + data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsDown, globalClusterIdx, pays, data); builder.data.NbTermesContraintesPourLesReserves += 2 * (nbConstraintsToAdd + 1); diff --git a/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp b/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp index 0110ff97de..2277760c4f 100644 --- a/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp +++ b/src/solver/optimisation/constraints/POutCapacityThreasholds.cpp @@ -2,6 +2,9 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) { + int globalClusterIdx + = data.thermalClusters[pays].NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; + if (!data.Simulation) { // 17 bis @@ -14,9 +17,6 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) // P^on_re+ : Participation of running units in cluster θ to Up reserves // P : Power output from cluster θ - int globalClusterIdx = data.thermalClusters[pays] - .NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; - // 17 bis (1) : l * M + Sum(P^on_re-) - P <= 0 { builder.updateHourWithinWeek(pdt); @@ -27,8 +27,10 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) for (const auto& reserveParticipations : capacityReservation.AllReservesParticipation) { - if (reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) - builder.RunningClusterReserveParticipation(globalClusterIdx, 1); + if ((reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + && (data.thermalClusters[pays] + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipations.clusterIdInArea] == globalClusterIdx)) + builder.RunningClusterReserveParticipation(reserveParticipations.indexClusterParticipation, 1); } } @@ -61,8 +63,10 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) for (const auto& reserveParticipations : capacityReservation.AllReservesParticipation) { - if (reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) - builder.RunningClusterReserveParticipation(globalClusterIdx, 1); + if ((reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + && (data.thermalClusters[pays] + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipations.clusterIdInArea] == globalClusterIdx)) + builder.RunningClusterReserveParticipation(reserveParticipations.indexClusterParticipation, 1); } } @@ -88,7 +92,7 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) { // Lambda that count the number of reserves that the cluster is participating to auto countReservesFromCluster - = [cluster](const std::vector& reservations) + = [cluster](const std::vector& reservations, int globalClusterIdx, int pays, ReserveData data) { int counter = 0; for (const auto& capacityReservation : reservations) @@ -96,7 +100,11 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) for (const auto& reserveParticipations : capacityReservation.AllReservesParticipation) { - if (reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + if ((reserveParticipations.maxPower != CLUSTER_NOT_PARTICIPATING) + && (data.thermalClusters[pays] + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipations + .clusterIdInArea] + == globalClusterIdx)) counter++; } } @@ -105,9 +113,9 @@ void POutCapacityThreasholds::add(int pays, int cluster, int pdt) int nbConstraintsToAdd = countReservesFromCluster( - data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsUp) + data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsUp, globalClusterIdx, pays, data) + countReservesFromCluster( - data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsDown); + data.areaReserves.thermalAreaReserves[pays].areaCapacityReservationsDown, globalClusterIdx, pays, data); builder.data.NbTermesContraintesPourLesReserves += 2*(nbConstraintsToAdd+2); diff --git a/src/solver/optimisation/constraints/PRunningUnits.cpp b/src/solver/optimisation/constraints/PRunningUnits.cpp index 399a3beaed..c47e1197a7 100644 --- a/src/solver/optimisation/constraints/PRunningUnits.cpp +++ b/src/solver/optimisation/constraints/PRunningUnits.cpp @@ -19,11 +19,11 @@ void PRunningUnits::add(int pays, int reserve, int cluster, int pdt, bool isUpRe = capacityReservation.AllReservesParticipation[cluster]; int globalClusterIdx = data.thermalClusters[pays] - .NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster]; + .NumeroDuPalierDansLEnsembleDesPaliersThermiques[reserveParticipation.clusterIdInArea]; builder.updateHourWithinWeek(pdt) - .RunningClusterReserveParticipation(globalClusterIdx, 1.0) - .ClusterReserveParticipation(globalClusterIdx, -1.0) + .RunningClusterReserveParticipation(reserveParticipation.indexClusterParticipation, 1.0) + .ClusterReserveParticipation(reserveParticipation.indexClusterParticipation, -1.0) .equalTo(); ConstraintNamer namer(builder.data.NomDesContraintes); diff --git a/src/solver/optimisation/constraints/ReserveParticipationGroup.cpp b/src/solver/optimisation/constraints/ReserveParticipationGroup.cpp index ee5fa42776..e3025173da 100644 --- a/src/solver/optimisation/constraints/ReserveParticipationGroup.cpp +++ b/src/solver/optimisation/constraints/ReserveParticipationGroup.cpp @@ -65,19 +65,19 @@ void ReserveParticipationGroup::BuildConstraints() // 24 reserveSatisfaction.add(pays, reserve, pdt, true); - uint32_t cluster = 0; + uint32_t cluster_participation = 0; for (const auto& clusterReserveParticipation : areaReserveUp.AllReservesParticipation) { if (clusterReserveParticipation.maxPower >= 0) { // 16 bis - pMaxReserve.add(pays, reserve, cluster, pdt, true); + pMaxReserve.add(pays, reserve, cluster_participation, pdt, true); // 17 quater - pRunningUnits.add(pays, reserve, cluster, pdt, true); + pRunningUnits.add(pays, reserve, cluster_participation, pdt, true); } - cluster++; + cluster_participation++; } reserve++; } @@ -90,19 +90,25 @@ void ReserveParticipationGroup::BuildConstraints() // 24 reserveSatisfaction.add(pays, reserve, pdt, false); - uint32_t cluster = 0; + uint32_t cluster_participation = 0; for (const auto& clusterReserveParticipation : areaReserveDown.AllReservesParticipation) { if (clusterReserveParticipation.maxPower >= 0) { // 16 bis - pMaxReserve.add(pays, reserve, cluster, pdt, false); + pMaxReserve.add(pays, + reserve, cluster_participation, + pdt, + false); // 17 quater - pRunningUnits.add(pays, reserve, cluster, pdt, false); + pRunningUnits.add(pays, + reserve, cluster_participation, + pdt, + false); } - cluster++; + cluster_participation++; } reserve++; } diff --git a/src/solver/optimisation/constraints/ReserveSatisfaction.cpp b/src/solver/optimisation/constraints/ReserveSatisfaction.cpp index 5320e68894..d7a9d85a2e 100644 --- a/src/solver/optimisation/constraints/ReserveSatisfaction.cpp +++ b/src/solver/optimisation/constraints/ReserveSatisfaction.cpp @@ -27,8 +27,7 @@ void ReserveSatisfaction::add(int pays, int reserve, int pdt, bool isUpReserve) { if (capacityReservation.AllReservesParticipation[cluster].maxPower != CLUSTER_NOT_PARTICIPATING) builder.RunningClusterReserveParticipation( - data.thermalClusters[pays] - .NumeroDuPalierDansLEnsembleDesPaliersThermiques[cluster], + capacityReservation.AllReservesParticipation[cluster].indexClusterParticipation, 1); } @@ -36,8 +35,7 @@ void ReserveSatisfaction::add(int pays, int reserve, int pdt, bool isUpReserve) .InternalExcessReserve(capacityReservation.globalReserveIndex, -1) .equalTo(); data.CorrespondanceCntNativesCntOptim[pdt] - .NumeroDeContrainteDesContraintesDeBesoinEnReserves[capacityReservation - .globalReserveIndex] + .NumeroDeContrainteDesContraintesDeBesoinEnReserves[capacityReservation.globalReserveIndex] = builder.data.nombreDeContraintes; ConstraintNamer namer(builder.data.NomDesContraintes); const int hourInTheYear = builder.data.weekInTheYear * 168 + pdt; diff --git a/src/solver/optimisation/include/antares/solver/optimisation/constraints/PMaxReserve.h b/src/solver/optimisation/include/antares/solver/optimisation/constraints/PMaxReserve.h index 73a1002cfe..6a3b166c8e 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/constraints/PMaxReserve.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/constraints/PMaxReserve.h @@ -16,7 +16,7 @@ class PMaxReserve : private ConstraintFactory * @brief Add variables to the constraint and update constraints Matrix * @param pays : area * @param reserve : capacity reservation - * @param cluster : global index of the cluster + * @param cluster : local index of the cluster * @param pdt : timestep * @param isUpReserve : true if ReserveUp, false if ReserveDown */ 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 cc55ef7dbf..e64a1018bc 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 @@ -273,6 +273,7 @@ struct RESERVE_PARTICIPATION float participationCost = CLUSTER_NOT_PARTICIPATING; int indexClusterParticipation = 0; std::string clusterName; + int clusterIdInArea; }; struct CAPACITY_RESERVATION diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 17710883e1..c243789731 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -335,16 +335,15 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, for (auto cluster : area.thermal.list.each_enabled_and_not_mustrun()) { RESERVE_PARTICIPATION reserveParticipation; - if (cluster->isParticipatingInReserve(key)) - { - reserveParticipation.maxPower = cluster->reserveMaxPower(key); - reserveParticipation.participationCost = cluster->reserveCost(key); - reserveParticipation.clusterName = cluster->name(); - reserveParticipation.indexClusterParticipation - = globalClusterParticipationIndex++; - areaCapacityReservationsUp.AllReservesParticipation.push_back( - reserveParticipation); - } + reserveParticipation.maxPower = cluster->reserveMaxPower(key); + reserveParticipation.participationCost = cluster->reserveCost(key); + reserveParticipation.clusterName = cluster->name(); + reserveParticipation.clusterIdInArea = cluster->index; + reserveParticipation.indexClusterParticipation + = globalClusterParticipationIndex; + globalClusterParticipationIndex++; + areaCapacityReservationsUp.AllReservesParticipation.push_back( + reserveParticipation); } areaReserves.areaCapacityReservationsUp.push_back(areaCapacityReservationsUp); @@ -367,16 +366,17 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, for (auto cluster : area.thermal.list.each_enabled_and_not_mustrun()) { RESERVE_PARTICIPATION reserveParticipation; - if (cluster->isParticipatingInReserve(key)) - { + //if (cluster->isParticipatingInReserve(key)) + //{ reserveParticipation.maxPower = cluster->reserveMaxPower(key); reserveParticipation.participationCost = cluster->reserveCost(key); reserveParticipation.clusterName = cluster->name(); - reserveParticipation.indexClusterParticipation - = globalClusterParticipationIndex++; + reserveParticipation.clusterIdInArea = cluster->index; + reserveParticipation.indexClusterParticipation = globalClusterParticipationIndex; + globalClusterParticipationIndex++; areaCapacityReservationsDown.AllReservesParticipation.push_back( reserveParticipation); - } + //} } areaReserves.areaCapacityReservationsDown.push_back(areaCapacityReservationsDown);