-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of the implementation of the reserve equations v.2 for …
…part 3
- Loading branch information
Showing
15 changed files
with
465 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/solver/optimisation/constraints/STStockEnergyLevelReserveParticipation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "antares/solver/optimisation/constraints/STStockEnergyLevelReserveParticipation.h" | ||
|
||
void STStockEnergyLevelReserveParticipation::add(int pays, int cluster, int reserve, int pdt, bool isUpReserve) | ||
{ | ||
int globalClusterIdx = data.shortTermStorageOfArea[pays][cluster].clusterGlobalIndex; | ||
CAPACITY_RESERVATION& capacityReservation | ||
= isUpReserve ? data.areaReserves[pays].areaCapacityReservationsUp[reserve] | ||
: data.areaReserves[pays].areaCapacityReservationsDown[reserve]; | ||
|
||
if (!data.Simulation) | ||
{ | ||
// 15 (h) (1) | ||
// Participation of down reserves requires a sufficient level of stock | ||
// Sum(P_{res,t_st} * R_{min,res} +/- J_res * R_{lambda,t_st}) <= n_min * R_up | ||
// R_t : stock level at time t | ||
// P_{res,t_st} : power participation for reserve down res at time t_st | ||
// R_{min,res} : max power participation ratio | ||
// R_up : max stock level | ||
{ | ||
float sign = isUpReserve ? -1. : 1.; | ||
|
||
RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation | ||
= capacityReservation.AllSTStorageReservesParticipation[cluster]; | ||
|
||
builder.updateHourWithinWeek(pdt); | ||
|
||
for (int t=0; t < capacityReservation.maxActivationDuration; t++) | ||
{ | ||
builder.STStorageClusterReserveDownParticipation( | ||
reserveParticipation.globalIndexClusterParticipation, | ||
capacityReservation.maxActivationRatio, | ||
t, builder.data.NombreDePasDeTempsPourUneOptimisation); | ||
builder.ShortTermStorageLevel(globalClusterIdx, sign * capacityReservation.maxEnergyActivationRatio, | ||
t, builder.data.NombreDePasDeTempsPourUneOptimisation); | ||
} | ||
|
||
builder.lessThan(); | ||
|
||
data.CorrespondanceCntNativesCntOptim[pdt] | ||
.NumeroDeContrainteDesContraintesSTStockEnergyLevelReserveParticipation | ||
[reserveParticipation.globalIndexClusterParticipation] | ||
= 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.STEnergyStockLevelReserveParticipationDown(builder.data.nombreDeContraintes, | ||
reserveParticipation.clusterName, | ||
capacityReservation.reserveName); | ||
builder.build(); | ||
} | ||
} | ||
else | ||
{ | ||
builder.data.NbTermesContraintesPourLesReserves += 2 * capacityReservation.maxActivationDuration; | ||
builder.data.nombreDeContraintes += 1; | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
src/solver/optimisation/constraints/STStockGlobalEnergyLevelReserveParticipation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#include "antares/solver/optimisation/constraints/STStockGlobalEnergyLevelReserveParticipation.h" | ||
|
||
void STStockGlobalEnergyLevelReserveParticipation::add(int pays, int cluster, int pdt) | ||
{ | ||
int globalClusterIdx = data.shortTermStorageOfArea[pays][cluster].clusterGlobalIndex; | ||
|
||
|
||
if (!data.Simulation) | ||
{ | ||
// Stock participation is energy constrained (optional constraints) | ||
// Sum(P_{res,t_st} * R_{min,res} +/- J_down/up * R_{lambda,t_st}) <= n_min * R_up | ||
// R_t : stock level at time t | ||
// P_{res,t_st} : power participation for reserve down res at time t_st | ||
// R_{min,res} : max power participation ratio | ||
// R_up : max stock level | ||
|
||
// DOWN reserves | ||
{ | ||
builder.updateHourWithinWeek(pdt); | ||
|
||
for (int t=0; t < data.areaReserves[pays].maxGlobalActivationDurationDown; t++) | ||
{ | ||
|
||
for (auto& capacityReservation : data.areaReserves[pays].areaCapacityReservationsDown) | ||
{ | ||
if (capacityReservation.AllSTStorageReservesParticipation.contains(cluster)) | ||
{ | ||
RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation = capacityReservation.AllSTStorageReservesParticipation[cluster]; | ||
builder.STStorageClusterReserveDownParticipation( | ||
reserveParticipation.globalIndexClusterParticipation, | ||
capacityReservation.maxActivationRatio, | ||
t, builder.data.NombreDePasDeTempsPourUneOptimisation); | ||
} | ||
} | ||
if (builder.NumberOfVariables() > 0) | ||
{ | ||
builder.ShortTermStorageLevel(globalClusterIdx, data.areaReserves[pays].maxGlobalEnergyActivationRatioDown, | ||
t, builder.data.NombreDePasDeTempsPourUneOptimisation); | ||
} | ||
} | ||
|
||
if (builder.NumberOfVariables() > 0) | ||
{ | ||
builder.lessThan(); | ||
|
||
data.CorrespondanceCntNativesCntOptim[pdt] | ||
.NumeroDeContrainteDesContraintesSTGlobalStockEnergyLevelReserveParticipationDown | ||
[globalClusterIdx] | ||
= 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.STGlobalEnergyStockLevelReserveParticipationDown(builder.data.nombreDeContraintes, | ||
"ShortTermStorage"); | ||
builder.build(); | ||
} | ||
} | ||
|
||
// UP reserves | ||
{ | ||
builder.updateHourWithinWeek(pdt); | ||
|
||
for (int t=0; t < data.areaReserves[pays].maxGlobalActivationDurationUp; t++) | ||
{ | ||
for (auto& capacityReservation : data.areaReserves[pays].areaCapacityReservationsUp) | ||
{ | ||
if (capacityReservation.AllSTStorageReservesParticipation.contains(cluster)) | ||
{ | ||
RESERVE_PARTICIPATION_STSTORAGE& reserveParticipation = capacityReservation.AllSTStorageReservesParticipation[cluster]; | ||
builder.STStorageClusterReserveUpParticipation( | ||
reserveParticipation.globalIndexClusterParticipation, | ||
capacityReservation.maxActivationRatio, | ||
t, builder.data.NombreDePasDeTempsPourUneOptimisation); | ||
} | ||
} | ||
if (builder.NumberOfVariables() > 0) | ||
{ | ||
builder.ShortTermStorageLevel(globalClusterIdx, -data.areaReserves[pays].maxGlobalEnergyActivationRatioUp, | ||
t, builder.data.NombreDePasDeTempsPourUneOptimisation); | ||
} | ||
} | ||
|
||
if (builder.NumberOfVariables() > 0) | ||
{ | ||
builder.lessThan(); | ||
|
||
data.CorrespondanceCntNativesCntOptim[pdt] | ||
.NumeroDeContrainteDesContraintesSTGlobalStockEnergyLevelReserveParticipationUp | ||
[globalClusterIdx] | ||
= 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.STGlobalEnergyStockLevelReserveParticipationUp(builder.data.nombreDeContraintes, | ||
"ShortTermStorage"); | ||
builder.build(); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// Lambda that count the number of reserveParticipations | ||
auto countReservesParticipations = [cluster](const std::vector<CAPACITY_RESERVATION>& reservations, int t_max) | ||
{ | ||
int counter = 0; | ||
for (const auto& capacityReservation: reservations) | ||
{ | ||
counter += capacityReservation.AllSTStorageReservesParticipation.count(cluster) * t_max; | ||
} | ||
return counter; | ||
}; | ||
|
||
int nbTermsUp = countReservesParticipations(data.areaReserves[pays].areaCapacityReservationsUp, data.areaReserves[pays].maxGlobalActivationDurationUp); | ||
int nbTermsDown = countReservesParticipations(data.areaReserves[pays].areaCapacityReservationsDown, data.areaReserves[pays].maxGlobalActivationDurationDown); | ||
|
||
builder.data.NbTermesContraintesPourLesReserves += (nbTermsUp + data.areaReserves[pays].maxGlobalActivationDurationUp) * (nbTermsUp > 0) + (nbTermsDown + data.areaReserves[pays].maxGlobalActivationDurationDown) * (nbTermsDown > 0); | ||
builder.data.nombreDeContraintes += (nbTermsUp > 0) + (nbTermsDown > 0); | ||
} | ||
} |
Oops, something went wrong.