Skip to content

Commit

Permalink
De-templatize HydroManagement::prepareNetDemand
Browse files Browse the repository at this point in the history
Templates make for larger binaries since 2 functions are required.
  • Loading branch information
flomnes committed Oct 5, 2023
1 parent cf4a792 commit 5d55e3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 4 additions & 9 deletions src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ bool HydroManagement::checkMinGeneration(uint numSpace, uint year) const
return ret;
}

template<enum Data::StudyMode ModeT>
void HydroManagement::prepareNetDemand(uint numSpace, uint year)
void HydroManagement::prepareNetDemand(uint numSpace, uint year, Data::StudyMode mode)
{
areas_.each([&](Data::Area& area) {
uint z = area.index;
Expand Down Expand Up @@ -398,7 +397,7 @@ void HydroManagement::prepareNetDemand(uint numSpace, uint year)
netdemand = + loadSeries[hour]
- windSeries[hour] - scratchpad.miscGenSum[hour]
- solarSeries[hour] - ror[hour]
- ((ModeT != Data::stdmAdequacy) ? scratchpad.mustrunSum[hour]
- ((mode != Data::stdmAdequacy) ? scratchpad.mustrunSum[hour]
: scratchpad.originalMustrunSum[hour]);
}

Expand All @@ -407,7 +406,7 @@ void HydroManagement::prepareNetDemand(uint numSpace, uint year)
{
netdemand = loadSeries[hour]
- scratchpad.miscGenSum[hour] - ror[hour]
- ((ModeT != Data::stdmAdequacy) ? scratchpad.mustrunSum[hour]
- ((mode != Data::stdmAdequacy) ? scratchpad.mustrunSum[hour]
: scratchpad.originalMustrunSum[hour]);

area.renewable.list.each([&](const Antares::Data::RenewableCluster& cluster) {
Expand Down Expand Up @@ -525,12 +524,8 @@ void HydroManagement::makeVentilation(double* randomReservoirLevel,
throw FatalError("hydro management: invalid minimum generation");
}

if (parameters_.adequacy())
prepareNetDemand<Data::stdmAdequacy>(numSpace, y);
else
prepareNetDemand<Data::stdmEconomy>(numSpace, y);

prepareEffectiveDemand(numSpace);
prepareNetDemand(numSpace, y, parameters_.mode);

prepareMonthlyOptimalGenerations(randomReservoirLevel, y, numSpace);
prepareDailyOptimalGenerations(state, y, numSpace);
Expand Down
3 changes: 1 addition & 2 deletions src/solver/hydro/management/management.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ class HydroManagement final
//! check minimum generation is lower than available inflows
bool checkMinGeneration(uint numSpace, uint year) const;
//! Prepare the net demand for each area
template<enum Data::StudyMode ModeT>
void prepareNetDemand(uint numSpace, uint year);
void prepareNetDemand(uint numSpace, uint year, Data::StudyMode mode);
//! Prepare the effective demand for each area
void prepareEffectiveDemand(uint numSpace);
//! Monthly Optimal generations
Expand Down

0 comments on commit 5d55e3e

Please sign in to comment.