Skip to content

Commit

Permalink
Merge remote-tracking branch 'rte/feature/reserve_model_lot2_scalian'…
Browse files Browse the repository at this point in the history
… into feature/reserve_model_lot2_scalian
  • Loading branch information
h-fournier committed Nov 25, 2024
2 parents 6b4a1c1 + 65d2843 commit d8e5806
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 80 deletions.
16 changes: 12 additions & 4 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
}
}


// Reserves
{
fs::path reserves = study.folderInput / "reserves" / area.id.to<std::string>() / "reserves.ini";
Expand Down Expand Up @@ -1041,7 +1040,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
study.usedByTheSolver);

fs::path reservesHydro = study.folderInput / "hydro" / "common" / area.id.to<std::string>() / "reserves.ini";
area.hydro.loadReserveParticipations(area, reservesHydro);
if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast)
{
area.hydro.loadReserveParticipations(area, reservesHydro);
}
}

// Wind
Expand Down Expand Up @@ -1075,7 +1077,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
area.thermal.list.enableMustrunForEveryone();
}
fs::path reservesThermal = study.folderInput / "thermal" / "clusters" / area.id.to<std::string>() / "reserves.ini";
area.thermal.list.loadReserveParticipations(area, reservesThermal);
if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast)
{
area.thermal.list.loadReserveParticipations(area, reservesThermal);
}
}

// Short term storage
Expand All @@ -1089,7 +1094,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,

fs::path reservesPath = study.folderInput / "st-storage" / "clusters"
/ area.id.to<std::string>() / "reserves.ini";
area.shortTermStorage.loadReserveParticipations(area, reservesPath);
if (study.parameters.unitCommitment.ucMode != UnitCommitmentMode::ucHeuristicFast)
{
area.shortTermStorage.loadReserveParticipations(area, reservesPath);
}
}

// Renewable cluster list
Expand Down
6 changes: 6 additions & 0 deletions src/libs/antares/study/include/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/solver/optimisation/constraints/POutBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
130 changes: 65 additions & 65 deletions src/solver/optimisation/constraints/ReserveSatisfaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/solver/optimisation/opt_rename_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/solver/simulation/sim_alloc_probleme_hebdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -224,4 +224,4 @@ void localBuildAnnualSurveyReport(SurveyResults& results,
} // namespace Solver
} // namespace Antares

#endif // __SOLVER_VARIABLE_ECONOMY_ReserveParticipationByLTStorage_H__
#endif // __SOLVER_VARIABLE_ECONOMY_ReserveParticipationByLTStorage_H__

0 comments on commit d8e5806

Please sign in to comment.