delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
Config.cpp
1
6#include "delpi/util/Config.h"
7
8#include <ostream>
9#include <string>
10#include <utility>
11
12#include "delpi/util/error.h"
13#include "delpi/util/filesystem.h"
14
15namespace delpi {
16Config::Config(std::string filename) : filename_{std::move(filename)} {}
17Config::Config(const bool read_from_stdin) : read_from_stdin_{read_from_stdin} {}
18Config::Config(const Format format) : format_{format} {}
19
20std::string Config::filename_extension() const { return GetExtension(filename_.get()); }
21
22Config::LpMode Config::actual_lp_mode() const {
23 switch (lp_mode_.get()) {
24 case LpMode::AUTO:
26 default:
27 return lp_mode_.get();
28 }
29}
30Config::Format Config::actual_format() const {
31 switch (format_.get()) {
32 case Format::AUTO:
33 if (filename_extension() == "mps") {
34 return Format::MPS;
35 }
36 if (filename_extension() == "lp") {
37 return Format::LP;
38 }
39 DELPI_RUNTIME_ERROR("Cannot determine format from stdin or unknown file extension");
40 default:
41 return format_.get();
42 }
43}
44
45std::ostream &operator<<(std::ostream &os, const Config::LpSolver &lp_solver) {
46 switch (lp_solver) {
48 return os << "qsoptex";
50 return os << "soplex";
51 default:
52 DELPI_UNREACHABLE();
53 }
54}
55
56std::ostream &operator<<(std::ostream &os, const Config::Format &format) {
57 switch (format) {
59 return os << "auto";
61 return os << "mps";
63 return os << "lp";
64 default:
65 DELPI_UNREACHABLE();
66 }
67}
68
69std::ostream &operator<<(std::ostream &os, const Config::LpMode &mode) {
70 switch (mode) {
72 return os << "A";
74 return os << "P";
76 return os << "I";
78 return os << "H";
79 default:
80 DELPI_UNREACHABLE();
81 }
82}
83
84std::ostream &operator<<(std::ostream &os, const Config &config) {
85 return os << "Config {\n"
86 << "csv = " << config.csv() << ",\n"
87 << "continuous_output = " << config.continuous_output() << ",\n"
88 << "debug_parsing = " << config.debug_parsing() << ",\n"
89 << "dry_run = " << config.dry_run() << ",\n"
90 << "delta = " << config.delta() << ",\n"
91 << "filename = '" << config.filename() << "',\n"
92 << "format = '" << config.format() << "',\n"
93 << "lp_mode = '" << config.lp_mode() << "',\n"
94 << "lp_solver = " << config.lp_solver() << ",\n"
95 << "number_of_jobs = " << config.number_of_jobs() << ",\n"
96 << "skip_optimise = '" << config.skip_optimise() << "',\n"
97 << "produce_model = " << config.produce_models() << ",\n"
98 << "random_seed = " << config.random_seed() << ",\n"
99 << "read_from_stdin = " << config.read_from_stdin() << ",\n"
100 << "silent = " << config.silent() << ",\n"
101 << "timeout = " << config.timeout() << ",\n"
102 << "verbose_delpi = " << config.verbose_delpi() << ",\n"
103 << "verbose_simplex = " << config.verbose_simplex() << ",\n"
104 << "verify = " << config.verify() << ",\n"
105 << "with_timings = " << config.with_timings() << ",\n"
106 << '}';
107}
108
109} // namespace delpi
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
@ 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
@ AUTO
Let the LP solver choose the mode. Default option.
Definition Config.h:52
@ 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.
std::string GetExtension(const std::string &name)
Get the extension of the file.