Skip to content

Commit

Permalink
Split thermal TS generation : remove useless use of prepareOutput and…
Browse files Browse the repository at this point in the history
… timeSeriesToArchive
  • Loading branch information
guilpier-code committed Jun 28, 2024
1 parent 41822b0 commit 34eace9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
13 changes: 10 additions & 3 deletions src/solver/simulation/include/antares/solver/simulation/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,16 @@ void ISimulation<ImplementationType>::regenerateTimeSeries(uint year)
if (refreshTSonCurrentYear)
{
auto clusters = getAllClustersToGen(study.areas, pData.haveToRefreshTSThermal);
fs::path savePath = fs::path(study.folderOutput.to<std::string>()) / "ts-generator"
/ "thermal" / "mc-" / std::to_string(year);
generateThermalTimeSeries(study, clusters, study.runtime->random[Data::seedTsGenThermal], savePath);
generateThermalTimeSeries(study, clusters, study.runtime->random[Data::seedTsGenThermal]);

bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal;
bool doWeWrite = archive && !study.parameters.noOutput;
if (doWeWrite)
{
fs::path savePath = fs::path(study.folderOutput.to<std::string>()) / "ts-generator"
/ "thermal" / "mc-" / std::to_string(year);
writeThermalTimeSeries(clusters, savePath);
}

// apply the spinning if we generated some in memory clusters
for (auto* cluster: clusters)
Expand Down
17 changes: 6 additions & 11 deletions src/solver/ts-generator/availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,7 @@ void writeTStoDisk(const Matrix<>& series,

bool generateThermalTimeSeries(Data::Study& study,
const std::vector<Data::ThermalCluster*>& clusters,
MersenneTwister& thermalRandom,
const fs::path& savePath)
MersenneTwister& thermalRandom)
{
logs.info();
logs.info() << "Generating the thermal time-series";
Expand All @@ -629,14 +628,12 @@ bool generateThermalTimeSeries(Data::Study& study,
generator.run(tsGenerationData);
}

bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal;
bool doWeWrite = archive && !study.parameters.noOutput;
if (! doWeWrite)
{
logs.info() << "Study parameters forbid writing thermal TS.";
return true;
}
return true;
}

void writeThermalTimeSeries(const std::vector<Data::ThermalCluster*>& clusters,
const fs::path& savePath)
{
for (auto* cluster: clusters)
{
auto areaName = cluster->parentArea->id.to<std::string>();
Expand All @@ -645,8 +642,6 @@ bool generateThermalTimeSeries(Data::Study& study,

writeTStoDisk(cluster->series.timeSeries, filePath);
}

return true;
}

// gp : we should try to add const identifiers before args here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ bool GenerateTimeSeries(Data::Study& study, uint year, IResultWriter& writer);

bool generateThermalTimeSeries(Data::Study& study,
const std::vector<Data::ThermalCluster*>& clusters,
MersenneTwister& thermalRandom,
const fs::path& savePath);
MersenneTwister& thermalRandom);

void writeThermalTimeSeries(const std::vector<Data::ThermalCluster*>& clusters,
const fs::path& savePath);

bool generateLinkTimeSeries(std::vector<LinkTSgenerationParams>& links,
StudyParamsForLinkTS&,
Expand Down
19 changes: 7 additions & 12 deletions src/tools/ts-generator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,12 @@ int main(int argc, char* argv[])
// ============ THERMAL : Getting data for generating time-series =========
auto study = std::make_shared<Data::Study>(true);
Data::StudyLoadOptions studyOptions;
studyOptions.prepareOutput = true;

if (!study->loadFromFolder(settings.studyFolder, studyOptions))
{
logs.error() << "Invalid study given to the generator";
return 1;
}

// Forces the writing of generated TS into the study's output sub-folder
study->parameters.timeSeriesToArchive |= Antares::Data::timeSeriesThermal;

auto thermalSavePath = fs::path(settings.studyFolder) / "output" / FormattedTime("%Y%m%d-%H%M");
thermalSavePath /= "ts-generator";
thermalSavePath /= "thermal";

std::vector<Data::ThermalCluster*> clusters;
if (settings.allThermal)
{
Expand All @@ -105,7 +96,6 @@ int main(int argc, char* argv[])
}
// ========================================================================


LinksTSgenerator linksTSgenerator(settings);
linksTSgenerator.extractData();

Expand All @@ -115,8 +105,13 @@ int main(int argc, char* argv[])

bool ret = TSGenerator::generateThermalTimeSeries(*study,
clusters,
thermalRandom,
thermalSavePath);
thermalRandom);

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;

Expand Down

0 comments on commit 34eace9

Please sign in to comment.