From f23b312bd3be06d29b3ff1ba9363f98bfc602084 Mon Sep 17 00:00:00 2001 From: guilpier-code <62292552+guilpier-code@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:51:26 +0200 Subject: [PATCH] Add getValue for thermal clusters, remove State::timeSeriesIndex (#1644) * Ramove global NumeroChroniquesTireesParPays : removing from class State * Move DataSeriesMemoryUsage to series.cpp * Move DataSeriesMemoryUsage to class * Use DataSeriesCommon::getValue for thermal * Fix index * Remove some uses of ThermiqueParPalier * [DEV] Add arg year in prepareClustersInMustRunMode * [FIX] Segfault by using getValue() * [DEV] Renamed getValue by getAvailablePower * [DEV] Add getSeriesIndex * [FIX] segfault with getSeriesIndex * [FIX] getseriesindex * [DEV] getMarketBidCost now takes hour and year * [DEV] use correct size, remove numspace from args * [FIX] size * [DEV] private getSeriesIndex * [DEV] remove ThermiqueParPalier * [FIX] post_process --------- Co-authored-by: Florian OMNES Co-authored-by: Vincent Payet --- src/libs/antares/study/CMakeLists.txt | 1 - .../antares/study/parts/common/series.cpp | 16 +++++++ src/libs/antares/study/parts/common/series.h | 17 ++++---- .../antares/study/parts/common/series.hxx | 42 ------------------- .../antares/study/parts/renewable/cluster.cpp | 2 +- .../antares/study/parts/thermal/cluster.cpp | 6 ++- .../antares/study/parts/thermal/cluster.h | 2 +- .../alea_tirage_au_sort_chroniques.cpp | 24 ----------- .../optimisation/post_process_commands.cpp | 14 ++----- src/solver/simulation/adequacy.cpp | 6 +-- src/solver/simulation/adequacy.h | 2 +- src/solver/simulation/common-eco-adq.cpp | 39 ++++++----------- src/solver/simulation/common-eco-adq.h | 6 +-- src/solver/simulation/economy.cpp | 6 +-- src/solver/simulation/economy.h | 2 +- .../simulation/sim_allocation_tableaux.cpp | 2 - src/solver/simulation/sim_structure_donnees.h | 1 - src/solver/simulation/solver.hxx | 2 +- .../economy/avail-dispatchable-generation.h | 22 +++------- .../economy/productionByRenewablePlant.h | 2 +- src/solver/variable/economy/profitByPlant.h | 2 +- .../variable/economy/renewableGeneration.h | 2 +- src/solver/variable/state.cpp | 11 ++--- src/solver/variable/state.h | 2 - src/solver/variable/state.hxx | 1 - 25 files changed, 72 insertions(+), 160 deletions(-) delete mode 100644 src/libs/antares/study/parts/common/series.hxx diff --git a/src/libs/antares/study/CMakeLists.txt b/src/libs/antares/study/CMakeLists.txt index 700b6aff2e..b4db365a29 100644 --- a/src/libs/antares/study/CMakeLists.txt +++ b/src/libs/antares/study/CMakeLists.txt @@ -59,7 +59,6 @@ source_group("study\\area\\ui" FILES ${SRC_STUDY_AREA_UI}) set(SRC_STUDY_PART_COMMON parts/common/series.h - parts/common/series.hxx parts/common/series.cpp parts/common/cluster.cpp parts/common/cluster.h diff --git a/src/libs/antares/study/parts/common/series.cpp b/src/libs/antares/study/parts/common/series.cpp index 1d0022078c..214dd1ea21 100644 --- a/src/libs/antares/study/parts/common/series.cpp +++ b/src/libs/antares/study/parts/common/series.cpp @@ -48,6 +48,22 @@ void DataSeriesCommon::markAsModified() const timeSeries.markAsModified(); } +uint64_t DataSeriesCommon::memoryUsage() const +{ + return timeSeries.memoryUsage(); +} + +double DataSeriesCommon::getAvailablePower(unsigned int hour, unsigned int year) const +{ + return timeSeries[getSeriesIndex(year)][hour]; +} +uint DataSeriesCommon::getSeriesIndex(unsigned int year) const +{ + if (timeSeries.width == 1) + return 0; + else + return timeseriesNumbers[0][year]; +} } // namespace Antares::Data diff --git a/src/libs/antares/study/parts/common/series.h b/src/libs/antares/study/parts/common/series.h index c5ac2d52f4..808fb98e3c 100644 --- a/src/libs/antares/study/parts/common/series.h +++ b/src/libs/antares/study/parts/common/series.h @@ -30,9 +30,7 @@ #include #include "../../fwd.h" -namespace Antares -{ -namespace Data +namespace Antares::Data { /*! ** \brief Data series (Common) @@ -44,7 +42,10 @@ class DataSeriesCommon void markAsModified() const; -public: + uint64_t memoryUsage() const; + + double getAvailablePower(unsigned int hour, unsigned int year) const; + /*! ** \brief Series (MW) ** @@ -56,10 +57,10 @@ class DataSeriesCommon ** \brief Monte-Carlo */ Matrix timeseriesNumbers; -}; // class DataSeriesCommon -} // namespace Data -} // namespace Antares -#include "series.hxx" +private: + uint getSeriesIndex(unsigned int year) const; +}; // class DataSeriesCommon +} // namespace Antares::Data #endif /* __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__ */ diff --git a/src/libs/antares/study/parts/common/series.hxx b/src/libs/antares/study/parts/common/series.hxx deleted file mode 100644 index b589e56532..0000000000 --- a/src/libs/antares/study/parts/common/series.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_HXX__ -#define __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_HXX__ - -namespace Antares -{ -namespace Data -{ -inline uint64_t DataSeriesMemoryUsage(DataSeriesCommon* t) -{ - return (t) ? t->timeSeries.memoryUsage() : 0; -} - -} // namespace Data -} // namespace Antares - -#endif // __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_HXX__ diff --git a/src/libs/antares/study/parts/renewable/cluster.cpp b/src/libs/antares/study/parts/renewable/cluster.cpp index 2a1f12b276..6dbfbdff48 100644 --- a/src/libs/antares/study/parts/renewable/cluster.cpp +++ b/src/libs/antares/study/parts/renewable/cluster.cpp @@ -222,7 +222,7 @@ uint64_t RenewableCluster::memoryUsage() const { uint64_t amount = sizeof(RenewableCluster); if (series) - amount += DataSeriesMemoryUsage(series); + amount += series->memoryUsage(); return amount; } diff --git a/src/libs/antares/study/parts/thermal/cluster.cpp b/src/libs/antares/study/parts/thermal/cluster.cpp index fb261e8bc7..a6c8c49d6d 100644 --- a/src/libs/antares/study/parts/thermal/cluster.cpp +++ b/src/libs/antares/study/parts/thermal/cluster.cpp @@ -648,7 +648,7 @@ uint64_t ThermalCluster::memoryUsage() const if (prepro) amount += prepro->memoryUsage(); if (series) - amount += DataSeriesMemoryUsage(series); + amount += series->memoryUsage(); amount += ecoInput.memoryUsage(); return amount; } @@ -770,8 +770,10 @@ double ThermalCluster::getMarginalCost(uint serieIndex, uint hourInTheYear) cons inside -> that is used for all (e.g.10) TS*/ } -double ThermalCluster::getMarketBidCost(uint serieIndex, uint hourInTheYear) const +double ThermalCluster::getMarketBidCost(uint hourInTheYear, uint year) const { + uint serieIndex = (series->timeSeries.width == 1) ? 0 : series->timeseriesNumbers[0][year]; + double mod = modulation[thermalModulationMarketBid][serieIndex]; if (costgeneration == Data::setManually) diff --git a/src/libs/antares/study/parts/thermal/cluster.h b/src/libs/antares/study/parts/thermal/cluster.h index 14120c906b..a75ce10a00 100644 --- a/src/libs/antares/study/parts/thermal/cluster.h +++ b/src/libs/antares/study/parts/thermal/cluster.h @@ -224,7 +224,7 @@ class ThermalCluster final : public Cluster, public std::enable_shared_from_this double getOperatingCost(uint tsIndex, uint hourInTheYear) const; double getMarginalCost(uint tsIndex, uint hourInTheYear) const; - double getMarketBidCost(uint tsIndex, uint hourInTheYear) const; + double getMarketBidCost(uint hourInTheYear, uint year) const; // Check & correct availability timeseries for thermal availability // Only applies if time-series are ready-made diff --git a/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp b/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp index b39a83fd76..a1c3c6a87e 100644 --- a/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp +++ b/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp @@ -93,30 +93,6 @@ void ApplyRandomTSnumbers(const Study& study, : 0; // zero-based } } - - // Thermal - { - auto end = area.thermal.list.mapping.end(); - for (auto it = area.thermal.list.mapping.begin(); it != end; ++it) - { - ThermalClusterList::SharedPtr cluster = it->second; - - if (!cluster->enabled) - { - continue; - } - - const auto& data = *cluster->series; - assert(year < data.timeseriesNumbers.height); - unsigned int clusterIndex = cluster->areaWideIndex; - - // the matrix data.series should be properly initialized at this stage - // because the ts-generator has already been launched - ptchro.ThermiqueParPalier[clusterIndex] = (data.timeSeries.width != 1) - ? (long)data.timeseriesNumbers[0][year] - : 0; // zero-based - } - } // thermal } // each area // ------------------------------ diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 27c571288d..ecdc94b6ff 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -21,7 +21,7 @@ DispatchableMarginPostProcessCmd::DispatchableMarginPostProcessCmd(PROBLEME_HEBD void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime_data) { unsigned int hourInYear = opt_runtime_data.hourInTheYear; - + unsigned int year = opt_runtime_data.year; area_list_.each([&](Data::Area& area) { double* dtgmrg = area.scratchpad[thread_number_].dispatchableGenerationMargin; for (uint h = 0; h != nbHoursInWeek; ++h) @@ -30,23 +30,17 @@ void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime if (not area.thermal.list.empty()) { auto& hourlyResults = problemeHebdo_->ResultatsHoraires[area.index]; - auto end = area.thermal.list.end(); + auto end = area.thermal.list.end(); for (auto i = area.thermal.list.begin(); i != end; ++i) { auto& cluster = *(i->second); - uint chro = NumeroChroniquesTireesParPays[thread_number_][area.index] - .ThermiqueParPalier[cluster.areaWideIndex]; - auto& matrix = cluster.series->timeSeries; - assert(chro < matrix.width); - auto& column = matrix.entry[chro]; - assert(hourInYear + nbHoursInWeek <= matrix.height && "index out of bounds"); - for (uint h = 0; h != nbHoursInWeek; ++h) { double production = hourlyResults.ProductionThermique[h] .ProductionThermiqueDuPalier[cluster.index]; - dtgmrg[h] += column[h + hourInYear] - production; + double availability = cluster.series->getAvailablePower(h + hourInYear, year); + dtgmrg[h] += availability - production; } } } diff --git a/src/solver/simulation/adequacy.cpp b/src/solver/simulation/adequacy.cpp index bb2c6b9536..73e11c3ffa 100644 --- a/src/solver/simulation/adequacy.cpp +++ b/src/solver/simulation/adequacy.cpp @@ -152,7 +152,7 @@ bool Adequacy::year(Progression::Task& progression, numSpace, hourInTheYear, hydroVentilationResults); BuildThermalPartOfWeeklyProblem(study, pProblemesHebdo[numSpace], - numSpace, hourInTheYear, randomForYear.pThermalNoisesByArea); + hourInTheYear, randomForYear.pThermalNoisesByArea, state.year); // Reinit optimisation if needed pProblemesHebdo[numSpace].ReinitOptimisation = reinitOptim; @@ -386,9 +386,9 @@ void Adequacy::simulationEnd() } } -void Adequacy::prepareClustersInMustRunMode(uint numSpace) +void Adequacy::prepareClustersInMustRunMode(uint numSpace, uint year) { - PrepareDataFromClustersInMustrunMode(study, numSpace); + PrepareDataFromClustersInMustrunMode(study, numSpace, year); } } // namespace Antares::Solver::Simulation diff --git a/src/solver/simulation/adequacy.h b/src/solver/simulation/adequacy.h index 34c393393e..8832670f1a 100644 --- a/src/solver/simulation/adequacy.h +++ b/src/solver/simulation/adequacy.h @@ -92,7 +92,7 @@ class Adequacy /*! ** \brief Prepare clusters in 'must-run' mode */ - void prepareClustersInMustRunMode(uint numSpace); + void prepareClustersInMustRunMode(uint numSpace, uint year); void initializeState(Variable::State& state, uint numSpace); diff --git a/src/solver/simulation/common-eco-adq.cpp b/src/solver/simulation/common-eco-adq.cpp index 76b5d2545f..588cb748d2 100644 --- a/src/solver/simulation/common-eco-adq.cpp +++ b/src/solver/simulation/common-eco-adq.cpp @@ -117,7 +117,7 @@ static void RecalculDesEchangesMoyens(Data::Study& study, } } -void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace) +void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uint year) { bool inAdequacy = (study.parameters.mode == Data::stdmAdequacy); @@ -130,7 +130,6 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace) if (inAdequacy) memset(scratchpad.originalMustrunSum, 0, sizeof(double) * HOURS_PER_YEAR); - auto& PtChro = NumeroChroniquesTireesParPays[numSpace][i]; double* mrs = scratchpad.mustrunSum; double* adq = scratchpad.originalMustrunSum; @@ -140,25 +139,19 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace) for (auto i = area.thermal.mustrunList.begin(); i != end; ++i) { auto& cluster = *(i->second); - auto& series = cluster.series->timeSeries; - uint tsIndex = static_cast(PtChro.ThermiqueParPalier[cluster.areaWideIndex]); - if (tsIndex >= series.width) - tsIndex = 0; - - auto& column = series[tsIndex]; if (inAdequacy && cluster.mustrunOrigin) { - for (uint h = 0; h != series.height; ++h) + for (uint h = 0; h != cluster.series->timeSeries.height; ++h) { - mrs[h] += column[h]; - adq[h] += column[h]; + mrs[h] += cluster.series->getAvailablePower(h, year); + adq[h] += cluster.series->getAvailablePower(h, year); } } else { - for (uint h = 0; h != series.height; ++h) - mrs[h] += column[h]; + for (uint h = 0; h != cluster.series->timeSeries.height; ++h) + mrs[h] += cluster.series->getAvailablePower(h, year); } } } @@ -172,14 +165,8 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace) if (!cluster.mustrunOrigin) continue; - auto& series = cluster.series->timeSeries; - uint tsIndex = static_cast(PtChro.ThermiqueParPalier[cluster.areaWideIndex]); - if (tsIndex >= series.width) - tsIndex = 0; - - auto& column = series[tsIndex]; - for (uint h = 0; h != series.height; ++h) - adq[h] += column[h]; + for (uint h = 0; h != cluster.series->timeSeries.height; ++h) + adq[h] += cluster.series->getAvailablePower(h, year); } } } @@ -385,9 +372,9 @@ void PrepareRandomNumbers(Data::Study& study, void BuildThermalPartOfWeeklyProblem(Data::Study& study, PROBLEME_HEBDO& problem, - uint numSpace, const int PasDeTempsDebut, - double** thermalNoises) + double** thermalNoises, + unsigned int year) { int hourInYear = PasDeTempsDebut; const uint nbPays = study.areas.size(); @@ -396,19 +383,17 @@ void BuildThermalPartOfWeeklyProblem(Data::Study& study, for (uint areaIdx = 0; areaIdx < nbPays; ++areaIdx) { auto& area = *study.areas.byIndex[areaIdx]; - auto& tsIndex = NumeroChroniquesTireesParPays[numSpace][areaIdx]; area.thermal.list.each([&](const Data::ThermalCluster& cluster) { auto& Pt = problem.PaliersThermiquesDuPays[areaIdx] .PuissanceDisponibleEtCout[cluster.index]; Pt.CoutHoraireDeProductionDuPalierThermique[hourInWeek] = - cluster.getMarketBidCost(tsIndex.ThermiqueParPalier[cluster.areaWideIndex], hourInYear) + cluster.getMarketBidCost(hourInYear, year) + thermalNoises[areaIdx][cluster.areaWideIndex]; Pt.PuissanceDisponibleDuPalierThermique[hourInWeek] - = cluster.series - ->timeSeries[tsIndex.ThermiqueParPalier[cluster.areaWideIndex]][hourInYear]; + = cluster.series->getAvailablePower(hourInYear, year); Pt.PuissanceMinDuPalierThermique[hourInWeek] = (Pt.PuissanceDisponibleDuPalierThermique[hourInWeek] < cluster.PthetaInf[hourInYear]) diff --git a/src/solver/simulation/common-eco-adq.h b/src/solver/simulation/common-eco-adq.h index 91b4a0b175..3d1f47c3b0 100644 --- a/src/solver/simulation/common-eco-adq.h +++ b/src/solver/simulation/common-eco-adq.h @@ -64,14 +64,14 @@ void PrepareRandomNumbers(Data::Study& study, void BuildThermalPartOfWeeklyProblem(Data::Study& study, PROBLEME_HEBDO& problem, - uint numSpace, const int PasDeTempsDebut, - double** thermalNoises); + double** thermalNoises, + unsigned int year); /*! ** \brief Prepare data from clusters in mustrun mode (eco+adq) */ -void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace); +void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uint year); /*! ** \brief Get if the quadratic optimization should be used according diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index 2f530b2f70..5caaf948fe 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -147,7 +147,7 @@ bool Economy::year(Progression::Task& progression, numSpace, hourInTheYear, hydroVentilationResults); BuildThermalPartOfWeeklyProblem(study, pProblemesHebdo[numSpace], - numSpace, hourInTheYear, randomForYear.pThermalNoisesByArea); + hourInTheYear, randomForYear.pThermalNoisesByArea, state.year); // Reinit optimisation if needed pProblemesHebdo[numSpace].ReinitOptimisation = reinitOptim; @@ -264,9 +264,9 @@ void Economy::simulationEnd() } } -void Economy::prepareClustersInMustRunMode(uint numSpace) +void Economy::prepareClustersInMustRunMode(uint numSpace, uint year) { - PrepareDataFromClustersInMustrunMode(study, numSpace); + PrepareDataFromClustersInMustrunMode(study, numSpace, year); } } // namespace Antares::Solver::Simulation diff --git a/src/solver/simulation/economy.h b/src/solver/simulation/economy.h index f9446a51a4..7eb8c174f5 100644 --- a/src/solver/simulation/economy.h +++ b/src/solver/simulation/economy.h @@ -93,7 +93,7 @@ class Economy /*! ** \brief Prepare clusters in 'must-run' mode */ - void prepareClustersInMustRunMode(uint numSpace); + void prepareClustersInMustRunMode(uint numSpace, uint year); void initializeState(Variable::State& state, uint numSpace); diff --git a/src/solver/simulation/sim_allocation_tableaux.cpp b/src/solver/simulation/sim_allocation_tableaux.cpp index ae4734862d..95003fc8f5 100644 --- a/src/solver/simulation/sim_allocation_tableaux.cpp +++ b/src/solver/simulation/sim_allocation_tableaux.cpp @@ -53,8 +53,6 @@ void SIM_AllocationTableaux(const Data::Study& study) { auto& area = *study.areas.byIndex[i]; - NumeroChroniquesTireesParPays[numSpace][i].ThermiqueParPalier - .assign(area.thermal.clusterCount(), 0); NumeroChroniquesTireesParPays[numSpace][i].RenouvelableParPalier .assign(area.renewable.clusterCount(), 0); } diff --git a/src/solver/simulation/sim_structure_donnees.h b/src/solver/simulation/sim_structure_donnees.h index 5356732f63..cdcdc9f0b1 100644 --- a/src/solver/simulation/sim_structure_donnees.h +++ b/src/solver/simulation/sim_structure_donnees.h @@ -31,7 +31,6 @@ typedef struct { - std::vector ThermiqueParPalier; std::vector RenouvelableParPalier; int Hydraulique; int Eolien; diff --git a/src/solver/simulation/solver.hxx b/src/solver/simulation/solver.hxx index 3e574aac15..177a2147fa 100644 --- a/src/solver/simulation/solver.hxx +++ b/src/solver/simulation/solver.hxx @@ -157,7 +157,7 @@ private: ApplyRandomTSnumbers(study, y, numSpace); // 3 - Preparing data related to Clusters in 'must-run' mode - simulation_->prepareClustersInMustRunMode(numSpace); + simulation_->prepareClustersInMustRunMode(numSpace, y); // 4 - Hydraulic ventilation { diff --git a/src/solver/variable/economy/avail-dispatchable-generation.h b/src/solver/variable/economy/avail-dispatchable-generation.h index 82c9ce5b86..8e118a77b8 100644 --- a/src/solver/variable/economy/avail-dispatchable-generation.h +++ b/src/solver/variable/economy/avail-dispatchable-generation.h @@ -192,22 +192,12 @@ class AvailableDispatchGen NextType::simulationEnd(); } - void addThermalClusterList(Data::ThermalClusterList& list, unsigned int numSpace) + void addThermalClusterList(Data::ThermalClusterList& list, unsigned int year, unsigned int numSpace) { - typedef Matrix MatrixType; - - const Data::ThermalClusterList::const_iterator end = list.end(); - for (Data::ThermalClusterList::const_iterator i = list.begin(); i != end; ++i) + for (auto& [name, cluster] : list) { - Data::ThermalCluster& cluster = *(i->second); - unsigned int chro = NumeroChroniquesTireesParPays[numSpace][pArea->index] - .ThermiqueParPalier[cluster.areaWideIndex]; - const MatrixType& matrix = cluster.series->timeSeries; - assert(chro < matrix.width); - const MatrixType::ColumnType& column = matrix.entry[chro]; - - for (unsigned int y = 0; y != matrix.height; ++y) - pValuesForTheCurrentYear[numSpace].hour[y] += column[y]; + for (unsigned int hour = 0; hour != cluster->series->timeSeries.height; ++hour) + pValuesForTheCurrentYear[numSpace].hour[hour] += cluster->series->getAvailablePower(hour, year); } } @@ -216,8 +206,8 @@ class AvailableDispatchGen // Somme de toutes les productions disponibles pour l'ensemble des // paliers thermiques (+must-run) pValuesForTheCurrentYear[numSpace].reset(); - addThermalClusterList(pArea->thermal.list, numSpace); - addThermalClusterList(pArea->thermal.mustrunList, numSpace); + addThermalClusterList(pArea->thermal.list, year, numSpace); + addThermalClusterList(pArea->thermal.mustrunList, year, numSpace); // Next variable NextType::yearBegin(year, numSpace); diff --git a/src/solver/variable/economy/productionByRenewablePlant.h b/src/solver/variable/economy/productionByRenewablePlant.h index 84589ea1f2..b2ce04306e 100644 --- a/src/solver/variable/economy/productionByRenewablePlant.h +++ b/src/solver/variable/economy/productionByRenewablePlant.h @@ -280,7 +280,7 @@ class ProductionByRenewablePlant : public Variable::IVariablerenewable.clusterCount(); ++clusterIndex) { const auto* renewableCluster = state.area->renewable.clusters[clusterIndex]; - uint serieIndex = state.timeseriesIndex->RenouvelableParPalier[clusterIndex]; + uint serieIndex = renewableCluster->series->timeseriesNumbers[0][state.year]; double renewableClusterProduction = renewableCluster->valueAtTimeStep(serieIndex, state.hourInTheYear); pValuesForTheCurrentYear[numSpace][renewableCluster->areaWideIndex].hour[state.hourInTheYear] diff --git a/src/solver/variable/economy/profitByPlant.h b/src/solver/variable/economy/profitByPlant.h index 2a8f79cde0..3438b8b387 100644 --- a/src/solver/variable/economy/profitByPlant.h +++ b/src/solver/variable/economy/profitByPlant.h @@ -277,7 +277,7 @@ class ProfitByPlant : public Variable::IVariable, NextT, VC auto* cluster = state.area->thermal.clusters[clusterIndex]; double hourlyClusterProduction = thermal[area->index].thermalClustersProductions[clusterIndex]; - uint tsIndex = state.timeseriesIndex->ThermiqueParPalier[cluster->areaWideIndex]; + uint tsIndex = cluster->series->timeseriesNumbers[0][state.year]; // Thermal cluster profit pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex].hour[hourInTheYear] = (hourlyClusterProduction - cluster->PthetaInf[hourInTheYear]) diff --git a/src/solver/variable/economy/renewableGeneration.h b/src/solver/variable/economy/renewableGeneration.h index 30f5d1f959..a75421e365 100644 --- a/src/solver/variable/economy/renewableGeneration.h +++ b/src/solver/variable/economy/renewableGeneration.h @@ -271,7 +271,7 @@ class RenewableGeneration ++clusterIndex) { const auto* renewableCluster = state.area->renewable.clusters[clusterIndex]; - uint serieIndex = state.timeseriesIndex->RenouvelableParPalier[clusterIndex]; + uint serieIndex = renewableCluster->series->timeseriesNumbers[0][state.year]; double renewableClusterProduction = renewableCluster->valueAtTimeStep(serieIndex, state.hourInTheYear); diff --git a/src/solver/variable/state.cpp b/src/solver/variable/state.cpp index ba85ab103d..dab81cdd20 100644 --- a/src/solver/variable/state.cpp +++ b/src/solver/variable/state.cpp @@ -84,9 +84,8 @@ void State::initFromThermalClusterIndex(const uint clusterAreaWideIndex) // alias to the current thermal cluster thermalCluster = area->thermal.clusters[clusterAreaWideIndex]; - uint serieIndex = timeseriesIndex->ThermiqueParPalier[clusterAreaWideIndex]; double thermalClusterAvailableProduction - = thermalCluster->series->timeSeries[serieIndex][hourInTheYear]; + = thermalCluster->series->getAvailablePower(hourInTheYear, this->year); // Minimum power of a group of the cluster for the current hour in the year double thermalClusterPMinOfAGroup = 0.; @@ -97,7 +96,6 @@ void State::initFromThermalClusterIndex(const uint clusterAreaWideIndex) // directly comes from the time-series // it doen't exist from the solver perspective assert(thermalCluster->series); - assert(timeseriesIndex != NULL); assert(hourInTheYear < thermalCluster->series->timeSeries.height); thermal[area->index].thermalClustersProductions[clusterAreaWideIndex] @@ -157,7 +155,7 @@ void State::initFromThermalClusterIndex(const uint clusterAreaWideIndex) void State::initFromThermalClusterIndexProduction(const uint clusterAreaWideIndex) { - uint serieIndex = timeseriesIndex->ThermiqueParPalier[clusterAreaWideIndex]; + uint serieIndex = thermalCluster->series->timeseriesNumbers[0][this->year]; if (thermal[area->index].thermalClustersProductions[clusterAreaWideIndex] > 0.) { @@ -242,13 +240,11 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex) // Get cluster properties Data::ThermalCluster* currentCluster = area->thermal.clusters[clusterAreaWideIndex]; - uint serieIndex = timeseriesIndex->ThermiqueParPalier[clusterAreaWideIndex]; assert(endHourForCurrentYear <= Variable::maxHoursInAYear); assert(endHourForCurrentYear <= currentCluster->series->timeSeries.height); assert(currentCluster); assert(currentCluster->series); - assert(timeseriesIndex != NULL); if (currentCluster->fixedCost > 0.) { @@ -268,7 +264,7 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex) ON_max[h] = 0u; // Getting available production from cluster data - double thermalClusterAvailableProduction = currentCluster->series->timeSeries[serieIndex][h]; + double thermalClusterAvailableProduction = currentCluster->series->getAvailablePower(h, this->year); double thermalClusterProduction = 0.; if (currentCluster->mustrun) { @@ -287,6 +283,7 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex) if (thermalClusterProduction <= 0.) continue; + uint serieIndex = currentCluster->series->timeseriesNumbers[0][this->year]; thermalClusterOperatingCostForYear[h] = thermalClusterProduction * currentCluster->getOperatingCost(serieIndex, h); diff --git a/src/solver/variable/state.h b/src/solver/variable/state.h index 1a66522607..7969a41906 100644 --- a/src/solver/variable/state.h +++ b/src/solver/variable/state.h @@ -206,8 +206,6 @@ class State //! Probleme Hebdo PROBLEME_HEBDO* problemeHebdo; - //! The timeseries indexes for the current area - NUMERO_CHRONIQUES_TIREES_PAR_PAYS* timeseriesIndex; //! Study mode: economy / adequacy Data::StudyMode studyMode; //! Study unit commitment mode: fast(ucHeuristic) / accurate(ucMILP) diff --git a/src/solver/variable/state.hxx b/src/solver/variable/state.hxx index 69645d0af5..dca9b0a9b5 100644 --- a/src/solver/variable/state.hxx +++ b/src/solver/variable/state.hxx @@ -73,7 +73,6 @@ inline void State::initFromAreaIndex(const unsigned int areaIndex, uint numSpace area = study.areas[areaIndex]; scratchpad = &area->scratchpad[numSpace]; thermalCluster = nullptr; - timeseriesIndex = &NumeroChroniquesTireesParPays[numSpace][areaIndex]; switch (studyMode) {