From 7c89461144393ab9b235a1d5bb90872443476d0c 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 | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/tools/batchrun/main.cpp b/src/tools/batchrun/main.cpp index 38d8c651b3..2bc8047899 100644 --- a/src/tools/batchrun/main.cpp +++ b/src/tools/batchrun/main.cpp @@ -32,12 +32,14 @@ #include #include #include +#include #include #include #include #include "../../ui/common/winmain.hxx" #include #include +#include #ifdef YUNI_OS_WINDOWS #include #endif @@ -84,7 +86,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 +98,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 +147,19 @@ 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."); @@ -277,8 +294,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();