From 3ba4878feff91d997b39495505c8e932f582df1e Mon Sep 17 00:00:00 2001 From: payetvin <113102157+payetvin@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:33:36 +0200 Subject: [PATCH 1/8] cherry pick 252a107 --- src/solver/optimisation/post_process_commands.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 16f36bc7bc..72334a7255 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -263,9 +263,9 @@ double CurtailmentSharingPostProcessCmd::calculateDensNewAndTotalLmrViolation() const auto& scratchpad = area_list_[Area]->scratchpad[thread_number_]; double dtgMrg = scratchpad.dispatchableGenerationMargin[hour]; // write down densNew values for all the hours - problemeHebdo_->ResultatsHoraires[Area].ValeursHorairesDENS[hour] - = std::max(0.0, densNew - dtgMrg); - ; + problemeHebdo_->ResultatsHoraires[Area].ValeursHorairesDENS[hour] = std::max( + 0.0, + densNew); // copy spilled Energy values into spilled Energy values after CSR problemeHebdo_->ResultatsHoraires[Area].ValeursHorairesSpilledEnergyAfterCSR[hour] = problemeHebdo_->ResultatsHoraires[Area] From d65a91828ea50e9f9516489287306a1125a7fcd7 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Mon, 15 Jul 2024 16:44:52 +0200 Subject: [PATCH 2/8] revision number --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17cb3478a9..a200843746 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version set(ANTARES_VERSION_HI 8) set(ANTARES_VERSION_LO 6) -set(ANTARES_VERSION_REVISION 8) +set(ANTARES_VERSION_REVISION 9) set(ANTARES_VERSION_YEAR 2024) project(antares From b022393c45456fdbb4a19b38adf02202db030b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Fri, 8 Mar 2024 15:11:47 +0100 Subject: [PATCH 3/8] cherry pick 9cbf137 --- src/tools/batchrun/main.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/tools/batchrun/main.cpp b/src/tools/batchrun/main.cpp index 34635bfe07..d937c8325d 100644 --- a/src/tools/batchrun/main.cpp +++ b/src/tools/batchrun/main.cpp @@ -32,12 +32,16 @@ #include #include #include +#include #include #include #include #include "../../ui/common/winmain.hxx" #include #include +#include +#include + #ifdef YUNI_OS_WINDOWS #include #endif @@ -84,7 +88,8 @@ int main(int argc, char* argv[]) Antares::Resources::Initialize(argc, argv, true); // options - String optInput; + std::string optInput; + std::string ortoolsSolver; bool optNoTSImport = false; bool optIgnoreAllConstraints = false; bool optForceExpansion = false; @@ -95,6 +100,7 @@ int main(int argc, char* argv[]) bool optNoOutput = false; bool optParallel = false; bool optVerbose = false; + bool ortoolsUsed = false; Nullable optYears; Nullable optSolver; Nullable optName; @@ -143,6 +149,20 @@ int main(int argc, char* argv[]) ' ', "force-parallel", "Override the max number of years computed simultaneously"); + + // add option for ortools use + // --use-ortools + options.addFlag(ortoolsUsed, ' ', "use-ortools", "Use ortools library to launch solver"); + + //--ortools-solver + options.add(ortoolsSolver, + ' ', + "ortools-solver", + "Ortools solver used for simulation (only available with use-ortools " + "option)\nAvailable solver list : " + + availableOrToolsSolversString()); + + options.remainingArguments(optInput); // Version options.addParagraph("\nMisc."); @@ -276,8 +296,11 @@ int main(int argc, char* argv[]) cmd << " --no-constraints"; if (optParallel) cmd << " --parallel"; - if (!(!optForceParallel)) + if (optForceParallel) cmd << " --force-parallel=" << *optForceParallel; + if (ortoolsUsed) + cmd << " --ortools-solver=" << ortoolsSolver; + cmd << " \"" << studypath << "\""; if (!optVerbose) cmd << sendToNull(); From dab893fd92bde096b7208ca40c6a422c5d55bde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Wed, 13 Mar 2024 12:53:13 +0100 Subject: [PATCH 4/8] cherry pick 9d9c7f6 --- src/tools/batchrun/main.cpp | 308 +++++++++++++++++++----------------- 1 file changed, 160 insertions(+), 148 deletions(-) diff --git a/src/tools/batchrun/main.cpp b/src/tools/batchrun/main.cpp index d937c8325d..1cc0004085 100644 --- a/src/tools/batchrun/main.cpp +++ b/src/tools/batchrun/main.cpp @@ -150,18 +150,17 @@ int main(int argc, char* argv[]) "force-parallel", "Override the max number of years computed simultaneously"); - // add option for ortools use - // --use-ortools - options.addFlag(ortoolsUsed, ' ', "use-ortools", "Use ortools library to launch solver"); - - //--ortools-solver - options.add(ortoolsSolver, - ' ', - "ortools-solver", - "Ortools solver used for simulation (only available with use-ortools " - "option)\nAvailable solver list : " - + availableOrToolsSolversString()); + // add option for ortools use + // --use-ortools + options.addFlag(ortoolsUsed, ' ', "use-ortools", "Use ortools library to launch solver"); + //--ortools-solver + options.add(ortoolsSolver, + ' ', + "ortools-solver", + "Ortools solver used for simulation (only available with use-ortools " + "option)\nAvailable solver list : " + + availableOrToolsSolversString()); options.remainingArguments(optInput); // Version @@ -196,166 +195,179 @@ int main(int argc, char* argv[]) logs.error() << "contradictory options: --economy and --adequacy"; return EXIT_FAILURE; } - } - - // Source Folder - logs.debug() << "Folder : `" << optInput << '`'; - String solver; - if (optSolver.empty()) - { - Solver::FindLocation(solver); - if (solver.empty()) - { - logs.fatal() << "The solver has not been found"; - return EXIT_FAILURE; - } - } - else - { - String tmp; - IO::MakeAbsolute(tmp, *optSolver); - IO::Normalize(solver, tmp); - if (not IO::File::Exists(solver)) + if (ortoolsUsed) { - logs.fatal() << "The solver has not been found. specify --solver=" << solver; - return EXIT_FAILURE; + const auto availableSolvers = getAvailableOrtoolsSolverName(); + if (auto it + = std::find(availableSolvers.begin(), availableSolvers.end(), ortoolsSolver); + it == availableSolvers.end()) + { + logs.error() << "Please specify a solver using --ortools-solver. Available solvers " + << availableOrToolsSolversString() << ""; + return EXIT_FAILURE; + } } - } - logs.info() << " Solver: '" << solver << "'"; - logs.info(); - logs.info(); - logs.info() << "Searching for studies..."; - logs.info(); - MyStudyFinder finder; - finder.lookup(optInput); - finder.wait(); + // Source Folder + logs.debug() << "Folder : `" << optInput << '`'; - if (not finder.list.empty()) - { - if (finder.list.size() > 1) - logs.info() << "Found " << finder.list.size() << " studyies"; + String solver; + if (optSolver.empty()) + { + Solver::FindLocation(solver); + if (solver.empty()) + { + logs.fatal() << "The solver has not been found"; + return EXIT_FAILURE; + } + } else - logs.info() << "Found 1 study"; - logs.info() << "Starting..."; - - if (!(!optName)) { - String name; - name = *optName; - name.replace("\"", "\\\""); - *optName = name; + String tmp; + IO::MakeAbsolute(tmp, *optSolver); + IO::Normalize(solver, tmp); + if (not IO::File::Exists(solver)) + { + logs.fatal() << "The solver has not been found. specify --solver=" << solver; + return EXIT_FAILURE; + } } - // The folder that contains the solver - String dirname; - IO::ExtractFilePath(dirname, solver); - - String cmd; + logs.info() << " Solver: '" << solver << "'"; + logs.info(); + logs.info(); + logs.info() << "Searching for studies..."; + logs.info(); + MyStudyFinder finder; + finder.lookup(optInput); + finder.wait(); - uint studyIndx = 0; - foreach (auto& studypath, finder.list) + if (not finder.list.empty()) { - ++studyIndx; - - logs.info(); - if (optVerbose) - logs.info(); - - logs.checkpoint() << "Running simulation: `" << studypath << "` (" << studyIndx << '/' - << (uint)finder.list.size() << ')'; - if (optVerbose) - logs.debug(); - - cmd.clear(); - if (not System::windows) - cmd << "nice "; + if (finder.list.size() > 1) + logs.info() << "Found " << finder.list.size() << " studyies"; else - cmd << "call "; // why is it required for working ??? - cmd << "\"" << solver << "\""; - if (optForce) - cmd << " --force"; - if (optForceExpansion) - cmd << " --economy"; - if (optForceEconomy) - cmd << " --economy"; - if (optForceAdequacy) - cmd << " --adequacy"; + logs.info() << "Found 1 study"; + logs.info() << "Starting..."; + if (!(!optName)) - cmd << " --name=\"" << *optName << "\""; - if (!(!optYears)) - cmd << " --year=" << *optYears; - if (optNoOutput) - cmd << " --no-output"; - if (optYearByYear) - cmd << " --year-by-year"; - if (optNoTSImport) - cmd << " --no-ts-import"; - if (optIgnoreAllConstraints) - cmd << " --no-constraints"; - if (optParallel) - cmd << " --parallel"; - if (optForceParallel) - cmd << " --force-parallel=" << *optForceParallel; - if (ortoolsUsed) - cmd << " --ortools-solver=" << ortoolsSolver; - - cmd << " \"" << studypath << "\""; - if (!optVerbose) - cmd << sendToNull(); - - // Changing the current working directory - IO::Directory::Current::Set(dirname); - // Executing the converter - if (optVerbose) - logs.info() << "Executing " << cmd; + { + String name; + name = *optName; + name.replace("\"", "\\\""); + *optName = name; + } - // Execute the command - int cmd_return_code = system(cmd.c_str()); + // The folder that contains the solver + String dirname; + IO::parent_path(dirname, solver); - if (cmd_return_code != 0) - logs.error() << "An error occured."; - else - logs.info() << "Success."; + String cmd; - if (cmd_return_code == -1) + uint studyIndx = 0; + foreach (auto& studypath, finder.list) { -#ifdef YUNI_OS_WINDOWS - switch (errno) + ++studyIndx; + + logs.info(); + if (optVerbose) + logs.info(); + + logs.checkpoint() << "Running simulation: `" << studypath << "` (" << studyIndx + << '/' << (uint)finder.list.size() << ')'; + if (optVerbose) + logs.debug(); + + cmd.clear(); + if (not System::windows) + cmd << "nice "; + else + cmd << "call "; // why is it required for working ??? + cmd << "\"" << solver << "\""; + if (optForce) + cmd << " --force"; + if (optForceExpansion) + cmd << " --economy"; + if (optForceEconomy) + cmd << " --economy"; + if (optForceAdequacy) + cmd << " --adequacy"; + if (!(!optName)) + cmd << " --name=\"" << *optName << "\""; + if (!(!optYears)) + cmd << " --year=" << *optYears; + if (optNoOutput) + cmd << " --no-output"; + if (optYearByYear) + cmd << " --year-by-year"; + if (optNoTSImport) + cmd << " --no-ts-import"; + if (optIgnoreAllConstraints) + cmd << " --no-constraints"; + if (optParallel) + cmd << " --parallel"; + if (optForceParallel) + cmd << " --force-parallel=" << *optForceParallel; + if (ortoolsUsed) + cmd << " --use-ortools --ortools-solver=" << ortoolsSolver; + + cmd << " \"" << studypath << "\""; + if (!optVerbose) + cmd << sendToNull(); + + // Changing the current working directory + IO::Directory::Current::Set(dirname); + // Executing the converter + if (optVerbose) + logs.info() << "Executing " << cmd; + + // Execute the command + int cmd_return_code = system(cmd.c_str()); + + if (cmd_return_code != 0) + logs.error() << "An error occured."; + else + logs.info() << "Success."; + + if (cmd_return_code == -1) { - case E2BIG: - logs.error() << "Argument list (which is system dependent) is too big"; - break; - case ENOENT: - logs.error() << "Command interpreter cannot be found"; - break; - case ENOEXEC: - logs.error() - << "Command-interpreter file has invalid format and is not executable"; - break; - case ENOMEM: - logs.error() << "Not enough memory is available to execute command"; - break; - } +#ifdef YUNI_OS_WINDOWS + switch (errno) + { + case E2BIG: + logs.error() << "Argument list (which is system dependent) is too big"; + break; + case ENOENT: + logs.error() << "Command interpreter cannot be found"; + break; + case ENOEXEC: + logs.error() + << "Command-interpreter file has invalid format and is not executable"; + break; + case ENOMEM: + logs.error() << "Not enough memory is available to execute command"; + break; + } #endif + } } - } - logs.info() << "Done."; + logs.info() << "Done."; - // Time interval - if (optVerbose) + // Time interval + if (optVerbose) + { + logs.debug(); + logs.debug(); + } + } + else { - logs.debug(); - logs.debug(); + logs.fatal() << "No study has been found."; + return 4; } - } - else - { - logs.fatal() << "No study has been found."; - return 4; - } - return 0; + return 0; + } } From 44678a22e7f9849bdd5c2e010ebefcdb7154918c Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Tue, 16 Jul 2024 15:32:56 +0200 Subject: [PATCH 5/8] fix compile --- src/solver/utils/ortools_utils.cpp | 13 +++++++++++++ src/solver/utils/ortools_utils.h | 7 +++++++ src/tools/batchrun/main.cpp | 5 ++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/solver/utils/ortools_utils.cpp b/src/solver/utils/ortools_utils.cpp index 7503fe3d5c..ff6b04caae 100644 --- a/src/solver/utils/ortools_utils.cpp +++ b/src/solver/utils/ortools_utils.cpp @@ -401,6 +401,19 @@ std::list getAvailableOrtoolsSolverName() return result; } +std::string availableOrToolsSolversString() +{ + const std::list availableSolverList = getAvailableOrtoolsSolverName(); + std::ostringstream solvers; + for (const std::string& avail: availableSolverList) + { + bool last = &avail == &availableSolverList.back(); + std::string sep = last ? "." : ", "; + solvers << avail << sep; + } + return solvers.str(); +} + MPSolver* MPSolverFactory(const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* probleme, const std::string& solverName) { diff --git a/src/solver/utils/ortools_utils.h b/src/solver/utils/ortools_utils.h index e5d63fe765..e08a52f0ca 100644 --- a/src/solver/utils/ortools_utils.h +++ b/src/solver/utils/ortools_utils.h @@ -21,6 +21,13 @@ void ORTOOLS_EcrireJeuDeDonneesLineaireAuFormatMPS(MPSolver* solver, */ std::list getAvailableOrtoolsSolverName(); +/*! + * \brief Return a single string containing all solvers available, separated by a ", " and ending + * with a ".". + * + */ +std::string availableOrToolsSolversString(); + /*! * \brief Create a MPSolver with correct linear or mixed variant * diff --git a/src/tools/batchrun/main.cpp b/src/tools/batchrun/main.cpp index 1cc0004085..f8f34f2abd 100644 --- a/src/tools/batchrun/main.cpp +++ b/src/tools/batchrun/main.cpp @@ -39,8 +39,7 @@ #include "../../ui/common/winmain.hxx" #include #include -#include -#include +#include "../solver/utils/ortools_utils.h" #ifdef YUNI_OS_WINDOWS #include @@ -261,7 +260,7 @@ int main(int argc, char* argv[]) // The folder that contains the solver String dirname; - IO::parent_path(dirname, solver); + IO::ExtractFilePath(dirname, solver); String cmd; From e5886cfd0f9f57fa6222b54246f0ff4739c3b05d Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Tue, 16 Jul 2024 15:38:29 +0200 Subject: [PATCH 6/8] fix link --- src/solver/misc/options.cpp | 14 -------------- src/tools/batchrun/CMakeLists.txt | 1 + 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/solver/misc/options.cpp b/src/solver/misc/options.cpp index e4d482a999..e1fb15d666 100644 --- a/src/solver/misc/options.cpp +++ b/src/solver/misc/options.cpp @@ -54,20 +54,6 @@ using namespace Yuni; using namespace Antares; using namespace Antares::Data; -static std::string availableOrToolsSolversString() -{ - const std::list availableSolverList = getAvailableOrtoolsSolverName(); - std::string availableSolverListStr; - for (auto it = availableSolverList.begin(); it != availableSolverList.end(); it++) - { - availableSolverListStr += *it + ";"; - } - // Remove last semicolumn - if (!availableSolverListStr.empty()) - availableSolverListStr.pop_back(); - return availableSolverListStr; -} - std::unique_ptr CreateParser(Settings& settings, Antares::Data::StudyLoadOptions& options) { diff --git a/src/tools/batchrun/CMakeLists.txt b/src/tools/batchrun/CMakeLists.txt index a4ba01d80b..2457da817f 100644 --- a/src/tools/batchrun/CMakeLists.txt +++ b/src/tools/batchrun/CMakeLists.txt @@ -39,6 +39,7 @@ set(BATCHRUN_LIBS libantares-core libantares-core-calendar yuni-static-core + utils ${CMAKE_THREADS_LIBS_INIT} ) From 55ad4ea1d0d59586760b378a155f969b3b64a496 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:31:09 +0200 Subject: [PATCH 7/8] allow unsecure nodejs version for centos --- .github/workflows/centos7.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 7a29b6c5b3..c0df6c327c 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -17,6 +17,7 @@ env: GITHUB_TOKEN: ${{ github.token }} IS_RELEASE: ${{ github.event_name == 'release' && github.event.action == 'created' }} IS_PUSH: ${{ github.event_name == 'push' }} + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: From 8ab8a5404dbcb2ddfc2f23435f4828cc4a92b770 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 10 Jan 2025 14:32:07 +0100 Subject: [PATCH 8/8] upper case for sts group --- .../parts/short-term-storage/properties.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libs/antares/study/parts/short-term-storage/properties.cpp b/src/libs/antares/study/parts/short-term-storage/properties.cpp index 0b997a2e77..be7c5a0bde 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.cpp +++ b/src/libs/antares/study/parts/short-term-storage/properties.cpp @@ -26,6 +26,8 @@ */ #include +#include + #include #include "properties.h" @@ -35,15 +37,15 @@ namespace Antares::Data::ShortTermStorage { const std::map Properties::ST_STORAGE_PROPERTY_GROUP_ENUM - = {{"PSP_open", Group::PSP_open}, - {"PSP_closed", Group::PSP_closed}, - {"Pondage", Group::Pondage}, - {"Battery", Group::Battery}, - {"Other1", Group::Other1}, - {"Other2", Group::Other2}, - {"Other3", Group::Other3}, - {"Other4", Group::Other4}, - {"Other5", Group::Other5}}; + = {{"PSP_OPEN", Group::PSP_open}, + {"PSP_CLOSED", Group::PSP_closed}, + {"PONDAGE", Group::Pondage}, + {"BATTERY", Group::Battery}, + {"OTHER1", Group::Other1}, + {"OTHER2", Group::Other2}, + {"OTHER3", Group::Other3}, + {"OTHER4", Group::Other4}, + {"OTHER5", Group::Other5}}; unsigned int groupIndex(Group group) { @@ -106,7 +108,9 @@ bool Properties::loadKey(const IniFile::Property* p) if (p->key == "group") { - if (auto it = Properties::ST_STORAGE_PROPERTY_GROUP_ENUM.find(p->value.c_str()); + std::string groupUpper = p->value.c_str(); + boost::to_upper(groupUpper); + if (auto it = Properties::ST_STORAGE_PROPERTY_GROUP_ENUM.find(groupUpper); it != Properties::ST_STORAGE_PROPERTY_GROUP_ENUM.end()) { this->group = it->second;