From 96c13d7ee62d314093b95f41d1fd07daa3935524 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 19 Dec 2024 11:18:24 +0100 Subject: [PATCH] Add dir loadfile/ , add readSystem --- src/solver/modeler/CMakeLists.txt | 1 + src/solver/modeler/loadFiles/CMakeLists.txt | 27 ++++++++++++ .../antares/solver/loadFiles/loadFiles.h | 34 ++++++++++++++ src/solver/modeler/loadFiles/readSystem.cpp | 44 +++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 src/solver/modeler/loadFiles/CMakeLists.txt create mode 100644 src/solver/modeler/loadFiles/include/antares/solver/loadFiles/loadFiles.h create mode 100644 src/solver/modeler/loadFiles/readSystem.cpp diff --git a/src/solver/modeler/CMakeLists.txt b/src/solver/modeler/CMakeLists.txt index 3c631240ac..2ad5b9a49d 100644 --- a/src/solver/modeler/CMakeLists.txt +++ b/src/solver/modeler/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(api) add_subdirectory(ortoolsImpl) +add_subdirectory(loadFiles) diff --git a/src/solver/modeler/loadFiles/CMakeLists.txt b/src/solver/modeler/loadFiles/CMakeLists.txt new file mode 100644 index 0000000000..f0ed12e20f --- /dev/null +++ b/src/solver/modeler/loadFiles/CMakeLists.txt @@ -0,0 +1,27 @@ +set(SOURCES + readSystem.cpp +) + +# Create the library +add_library(loadFiles STATIC ${SOURCES}) +add_library(Antares::loadFiles ALIAS loadFiles) + +# Specify include directories +target_include_directories(loadFiles + PUBLIC + $ +) + +# Link dependencies (if any) +target_link_libraries(loadFiles + PUBLIC + Antares::antares-study-system-model + PRIVATE + io + Antares::systemParser + Antares::modelConverter +) + +install(DIRECTORY include/antares + DESTINATION "include" +) diff --git a/src/solver/modeler/loadFiles/include/antares/solver/loadFiles/loadFiles.h b/src/solver/modeler/loadFiles/include/antares/solver/loadFiles/loadFiles.h new file mode 100644 index 0000000000..c3018b9d09 --- /dev/null +++ b/src/solver/modeler/loadFiles/include/antares/solver/loadFiles/loadFiles.h @@ -0,0 +1,34 @@ +/* + * Copyright 2007-2024, RTE (https://www.rte-france.com) + * See AUTHORS.txt + * SPDX-License-Identifier: MPL-2.0 + * This file is part of Antares-Simulator, + * Adequacy and Performance assessment for interconnected energy networks. + * + * Antares_Simulator is free software: you can redistribute it and/or modify + * it under the terms of the Mozilla Public Licence 2.0 as published by + * the Mozilla Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Antares_Simulator is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Mozilla Public Licence 2.0 for more details. + * + * You should have received a copy of the Mozilla Public Licence 2.0 + * along with Antares_Simulator. If not, see . + */ + +#pragma once + +#include + +#include "antares/study/system-model/system.h" + +namespace Antares::Solver::LoadFiles +{ + +Study::SystemModel::System loadSystem(const std::filesystem::path& studyPath, + const std::vector& libraries); + +} // namespace Antares::Solver::LoadFiles diff --git a/src/solver/modeler/loadFiles/readSystem.cpp b/src/solver/modeler/loadFiles/readSystem.cpp new file mode 100644 index 0000000000..474b9ece60 --- /dev/null +++ b/src/solver/modeler/loadFiles/readSystem.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2007-2024, RTE (https://www.rte-france.com) + * See AUTHORS.txt + * SPDX-License-Identifier: MPL-2.0 + * This file is part of Antares-Simulator, + * Adequacy and Performance assessment for interconnected energy networks. + * + * Antares_Simulator is free software: you can redistribute it and/or modify + * it under the terms of the Mozilla Public Licence 2.0 as published by + * the Mozilla Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Antares_Simulator is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Mozilla Public Licence 2.0 for more details. + * + * You should have received a copy of the Mozilla Public Licence 2.0 + * along with Antares_Simulator. If not, see . + */ + +#include + +#include +#include + +#include "antares/solver/loadFiles/loadFiles.h" + +namespace fs = std::filesystem; + +namespace Antares::Solver::LoadFiles +{ + +Study::SystemModel::System loadSystem(const fs::path& studyPath, const std::vector& libraries) +{ + const std::string systemStr = IO::readFile(studyPath / "input" / "system.yml"); + + SystemParser::Parser parser; + SystemParser::System systemObj = parser.parse(systemStr); + + return SystemConverter::convert(systemObj, libraries);; +} + +} // namespace Antares::Solver::LoadFiles