From 7c65bf88ece6e42e79cb52c072198f0935ff75f6 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Mon, 1 Jul 2024 17:09:10 +0200 Subject: [PATCH] Fix a few newly-introduced code smells --- .../antares/solver/hydro/management/management.h | 4 ++-- src/solver/hydro/management/PrepareInflows.cpp | 5 ++--- src/solver/hydro/management/management.cpp | 2 +- src/solver/hydro/management/monthly.cpp | 2 +- src/solver/ts-generator/availability.cpp | 10 +++++----- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/solver/hydro/include/antares/solver/hydro/management/management.h b/src/solver/hydro/include/antares/solver/hydro/management/management.h index a8576248b4..8f4cf12d01 100644 --- a/src/solver/hydro/include/antares/solver/hydro/management/management.h +++ b/src/solver/hydro/include/antares/solver/hydro/management/management.h @@ -85,9 +85,9 @@ class HydroManagement final const Antares::Data::Area::ScratchMap& scratchmap, HydroSpecificMap& hydro_specific_map); //! Prepare the effective demand for each area - void prepareEffectiveDemand(uint year, HydroSpecificMap& hydro_specific_map); + void prepareEffectiveDemand(uint year, HydroSpecificMap& hydro_specific_map) const; //! Monthly Optimal generations - void prepareMonthlyOptimalGenerations(double* random_reservoir_level, + void prepareMonthlyOptimalGenerations(const double* random_reservoir_level, uint y, HydroSpecificMap& hydro_specific_map); diff --git a/src/solver/hydro/management/PrepareInflows.cpp b/src/solver/hydro/management/PrepareInflows.cpp index c13d11a64b..01eb38efaf 100644 --- a/src/solver/hydro/management/PrepareInflows.cpp +++ b/src/solver/hydro/management/PrepareInflows.cpp @@ -19,8 +19,7 @@ void PrepareInflows::Run(uint year) void PrepareInflows::LoadInflows(uint year) { areas_.each( - // un-const because now data is a member of area [&](const Data::Area& area) - [&](Data::Area& area) + [this, year](Data::Area& area) { const auto& srcinflows = area.hydro.series->storage.getColumn(year); @@ -69,7 +68,7 @@ void PrepareInflows::LoadInflows(uint year) void PrepareInflows::ChangeInflowsToAccommodateFinalLevels(uint year) { areas_.each( - [this, &year](Data::Area& area) + [&year](Data::Area& area) { auto& data = area.hydro.managementData[year]; diff --git a/src/solver/hydro/management/management.cpp b/src/solver/hydro/management/management.cpp index e4aeecde1e..0ad4d4a357 100644 --- a/src/solver/hydro/management/management.cpp +++ b/src/solver/hydro/management/management.cpp @@ -196,7 +196,7 @@ void HydroManagement::prepareNetDemand(uint year, }); } -void HydroManagement::prepareEffectiveDemand(uint year, HydroSpecificMap& hydro_specific_map) +void HydroManagement::prepareEffectiveDemand(uint year, HydroSpecificMap& hydro_specific_map) const { areas_.each( [this, &year, &hydro_specific_map](Data::Area& area) diff --git a/src/solver/hydro/management/monthly.cpp b/src/solver/hydro/management/monthly.cpp index 684ac4db16..b5a88233ba 100644 --- a/src/solver/hydro/management/monthly.cpp +++ b/src/solver/hydro/management/monthly.cpp @@ -151,7 +151,7 @@ double HydroManagement::prepareMonthlyTargetGenerations( return total; } -void HydroManagement::prepareMonthlyOptimalGenerations(double* random_reservoir_level, +void HydroManagement::prepareMonthlyOptimalGenerations(const double* random_reservoir_level, uint y, HydroSpecificMap& hydro_specific_map) { diff --git a/src/solver/ts-generator/availability.cpp b/src/solver/ts-generator/availability.cpp index 0702c9e7b9..efb5991093 100644 --- a/src/solver/ts-generator/availability.cpp +++ b/src/solver/ts-generator/availability.cpp @@ -612,10 +612,10 @@ std::vector getAllClustersToGen(const Data::AreaList& are return clusters; } -void writeResultsToDisk(const Data::Study& study, - Solver::IResultWriter& writer, - const Matrix<>& series, - const std::string& savePath) +static void writeResultsToDisk(const Data::Study& study, + Solver::IResultWriter& writer, + const Matrix<>& series, + const std::string& savePath) { if (study.parameters.noOutput) { @@ -627,7 +627,7 @@ void writeResultsToDisk(const Data::Study& study, writer.addEntryFromBuffer(savePath, buffer); } -void writeResultsToDisk(const Matrix<>& series, const std::filesystem::path savePath) +static void writeResultsToDisk(const Matrix<>& series, const std::filesystem::path& savePath) { std::string buffer; series.saveToBuffer(buffer, 0);