From 7b6310c7bcf954f3ce1ee1b805764752973c1209 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 19 Jul 2024 16:40:40 +0200 Subject: [PATCH] thermal cluster prepro --- .../include/antares/study/parts/thermal/cluster.h | 4 ++-- src/libs/antares/study/include/antares/study/study.h | 2 -- .../antares/study/include/antares/study/study.hxx | 3 --- src/libs/antares/study/parts/thermal/cluster.cpp | 9 ++------- .../antares/study/parts/thermal/cluster_list.cpp | 2 +- src/libs/antares/study/study.cpp | 12 ------------ src/solver/ts-generator/availability.cpp | 2 +- .../datagrid/renderer/area/thermalprepro.cpp | 2 +- 8 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h b/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h index 7d1ce30bac..b7efcc29ec 100644 --- a/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h +++ b/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h @@ -115,7 +115,7 @@ class ThermalCluster final: public Cluster, public std::enable_shared_from_this< explicit ThermalCluster(Data::Area* parent); ThermalCluster() = delete; - ~ThermalCluster(); + ~ThermalCluster() = default; /*! ** \brief Invalidate all data associated to the thermal cluster @@ -353,7 +353,7 @@ class ThermalCluster final: public Cluster, public std::enable_shared_from_this< std::vector PthetaInf; //! Data for the preprocessor - PreproAvailability* prepro = nullptr; + std::shared_ptr prepro; /*! ** \brief Production Cost, Market Bid Cost and Marginal Cost Matrixes - Per Hour and per Time diff --git a/src/libs/antares/study/include/antares/study/study.h b/src/libs/antares/study/include/antares/study/study.h index c7a5382c19..2821e225a5 100644 --- a/src/libs/antares/study/include/antares/study/study.h +++ b/src/libs/antares/study/include/antares/study/study.h @@ -363,8 +363,6 @@ class Study: public Yuni::NonCopyable, public LayerData void destroyAllWindTSGeneratorData(); //! Destroy all data of the hydro TS generator void destroyAllHydroTSGeneratorData(); - //! Destroy all data of the thermal TS generator - void destroyAllThermalTSGeneratorData(); /*! ** \brief Import all time-series into the input folder diff --git a/src/libs/antares/study/include/antares/study/study.hxx b/src/libs/antares/study/include/antares/study/study.hxx index 9f0053d0a4..5c1ad58282 100644 --- a/src/libs/antares/study/include/antares/study/study.hxx +++ b/src/libs/antares/study/include/antares/study/study.hxx @@ -53,9 +53,6 @@ inline void Study::destroyTSGeneratorData() case TimeSeriesType::timeSeriesHydro: destroyAllHydroTSGeneratorData(); break; - case TimeSeriesType::timeSeriesThermal: - destroyAllThermalTSGeneratorData(); - break; default: break; } diff --git a/src/libs/antares/study/parts/thermal/cluster.cpp b/src/libs/antares/study/parts/thermal/cluster.cpp index da502ac29e..da27869de8 100644 --- a/src/libs/antares/study/parts/thermal/cluster.cpp +++ b/src/libs/antares/study/parts/thermal/cluster.cpp @@ -129,11 +129,6 @@ Data::ThermalCluster::ThermalCluster(Area* parent): assert(parent && "A parent for a thermal dispatchable cluster can not be null"); } -Data::ThermalCluster::~ThermalCluster() -{ - delete prepro; -} - uint ThermalCluster::groupId() const { return groupID; @@ -202,7 +197,7 @@ void Data::ThermalCluster::copyFrom(const ThermalCluster& cluster) // prepro if (!prepro) { - prepro = new PreproAvailability(id(), unitCount); + prepro = std::make_shared(id(), unitCount); } prepro->copyFrom(*cluster.prepro); @@ -477,7 +472,7 @@ void Data::ThermalCluster::reset() // we must simply reset their content. if (!prepro) { - prepro = new PreproAvailability(id(), unitCount); + prepro = std::make_shared(id(), unitCount); } prepro->reset(); diff --git a/src/libs/antares/study/parts/thermal/cluster_list.cpp b/src/libs/antares/study/parts/thermal/cluster_list.cpp index 8435870d0a..43251321c3 100644 --- a/src/libs/antares/study/parts/thermal/cluster_list.cpp +++ b/src/libs/antares/study/parts/thermal/cluster_list.cpp @@ -388,7 +388,7 @@ void ThermalClusterList::ensureDataPrepro() { if (!c->prepro) { - c->prepro = new PreproAvailability(c->id(), c->unitCount); + c->prepro = std::make_shared(c->id(), c->unitCount); } } } diff --git a/src/libs/antares/study/study.cpp b/src/libs/antares/study/study.cpp index 3f22be34bc..2ef5ccc5dd 100644 --- a/src/libs/antares/study/study.cpp +++ b/src/libs/antares/study/study.cpp @@ -1104,18 +1104,6 @@ void Study::destroyAllWindTSGeneratorData() areas.each([](Data::Area& area) { FreeAndNil(area.wind.prepro); }); } -void Study::destroyAllThermalTSGeneratorData() -{ - areas.each( - [](const Data::Area& area) - { - for (const auto& cluster: area.thermal.list.each_enabled_and_not_mustrun()) - { - FreeAndNil(cluster->prepro); - } - }); -} - void Study::ensureDataAreLoadedForAllBindingConstraints() { for (const auto& constraint: bindingConstraints) diff --git a/src/solver/ts-generator/availability.cpp b/src/solver/ts-generator/availability.cpp index a94fd99e46..1ac5e7675b 100644 --- a/src/solver/ts-generator/availability.cpp +++ b/src/solver/ts-generator/availability.cpp @@ -38,7 +38,7 @@ AvailabilityTSGeneratorData::AvailabilityTSGeneratorData(Data::ThermalCluster* c plannedVolatility(cluster->plannedVolatility), forcedLaw(cluster->forcedLaw), plannedLaw(cluster->plannedLaw), - prepro(cluster->prepro), + prepro(cluster->prepro.get()), modulationCapacity(cluster->modulation[Data::thermalModulationCapacity]), name(cluster->name()) { diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermalprepro.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermalprepro.cpp index 4c39002613..d169a59f91 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermalprepro.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermalprepro.cpp @@ -183,7 +183,7 @@ bool ThermalClusterPrepro::cellValue(int x, int y, const String& value) void ThermalClusterPrepro::internalThermalClusterChanged(Antares::Data::ThermalCluster* cluster) { pCluster = cluster; - pPreproAvailability = (cluster) ? cluster->prepro : nullptr; + pPreproAvailability = (cluster) ? cluster->prepro.get() : nullptr; MatrixAncestorType::matrix((pPreproAvailability) ? &pPreproAvailability->data : nullptr); onRefresh(); }