diff --git a/src/solver/ts-generator/availability.cpp b/src/solver/ts-generator/availability.cpp index 938d395089..c51b006dde 100644 --- a/src/solver/ts-generator/availability.cpp +++ b/src/solver/ts-generator/availability.cpp @@ -76,7 +76,6 @@ class AvailabilityTSgenerator final public: explicit AvailabilityTSgenerator(Data::Study&, unsigned, MersenneTwister&); explicit AvailabilityTSgenerator(bool, unsigned, MersenneTwister&); - explicit GeneratorTempData(bool, unsigned, MersenneTwister&); void run(AvailabilityTSGeneratorData&) const; @@ -628,20 +627,6 @@ void writeTStoDisk(const Matrix<>& series, Antares::IO::fileSetContent(savePath.string(), buffer); } -void writeResultsToDisk(const Matrix<>& series, - const std::filesystem::path savePath) -{ - std::string buffer; - series.saveToBuffer(buffer, 0); - - std::filesystem::path parentDir = savePath.parent_path(); - if (! std::filesystem::exists(parentDir)) - { - std::filesystem::create_directories(parentDir); - } - Antares::IO::fileSetContent(savePath.string(), buffer); -} - bool generateThermalTimeSeries(Data::Study& study, const std::vector& clusters, const std::string& savePath) diff --git a/src/tools/ts-generator/main.cpp b/src/tools/ts-generator/main.cpp index 3910ebfa5b..74040e3f69 100644 --- a/src/tools/ts-generator/main.cpp +++ b/src/tools/ts-generator/main.cpp @@ -70,168 +70,6 @@ std::vector getClustersToGen(Data::AreaList& areas, return clusters; } -bool readLinkIniProperty(LinkTSgenerationParams* link, - const Yuni::String& key, - const Yuni::String& value) -{ - if (key == "unitcount") - { - return value.to(link->unitCount); - } - - if (key == "nominalcapacity") - { - return value.to(link->nominalCapacity); - } - - if (key == "law.planned") - { - return value.to(link->plannedLaw); - } - - if (key == "law.forced") - { - return value.to(link->forcedLaw); - } - - if (key == "volatility.planned") - { - return value.to(link->plannedVolatility); - } - - if (key == "volatility.forced") - { - return value.to(link->forcedVolatility); - } - - if (key == "force-no-generation") - { - return value.to(link->forceNoGeneration); - } - return true; -} - -void readLinkIniProperties(LinkTSgenerationParams* link, - IniFile::Section* section) -{ - for (const IniFile::Property* p = section->firstProperty; p; p = p->next) - { - if (! readLinkIniProperty(link, p->key, p->value)) - { - std::string linkName = link->namesPair.first + "." + link->namesPair.second; - logs.warning() << "Link '" << linkName << "' : reading value of '" - << p->key << "' went wrong"; - link->hasValidData = false; - } - } -} - -void readSourceAreaIniFile(fs::path pathToIni, - std::string sourceAreaName, - std::vector& linkList) -{ - IniFile ini; - ini.open(pathToIni); // gp : we should handle reading issues - for (auto* section = ini.firstSection; section; section = section->next) - { - std::string targetAreaName = transformNameIntoID(section->name); - const LinkPair processedLink = std::make_pair(sourceAreaName, targetAreaName); - if (auto* foundLink = findLinkInList(processedLink, linkList); foundLink) - { - readLinkIniProperties(foundLink, section); - } - } -} - -void readIniProperties(std::vector& linkList, fs::path toLinksDir) -{ - for(auto& link : linkList) - { - std::string sourceAreaName = link.namesPair.first; - fs::path pathToIni = toLinksDir / sourceAreaName / "properties.ini"; - readSourceAreaIniFile(pathToIni, sourceAreaName, linkList); - } -} - -bool readLinkPreproTimeSeries(LinkTSgenerationParams& link, - fs::path sourceAreaDir) -{ - bool to_return = true; - const auto preproId = link.namesPair.first + "/" + link.namesPair.second; - link.prepro = std::make_unique(preproId, link.unitCount); - - auto preproFileRoot = sourceAreaDir / "prepro" / link.namesPair.second; - - auto preproFile = preproFileRoot; - preproFile += ".txt"; - if (fs::exists(preproFile)) - { - to_return = link.prepro->data.loadFromCSVFile( - preproFile.string(), - Data::PreproAvailability::preproAvailabilityMax, - DAYS_PER_YEAR) - && link.prepro->validate() - && to_return; - } - - auto modulationFileDirect = preproFileRoot; - modulationFileDirect += "_mod_direct.txt"; - if (fs::exists(modulationFileDirect)) - { - to_return = link.modulationCapacityDirect.loadFromCSVFile( - modulationFileDirect.string(), - 1, - HOURS_PER_YEAR) - && to_return; - } - - auto modulationFileIndirect = preproFileRoot; - modulationFileIndirect += "_mod_indirect.txt"; - if (fs::exists(modulationFileIndirect)) - { - to_return = link.modulationCapacityIndirect.loadFromCSVFile( - modulationFileIndirect.string(), - 1, - HOURS_PER_YEAR) - && to_return; - } - // Makes possible a skip of TS generation when time comes - link.hasValidData = link.hasValidData && to_return; - return to_return; -} - -void readPreproTimeSeries(std::vector& linkList, - fs::path toLinksDir) -{ - for(auto& link : linkList) - { - std::string sourceAreaName = link.namesPair.first; - fs::path sourceAreaDir = toLinksDir / sourceAreaName; - if (! readLinkPreproTimeSeries(link, sourceAreaDir)) - { - logs.warning() << "Could not load all prepro data for link '" - << link.namesPair.first << "." << link.namesPair.second << "'"; - } - } -} - -void readLinksSpecificTSparameters(std::vector& linkList, - fs::path studyFolder) -{ - fs::path toLinksDir = studyFolder / "input" / "links"; - readIniProperties(linkList, toLinksDir); - readPreproTimeSeries(linkList, toLinksDir); -} - -std::string DateAndTime() -{ - YString to_return; - unsigned int now = Yuni::DateTime::Now(); - Yuni::DateTime::TimestampToString(to_return, "%Y%m%d-%H%M", now); - return to_return.to(); -} -// ============================================================================ - int main(int argc, char* argv[]) { logs.applicationName("ts-generator");