delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
Config.h
1
10#pragma once
11
12#include <iosfwd>
13#include <string>
14#include <string_view>
15
16#include "delpi/util/OptionValue.hpp"
17
18namespace delpi {
19
20#define DELPI_PARAMETER(param_name, type, default_value, help) \
21 public: \
22 \
23 OptionValue<type> &m_##param_name() { return param_name##_; } \
24 \
25 [[nodiscard]] const type &param_name() const { return param_name##_.get(); } \
26 static constexpr type default_##param_name{default_value}; \
27 static constexpr const char *const help_##param_name{help}; \
28 \
29 private: \
30 OptionValue<type> param_name##_{default_value};
31
36class Config {
37 public:
39 enum class LpSolver {
43 };
44
45 enum class Format {
49 };
50
57
59 Config() = default;
64 explicit Config(std::string filename);
69 explicit Config(bool read_from_stdin);
74 explicit Config(Format format);
75
76 public:
77 static constexpr std::string_view help_filename{"Input file name"};
78
80 [[nodiscard]] const std::string &filename() const { return filename_.get(); }
82 [[nodiscard]] std::string filename_extension() const;
84 OptionValue<std::string> &m_filename() { return filename_; }
89 [[nodiscard]] LpMode actual_lp_mode() const;
94 [[nodiscard]] Format actual_format() const;
95
96 private:
97 OptionValue<std::string> filename_{""};
98
99 DELPI_PARAMETER(continuous_output, bool, false,
100 "Continuous output.\n"
101 "\t\tIf a delta-optimal solution with actual_delta > delta is found, output it and continue")
102 DELPI_PARAMETER(csv, bool, false, "Produce CSV output. Must also specify --with-timings to get the time stats")
103 DELPI_PARAMETER(debug_parsing, bool, false, "Debug parsing")
104 DELPI_PARAMETER(delta, double, 0, "Delta used by the LP solver solver")
105 DELPI_PARAMETER(format, Format, delpi::Config::Format::AUTO,
106 "Input file format\n"
107 "\t\tOne of: auto (1), mps (2)")
108 DELPI_PARAMETER(lp_mode, LpMode, delpi::Config::LpMode::AUTO,
109 "LP mode used by the LP solver.\n"
110 "\t\tNot all solvers may support all modes\n"
111 "\t\tOne of: auto (1), pure-precision-boosting (2), pure-iterative-refinement (3), hybrid (4)")
112 DELPI_PARAMETER(lp_solver, LpSolver, delpi::Config::LpSolver::SOPLEX,
113 "Underlying LP solver used by the theory solver.\n"
114 "\t\tOne of: soplex (1), qsoptex (2)")
115 DELPI_PARAMETER(number_of_jobs, unsigned int, 1u, "Number of jobs")
116 DELPI_PARAMETER(skip_optimise, bool, false,
117 "Whether to skip the objective function, turning the optimisation in a feasibility problem. "
118 "Only affects the MPS format")
119 DELPI_PARAMETER(dry_run, bool, false, "Whether to stop the program before running any optimization algorithm")
120 DELPI_PARAMETER(produce_models, bool, false,
121 "Produce models, showing a valid assignment.\n"
122 "\t\tOnly applicable if the problem is feasible")
123 DELPI_PARAMETER(random_seed, unsigned int, 0u,
124 "Set the random seed. 0 means that the seed will be generated on the fly")
125 DELPI_PARAMETER(read_from_stdin, bool, false, "Read the input from the standard input")
126 DELPI_PARAMETER(silent, bool, false, "Silent mode. Nothing will be printed on the standard output")
127 DELPI_PARAMETER(
128 timeout, unsigned int, 0,
129 "Timeout in milliseconds for the main routine, without accounting for input parsing. 0 means no timeout")
130 DELPI_PARAMETER(verbose_delpi, int, 2, "Verbosity level for delpi. In the range [0, 5]")
131 DELPI_PARAMETER(verbose_simplex, int, 0, "Verbosity level for simplex. In the range [0, 5]")
132 DELPI_PARAMETER(verify, bool, false,
133 "If the input produces a feasible output, verify the assignment against the input")
134 DELPI_PARAMETER(with_timings, bool, false, "Report timings alongside results")
135};
136
137std::ostream &operator<<(std::ostream &os, const Config &config);
138std::ostream &operator<<(std::ostream &os, const Config::LpSolver &lp_solver);
139std::ostream &operator<<(std::ostream &os, const Config::Format &format);
140std::ostream &operator<<(std::ostream &os, const Config::LpMode &mode);
141
142} // namespace delpi
143
144#ifdef DELPI_INCLUDE_FMT
145
146#include "delpi/util/logging.h"
147
148OSTREAM_FORMATTER(delpi::Config);
149OSTREAM_FORMATTER(delpi::Config::LpSolver);
150OSTREAM_FORMATTER(delpi::Config::Format);
151OSTREAM_FORMATTER(delpi::Config::LpMode);
152
153#endif
Simple dataclass used to store the configuration of the program.
Definition Config.h:36
LpSolver
Underlying LP solver used by the theory solver.
Definition Config.h:39
@ DELPI
Delpi Solver.
Definition Config.h:42
@ QSOPTEX
Qsoptex Solver.
Definition Config.h:41
@ SOPLEX
Soplex Solver. Default option.
Definition Config.h:40
LpMode
LP mode used by the LP solver.
Definition Config.h:51
@ HYBRID
Use both modes, if available.
Definition Config.h:55
@ PURE_PRECISION_BOOSTING
Use the precision boosting mode, if available.
Definition Config.h:53
@ PURE_ITERATIVE_REFINEMENT
Use the iterative refinement mode, if available.
Definition Config.h:54
Format
Format of the input file.
Definition Config.h:45
@ LP
LP format.
Definition Config.h:48
@ AUTO
Automatically detect the input format based on the file extension. Default option.
Definition Config.h:46
@ MPS
MPS format.
Definition Config.h:47
Global namespace for the delpi library.