Skip to content

Commit

Permalink
De-templatize HydroManagement::prepareNetDemand (#1679)
Browse files Browse the repository at this point in the history
* De-templatize `HydroManagement::prepareNetDemand`

Templates make for larger binaries since 2 functions are required.

* Swap 2 lines of code
  • Loading branch information
flomnes authored Oct 5, 2023
1 parent cf4a792 commit 1b89fbf
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,11 +524,7 @@ 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);

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

prepareMonthlyOptimalGenerations(randomReservoirLevel, 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 1b89fbf

Please sign in to comment.