Skip to content

Commit

Permalink
Add OR-Tools solver option for batchrun tool (#1981)
Browse files Browse the repository at this point in the history
Allow the **batchrun** tool to forward OR-Tools options to
antares-solver.
  • Loading branch information
flomnes committed Mar 19, 2024
1 parent a6fec7a commit 7c89461
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/tools/batchrun/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
#include <yuni/core/nullable.h>
#include <map>
#include <iostream>
#include <string>
#include <yuni/core/string.h>
#include <yuni/core/getopt.h>
#include <antares/study/finder.h>
#include "../../ui/common/winmain.hxx"
#include <antares/version.h>
#include <antares/locale.h>
#include <antares/solver/utils/ortools_utils.h>
#ifdef YUNI_OS_WINDOWS
#include <process.h>
#endif
Expand Down Expand Up @@ -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;
Expand All @@ -95,6 +98,7 @@ int main(int argc, char* argv[])
bool optNoOutput = false;
bool optParallel = false;
bool optVerbose = false;
bool ortoolsUsed = false;
Nullable<uint> optYears;
Nullable<String> optSolver;
Nullable<String> optName;
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7c89461

Please sign in to comment.