diff --git a/src/libs/antares/inifile/inifile.cpp b/src/libs/antares/inifile/inifile.cpp index e6524920ee..67190a0654 100644 --- a/src/libs/antares/inifile/inifile.cpp +++ b/src/libs/antares/inifile/inifile.cpp @@ -65,7 +65,9 @@ void IniFile::Section::saveToStream(std::ostream& stream_out, uint64_t& written) stream_out << '[' << name << "]\n"; written += 4 /* []\n\n */ + name.size(); - each([&](const IniFile::Property& p) { p.saveToStream(stream_out, written); }); + each([&stream_out, &written](const IniFile::Property& p) { + p.saveToStream(stream_out, written); + }); stream_out << '\n'; } @@ -168,9 +170,9 @@ static std::string getSectionName(const std::string& line) return splitLine[1]; } -static bool isProperty(const std::string& line) +static bool isProperty(std::string_view line) { - return std::ranges::count(line.begin(), line.end(), '=') == 1; + return std::ranges::count(line, '=') == 1; } static IniFile::Property getProperty(std::string line) @@ -264,7 +266,9 @@ bool IniFile::open(const fs::path& filename, bool warnings) void IniFile::saveToStream(std::ostream& stream_out, uint64_t& written) const { - each([&](const IniFile::Section& s) {s.saveToStream(stream_out, written); }); + each([&stream_out, &written](const IniFile::Section& s) { + s.saveToStream(stream_out, written); + }); if (written != 0) { diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 417e60bae4..219f7ee8aa 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -1275,13 +1275,10 @@ Area* AreaList::findFromPosition(const int x, const int y) const for (auto i = this->areas.rbegin(); i != end; ++i) { auto lastArea = i->second; - if (lastArea->ui) + if (lastArea->ui && std::abs(lastArea->ui->x - x) < nearestDistance + && std::abs(lastArea->ui->y - y) < nearestDistance) { - if (std::abs(lastArea->ui->x - x) < nearestDistance - && std::abs(lastArea->ui->y - y) < nearestDistance) - { - nearestItem = lastArea; - } + nearestItem = lastArea; } } return nearestItem; @@ -1327,14 +1324,12 @@ void AreaListEnsureDataLoadPrepro(AreaList* l) /* Asserts */ assert(l); - l->each( - [&](Data::Area& area) - { - if (!area.load.prepro) - { - area.load.prepro = new Antares::Data::Load::Prepro(); - } - }); + l->each([](Data::Area& area) { + if (!area.load.prepro) + { + area.load.prepro = new Antares::Data::Load::Prepro(); + } + }); } void AreaListEnsureDataSolarPrepro(AreaList* l) @@ -1700,9 +1695,9 @@ void AreaList::removeWindTimeseries() void AreaList::removeThermalTimeseries() { each( - [](Data::Area& area) + [](const Data::Area& area) { - for (auto& c: area.thermal.list.all()) + for (const auto& c: area.thermal.list.all()) { c->series.reset(); } diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp index ce168c7eef..ff181e7ed8 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp @@ -60,10 +60,7 @@ bool BindingConstraintGroupRepository::buildFrom(const BindingConstraintsReposit bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const { - bool allConsistent = !std::any_of( - groups_.begin(), - groups_.end(), - [](const auto& group) + bool allConsistent = !std::ranges::any_of(groups_, [](const auto& group) { const auto& constraints = group->constraints(); if (constraints.empty()) @@ -71,9 +68,7 @@ bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const return false; } auto width = (*constraints.begin())->RHSTimeSeries().width; - bool isConsistent = std::all_of( - constraints.begin(), - constraints.end(), + bool isConsistent = std::ranges::all_of(constraints, [&width](const std::shared_ptr& bc) { bool sameWidth = bc->RHSTimeSeries().width == width; @@ -94,18 +89,15 @@ bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const void BindingConstraintGroupRepository::resizeAllTimeseriesNumbers(unsigned int nb_years) { - std::for_each(groups_.begin(), - groups_.end(), - [&](auto& group) { group->timeseriesNumbers.reset(nb_years); }); + std::ranges::for_each(groups_, [&nb_years](auto& group) + { group->timeseriesNumbers.reset(nb_years); }); } BindingConstraintGroup* BindingConstraintGroupRepository::operator[](const std::string& name) const { - if (auto group = std::find_if(groups_.begin(), - groups_.end(), - [&name](auto& group_of_constraint) - { return group_of_constraint->name() == name; }); - group != groups_.end()) + if (auto group = std::ranges::find_if(groups_, [&name](auto& group_of_constraint) + { return group_of_constraint->name() == name; }); + group != groups_.end()) { return group->get(); } diff --git a/src/libs/antares/study/cleaner/cleaner-v20.cpp b/src/libs/antares/study/cleaner/cleaner-v20.cpp index b3dc2ed6f6..3c8f183be4 100644 --- a/src/libs/antares/study/cleaner/cleaner-v20.cpp +++ b/src/libs/antares/study/cleaner/cleaner-v20.cpp @@ -391,20 +391,20 @@ bool listOfFilesAnDirectoriesToKeep(StudyCleaningInfos* infos) buffer.clear() << infos->folder << "/input/bindingconstraints/bindingconstraints.ini"; if (ini.open(buffer)) { - String v; ini.each( - [&](const IniFile::Section& section) + [&e](const IniFile::Section& section) { auto* property = section.firstProperty; for (; property; property = property->next) { if (property->key == "id") { - v = property->value; + String v = property->value; v.toLower(); - buffer.clear() << "input/bindingconstraints/" << v << ".txt"; - e.add(buffer); + String tmp; + tmp << "input/bindingconstraints/" << v << ".txt"; + e.add(tmp); // Go to the next binding constraint break; } diff --git a/src/libs/antares/study/filter.cpp b/src/libs/antares/study/filter.cpp index aa8916c26c..cb94bf5d30 100644 --- a/src/libs/antares/study/filter.cpp +++ b/src/libs/antares/study/filter.cpp @@ -82,7 +82,7 @@ uint stringIntoDatePrecision(const AnyString& string) uint flag = 0; string.words(",; \r\n\t", - [&](const AnyString& word) -> bool + [&flag](const AnyString& word) -> bool { ShortString16 s = word; s.toLower(); diff --git a/src/libs/antares/study/include/antares/study/parameters.h b/src/libs/antares/study/include/antares/study/parameters.h index d9a1d467f0..c66cf9757f 100644 --- a/src/libs/antares/study/include/antares/study/parameters.h +++ b/src/libs/antares/study/include/antares/study/parameters.h @@ -50,21 +50,6 @@ namespace Antares::Data class Parameters final { public: - //! \name Constructor - //@{ - /*! - ** \brief Default Constructor - ** - ** \warning None of the variables are initialized. You must explicitly use - ** the method `reset()` or the method `loadFromFile()` - ** \see reset() - ** \see loadFromFile() - */ - Parameters(); - //! Destructor - ~Parameters(); - //@} - //! \name Simulation mode //@{ //! Get if the simulation is in economy mode @@ -91,7 +76,7 @@ class Parameters final ** \return True if the settings have been loaded, false if at least one error has occured */ bool loadFromFile(const AnyString& filename, - StudyVersion& version, + const StudyVersion& version, const StudyLoadOptions& options); /*! @@ -493,7 +478,7 @@ class Parameters final //@{ //! No output // This variable is not stored within the study but only used by the solver - bool noOutput; + bool noOutput = false; //@} bool hydroDebug; diff --git a/src/libs/antares/study/load.cpp b/src/libs/antares/study/load.cpp index dca1b1eb15..00214717e8 100644 --- a/src/libs/antares/study/load.cpp +++ b/src/libs/antares/study/load.cpp @@ -286,7 +286,7 @@ bool Study::internalLoadBindingConstraints(const StudyLoadOptions& options) class SetHandlerAreas { public: - SetHandlerAreas(Study& study): + explicit SetHandlerAreas(Study& study): pStudy(study) { } @@ -411,7 +411,7 @@ bool Study::reloadXCastData() // if changes are required, please update AreaListLoadFromFolderSingleArea() bool ret = true; areas.each( - [&](Data::Area& area) + [this, &ret](Data::Area& area) { assert(area.load.prepro); assert(area.solar.prepro); diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 3517b09d21..a598ee1566 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -54,7 +54,7 @@ static bool ConvertCStrToListTimeSeries(const String& value, uint& v) } value.words(" ,;\t\r\n", - [&](const AnyString& element) -> bool + [&v](const AnyString& element) { ShortString16 word(element); word.toLower(); @@ -208,13 +208,6 @@ const char* SimulationModeToCString(SimulationMode mode) } } -Parameters::Parameters(): - noOutput(false) -{ -} - -Parameters::~Parameters() = default; - bool Parameters::economy() const { return mode == SimulationMode::Economy; @@ -231,8 +224,8 @@ void Parameters::resetSeeds() // For retro-compatibility, the wind ts-generator should produce the // same results than before 3.8. // It must have the same seed than before - auto increment = (unsigned)antaresSeedIncrement; - auto s = (unsigned)antaresSeedDefaultValue; + auto increment = antaresSeedIncrement; + auto s = antaresSeedDefaultValue; seed[seedTsGenWind] = s; // The same way for all others @@ -1981,7 +1974,7 @@ void Parameters::saveToINI(IniFile& ini) const } bool Parameters::loadFromFile(const AnyString& filename, - StudyVersion& version, + const StudyVersion& version, const StudyLoadOptions& options) { // Loading the INI file diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index e00934dfe7..9be5c2ca57 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -263,8 +263,8 @@ bool ClusterList::saveDataSeriesToFolder(const AnyString& folder) cons template bool ClusterList::loadDataSeriesFromFolder(Study& s, const AnyString& folder) { - return std::ranges::all_of(allClusters_, - [&](auto c) { return c->loadDataSeriesFromFolder(s, folder); }); + return std::ranges::all_of(allClusters_, [&s, &folder](auto c) + { return c->loadDataSeriesFromFolder(s, folder); }); } template diff --git a/src/libs/antares/study/parts/hydro/allocation.cpp b/src/libs/antares/study/parts/hydro/allocation.cpp index 93ee0ef5d0..597264cf20 100644 --- a/src/libs/antares/study/parts/hydro/allocation.cpp +++ b/src/libs/antares/study/parts/hydro/allocation.cpp @@ -170,31 +170,28 @@ bool HydroAllocation::loadFromFile(const AreaName& referencearea, clear(); IniFile ini; - if (fs::exists(filename) && ini.open(filename)) - { - if (!ini.empty()) - { - AreaName areaname; - ini.each( - [&](const IniFile::Section& section) - { - for (auto* p = section.firstProperty; p; p = p->next) - { - double coeff = p->value.to(); - if (!Utils::isZero(coeff)) - { - areaname = p->key; - areaname.toLower(); - pValues[areaname] = coeff; - } - } - }); - } - } - else + if (!fs::exists(filename) || !ini.open(filename)) { pValues[referencearea] = 1.0; + return true; } + + if (ini.empty()) + return true; + + ini.each([this](const IniFile::Section& section) + { + for (auto* p = section.firstProperty; p; p = p->next) + { + double coeff = p->value.to(); + if (!Utils::isZero(coeff)) + { + AreaName areaname = p->key; + areaname.toLower(); + pValues[areaname] = coeff; + } + } + }); return true; } diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index 0343c2878f..d955da1c81 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -144,7 +144,7 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) // Initialize all alpha values to 0 study.areas.each( - [&](Data::Area& area) + [&ret, &buffer, &study, &folder](Data::Area& area) { area.hydro.interDailyBreakdown = 1.; area.hydro.intraDailyModulation = 24.; @@ -462,69 +462,93 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) String buffer; buffer.clear() << folder << SEP << "common" << SEP << "capacity"; + struct AllSections + { + IniFile::Section* s; + IniFile::Section* smod; + IniFile::Section* sIMB; + IniFile::Section* sreservoir; + IniFile::Section* sreservoirCapacity; + IniFile::Section* sFollowLoad; + IniFile::Section* sUseWater; + IniFile::Section* sHardBounds; + IniFile::Section* sInitializeReservoirDate; + IniFile::Section* sUseHeuristic; + IniFile::Section* sUseLeeway; + IniFile::Section* sPowerToLevel; + IniFile::Section* sLeewayLow; + IniFile::Section* sLeewayUp; + IniFile::Section* spumpingEfficiency; + + AllSections(IniFile& ini) : + s(ini.addSection("inter-daily-breakdown")), + smod(ini.addSection("intra-daily-modulation")), + sIMB(ini.addSection("inter-monthly-breakdown")), + sreservoir(ini.addSection("reservoir")), + sreservoirCapacity(ini.addSection("reservoir capacity")), + sFollowLoad(ini.addSection("follow load")), + sUseWater(ini.addSection("use water")), + sHardBounds(ini.addSection("hard bounds")), + sInitializeReservoirDate(ini.addSection("initialize reservoir date")), + sUseHeuristic(ini.addSection("use heuristic")), + sUseLeeway(ini.addSection("use leeway")), + sPowerToLevel(ini.addSection("power to level")), + sLeewayLow(ini.addSection("leeway low")), + sLeewayUp(ini.addSection("leeway up")), + spumpingEfficiency(ini.addSection("pumping efficiency")) + { + } + }; + // Init IniFile ini; - auto* s = ini.addSection("inter-daily-breakdown"); - auto* smod = ini.addSection("intra-daily-modulation"); - auto* sIMB = ini.addSection("inter-monthly-breakdown"); - auto* sreservoir = ini.addSection("reservoir"); - auto* sreservoirCapacity = ini.addSection("reservoir capacity"); - auto* sFollowLoad = ini.addSection("follow load"); - auto* sUseWater = ini.addSection("use water"); - auto* sHardBounds = ini.addSection("hard bounds"); - auto* sInitializeReservoirDate = ini.addSection("initialize reservoir date"); - auto* sUseHeuristic = ini.addSection("use heuristic"); - auto* sUseLeeway = ini.addSection("use leeway"); - auto* sPowerToLevel = ini.addSection("power to level"); - auto* sLeewayLow = ini.addSection("leeway low"); - auto* sLeewayUp = ini.addSection("leeway up"); - auto* spumpingEfficiency = ini.addSection("pumping efficiency"); + AllSections allSections(ini); // return status bool ret = true; // Add all alpha values for each area areas.each( - [&](const Data::Area& area) + [&allSections, &buffer, &folder, &ret](const Data::Area& area) { - s->add(area.id, area.hydro.interDailyBreakdown); - smod->add(area.id, area.hydro.intraDailyModulation); - sIMB->add(area.id, area.hydro.intermonthlyBreakdown); - sInitializeReservoirDate->add(area.id, area.hydro.initializeReservoirLevelDate); - sLeewayLow->add(area.id, area.hydro.leewayLowerBound); - sLeewayUp->add(area.id, area.hydro.leewayUpperBound); - spumpingEfficiency->add(area.id, area.hydro.pumpingEfficiency); + allSections.s->add(area.id, area.hydro.interDailyBreakdown); + allSections.smod->add(area.id, area.hydro.intraDailyModulation); + allSections.sIMB->add(area.id, area.hydro.intermonthlyBreakdown); + allSections.sInitializeReservoirDate->add(area.id, area.hydro.initializeReservoirLevelDate); + allSections.sLeewayLow->add(area.id, area.hydro.leewayLowerBound); + allSections.sLeewayUp->add(area.id, area.hydro.leewayUpperBound); + allSections.spumpingEfficiency->add(area.id, area.hydro.pumpingEfficiency); if (area.hydro.reservoirCapacity > 1e-6) { - sreservoirCapacity->add(area.id, area.hydro.reservoirCapacity); + allSections.sreservoirCapacity->add(area.id, area.hydro.reservoirCapacity); } if (area.hydro.reservoirManagement) { - sreservoir->add(area.id, true); + allSections.sreservoir->add(area.id, true); } if (!area.hydro.followLoadModulations) { - sFollowLoad->add(area.id, false); + allSections.sFollowLoad->add(area.id, false); } if (area.hydro.useWaterValue) { - sUseWater->add(area.id, true); + allSections.sUseWater->add(area.id, true); } if (area.hydro.hardBoundsOnRuleCurves) { - sHardBounds->add(area.id, true); + allSections.sHardBounds->add(area.id, true); } if (!area.hydro.useHeuristicTarget) { - sUseHeuristic->add(area.id, false); + allSections.sUseHeuristic->add(area.id, false); } if (area.hydro.useLeeway) { - sUseLeeway->add(area.id, true); + allSections.sUseLeeway->add(area.id, true); } if (area.hydro.powerToLevel) { - sPowerToLevel->add(area.id, true); + allSections.sPowerToLevel->add(area.id, true); } // max hours gen diff --git a/src/libs/antares/study/parts/short-term-storage/container.cpp b/src/libs/antares/study/parts/short-term-storage/container.cpp index 1c9ca78bf7..749613a14b 100644 --- a/src/libs/antares/study/parts/short-term-storage/container.cpp +++ b/src/libs/antares/study/parts/short-term-storage/container.cpp @@ -37,9 +37,8 @@ namespace Antares::Data::ShortTermStorage { bool STStorageInput::validate() const { - return std::all_of(storagesByIndex.cbegin(), - storagesByIndex.cend(), - [](auto& cluster) { return cluster.validate(); }); + return std::ranges::all_of(storagesByIndex, [](auto& cluster) + { return cluster.validate(); }); } bool STStorageInput::createSTStorageClustersFromIniFile(const fs::path& path) @@ -69,9 +68,8 @@ bool STStorageInput::createSTStorageClustersFromIniFile(const fs::path& path) storagesByIndex.push_back(cluster); } - std::sort(storagesByIndex.begin(), - storagesByIndex.end(), - [&](const auto& a, const auto& b) { return a.properties.name < b.properties.name; }); + std::ranges::sort(storagesByIndex, [](const auto& a, const auto& b) + { return a.properties.name < b.properties.name; }); return true; } @@ -102,9 +100,8 @@ bool STStorageInput::saveToFolder(const std::string& folder) const IniFile ini; logs.debug() << "saving file " << pathIni; - std::for_each(storagesByIndex.cbegin(), - storagesByIndex.cend(), - [&ini](auto& storage) { return storage.saveProperties(ini); }); + std::ranges::for_each(storagesByIndex, [&ini](auto& storage) + { return storage.saveProperties(ini); }); return ini.save(pathIni); } @@ -112,29 +109,20 @@ bool STStorageInput::saveToFolder(const std::string& folder) const bool STStorageInput::saveDataSeriesToFolder(const std::string& folder) const { Yuni::IO::Directory::Create(folder); - return std::all_of(storagesByIndex.cbegin(), - storagesByIndex.cend(), - [&folder](auto& storage) - { return storage.saveSeries(folder + SEP + storage.id); }); + return std::ranges::all_of(storagesByIndex, [&folder](auto& storage) + { return storage.saveSeries(folder + SEP + storage.id); }); } std::size_t STStorageInput::count() const { - return std::count_if(storagesByIndex.begin(), - storagesByIndex.end(), - [](const STStorageCluster& st) { return st.properties.enabled; }); + return std::ranges::count_if(storagesByIndex, [](const STStorageCluster& st) + { return st.properties.enabled; }); } uint STStorageInput::removeDisabledClusters() { - const auto& it = std::remove_if(storagesByIndex.begin(), - storagesByIndex.end(), - [](const auto& c) { return !c.enabled(); }); - - uint disabledCount = std::distance(it, storagesByIndex.end()); - storagesByIndex.erase(it, storagesByIndex.end()); - - return disabledCount; + return std::erase_if(storagesByIndex, [](const auto& c) + { return !c.enabled(); }); } } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index f10da99345..035faf86ac 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -103,7 +103,7 @@ static void StudyRuntimeInfosInitializeAreaLinks(Study& study, StudyRuntimeInfos uint indx = 0; study.areas.each( - [&](Data::Area& area) + [&indx, &r](Data::Area& area) { area.buildLinksIndexes(); @@ -213,9 +213,9 @@ void StudyRuntimeInfos::initializeRangeLimits(const Study& study, StudyRangeLimi } else { - simulationDaysPerMonth[(uint)ca.month] = study.calendar.months[(uint)ca.month].days + simulationDaysPerMonth[ca.month] = study.calendar.months[ca.month].days - ca.dayMonth; - simulationDaysPerMonth[(uint)cb.month] = cb.dayMonth + 1; + simulationDaysPerMonth[cb.month] = cb.dayMonth + 1; for (uint i = ca.month + 1; i < cb.month; ++i) { simulationDaysPerMonth[i] = study.calendar.months[i].days; @@ -270,9 +270,9 @@ void StudyRuntimeInfos::checkThermalTSGeneration(Study& study) thermalTSRefresh = globalThermalTSgeneration; study.areas.each( - [this, globalThermalTSgeneration](Data::Area& area) + [this, globalThermalTSgeneration](const Data::Area& area) { - for (auto& c: area.thermal.list.each_enabled_and_not_mustrun()) + for (const auto& c: area.thermal.list.each_enabled_and_not_mustrun()) { thermalTSRefresh = thermalTSRefresh || c->doWeGenerateTS(globalThermalTSgeneration); } @@ -441,8 +441,7 @@ void StudyRangeLimits::checkIntegrity() const void StudyRuntimeInfos::disableAllFilters(Study& study) { - study.areas.each( - [&](Data::Area& area) + study.areas.each([](Data::Area& area) { area.filterSynthesis = filterAll; area.filterYearByYear = filterAll; diff --git a/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp b/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp index 24b5b8cb6b..46a0694a58 100644 --- a/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp +++ b/src/libs/antares/study/scenario-builder/BindingConstraintsTSNumbersData.cpp @@ -80,9 +80,8 @@ bool BindingConstraintsTSNumberData::apply(Study& study) bool BindingConstraintsTSNumberData::reset(const Study& study) { const uint nbYears = study.parameters.nbYears; - std::for_each(study.bindingConstraintsGroups.begin(), - study.bindingConstraintsGroups.end(), - [&](const auto& group) + std::ranges::for_each(study.bindingConstraintsGroups, + [this, &nbYears](const auto& group) { auto& ts_numbers = rules_[group->name()]; ts_numbers.reset(1, nbYears); diff --git a/src/libs/antares/study/scenario-builder/sets.cpp b/src/libs/antares/study/scenario-builder/sets.cpp index 962f7c122d..76dbcb9166 100644 --- a/src/libs/antares/study/scenario-builder/sets.cpp +++ b/src/libs/antares/study/scenario-builder/sets.cpp @@ -195,7 +195,7 @@ bool Sets::internalLoadFromINIFile(const AnyString& filename) } ini.each( - [&](const IniFile::Section& section) + [this](const IniFile::Section& section) { if (section.name.empty()) { diff --git a/src/libs/antares/study/study.cpp b/src/libs/antares/study/study.cpp index 23f547783d..511e61a592 100644 --- a/src/libs/antares/study/study.cpp +++ b/src/libs/antares/study/study.cpp @@ -520,7 +520,7 @@ void Study::performTransformationsBeforeLaunchingSimulation() // ForEach area areas.each( - [&](Data::Area& area) + [this](Data::Area& area) { if (not parameters.geographicTrimming) { @@ -698,7 +698,7 @@ void Study::saveAboutTheStudy(Solver::IResultWriter& resultWriter) buffer << "@ " << i->first << "\r\n"; } } - areas.each([&](const Data::Area& area) { buffer << area.name << "\r\n"; }); + areas.each([&buffer](const Data::Area& area) { buffer << area.name << "\r\n"; }); resultWriter.addEntryFromBuffer(path.c_str(), buffer); } @@ -789,7 +789,7 @@ bool Study::areaDelete(Area* area) // and the scenario builder data *before* reloading uiinfo. { // Updating all hydro allocation - areas.each([&](Data::Area& areait) { areait.hydro.allocation.remove(area->id); }); + areas.each([&area](Data::Area& areait) { areait.hydro.allocation.remove(area->id); }); // We __must__ update the scenario builder data // We may delete an area and re-create a new one with the same @@ -856,7 +856,7 @@ void Study::areaDelete(Area::Vector& arealist) << area.name; // Updating all hydro allocation - areas.each([&](Data::Area& areait) { areait.hydro.allocation.remove(area.id); }); + areas.each([&area](Data::Area& areait) { areait.hydro.allocation.remove(area.id); }); // Remove all binding constraints attached to the area bindingConstraints.remove(*i); @@ -955,7 +955,8 @@ bool Study::areaRename(Area* area, AreaName newName) logs.info() << "renaming area " << area->name << " into " << newName; // Updating all hydro allocation - areas.each([&](Data::Area& areait) { areait.hydro.allocation.rename(oldid, newid); }); + areas.each([&oldid, &newid](Data::Area& areait) + { areait.hydro.allocation.rename(oldid, newid); }); ScenarioBuilderUpdater updaterSB(*this); bool ret = true; @@ -1088,34 +1089,33 @@ bool Study::clusterRename(Cluster* cluster, ClusterName newName) void Study::destroyAllLoadTSGeneratorData() { - areas.each([&](Data::Area& area) { FreeAndNil(area.load.prepro); }); + areas.each([](Data::Area& area) { FreeAndNil(area.load.prepro); }); } void Study::destroyAllSolarTSGeneratorData() { - areas.each([&](Data::Area& area) { FreeAndNil(area.solar.prepro); }); + areas.each([](Data::Area& area) { FreeAndNil(area.solar.prepro); }); } void Study::destroyAllHydroTSGeneratorData() { - areas.each([&](Data::Area& area) { FreeAndNil(area.hydro.prepro); }); + areas.each([](Data::Area& area) { FreeAndNil(area.hydro.prepro); }); } void Study::destroyAllWindTSGeneratorData() { - areas.each([&](Data::Area& area) { FreeAndNil(area.wind.prepro); }); + areas.each([](Data::Area& area) { FreeAndNil(area.wind.prepro); }); } void Study::destroyAllThermalTSGeneratorData() { - areas.each( - [&](Data::Area& area) - { - for (const auto& cluster: area.thermal.list.each_enabled_and_not_mustrun()) - { - FreeAndNil(cluster->prepro); - } - }); + areas.each([](const Data::Area& area) + { + for (const auto& cluster: area.thermal.list.each_enabled_and_not_mustrun()) + { + FreeAndNil(cluster->prepro); + } + }); } void Study::ensureDataAreLoadedForAllBindingConstraints() @@ -1356,8 +1356,9 @@ bool Study::checkForFilenameLimits(bool output, const String& chfolder) const String areaname; areas.each( - [&](const Area& area) + [&output, &linkname, &areaname](const Area& area) { + if (areaname.size() < area.id.size()) { areaname = area.id; @@ -1368,19 +1369,12 @@ bool Study::checkForFilenameLimits(bool output, const String& chfolder) const { auto& link = *(i->second); uint len = link.from->id.size() + link.with->id.size(); - len += output ? 3 : 1; + len += 3; if (len > linkname.size()) { linkname.clear(); linkname << i->second->from->id; - if (output) - { - linkname << " - "; // 3 - } - else - { - linkname << SEP; - } + linkname << " - "; // 3 linkname << i->second->with->id; } } @@ -1436,7 +1430,7 @@ bool Study::checkForFilenameLimits(bool output, const String& chfolder) const // or even constraints areas.each( - [&](const Area& area) + [&areaname, &clustername](const Area& area) { if (areaname.size() < area.id.size()) { diff --git a/src/libs/antares/study/study.importprepro.cpp b/src/libs/antares/study/study.importprepro.cpp index 837f37a485..3b8263eadf 100644 --- a/src/libs/antares/study/study.importprepro.cpp +++ b/src/libs/antares/study/study.importprepro.cpp @@ -50,56 +50,52 @@ bool Study::importTimeseriesIntoInput() if (parameters.haveToImport(timeSeriesLoad)) { logs.info() << "Importing load timeseries..."; - areas.each( - [&](const Data::Area& area) - { - logs.info() << "Importing load timeseries : " << area.name; - buffer.clear() << folderInput << SEP << "load" << SEP << "series"; - ret = area.load.series.saveToFolder(area.id, buffer.c_str(), "load_") && ret; - ++progression; - }); + for (const auto& [areaName, area] : areas) + { + logs.info() << "Importing load timeseries : " << areaName; + buffer.clear() << folderInput << SEP << "load" << SEP << "series"; + ret = area->load.series.saveToFolder(area->id, buffer.c_str(), "load_") && ret; + ++progression; + } } // Solar if (parameters.haveToImport(timeSeriesSolar)) { logs.info() << "Importing solar timeseries..."; - areas.each( - [&](const Data::Area& area) - { - logs.info() << "Importing solar timeseries : " << area.name; - buffer.clear() << folderInput << SEP << "solar" << SEP << "series"; - ret = area.solar.series.saveToFolder(area.id, buffer.c_str(), "solar_") && ret; - ++progression; - }); + for (const auto& [areaName, area] : areas) + { + logs.info() << "Importing solar timeseries : " << areaName; + buffer.clear() << folderInput << SEP << "solar" << SEP << "series"; + ret = area->solar.series.saveToFolder(area->id, buffer.c_str(), "solar_") && ret; + ++progression; + } } // Hydro if (parameters.haveToImport(timeSeriesHydro)) { logs.info() << "Importing hydro timeseries..."; - areas.each( - [&](const Data::Area& area) - { - logs.info() << "Importing hydro timeseries : " << area.name; - buffer.clear() << folderInput << SEP << "hydro" << SEP << "series"; - ret = area.hydro.series->saveToFolder(area.id, buffer) && ret; - ++progression; - }); + for (const auto& [areaName, area] : areas) + { + logs.info() << "Importing hydro timeseries : " << areaName; + buffer.clear() << folderInput << SEP << "hydro" << SEP << "series"; + ret = area->hydro.series->saveToFolder(area->id, buffer) && ret; + ++progression; + } } // Wind if (parameters.haveToImport(timeSeriesWind)) { logs.info() << "Importing wind timeseries..."; - areas.each( - [&](const Data::Area& area) - { - logs.info() << "Importing wind timeseries : " << area.name; - buffer.clear() << folderInput << SEP << "wind" << SEP << "series"; - area.wind.series.saveToFolder(area.id, buffer.c_str(), "wind_") && ret; - ++progression; - }); + for (const auto& [areaName, area] : areas) + { + logs.info() << "Importing wind timeseries : " << areaName; + buffer.clear() << folderInput << SEP << "wind" << SEP << "series"; + area->wind.series.saveToFolder(area->id, buffer.c_str(), "wind_") && ret; + ++progression; + } } // Thermal @@ -108,18 +104,17 @@ bool Study::importTimeseriesIntoInput() logs.info() << "Importing thermal timeseries..."; String msg; - areas.each( - [&](Data::Area& area) - { - msg.clear() << "Importing thermal timeseries : " << area.name; + for (const auto& [areaName, area] : areas) + { + msg.clear() << "Importing thermal timeseries : " << areaName; - // Spinning - area.thermal.list.reverseCalculationOfSpinning(); + // Spinning + area->thermal.list.reverseCalculationOfSpinning(); - buffer.clear() << folderInput << SEP << "thermal" << SEP << "series"; - ret = area.thermal.list.saveDataSeriesToFolder(buffer.c_str()) && ret; - ++progression; - }); + buffer.clear() << folderInput << SEP << "thermal" << SEP << "series"; + ret = area->thermal.list.saveDataSeriesToFolder(buffer.c_str()) && ret; + ++progression; + } } return ret; diff --git a/src/libs/antares/study/xcast/xcast.cpp b/src/libs/antares/study/xcast/xcast.cpp index 4233784088..51ed1624b0 100644 --- a/src/libs/antares/study/xcast/xcast.cpp +++ b/src/libs/antares/study/xcast/xcast.cpp @@ -201,19 +201,15 @@ bool XCast::loadFromFolder(const AnyString& folder) IniFile ini; if (ini.open(buffer)) { - // For each section - const IniFile::Property* p; - CString<30, false> key; - ini.each( - [&](const IniFile::Section& section) + [this, &buffer](const IniFile::Section& section) { // For each property if (section.name == "general") { - for (p = section.firstProperty; p != nullptr; p = p->next) + for (const IniFile::Property* p = section.firstProperty; p != nullptr; p = p->next) { - key = p->key; + CString<30, false> key = p->key; key.toLower(); if (key == "distribution") { diff --git a/src/libs/antares/sys/policy.cpp b/src/libs/antares/sys/policy.cpp index b9a60ea4af..0427c7441c 100644 --- a/src/libs/antares/sys/policy.cpp +++ b/src/libs/antares/sys/policy.cpp @@ -65,22 +65,20 @@ static void OpenFromINIFileWL(const String& filename, const StringT& hostname) return; } - PolicyKey key; - ShortString128 hostnameVersion; - ShortString128 hostnameAll; - hostnameVersion << hostname << ':' << ANTARES_VERSION; - hostnameAll << hostname << ":*"; + std::string hostnameVersion = hostname + ':' + ANTARES_VERSION; + std::string hostnameAll = hostname + ":*"; ini.each( - [&](const IniFile::Section& section) + [&hostnameVersion, &hostnameAll](const IniFile::Section& section) { // This section is dedicated to another host if (section.name == "*:*" or section.name == "*:" ANTARES_VERSION or section.name.equals(hostnameAll) or section.name.equals(hostnameVersion)) { section.each( - [&](const IniFile::Property& property) + [](const IniFile::Property& property) { + PolicyKey key; key = property.key; key.trim(" \t"); (*entries)[key] = property.value; diff --git a/src/solver/application/application.cpp b/src/solver/application/application.cpp index d221d19eb6..d222ad88c0 100644 --- a/src/solver/application/application.cpp +++ b/src/solver/application/application.cpp @@ -118,7 +118,7 @@ void Application::readDataForTheStudy(Data::StudyLoadOptions& options) std::exception_ptr loadingException; try { - pDurationCollector("study_loading") << [&] + pDurationCollector("study_loading") << [this, &study, &options] { if (study.loadFromFolder(pSettings.studyFolder, options)) { diff --git a/src/solver/hydro/management/daily.cpp b/src/solver/hydro/management/daily.cpp index 8391b523d0..5c6bcab897 100644 --- a/src/solver/hydro/management/daily.cpp +++ b/src/solver/hydro/management/daily.cpp @@ -414,10 +414,8 @@ inline void HydroManagement::prepareDailyOptimalGenerations( break; case NON: throw solutionNotFound(area.name.c_str(), y); - break; case EMERGENCY_SHUT_DOWN: throw fatalError(area.name.c_str(), y); - break; } H2O_J_Free(problem); @@ -535,10 +533,8 @@ inline void HydroManagement::prepareDailyOptimalGenerations( break; case NON: throw solutionNotFound(area.name.c_str(), y); - break; case EMERGENCY_SHUT_DOWN: throw fatalError(area.name.c_str(), y); - break; } H2O2_J_Free(problem); @@ -554,7 +550,7 @@ inline void HydroManagement::prepareDailyOptimalGenerations( void HydroManagement::prepareDailyOptimalGenerations(uint y, Antares::Data::Area::ScratchMap& scratchmap) { - areas_.each([&](Data::Area& area) + areas_.each([this, &scratchmap, &y](Data::Area& area) { prepareDailyOptimalGenerations(area, y, scratchmap); }); } } // namespace Antares diff --git a/src/solver/hydro/management/management.cpp b/src/solver/hydro/management/management.cpp index b20be5e375..6cea703442 100644 --- a/src/solver/hydro/management/management.cpp +++ b/src/solver/hydro/management/management.cpp @@ -143,7 +143,7 @@ HydroManagement::HydroManagement(const Data::AreaList& areas, void HydroManagement::prepareInflowsScaling(uint year) { areas_.each( - [&](const Data::Area& area) + [this, &year](const Data::Area& area) { const auto& srcinflows = area.hydro.series->storage.getColumn(year); @@ -440,7 +440,7 @@ void HydroManagement::prepareNetDemand(uint year, void HydroManagement::prepareEffectiveDemand() { areas_.each( - [&](Data::Area& area) + [this](Data::Area& area) { auto& data = tmpDataByArea_[&area]; @@ -453,7 +453,7 @@ void HydroManagement::prepareEffectiveDemand() double effectiveDemand = 0; // area.hydro.allocation is indexed by area index area.hydro.allocation.eachNonNull( - [&](unsigned areaIndex, double value) + [this, &effectiveDemand, &day](unsigned areaIndex, double value) { const auto* area = areas_.byIndex[areaIndex]; effectiveDemand += tmpDataByArea_[area].DLN[day] * value; diff --git a/src/solver/hydro/management/monthly.cpp b/src/solver/hydro/management/monthly.cpp index 2cb868da72..62ce897eb8 100644 --- a/src/solver/hydro/management/monthly.cpp +++ b/src/solver/hydro/management/monthly.cpp @@ -151,7 +151,7 @@ void HydroManagement::prepareMonthlyOptimalGenerations(double* random_reservoir_ { uint indexArea = 0; areas_.each( - [&](Data::Area& area) + [this, &random_reservoir_level, &y, &indexArea](Data::Area& area) { auto& data = tmpDataByArea_[&area]; diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index c90c8b4809..1b170ae353 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -47,7 +47,7 @@ void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime unsigned int hourInYear = opt_runtime_data.hourInTheYear; unsigned int year = opt_runtime_data.year; area_list_.each( - [&](Data::Area& area) + [this, &hourInYear, &year](Data::Area& area) { double* dtgmrg = area.scratchpad[thread_number_].dispatchableGenerationMargin; for (uint h = 0; h != nbHoursInWeek; ++h) diff --git a/src/solver/simulation/common-eco-adq.cpp b/src/solver/simulation/common-eco-adq.cpp index b413b632d5..1f56235499 100644 --- a/src/solver/simulation/common-eco-adq.cpp +++ b/src/solver/simulation/common-eco-adq.cpp @@ -401,7 +401,7 @@ void SetInitialHydroLevel(Data::Study& study, const HYDRO_VENTILATION_RESULTS& hydroVentilationResults) { uint firstDaySimu = study.parameters.simulationDays.first; - study.areas.each([&](Data::Area& area) + study.areas.each([&problem, &firstDaySimu, &hydroVentilationResults](const Data::Area& area) { if (area.hydro.reservoirManagement) { diff --git a/src/solver/simulation/common-hydro-levels.cpp b/src/solver/simulation/common-hydro-levels.cpp index b322d62dec..81602073a1 100644 --- a/src/solver/simulation/common-hydro-levels.cpp +++ b/src/solver/simulation/common-hydro-levels.cpp @@ -33,54 +33,50 @@ void computingHydroLevels(const Data::AreaList& areas, bool remixWasRun, bool computeAnyway) { - areas.each( - [&](const Data::Area& area) - { - if (!area.hydro.reservoirManagement) - { - return; - } + for (const auto& [_, area] : areas) + { + if (!area->hydro.reservoirManagement) + { + continue; + } - if (not computeAnyway) - { - if (area.hydro.useHeuristicTarget != remixWasRun) - { - return; - } - } + if (!computeAnyway && area->hydro.useHeuristicTarget != remixWasRun) + { + continue; + } - uint index = area.index; + uint index = area->index; - double reservoirCapacity = area.hydro.reservoirCapacity; + double reservoirCapacity = area->hydro.reservoirCapacity; - std::vector& inflows = problem.CaracteristiquesHydrauliques[index] - .ApportNaturelHoraire; + std::vector& inflows = problem.CaracteristiquesHydrauliques[index] + .ApportNaturelHoraire; - RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; + RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; - std::vector& turb = weeklyResults.TurbinageHoraire; + std::vector& turb = weeklyResults.TurbinageHoraire; - std::vector& pump = weeklyResults.PompageHoraire; - double pumpingRatio = area.hydro.pumpingEfficiency; + std::vector& pump = weeklyResults.PompageHoraire; + double pumpingRatio = area->hydro.pumpingEfficiency; - double nivInit = problem.CaracteristiquesHydrauliques[index].NiveauInitialReservoir; - std::vector& niv = weeklyResults.niveauxHoraires; + double nivInit = problem.CaracteristiquesHydrauliques[index].NiveauInitialReservoir; + std::vector& niv = weeklyResults.niveauxHoraires; - std::vector& ovf = weeklyResults.debordementsHoraires; + std::vector& ovf = weeklyResults.debordementsHoraires; - computeTimeStepLevel + computeTimeStepLevel computeLvlObj(nivInit, inflows, ovf, turb, pumpingRatio, pump, reservoirCapacity); - for (uint h = 0; h < nbHoursInAWeek - 1; h++) - { - computeLvlObj.run(); - niv[h] = computeLvlObj.getLevel() * 100 / reservoirCapacity; - computeLvlObj.prepareNextStep(); - } + for (uint h = 0; h < nbHoursInAWeek - 1; h++) + { + computeLvlObj.run(); + niv[h] = computeLvlObj.getLevel() * 100 / reservoirCapacity; + computeLvlObj.prepareNextStep(); + } - computeLvlObj.run(); - niv[nbHoursInAWeek - 1] = computeLvlObj.getLevel() * 100 / reservoirCapacity; - }); + computeLvlObj.run(); + niv[nbHoursInAWeek - 1] = computeLvlObj.getLevel() * 100 / reservoirCapacity; + } } void interpolateWaterValue(const Data::AreaList& areas, @@ -98,65 +94,63 @@ void interpolateWaterValue(const Data::AreaList& areas, daysOfWeek[d] = weekFirstDay + d; } - areas.each( - [&](const Data::Area& area) - { - uint index = area.index; + for (const auto& [_, area] : areas) + { + uint index = area->index; - RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; + RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; - auto& waterVal = weeklyResults.valeurH2oHoraire; - std::fill(waterVal.begin(), waterVal.end(), 0.); + auto& waterVal = weeklyResults.valeurH2oHoraire; + std::fill(waterVal.begin(), waterVal.end(), 0.); - if (!area.hydro.reservoirManagement || !area.hydro.useWaterValue) - { - return; - } + if (!area->hydro.reservoirManagement || !area->hydro.useWaterValue) + { + return; + } - if (!area.hydro.useWaterValue) - { - return; - } + if (!area->hydro.useWaterValue) + { + return; + } - double reservoirCapacity = area.hydro.reservoirCapacity; + double reservoirCapacity = area->hydro.reservoirCapacity; - std::vector& niv = weeklyResults.niveauxHoraires; + std::vector& niv = weeklyResults.niveauxHoraires; - waterVal[0] = Data::getWaterValue(problem.previousSimulationFinalLevel[index] * 100 - / reservoirCapacity, - area.hydro.waterValues, - weekFirstDay); + waterVal[0] = Data::getWaterValue(problem.previousSimulationFinalLevel[index] * 100 + / reservoirCapacity, + area->hydro.waterValues, + weekFirstDay); - for (uint h = 1; h < nbHoursInAWeek; h++) - { - waterVal[h] = Data::getWaterValue(niv[h - 1], - area.hydro.waterValues, - daysOfWeek[h / 24]); - } - }); + for (uint h = 1; h < nbHoursInAWeek; h++) + { + waterVal[h] = Data::getWaterValue(niv[h - 1], + area->hydro.waterValues, + daysOfWeek[h / 24]); + } + } } void updatingWeeklyFinalHydroLevel(const Data::AreaList& areas, PROBLEME_HEBDO& problem) { - areas.each( - [&](const Data::Area& area) - { - if (!area.hydro.reservoirManagement) - { - return; - } + for (const auto& [_, area] : areas) + { + if (!area->hydro.reservoirManagement) + { + continue; + } - uint index = area.index; + uint index = area->index; - double reservoirCapacity = area.hydro.reservoirCapacity; + double reservoirCapacity = area->hydro.reservoirCapacity; - RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; + RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index]; - std::vector& niv = weeklyResults.niveauxHoraires; + std::vector& niv = weeklyResults.niveauxHoraires; - problem.previousSimulationFinalLevel[index] = niv[nbHoursInAWeek - 1] * reservoirCapacity - / 100; - }); + problem.previousSimulationFinalLevel[index] = niv[nbHoursInAWeek - 1] * reservoirCapacity + / 100; + } } } // namespace Antares::Solver::Simulation diff --git a/src/solver/simulation/common-hydro-remix.cpp b/src/solver/simulation/common-hydro-remix.cpp index a94b8f1dfe..dcf39052ce 100644 --- a/src/solver/simulation/common-hydro-remix.cpp +++ b/src/solver/simulation/common-hydro-remix.cpp @@ -51,7 +51,8 @@ static bool Remix(const Data::AreaList& areas, bool status = true; areas.each( - [&](const Data::Area& area) + [&HE, &DE, &remix, &G, &status, &problem, &numSpace, &hourInYear] + (const Data::Area& area) { auto index = area.index; diff --git a/src/solver/simulation/include/antares/solver/simulation/solver.hxx b/src/solver/simulation/include/antares/solver/simulation/solver.hxx index adf8c23c4d..8084130e9f 100644 --- a/src/solver/simulation/include/antares/solver/simulation/solver.hxx +++ b/src/solver/simulation/include/antares/solver/simulation/solver.hxx @@ -159,7 +159,7 @@ public: simulation_->prepareClustersInMustRunMode(scratchmap, y); // 4 - Hydraulic ventilation - pDurationCollector("hydro_ventilation") << [&] { + pDurationCollector("hydro_ventilation") << [this, &randomReservoirLevel] { hydroManagement.makeVentilation(randomReservoirLevel, y, scratchmap); @@ -205,7 +205,7 @@ public: // 9 - Write results for the current year if (yearByYear) { - pDurationCollector("yby_export") << [&] + pDurationCollector("yby_export") << [this] { // Before writing, some variable may require minor modifications simulation_->variables.beforeYearByYearExport(y, numSpace); @@ -776,7 +776,8 @@ void ISimulation::computeRandomNumbers( bool SpilledEnergySeedIsDefault = (currentSpilledEnergySeed == defaultSpilledEnergySeed); areaIndex = 0; study.areas.each( - [&](Data::Area& area) + [&isPerformed, &areaIndex, &randomUnsupplied, &randomSpilled, &randomForYears, &indexYear, + &SpilledEnergySeedIsDefault](Data::Area& area) { (void)area; // Avoiding warnings at compilation (unused variable) on linux if (isPerformed) @@ -938,7 +939,7 @@ static inline void logPerformedYearsInAset(setOfParallelYears& set) std::string performedYearsToLog = ""; std::ranges::for_each(set.yearsIndices, - [&](const uint& y) + [&set, &performedYearsToLog](const uint& y) { if (set.isYearPerformed[y]) { diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 155cb6b3bc..ed13d54fe1 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -198,7 +198,7 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, problem.CaracteristiquesHydrauliques[i].TailleReservoir = area.hydro.reservoirCapacity; - for (int pdt = 0; pdt < NombreDePasDeTemps; pdt++) + for (unsigned pdt = 0; pdt < NombreDePasDeTemps; pdt++) { problem.CaracteristiquesHydrauliques[i].NiveauHoraireInf[pdt] = 0; problem.CaracteristiquesHydrauliques[i].NiveauHoraireSup[pdt] diff --git a/src/solver/ts-generator/generator.cpp b/src/solver/ts-generator/generator.cpp index 2cb4227755..3423a9a8ad 100644 --- a/src/solver/ts-generator/generator.cpp +++ b/src/solver/ts-generator/generator.cpp @@ -27,7 +27,7 @@ namespace Antares::TSGenerator void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params) { areas.each( - [&](Data::Area& area) + [¶ms](Data::Area& area) { // Load if (params.timeSeriesToGenerate & Data::timeSeriesLoad) diff --git a/src/solver/ts-generator/hydro.cpp b/src/solver/ts-generator/hydro.cpp index 1b4ac3496d..29d0a29f42 100644 --- a/src/solver/ts-generator/hydro.cpp +++ b/src/solver/ts-generator/hydro.cpp @@ -42,7 +42,7 @@ static void PreproRoundAllEntriesPlusDerated(Data::Study& study) bool derated = study.parameters.derated; study.areas.each( - [&](Data::Area& area) + [&derated](Data::Area& area) { auto& hydroseries = *(area.hydro.series); @@ -180,7 +180,6 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, Solver::IResu uint month = i % 12; uint realmonth = calendar.months[month].realmonth; - uint daysPerMonth = calendar.months[month].days; assert(l < series.ror.timeSeries.width); assert(not std::isnan(colPOW[realmonth])); @@ -283,11 +282,11 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, Solver::IResu else { logs.info() << "Archiving the hydro time-series"; - const int precision = 0; - Yuni::String output; study.areas.each( - [&](const Data::Area& area) + [&study, ¤tYear, &writer, &progression](const Data::Area& area) { + const int precision = 0; + Yuni::String output; study.buffer.clear() << "ts-generator" << SEP << "hydro" << SEP << "mc-" << currentYear << SEP << area.id; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index feb8412f49..ca0c96087a 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -86,7 +86,7 @@ void XCast::exportTimeSeriesToTheOutput(Progression::Task& progression, Predicat filename.reserve(output.size() + 80); study.areas.each( - [&](Data::Area& area) + [this, &filename, &progression, &predicate, &output](Data::Area& area) { filename.clear() << output << SEP << area.id << ".txt"; std::string buffer; @@ -593,7 +593,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (study.parameters.derated) { - study.areas.each([&](Data::Area& area) { predicate.matrix(area).averageTimeseries(); }); + study.areas.each([&predicate](Data::Area& area) { predicate.matrix(area).averageTimeseries(); }); } if (study.parameters.timeSeriesToArchive & timeSeriesType) diff --git a/src/solver/variable/include/antares/solver/variable/area.hxx b/src/solver/variable/include/antares/solver/variable/area.hxx index 4fdeb096c0..d3b34bb973 100644 --- a/src/solver/variable/include/antares/solver/variable/area.hxx +++ b/src/solver/variable/include/antares/solver/variable/area.hxx @@ -369,7 +369,7 @@ void Areas::hourForEachArea(State& state, uint numSpace) { // For each area... state.study.areas.each( - [&](Data::Area& area) + [this, &state, &numSpace](Data::Area& area) { state.area = &area; // the current area @@ -402,7 +402,7 @@ void Areas::weekForEachArea(State& state, uint numSpace) { // For each area... state.study.areas.each( - [&](Data::Area& area) + [this, &state, &numSpace](Data::Area& area) { state.area = &area; // the current area @@ -437,7 +437,7 @@ void Areas::yearEndBuild(State& state, uint year, uint numSpace) { // For each area... state.study.areas.each( - [&](Data::Area& area) + [this, &state, &year, &numSpace](Data::Area& area) { state.area = &area; // the current area diff --git a/src/solver/variable/surveyresults/surveyresults.cpp b/src/solver/variable/surveyresults/surveyresults.cpp index e05283ff5a..0402fb6c15 100644 --- a/src/solver/variable/surveyresults/surveyresults.cpp +++ b/src/solver/variable/surveyresults/surveyresults.cpp @@ -127,7 +127,7 @@ static void ExportGridInfosAreas(const Data::Study& study, "marginal cost\tfixed cost\tstartup cost\tmarket bid cost\tspread cost\n"; study.areas.each( - [&](const Data::Area& area) + [&out, &outLinks, &outThermal](const Data::Area& area) { out << area.id << '\t'; out << area.name << '\n';