Scippy

SCIP

Solving Constraint Integer Programs

cmd_line_args.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program PolySCIP */
4 /* */
5 /* Copyright (C) 2012-2019 Konrad-Zuse-Zentrum */
6 /* fuer Informationstechnik Berlin */
7 /* */
8 /* PolySCIP is distributed under the terms of the ZIB Academic License. */
9 /* */
10 /* You should have received a copy of the ZIB Academic License */
11 /* along with PolySCIP; see the file LICENCE. */
12 /* */
13 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 /**
16  * @file cmd_line_args.cpp
17  * @brief Implements PolySCIP command line arguments via TCLAP
18  * @author Sebastian Schenker
19  *
20  */
21 
22 
23 #include "cmd_line_args.h"
24 
25 #include <string>
26 #include <vector>
27 
28 #include "PolySCIPConfig.h" // defines EXECUTABLE_NAME, POLYSCIP_VERSION_{MAJOR,MINOR}
29 #include "tclap/CmdLine.h"
30 
31 using std::string;
32 using TCLAP::CmdLine;
33 using TCLAP::SwitchArg;
34 using TCLAP::ValueArg;
35 using TCLAP::UnlabeledValueArg;
36 
37 namespace polyscip {
38 
39  /**
40  * Constructor
41  * @param argc Argument count
42  * @param argv Argument vector
43  */
44  CmdLineArgs::CmdLineArgs(int argc, const char *const *argv)
45  : executable_name_(EXECUTABLE_NAME)
46  {
47  version_no_ = std::to_string(POLYSCIP_VERSION_MAJOR) + string(".") + std::to_string(POLYSCIP_VERSION_MINOR);
48  CmdLine cmd(executable_name_,' ', version_no_);
49  cmd.setExceptionHandling(false); // set internal exception handling
50  SwitchArg only_extremal_arg("x", "extremal", "compute only extremal supported non-dominated results", false);
51  cmd.add(only_extremal_arg);
52  SwitchArg be_verbose_arg("v", "verbose", "verbose PolySCIP cmd line output ", false);
53  cmd.add(be_verbose_arg);
54  SwitchArg write_results_arg("w", "writeResults", "write results to file; default path is ./", false);
55  cmd.add(write_results_arg);
56  SwitchArg output_sols_arg("s", "noSolutions", "switching output of solutions off", true);
57  cmd.add(output_sols_arg);
58  SwitchArg output_outcomes_arg("o", "noOutcomes", "switching output of outcomes off", true);
59  cmd.add(output_outcomes_arg);
60  std::vector<int> round_vals = {5,10,15};
61  TCLAP::ValuesConstraint<int> allowed_vals(round_vals);
62  ValueArg<int> round_weighted_obj_coeff_arg("r", "round",
63  "round weighted objective coefficient in fct 'setWeightedObjective' at r-th decimal position",
64  false, 0, &allowed_vals);
65  cmd.add(round_weighted_obj_coeff_arg);
66  ValueArg<TimeLimitType> time_limit_arg("t", "timeLimit",
67  "time limit in seconds for total SCIP computation time",
68  false, kTimeLimitInf, "seconds");
69  cmd.add(time_limit_arg);
70  ValueArg<double> delta_arg("d", "delta", "Delta used in computation of feasible boxes; default value: 0.01",
71  false, 0.01, "double");
72  cmd.add(delta_arg);
73  ValueArg<double> epsilon_arg("e", "epsilon", "epsilon used in computation of unsupported points; default value: 1e-3",
74  false, 1e-3, "double");
75  cmd.add(epsilon_arg);
76  ValueArg<string> write_sols_path_arg("W", "writeSolsPath",
77  "PATH for -w",
78  false, "./", "PATH");
79  cmd.add(write_sols_path_arg);
80  ValueArg<string> param_file_arg("p", "params", "parameter settings file for SCIP",
81  false, "", "paramFile.set");
82  cmd.add(param_file_arg);
83  UnlabeledValueArg<string> prob_file_arg("probFile", "problem file in MOP format",
84  true, "", "problemFile.mop");
85  cmd.add(prob_file_arg);
86  cmd.parse(argc, argv);
87 
88  be_verbose_ = be_verbose_arg.getValue();
89  only_extremal_ = only_extremal_arg.getValue();
90  write_results_ = write_results_arg.getValue();
91  output_solutions_ = output_sols_arg.getValue();
92  output_outcomes_ = output_outcomes_arg.getValue();
93  round_weighted_obj_coeff_ = round_weighted_obj_coeff_arg.getValue();
94  time_limit_ = time_limit_arg.getValue();
95  delta_ = delta_arg.getValue();
96  epsilon_ = epsilon_arg.getValue();
97  write_results_path_ = write_sols_path_arg.getValue();
98  param_file_ = param_file_arg.getValue();
99  prob_file_ = prob_file_arg.getValue();
100  }
101 
102 }
Some preprocessor directives.
static constexpr auto kTimeLimitInf
Constant used for default value of cmd line parameter -t | - - timeLimit.
Definition: cmd_line_args.h:40
#define EXECUTABLE_NAME
Name of executable.
#define POLYSCIP_VERSION_MINOR
Current minor version of PolySCIP.
#define POLYSCIP_VERSION_MAJOR
Current major version of PolySCIP.
Definition: PolySCIPConfig.h:9
CmdLineArgs(int argc, const char *const *argv)
PolySCIP command line arguments.