From 2d129d8e15c6eadf342b117a956e2133e62725ec Mon Sep 17 00:00:00 2001 From: Abdoulbari Zakir Date: Mon, 16 Dec 2024 16:32:02 +0100 Subject: [PATCH] remove unused var and apply clang-format --- .../short-term-storage/AdditionalConstraint.h | 24 +++--- .../study/parts/short-term-storage/cluster.h | 32 ++++---- .../parts/short-term-storage/container.h | 43 +++++----- src/libs/antares/study/runtime/runtime.cpp | 8 +- .../optimisation/constraints/Group1.cpp | 6 +- .../ShortTermStorageCumulation.cpp | 79 ++++++++++--------- .../constraints/ShortTermStorageCumulation.h | 12 ++- ...opt_gestion_second_membre_cas_lineaire.cpp | 13 ++- .../optimisation/opt_rename_problem.cpp | 13 ++- .../simulation/sim_alloc_probleme_hebdo.cpp | 6 +- 10 files changed, 119 insertions(+), 117 deletions(-) diff --git a/src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.h b/src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.h index 85d054dfe8..811c6b6e92 100644 --- a/src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.h +++ b/src/libs/antares/study/include/antares/study/parts/short-term-storage/AdditionalConstraint.h @@ -23,17 +23,19 @@ #include #include -namespace Antares::Data::ShortTermStorage { - struct AdditionalConstraint { - std::string name; - std::string cluster_id; - std::string variable; - std::string operatorType; - std::vector hours; - double rhs; +namespace Antares::Data::ShortTermStorage +{ +struct AdditionalConstraint +{ + std::string name; + std::string cluster_id; + std::string variable; + std::string operatorType; + std::vector hours; + double rhs; - unsigned int globalIndex = 0; + unsigned int globalIndex = 0; - bool validate() const; - }; + bool validate() const; +}; } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/include/antares/study/parts/short-term-storage/cluster.h b/src/libs/antares/study/include/antares/study/parts/short-term-storage/cluster.h index 03c45e04f8..df74a350b0 100644 --- a/src/libs/antares/study/include/antares/study/parts/short-term-storage/cluster.h +++ b/src/libs/antares/study/include/antares/study/parts/short-term-storage/cluster.h @@ -26,29 +26,31 @@ #include +#include "AdditionalConstraint.h" #include "properties.h" #include "series.h" -#include "AdditionalConstraint.h" -namespace Antares::Data::ShortTermStorage { - class STStorageCluster { - public: - bool enabled() const; +namespace Antares::Data::ShortTermStorage +{ +class STStorageCluster +{ +public: + bool enabled() const; - bool validate() const; + bool validate() const; - bool loadFromSection(const IniFile::Section §ion); + bool loadFromSection(const IniFile::Section& section); - bool loadSeries(const std::filesystem::path &folder) const; + bool loadSeries(const std::filesystem::path& folder) const; - void saveProperties(IniFile &ini) const; + void saveProperties(IniFile& ini) const; - bool saveSeries(const std::string &path) const; + bool saveSeries(const std::string& path) const; - std::string id; + std::string id; - std::shared_ptr series = std::make_shared(); - mutable Properties properties; - std::vector additional_constraints; - }; + std::shared_ptr series = std::make_shared(); + mutable Properties properties; + std::vector additional_constraints; +}; } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/include/antares/study/parts/short-term-storage/container.h b/src/libs/antares/study/include/antares/study/parts/short-term-storage/container.h index b087ff738f..d4e0233b5c 100644 --- a/src/libs/antares/study/include/antares/study/parts/short-term-storage/container.h +++ b/src/libs/antares/study/include/antares/study/parts/short-term-storage/container.h @@ -23,36 +23,37 @@ #include #include -#include "cluster.h" #include "AdditionalConstraint.h" +#include "cluster.h" -namespace Antares::Data::ShortTermStorage { - class STStorageInput { - public: - bool validate() const; +namespace Antares::Data::ShortTermStorage +{ +class STStorageInput +{ +public: + bool validate() const; - /// 1. Read list.ini - bool createSTStorageClustersFromIniFile(const std::filesystem::path &path); + /// 1. Read list.ini + bool createSTStorageClustersFromIniFile(const std::filesystem::path& path); - /// 2. Read ALL series - bool loadSeriesFromFolder(const std::filesystem::path &folder) const; + /// 2. Read ALL series + bool loadSeriesFromFolder(const std::filesystem::path& folder) const; - /// Number of enabled ST storages, ignoring disabled ST storages - std::size_t count() const; + /// Number of enabled ST storages, ignoring disabled ST storages + std::size_t count() const; - bool LoadConstraintsFromIniFile(const std::filesystem::path &filePath - ); + bool LoadConstraintsFromIniFile(const std::filesystem::path& filePath); - /// erase disabled cluster from the vector - uint removeDisabledClusters(); + /// erase disabled cluster from the vector + uint removeDisabledClusters(); - bool saveToFolder(const std::string &folder) const; + bool saveToFolder(const std::string& folder) const; - bool saveDataSeriesToFolder(const std::string &folder) const; + bool saveDataSeriesToFolder(const std::string& folder) const; - std::vector storagesByIndex; + std::vector storagesByIndex; - /// Number cumulative - constraint - std::size_t cumulativeConstraintCount() const; - }; + /// Number cumulative - constraint + std::size_t cumulativeConstraintCount() const; +}; } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index 0c4daeefb4..32bfb0f28e 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -94,8 +94,8 @@ static void StudyRuntimeInfosInitializeAllAreas(Study& study, StudyRuntimeInfos& r.thermalPlantTotalCountMustRun += area.thermal.list.enabledAndMustRunCount(); r.shortTermStorageCount += area.shortTermStorage.count(); - r.shortTermStorageCumulativeConstraintCount += area.shortTermStorage. - cumulativeConstraintCount(); + r.shortTermStorageCumulativeConstraintCount += area.shortTermStorage + .cumulativeConstraintCount(); } } @@ -365,8 +365,8 @@ bool StudyRuntimeInfos::loadFromStudy(Study& study) logs.info() << " thermal clusters: " << thermalPlantTotalCount; logs.info() << " thermal clusters (must-run): " << thermalPlantTotalCountMustRun; logs.info() << " short-term storages: " << shortTermStorageCount; - logs.info() << " short-term storage cumulative constraints count: " << - shortTermStorageCumulativeConstraintCount; + logs.info() << " short-term storage cumulative constraints count: " + << shortTermStorageCumulativeConstraintCount; logs.info() << " binding constraints: " << study.bindingConstraints.activeConstraints().size(); logs.info() << " geographic trimming:" << (gd.geographicTrimming ? "true" : "false"); diff --git a/src/solver/optimisation/constraints/Group1.cpp b/src/solver/optimisation/constraints/Group1.cpp index 6c9620f3e0..be8383d822 100644 --- a/src/solver/optimisation/constraints/Group1.cpp +++ b/src/solver/optimisation/constraints/Group1.cpp @@ -52,11 +52,9 @@ ShortTermStorageData Group1::GetShortTermStorageData() ShortTermStorageCumulativeConstraintData Group1::GetShortTermStorageCumulativeConstraintData() { - return { - problemeHebdo_->CorrespondanceCntNativesCntOptim, + return {problemeHebdo_->CorrespondanceCntNativesCntOptim, problemeHebdo_->ShortTermStorage, - problemeHebdo_->CorrespondanceCntNativesCntOptimHebdomadaires - }; + problemeHebdo_->CorrespondanceCntNativesCntOptimHebdomadaires}; } FlowDissociationData Group1::GetFlowDissociationData() diff --git a/src/solver/optimisation/constraints/ShortTermStorageCumulation.cpp b/src/solver/optimisation/constraints/ShortTermStorageCumulation.cpp index f10a686269..7df86685c1 100644 --- a/src/solver/optimisation/constraints/ShortTermStorageCumulation.cpp +++ b/src/solver/optimisation/constraints/ShortTermStorageCumulation.cpp @@ -1,5 +1,5 @@ /* -* Copyright 2007-2024, RTE (https://www.rte-france.com) + * Copyright 2007-2024, RTE (https://www.rte-france.com) * See AUTHORS.txt * SPDX-License-Identifier: MPL-2.0 * This file is part of Antares-Simulator, @@ -23,25 +23,28 @@ #include "antares/solver/optimisation/constraints/ShortTermStorageCumulation.h" void ShortTermStorageCumulation::Injection(unsigned int index, -const ::ShortTermStorage::PROPERTIES& input - ){ + const ::ShortTermStorage::PROPERTIES& input) +{ builder.ShortTermStorageInjection(index, 1.0); - } +} + void ShortTermStorageCumulation::Withdrawal(unsigned int index, -const ::ShortTermStorage::PROPERTIES& input - ){ - builder.ShortTermStorageWithdrawal(index, 1.0);} -void ShortTermStorageCumulation::Netting(unsigned int index, - const ::ShortTermStorage::PROPERTIES& input){ + const ::ShortTermStorage::PROPERTIES& input) +{ + builder.ShortTermStorageWithdrawal(index, 1.0); +} +void ShortTermStorageCumulation::Netting(unsigned int index, + const ::ShortTermStorage::PROPERTIES& input) +{ + builder.ShortTermStorageInjection(index, input.injectionEfficiency) + .ShortTermStorageWithdrawal(index, -input.withdrawalEfficiency); +} - builder.ShortTermStorageInjection(index, input.injectionEfficiency ). - ShortTermStorageWithdrawal(index, -input.withdrawalEfficiency); - } auto getMemberFunction = [](const std::string& name) --> std::pair + -> std::pair { if (name == "withdrawal") { @@ -58,49 +61,51 @@ auto getMemberFunction = [](const std::string& name) return {"", nullptr}; // Return null if no match }; - -char ConvertSign(const std::string& sign){ - if (sign == "greater") { +char ConvertSign(const std::string& sign) +{ + if (sign == "greater") + { return '>'; } - else if (sign == "less") { - return '<'; - } - else { - return '='; - } + else if (sign == "less") + { + return '<'; + } + else + { + return '='; + } } -void ShortTermStorageCumulation::add(int pays){ - +void ShortTermStorageCumulation::add(int pays) +{ ConstraintNamer namer(builder.data.NomDesContraintes); namer.UpdateArea(builder.data.NomsDesPays[pays]); for (const auto& storage: data.ShortTermStorage[pays]) { - // TODO global index for constraints for data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[index] + // TODO global index for constraints for + // data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[index] for (const auto& constraint: storage.additional_constraints) { - //sum (var[h]) sign rhs, h in list provied by user - auto [constraintType,memberFunction] = getMemberFunction(constraint.variable); + // sum (var[h]) sign rhs, h in list provied by user + auto [constraintType, memberFunction] = getMemberFunction(constraint.variable); namer.ShortTermStorageCumulation(constraintType, builder.data.nombreDeContraintes, storage.name, - constraint.name - ); + constraint.name); const auto index = storage.clusterGlobalIndex; - //TODO - data.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation[constraint - .globalIndex] - = builder.data.nombreDeContraintes; + // TODO + data.CorrespondanceCntNativesCntOptimHebdomadaires + .ShortTermStorageCumulation[constraint.globalIndex] + = builder.data.nombreDeContraintes; for (const auto& hour: constraint.hours) { builder.updateHourWithinWeek(hour - 1); (this->*memberFunction)(index, storage); } - builder.SetOperator(ConvertSign(constraint.operatorType)) - .build(); + builder.SetOperator(ConvertSign(constraint.operatorType)).build(); } } } diff --git a/src/solver/optimisation/include/antares/solver/optimisation/constraints/ShortTermStorageCumulation.h b/src/solver/optimisation/include/antares/solver/optimisation/constraints/ShortTermStorageCumulation.h index 99bbea0584..572ad77821 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/constraints/ShortTermStorageCumulation.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/constraints/ShortTermStorageCumulation.h @@ -25,19 +25,17 @@ class ShortTermStorageCumulation: private ConstraintFactory { public: - ShortTermStorageCumulation(ConstraintBuilder& builder, ShortTermStorageCumulativeConstraintData& data): + ShortTermStorageCumulation(ConstraintBuilder& builder, + ShortTermStorageCumulativeConstraintData& data): ConstraintFactory(builder), data(data) { } void add(int pays); - void Injection(unsigned int index, - const ::ShortTermStorage::PROPERTIES& input); - void Withdrawal(unsigned int index, - const ::ShortTermStorage::PROPERTIES& input); - void Netting(unsigned int index, - const ::ShortTermStorage::PROPERTIES& input); + void Injection(unsigned int index, const ::ShortTermStorage::PROPERTIES& input); + void Withdrawal(unsigned int index, const ::ShortTermStorage::PROPERTIES& input); + void Netting(unsigned int index, const ::ShortTermStorage::PROPERTIES& input); private: ShortTermStorageCumulativeConstraintData& data; diff --git a/src/solver/optimisation/opt_gestion_second_membre_cas_lineaire.cpp b/src/solver/optimisation/opt_gestion_second_membre_cas_lineaire.cpp index cfa41290a6..c04d416f00 100644 --- a/src/solver/optimisation/opt_gestion_second_membre_cas_lineaire.cpp +++ b/src/solver/optimisation/opt_gestion_second_membre_cas_lineaire.cpp @@ -44,11 +44,10 @@ static void shortTermStorageLevelsRHS( } static void shortTermStorageCumulationRHS( - const std::vector<::ShortTermStorage::AREA_INPUT>& shortTermStorageInput, - int numberOfAreas, - std::vector& SecondMembre, - const CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& - CorrespondancesDesContraintesHebdomadaires) + const std::vector<::ShortTermStorage::AREA_INPUT>& shortTermStorageInput, + int numberOfAreas, + std::vector& SecondMembre, + const CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& CorrespondancesDesContraintesHebdomadaires) { for (int areaIndex = 0; areaIndex < numberOfAreas; areaIndex++) { @@ -56,8 +55,8 @@ static void shortTermStorageCumulationRHS( { for (const auto& constraint: storage.additional_constraints) { - int cnt = CorrespondancesDesContraintesHebdomadaires.ShortTermStorageCumulation - [constraint.globalIndex]; + int cnt = CorrespondancesDesContraintesHebdomadaires + .ShortTermStorageCumulation[constraint.globalIndex]; SecondMembre[cnt] = constraint.rhs; } } diff --git a/src/solver/optimisation/opt_rename_problem.cpp b/src/solver/optimisation/opt_rename_problem.cpp index 1e17479147..b385c0f8f5 100644 --- a/src/solver/optimisation/opt_rename_problem.cpp +++ b/src/solver/optimisation/opt_rename_problem.cpp @@ -420,11 +420,10 @@ void ConstraintNamer::ShortTermStorageCumulation(const std::string& constraint_t const std::string& short_term_name, const std::string& constraint_name) { - targetUpdater_.UpdateTargetAtIndex(BuildName(constraint_type, - LocationIdentifier(area_, AREA) + SEPARATOR - + "ShortTermStorage" + "<" + short_term_name - + ">", - ShortTermStorageCumulationIdentifier( - constraint_name)), - constraint); + targetUpdater_.UpdateTargetAtIndex( + BuildName(constraint_type, + LocationIdentifier(area_, AREA) + SEPARATOR + "ShortTermStorage" + "<" + + short_term_name + ">", + ShortTermStorageCumulationIdentifier(constraint_name)), + constraint); } diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 85f361371f..78785f0fd3 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -249,10 +249,8 @@ void SIM_AllocationLinks(PROBLEME_HEBDO& problem, const uint linkCount, unsigned void SIM_AllocationShortermStorageCumulation(PROBLEME_HEBDO& problem, const Antares::Data::Study& study) { - problem.CorrespondanceCntNativesCntOptimHebdomadaires - .ShortTermStorageCumulation.assign( - study.runtime.shortTermStorageCumulativeConstraintCount, - 0); + problem.CorrespondanceCntNativesCntOptimHebdomadaires.ShortTermStorageCumulation + .assign(study.runtime.shortTermStorageCumulativeConstraintCount, 0); } void SIM_AllocationConstraints(PROBLEME_HEBDO& problem,