From 9cbf13781e7964b92992ba8a0a1965d963e2c949 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] Add OR-Tools solver option for `batchrun` tool (#1981) Allow the **batchrun** tool to forward OR-Tools options to antares-solver. --- src/tools/batchrun/main.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tools/batchrun/main.cpp b/src/tools/batchrun/main.cpp index 1eacc7e82e..6e1667c8d6 100644 --- a/src/tools/batchrun/main.cpp +++ b/src/tools/batchrun/main.cpp @@ -27,12 +27,15 @@ #include #include #include +#include #include #include #include #include #include #include +#include + #ifdef YUNI_OS_WINDOWS #include #endif @@ -79,7 +82,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; @@ -90,6 +94,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; @@ -138,6 +143,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."); @@ -271,8 +290,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();