Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link TS generation : splitting into multiple files #2171

Merged
merged 31 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f557ada
Remove TS links from solver : extract link names from study.
guilpier-code Jun 11, 2024
0c9ff69
Remove TS links from solver : extract study general parameters relate…
guilpier-code Jun 11, 2024
75476f2
Remove TS links from solver : extract properties from files "properti…
guilpier-code Jun 12, 2024
efa2b35
Remove TS links from solver : adding the reading of prepro TS
guilpier-code Jun 12, 2024
825ca9b
Remove TS links from solver : actually generating TS for links
guilpier-code Jun 13, 2024
a2b3bed
Remove TS links from solver : remove now useless code
guilpier-code Jun 13, 2024
040e83c
Remove TS links from solver : remove more code + correcting reading e…
guilpier-code Jun 13, 2024
3ea7537
Remove TS links from solver : useless code removal
guilpier-code Jun 13, 2024
1999d0c
[skip ci] Remove TS links from solver : code removal
guilpier-code Jun 13, 2024
1862e31
Remove TS links from solver : review corrections + more simplifications
guilpier-code Jun 14, 2024
e284102
Remove TS links from solver : simplifying the data load error handling
guilpier-code Jun 14, 2024
b671e22
Eliminate need for index in loop
flomnes Jun 14, 2024
c844e03
Split TS generation into files : move options handling to separate so…
guilpier-code Jun 14, 2024
fcca483
Split TS generation into files : start moving code for links TS to ne…
guilpier-code Jun 14, 2024
2a1fa53
Split TS generation into files : move code related to TS for links fr…
guilpier-code Jun 14, 2024
46cf379
Split TS generation into files : removing useless header include and …
guilpier-code Jun 17, 2024
8d03e1e
Split TS generation into files : simplifying a loop
guilpier-code Jun 24, 2024
c60b905
Split TS generation into files : move header files to the right place
guilpier-code Jun 25, 2024
ebdef47
Split TS generation into files : taking code review into account
guilpier-code Jun 25, 2024
b2cc58e
Split TS generation into files : remove code duplication about time
guilpier-code Jun 25, 2024
2710aa4
Split TS generation into files : renaming
guilpier-code Jun 25, 2024
f842001
Split TS generation into files : simplifying and renaming function wr…
guilpier-code Jun 25, 2024
82d9bb0
Split TS generation into files : correction for a regression on CI
guilpier-code Jun 26, 2024
4961ceb
TS : generator : make it work for thermal (#2200)
guilpier-code Jun 28, 2024
76a83f9
Merge remote-tracking branch 'remotes/origin/develop' into fix/split-…
guilpier-code Jun 28, 2024
2abab72
Split TS generation into files : correction after merge
guilpier-code Jun 28, 2024
7c094b2
Merge remote-tracking branch 'github/develop' into fix/split-ts-gener…
flomnes Jun 28, 2024
c133e88
TS generator : refactor thermal part (#2202)
guilpier-code Jul 5, 2024
78b0e68
Merge remote-tracking branch 'github/develop' into fix/split-ts-gener…
flomnes Jul 9, 2024
fa17f6e
Formatting
flomnes Jul 9, 2024
e7e7270
Update src/libs/antares/utils/utils.cpp
flomnes Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/libs/antares/utils/include/antares/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ namespace Antares
*/
template<class StringT>
void TransformNameIntoID(const AnyString& name, StringT& out);

std::string transformNameIntoID(const std::string& name);

std::string FormattedTime(const std::string& format);

/*!
** \brief Beautify a name, for renaming an area for example
*/
Expand All @@ -51,11 +52,8 @@ std::vector<std::pair<std::string, std::string>> splitStringIntoPairs(const std:

namespace Utils
{

bool isZero(double d);

double round(double d, unsigned precision);

} // namespace Utils
} // namespace Antares

Expand Down
12 changes: 12 additions & 0 deletions src/libs/antares/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ void BeautifyName(std::string& out, const std::string& oldname)
out = yuniOut.c_str();
}

std::string FormattedTime(const std::string& format)
{
using namespace std::chrono;
auto time = system_clock::to_time_t(system_clock::now());
std::tm local_time = *std::localtime(&time);

char time_buffer[256];
std::strftime(time_buffer, sizeof(time_buffer), format.c_str(), &local_time);

return std::string(time_buffer);
}

std::vector<std::pair<std::string, std::string>> splitStringIntoPairs(const std::string& s,
char delimiter1,
char delimiter2)
Expand Down
19 changes: 3 additions & 16 deletions src/solver/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,20 +435,6 @@ void Application::runSimulationInAdequacyMode()
observer);
}

static std::string timeToString()
{
using namespace std::chrono;
auto time = system_clock::to_time_t(system_clock::now());
std::tm local_time = *std::localtime(&time);

char time_buffer[256];
std::strftime(time_buffer, sizeof(time_buffer), "%Y%m%d-%H%M%S", &local_time);

std::string currentTime = time_buffer;

return currentTime;
}

void Application::resetLogFilename() const
{
fs::path logfile = fs::path(pSettings.studyFolder.c_str()) / "logs";
Expand All @@ -459,8 +445,9 @@ void Application::resetLogFilename() const
+ ". Aborting now.");
}

logfile /= "solver-"; // append the filename
logfile += timeToString() + ".log"; // complete filename with timestamp and extension
logfile /= "solver-"; // append the filename
logfile += FormattedTime("%Y%m%d-%H%M%S")
+ ".log"; // complete filename with timestamp and extension

// Assigning the log filename
logs.logfile(logfile.string());
Expand Down
19 changes: 14 additions & 5 deletions src/solver/simulation/include/antares/solver/simulation/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,24 @@ void ISimulation<ImplementationType>::regenerateTimeSeries(uint year)
if (refreshTSonCurrentYear)
{
auto clusters = getAllClustersToGen(study.areas, pData.haveToRefreshTSThermal);
#define SEP Yuni::IO::Separator
const std::string savePath = std::string("ts-generator") + SEP + "thermal" + SEP + "mc-"
+ std::to_string(year);
#undef SEP
generateThermalTimeSeries(study, clusters, pResultWriter, 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)
{
cluster->calculationOfSpinning();
}
}
};
}
Expand Down
Loading
Loading