From 2710aa47b6c0ac14d601dd1ea57e463cf95d1380 Mon Sep 17 00:00:00 2001 From: Guillaume PIERRE Date: Tue, 25 Jun 2024 16:54:40 +0200 Subject: [PATCH] Split TS generation into files : renaming --- src/solver/ts-generator/availability.cpp | 56 +++++++++++---------- src/tools/ts-generator/linksTSgenerator.cpp | 2 +- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/solver/ts-generator/availability.cpp b/src/solver/ts-generator/availability.cpp index 696725f846..0c4c83fd32 100644 --- a/src/solver/ts-generator/availability.cpp +++ b/src/solver/ts-generator/availability.cpp @@ -70,13 +70,13 @@ AvailabilityTSGeneratorData::AvailabilityTSGeneratorData(LinkTSgenerationParams& namespace { -class GeneratorTempData final +class AvailabilityTSgenerator final { public: - explicit GeneratorTempData(Data::Study&, unsigned, MersenneTwister&); - explicit GeneratorTempData(bool, unsigned, MersenneTwister&); + explicit AvailabilityTSgenerator(Data::Study&, unsigned, MersenneTwister&); + explicit AvailabilityTSgenerator(bool, unsigned, MersenneTwister&); - void generateTS(AvailabilityTSGeneratorData&) const; + void run(AvailabilityTSGeneratorData&) const; private: bool derated; @@ -101,14 +101,18 @@ class GeneratorTempData final const T& duration) const; }; -GeneratorTempData::GeneratorTempData(Data::Study& study, unsigned nbOfSeriesToGen, MersenneTwister& rndGenerator): +AvailabilityTSgenerator::AvailabilityTSgenerator(Data::Study& study, + unsigned nbOfSeriesToGen, + MersenneTwister& rndGenerator): derated(study.parameters.derated), nbOfSeriesToGen_(nbOfSeriesToGen), rndgenerator(rndGenerator) { } -GeneratorTempData::GeneratorTempData(bool derated, unsigned int nbOfSeriesToGen, MersenneTwister& rndGenerator): +AvailabilityTSgenerator::AvailabilityTSgenerator(bool derated, + unsigned int nbOfSeriesToGen, + MersenneTwister& rndGenerator): derated(derated), nbOfSeriesToGen_(nbOfSeriesToGen), rndgenerator(rndGenerator) @@ -116,11 +120,11 @@ GeneratorTempData::GeneratorTempData(bool derated, unsigned int nbOfSeriesToGen, } template -void GeneratorTempData::prepareIndispoFromLaw(Data::StatisticalLaw law, - double volatility, - std::array& A, - std::array& B, - const T& duration) const +void AvailabilityTSgenerator::prepareIndispoFromLaw(Data::StatisticalLaw law, + double volatility, + std::array& A, + std::array& B, + const T& duration) const { switch (law) { @@ -161,11 +165,11 @@ void GeneratorTempData::prepareIndispoFromLaw(Data::StatisticalLaw law, } } -int GeneratorTempData::durationGenerator(Data::StatisticalLaw law, - int expec, - double volat, - double a, - double b) const +int AvailabilityTSgenerator::durationGenerator(Data::StatisticalLaw law, + int expec, + double volat, + double a, + double b) const { if (volat == 0 || expec == 1) { @@ -193,7 +197,7 @@ int GeneratorTempData::durationGenerator(Data::StatisticalLaw law, return 0; } -void GeneratorTempData::generateTS(AvailabilityTSGeneratorData& tsGenerationData) const +void AvailabilityTSgenerator::run(AvailabilityTSGeneratorData& tsGenerationData) const { assert(tsGenerationData.prepro); @@ -647,14 +651,14 @@ bool generateThermalTimeSeries(Data::Study& study, bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal; - auto generator = GeneratorTempData(study, - study.parameters.nbTimeSeriesThermal, - study.runtime->random[Data::seedTsGenThermal]); + auto generator = AvailabilityTSgenerator(study, + study.parameters.nbTimeSeriesThermal, + study.runtime->random[Data::seedTsGenThermal]); for (auto* cluster: clusters) { AvailabilityTSGeneratorData tsGenerationData(cluster); - generator.generateTS(tsGenerationData); + generator.run(tsGenerationData); if (archive) // For compatibilty with in memory thermal TS generation { @@ -675,9 +679,9 @@ bool generateLinkTimeSeries(std::vector& links, logs.info(); logs.info() << "Generation of links time-series"; - auto generator = GeneratorTempData(generalParams.derated, - generalParams.nbLinkTStoGenerate, - generalParams.random); + auto generator = AvailabilityTSgenerator(generalParams.derated, + generalParams.nbLinkTStoGenerate, + generalParams.random); for (auto& link: links) { if (! link.hasValidData) @@ -696,7 +700,7 @@ bool generateLinkTimeSeries(std::vector& links, // DIRECT AvailabilityTSGeneratorData tsConfigDataDirect(link, ts, link.modulationCapacityDirect, link.namesPair.second); - generator.generateTS(tsConfigDataDirect); + generator.run(tsConfigDataDirect); std::string filePath = savePath + SEP + link.namesPair.first + SEP + link.namesPair.second + "_direct.txt"; @@ -705,7 +709,7 @@ bool generateLinkTimeSeries(std::vector& links, // INDIRECT AvailabilityTSGeneratorData tsConfigDataIndirect(link, ts, link.modulationCapacityIndirect, link.namesPair.second); - generator.generateTS(tsConfigDataIndirect); + generator.run(tsConfigDataIndirect); filePath = savePath + SEP + link.namesPair.first + SEP + link.namesPair.second + "_indirect.txt"; diff --git a/src/tools/ts-generator/linksTSgenerator.cpp b/src/tools/ts-generator/linksTSgenerator.cpp index b87351f4b4..87d1e94aad 100644 --- a/src/tools/ts-generator/linksTSgenerator.cpp +++ b/src/tools/ts-generator/linksTSgenerator.cpp @@ -56,7 +56,7 @@ bool readLinkGeneralProperty(StudyParamsForLinkTS& params, params.random.reset(seed); return true; } - return true; // gp : should we return true here ? + return true; } std::vector CreateLinkList(const LinkPairs& linksFromCmdLine)