From 1fa52a88e807457c1f8893fcb931108db294e3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Fri, 29 Sep 2023 10:47:33 +0200 Subject: [PATCH] Introduce & use DataSeriesCommon::getAvailablePowerYearly (#1660) --- src/libs/antares/study/parts/common/series.cpp | 6 ++++++ src/libs/antares/study/parts/common/series.h | 6 +++++- src/solver/optimisation/post_process_commands.cpp | 4 ++-- src/solver/simulation/common-eco-adq.cpp | 11 ++++++----- src/solver/ts-generator/thermal.cpp | 6 +++--- .../variable/economy/avail-dispatchable-generation.h | 3 ++- src/solver/variable/state.cpp | 3 ++- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/libs/antares/study/parts/common/series.cpp b/src/libs/antares/study/parts/common/series.cpp index 214dd1ea21..cfbf5e372a 100644 --- a/src/libs/antares/study/parts/common/series.cpp +++ b/src/libs/antares/study/parts/common/series.cpp @@ -57,6 +57,12 @@ double DataSeriesCommon::getAvailablePower(unsigned int hour, unsigned int year) { return timeSeries[getSeriesIndex(year)][hour]; } + +const DataSeriesCommon::SingleYear& DataSeriesCommon::getAvailablePowerYearly(unsigned int year) const +{ + return timeSeries[getSeriesIndex(year)]; +} + uint DataSeriesCommon::getSeriesIndex(unsigned int year) const { if (timeSeries.width == 1) diff --git a/src/libs/antares/study/parts/common/series.h b/src/libs/antares/study/parts/common/series.h index 808fb98e3c..1be27e94cb 100644 --- a/src/libs/antares/study/parts/common/series.h +++ b/src/libs/antares/study/parts/common/series.h @@ -38,6 +38,9 @@ namespace Antares::Data class DataSeriesCommon { public: + using AllYears = Matrix; + using SingleYear = AllYears::ColumnType; + bool forceReload(bool reload = false) const; void markAsModified() const; @@ -45,13 +48,14 @@ class DataSeriesCommon uint64_t memoryUsage() const; double getAvailablePower(unsigned int hour, unsigned int year) const; + const SingleYear& getAvailablePowerYearly(unsigned int year) const; /*! ** \brief Series (MW) ** ** Merely a matrix of TimeSeriesCount * 8760 values */ - Matrix timeSeries; + AllYears timeSeries; /*! ** \brief Monte-Carlo diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index ecdc94b6ff..a1206fe740 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -35,12 +35,12 @@ void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime for (auto i = area.thermal.list.begin(); i != end; ++i) { auto& cluster = *(i->second); + const auto& availableProduction = cluster.series->getAvailablePowerYearly(year); for (uint h = 0; h != nbHoursInWeek; ++h) { double production = hourlyResults.ProductionThermique[h] .ProductionThermiqueDuPalier[cluster.index]; - double availability = cluster.series->getAvailablePower(h + hourInYear, year); - dtgmrg[h] += availability - production; + dtgmrg[h] += availableProduction[h + hourInYear] - production; } } } diff --git a/src/solver/simulation/common-eco-adq.cpp b/src/solver/simulation/common-eco-adq.cpp index 588cb748d2..a3f2099ce9 100644 --- a/src/solver/simulation/common-eco-adq.cpp +++ b/src/solver/simulation/common-eco-adq.cpp @@ -139,19 +139,19 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uin for (auto i = area.thermal.mustrunList.begin(); i != end; ++i) { auto& cluster = *(i->second); - + const auto& availableProduction = cluster.series->getAvailablePowerYearly(year); if (inAdequacy && cluster.mustrunOrigin) { for (uint h = 0; h != cluster.series->timeSeries.height; ++h) { - mrs[h] += cluster.series->getAvailablePower(h, year); - adq[h] += cluster.series->getAvailablePower(h, year); + mrs[h] += availableProduction[h]; + adq[h] += availableProduction[h]; } } else { for (uint h = 0; h != cluster.series->timeSeries.height; ++h) - mrs[h] += cluster.series->getAvailablePower(h, year); + mrs[h] += availableProduction[h]; } } } @@ -165,8 +165,9 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uin if (!cluster.mustrunOrigin) continue; + const auto& availableProduction = cluster.series->getAvailablePowerYearly(year); for (uint h = 0; h != cluster.series->timeSeries.height; ++h) - adq[h] += cluster.series->getAvailablePower(h, year); + adq[h] += availableProduction[h]; } } } diff --git a/src/solver/ts-generator/thermal.cpp b/src/solver/ts-generator/thermal.cpp index d7e49b0ac1..9196cfe489 100644 --- a/src/solver/ts-generator/thermal.cpp +++ b/src/solver/ts-generator/thermal.cpp @@ -356,7 +356,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust auto& modulation = cluster.modulation[Data::thermalModulationCapacity]; - Matrix<>::ColumnType* dstSeries = nullptr; + Antares::Data::DataSeriesCommon::SingleYear dstSeries = nullptr; const uint tsCount = nbThermalTimeseries + 2; for (uint tsIndex = 0; tsIndex != tsCount; ++tsIndex) @@ -364,7 +364,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust uint hour = 0; if (tsIndex > 1) - dstSeries = &cluster.series->timeSeries[tsIndex - 2]; + dstSeries = cluster.series->timeSeries[tsIndex - 2]; for (uint dayInTheYear = 0; dayInTheYear < daysPerYear; ++dayInTheYear) { @@ -596,7 +596,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust double AVPDayInTheYear = AVP[dayInTheYear]; for (uint h = 0; h != 24; ++h) { - (*dstSeries)[hour] = Math::Round(AVPDayInTheYear * modulation[hour]); + dstSeries[hour] = Math::Round(AVPDayInTheYear * modulation[hour]); ++hour; } } diff --git a/src/solver/variable/economy/avail-dispatchable-generation.h b/src/solver/variable/economy/avail-dispatchable-generation.h index 8e118a77b8..2df9c4fb60 100644 --- a/src/solver/variable/economy/avail-dispatchable-generation.h +++ b/src/solver/variable/economy/avail-dispatchable-generation.h @@ -196,8 +196,9 @@ class AvailableDispatchGen { for (auto& [name, cluster] : list) { + const auto& availableProduction = cluster->series->getAvailablePowerYearly(year); for (unsigned int hour = 0; hour != cluster->series->timeSeries.height; ++hour) - pValuesForTheCurrentYear[numSpace].hour[hour] += cluster->series->getAvailablePower(hour, year); + pValuesForTheCurrentYear[numSpace].hour[hour] += availableProduction[hour]; } } diff --git a/src/solver/variable/state.cpp b/src/solver/variable/state.cpp index dab81cdd20..726cb1b478 100644 --- a/src/solver/variable/state.cpp +++ b/src/solver/variable/state.cpp @@ -257,6 +257,7 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex) maxDurationON = endHourForCurrentYear; // min, and max unit ON calculation + const auto& availableProduction = currentCluster->series->getAvailablePowerYearly(this->year); for (uint h = startHourForCurrentYear; h < endHourForCurrentYear; ++h) { maxUnitNeeded = 0u; @@ -264,7 +265,7 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex) ON_max[h] = 0u; // Getting available production from cluster data - double thermalClusterAvailableProduction = currentCluster->series->getAvailablePower(h, this->year); + double thermalClusterAvailableProduction = availableProduction[h]; double thermalClusterProduction = 0.; if (currentCluster->mustrun) {