diff --git a/src/tools/ts-generator/include/antares/tools/ts-generator/tsGenerationOptions.h b/src/tools/ts-generator/include/antares/tools/ts-generator/tsGenerationOptions.h index dfc58257f5..2942964bd9 100644 --- a/src/tools/ts-generator/include/antares/tools/ts-generator/tsGenerationOptions.h +++ b/src/tools/ts-generator/include/antares/tools/ts-generator/tsGenerationOptions.h @@ -26,4 +26,6 @@ bool parseOptions(int, char*[], Settings&); std::unique_ptr createTsGeneratorParser(Settings&); bool checkOptions(Settings& options); +bool linkTSrequired(Settings& options); +bool thermalTSrequired(Settings& options); } diff --git a/src/tools/ts-generator/linksTSgenerator.cpp b/src/tools/ts-generator/linksTSgenerator.cpp index 62940cd377..6c16dfc0a3 100644 --- a/src/tools/ts-generator/linksTSgenerator.cpp +++ b/src/tools/ts-generator/linksTSgenerator.cpp @@ -226,7 +226,7 @@ void readPreproTimeSeries(std::vector& linkList, fs::path sourceAreaDir = toLinksDir / sourceAreaName; if (! readLinkPreproTimeSeries(link, sourceAreaDir)) { - logs.warning() << "Could not load all prepro data for link '" + logs.warning() << "Could not load all prepro/modulation data for link '" << link.namesPair.first << "." << link.namesPair.second << "'"; } } diff --git a/src/tools/ts-generator/main.cpp b/src/tools/ts-generator/main.cpp index 207617f5be..f320ee5989 100644 --- a/src/tools/ts-generator/main.cpp +++ b/src/tools/ts-generator/main.cpp @@ -76,44 +76,49 @@ int main(int argc, char* argv[]) if (! checkOptions(settings)) return 1; - // ============ THERMAL : Getting data for generating time-series ========= - auto study = std::make_shared(true); - Data::StudyLoadOptions studyOptions; - if (!study->loadFromFolder(settings.studyFolder, studyOptions)) - { - logs.error() << "Invalid study given to the generator"; - return 1; - } + bool return_code {true}; - std::vector clusters; - if (settings.allThermal) - { - clusters = getAllClustersToGen(study->areas, true); - } - else if (!settings.thermalListToGen.empty()) + if (thermalTSrequired(settings)) { - clusters = getClustersToGen(study->areas, settings.thermalListToGen); - } - // ======================================================================== - - LinksTSgenerator linksTSgenerator(settings); - linksTSgenerator.extractData(); - - // ============ TS Generation ============================================= - MersenneTwister thermalRandom; - thermalRandom.reset(study->parameters.seed[Data::seedTsGenThermal]); - - bool ret = TSGenerator::generateThermalTimeSeries(*study, - clusters, - thermalRandom); + // === Data for TS generation === + auto study = std::make_shared(true); + Data::StudyLoadOptions studyOptions; + if (!study->loadFromFolder(settings.studyFolder, studyOptions)) + { + logs.error() << "Invalid study given to the generator"; + return 1; + } - auto thermalSavePath = fs::path(settings.studyFolder) / "output" / FormattedTime("%Y%m%d-%H%M"); - thermalSavePath /= "ts-generator"; - thermalSavePath /= "thermal"; + std::vector clusters; + if (settings.allThermal) + { + clusters = getAllClustersToGen(study->areas, true); + } + else if (!settings.thermalListToGen.empty()) + { + clusters = getClustersToGen(study->areas, settings.thermalListToGen); + } - writeThermalTimeSeries(clusters, thermalSavePath); + // === TS generation === + MersenneTwister thermalRandom; + thermalRandom.reset(study->parameters.seed[Data::seedTsGenThermal]); + return_code = TSGenerator::generateThermalTimeSeries(*study, + clusters, + thermalRandom); + + // === Writing generated TS on disk === + auto thermalSavePath = fs::path(settings.studyFolder) / "output" / FormattedTime("%Y%m%d-%H%M"); + thermalSavePath /= "ts-generator"; + thermalSavePath /= "thermal"; + writeThermalTimeSeries(clusters, thermalSavePath); + } - ret = linksTSgenerator.generate() && ret; + if (linkTSrequired(settings)) + { + LinksTSgenerator linksTSgenerator(settings); + linksTSgenerator.extractData(); + return_code = linksTSgenerator.generate() && return_code; + } - return !ret; // return 0 for success + return !return_code; // return 0 for success } \ No newline at end of file diff --git a/src/tools/ts-generator/tsGenerationOptions.cpp b/src/tools/ts-generator/tsGenerationOptions.cpp index 16750a2173..48ee5b09e4 100644 --- a/src/tools/ts-generator/tsGenerationOptions.cpp +++ b/src/tools/ts-generator/tsGenerationOptions.cpp @@ -63,4 +63,12 @@ bool checkOptions(Settings& options) return true; } +bool linkTSrequired(Settings& options) +{ + return options.allLinks || !options.linksListToGen.empty(); +} +bool thermalTSrequired(Settings& options) +{ + return options.allThermal || !options.thermalListToGen.empty(); +} } \ No newline at end of file