From 976acd476541b6a6e1649b6af5f2602d2414db6b Mon Sep 17 00:00:00 2001 From: Guillaume PIERRE Date: Mon, 11 Sep 2023 17:14:37 +0200 Subject: [PATCH] Move economic thermal costs input files into series directory --- src/libs/antares/study/area/list.cpp | 1 + .../study/parts/common/cluster_list.cpp | 30 +++-------------- .../study/parts/thermal/cluster_list.cpp | 33 ++++++++++++++----- .../study/parts/thermal/cluster_list.h | 2 ++ 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 53f1c40f5cf..85655722507 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -936,6 +936,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, ret = area.thermal.list.loadPreproFromFolder(study, options, buffer) && ret; buffer.clear() << study.folderInput << SEP << "thermal" << SEP << "series"; ret = area.thermal.list.loadDataSeriesFromFolder(study, options, buffer) && ret; + ret = area.thermal.list.loadEconomicCosts(study, buffer) && ret; // In adequacy mode, all thermal clusters must be in 'mustrun' mode if (study.usedByTheSolver && study.parameters.mode == stdmAdequacy) diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index b28b495d781..6f5b85dbc42 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -368,17 +368,17 @@ int ClusterList::saveDataSeriesToFolder(const AnyString& folder, const return ret; } -template<> -int ClusterList::loadDataSeriesFromFolder(Study& s, - const StudyLoadOptions& options, - const AnyString& folder) +template +int ClusterList::loadDataSeriesFromFolder(Study& s, + const StudyLoadOptions& options, + const AnyString& folder) { if (empty()) return 1; int ret = 1; - each([&ret, &options, &s, &folder](ThermalCluster& c) { + each([&](ClusterT& c) { if (c.series) ret = c.loadDataSeriesFromFolder(s, folder) and ret; @@ -388,26 +388,6 @@ int ClusterList::loadDataSeriesFromFolder(Study& s, return ret; } -template<> -int ClusterList::loadDataSeriesFromFolder(Study& s, - const StudyLoadOptions& options, - const AnyString& folder) -{ - if (empty()) - return 1; - - int ret = 1; - - each([&](Cluster& cluster) { - if (cluster.series) - ret = cluster.loadDataSeriesFromFolder(s, folder) and ret; - - ++options.progressTicks; - options.pushProgressLogs(); - }); - return ret; -} - template void ClusterList::ensureDataTimeSeries() { diff --git a/src/libs/antares/study/parts/thermal/cluster_list.cpp b/src/libs/antares/study/parts/thermal/cluster_list.cpp index 6d41613f938..3ebc2013fa3 100644 --- a/src/libs/antares/study/parts/thermal/cluster_list.cpp +++ b/src/libs/antares/study/parts/thermal/cluster_list.cpp @@ -493,20 +493,35 @@ bool ThermalClusterList::loadPreproFromFolder(Study& study, ret = result and ret; } - { - assert(c.parentArea and "cluster: invalid parent area"); - buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id(); - - bool result = c.ecoInput.loadFromFolder(study, buffer); - c.ComputeCostTimeSeries(); - - ret = result && ret; - } ++options.progressTicks; options.pushProgressLogs(); } return ret; } + +bool ThermalClusterList::loadEconomicCosts(Study& study, const AnyString& folder) +{ + if (empty()) + return true; + + Clob buffer; + bool ret = true; + + for (auto it = begin(); it != end(); ++it) + { + auto& c = *(it->second); + + assert(c.parentArea and "cluster: invalid parent area"); + buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id(); + + bool result = c.ecoInput.loadFromFolder(study, buffer); + c.ComputeCostTimeSeries(); + + ret = result && ret; + } + return ret; +} + } // namespace Data } // namespace Antares diff --git a/src/libs/antares/study/parts/thermal/cluster_list.h b/src/libs/antares/study/parts/thermal/cluster_list.h index e84849d8a6c..9cdfbd3bf7c 100644 --- a/src/libs/antares/study/parts/thermal/cluster_list.h +++ b/src/libs/antares/study/parts/thermal/cluster_list.h @@ -82,6 +82,8 @@ class ThermalClusterList : public ClusterList */ bool loadPreproFromFolder(Study& s, const StudyLoadOptions& options, const AnyString& folder); + bool loadEconomicCosts(Study& s, const AnyString& folder); + bool savePreproToFolder(const AnyString& folder) const; bool saveToFolder(const AnyString& folder) const override;