dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
Config.cpp
1
6#include "Config.h"
7
8#include <iostream>
9#include <utility>
10
11#include "dlinear/util/exception.h"
12#include "dlinear/util/filesystem.h"
13
14namespace dlinear {
15Config::Config(std::string filename) : filename_{std::move(filename)} {}
16Config::Config(bool read_from_stdin) : read_from_stdin_{read_from_stdin} {}
17
18std::string Config::filename_extension() const { return GetExtension(filename_.get()); }
19
21 if (disable_expansion_.get()) return false;
22 const Format format = actual_format();
24}
26 switch (lp_mode_.get()) {
27 case LPMode::AUTO:
29 default:
30 return lp_mode_.get();
31 }
32}
34 switch (format_.get()) {
35 case Format::AUTO:
36 if (filename_extension() == "mps") {
37 return Format::MPS;
38 } else if (filename_extension() == "smt2") {
39 return Format::SMT2;
40 } else if (filename_extension() == "vnnlib") {
41 return Format::VNNLIB;
42 }
43 DLINEAR_RUNTIME_ERROR("Cannot determine format from stdin or unknown file extension");
44 default:
45 return format_.get();
46 }
47}
49 switch (bound_propagation_type_.get()) {
51 switch (actual_format()) {
52 case Format::SMT2:
54 case Format::MPS:
56 case Format::VNNLIB:
58 default:
59 DLINEAR_UNREACHABLE();
60 }
61 default:
62 return bound_propagation_type_.get();
63 }
64}
66 switch (bound_propagation_frequency_.get()) {
68 switch (actual_format()) {
69 case Format::SMT2:
71 case Format::MPS:
73 case Format::VNNLIB:
75 default:
76 DLINEAR_UNREACHABLE();
77 }
78 default:
79 return bound_propagation_frequency_.get();
80 }
81}
83 switch (bound_implication_frequency_.get()) {
85 switch (actual_format()) {
86 case Format::SMT2:
88 case Format::MPS:
89 case Format::VNNLIB:
91 default:
92 DLINEAR_UNREACHABLE();
93 }
94 default:
95 return bound_implication_frequency_.get();
96 }
97}
98
99std::ostream &operator<<(std::ostream &os, const Config::SatDefaultPhase &sat_default_phase) {
100 switch (sat_default_phase) {
102 return os << "False";
104 return os << "True";
106 return os << "Jeroslow-Wang";
108 return os << "Random Initial Phase";
109 default:
110 DLINEAR_UNREACHABLE();
111 }
112}
113
114std::ostream &operator<<(std::ostream &os, const Config::LPSolver &lp_solver) {
115 switch (lp_solver) {
117 return os << "qsoptex";
119 return os << "soplex";
120 default:
121 DLINEAR_UNREACHABLE();
122 }
123}
124
125std::ostream &operator<<(std::ostream &os, const Config::SatSolver &sat_solver) {
126 switch (sat_solver) {
128 return os << "cadical";
130 return os << "picosat";
131 default:
132 DLINEAR_UNREACHABLE();
133 }
134}
135
136std::ostream &operator<<(std::ostream &os, const Config::Format &format) {
137 switch (format) {
139 return os << "auto";
141 return os << "mps";
143 return os << "smt2";
145 return os << "vnnlib";
146 default:
147 DLINEAR_UNREACHABLE();
148 }
149}
150
151std::ostream &operator<<(std::ostream &os, const Config::LPMode &mode) {
152 switch (mode) {
154 return os << "A";
156 return os << "P";
158 return os << "I";
160 return os << "H";
161 default:
162 DLINEAR_UNREACHABLE();
163 }
164}
165
166std::ostream &operator<<(std::ostream &os, const Config::BoundPropagationType &type) {
167 switch (type) {
169 return os << "auto";
171 return os << "eq-binomial";
173 return os << "eq-polynomial";
175 return os << "bound-polynomial";
176 default:
177 DLINEAR_UNREACHABLE();
178 }
179}
180
181std::ostream &operator<<(std::ostream &os, const Config::PreprocessingRunningFrequency &frequency) {
182 switch (frequency) {
184 return os << "auto";
186 return os << "never";
188 return os << "on-fixed";
190 return os << "on-iteration";
192 return os << "always";
193 default:
194 DLINEAR_UNREACHABLE();
195 }
196}
197
198std::ostream &operator<<(std::ostream &os, const Config &config) {
199 return os << "Config {\n"
200 << "bound_implication_frequency = " << config.bound_implication_frequency() << ",\n"
201 << "bound_propagation_frequency = " << config.bound_propagation_frequency() << ",\n"
202 << "bound_propagation_type = " << config.bound_propagation_type() << ",\n"
203 << "csv = " << config.csv() << ",\n"
204 << "complete = " << config.complete() << ",\n"
205 << "continuous_output = " << config.continuous_output() << ",\n"
206 << "debug_parsing = " << config.debug_parsing() << ",\n"
207 << "debug_scanning = " << config.debug_scanning() << ",\n"
208 << "disable_expansion = " << config.disable_expansion() << ",\n"
209 << "enforce_check_sat = " << config.enforce_check_sat() << ",\n"
210 << "filename = '" << config.filename() << "',\n"
211 << "format = '" << config.format() << "',\n"
212 << "lp_mode = '" << config.lp_mode() << "',\n"
213 << "lp_solver = " << config.lp_solver() << ",\n"
214 << "number_of_jobs = " << config.number_of_jobs() << ",\n"
215 << "onnx_file = '" << config.onnx_file() << ",\n"
216 << "optimize = '" << config.optimize() << "',\n"
217 << "precision = " << config.precision() << ",\n"
218 << "produce_model = " << config.produce_models() << ",\n"
219 << "random_seed = " << config.random_seed() << ",\n"
220 << "read_from_stdin = " << config.read_from_stdin() << ",\n"
221 << "sat_default_phase = " << config.sat_default_phase() << ",\n"
222 << "sat_solver = " << config.sat_solver() << ",\n"
223 << "silent = " << config.silent() << ",\n"
224 << "simplex_sat_phase = " << config.simplex_sat_phase() << ",\n"
225 << "skip_check_sat = " << config.skip_check_sat() << ",\n"
226 << "verbose_dlinear = " << config.verbose_dlinear() << ",\n"
227 << "verbose_simplex = " << config.verbose_simplex() << ",\n"
228 << "verify = " << config.verify() << ",\n"
229 << "with_timings = " << config.with_timings() << ",\n"
230 << '}';
231}
232
233} // namespace dlinear
SatSolver
Underlying SAT solver used by the abstract SAT solver.
Definition Config.h:46
@ CADICAL
Cadical Solver. Default option.
@ PICOSAT
Picosat Solver.
LPMode
LP mode used by the LP solver.
Definition Config.h:65
@ HYBRID
Use both modes, if available.
@ PURE_PRECISION_BOOSTING
Use the precision boosting mode, if available.
@ AUTO
Let the LP solver choose the mode. Default option.
@ PURE_ITERATIVE_REFINEMENT
Use the iterative refinement mode, if available.
Format
Format of the input file.
Definition Config.h:58
@ VNNLIB
VNNLIB format.
@ AUTO
Automatically detect the input format based on the file extension. Default option.
BoundPropagationType actual_bound_propagation_type() const
Get read-only access to the actual actual_bound_propagation_type parameter of the configuration.
Definition Config.cpp:48
BoundPropagationType
Types of bound propagation supported by the bound propagator.
Definition Config.h:72
@ EQ_POLYNOMIAL
Only propagate bound in theory formulae in the form .
@ EQ_BINOMIAL
Only propagate bounds in theory formulas in the form .
@ BOUND_POLYNOMIAL
Propagate all possible constraints.
@ AUTO
Automatically select the best configuration based on expected performance. Default option.
PreprocessingRunningFrequency actual_bound_implication_frequency() const
Get read-only access to the actual bound_implication_frequency parameter of the configuration.
Definition Config.cpp:82
LPSolver
Underlying LP solver used by the theory solver.
Definition Config.h:41
@ QSOPTEX
Qsoptex Solver.
@ SOPLEX
Soplex Solver. Default option.
Format actual_format() const
Get read-only access to the actual format parameter of the configuration.
Definition Config.cpp:33
const Format & format() const
Get read-write access to the format parameter of the configuration.
Definition Config.h:178
PreprocessingRunningFrequency
Frequency at which the preprocessors will run.
Definition Config.h:79
@ ON_ITERATION
Run this preprocess only at every iteration.
@ NEVER
Never run this preprocess, effectively disabling it.
@ ON_FIXED
Run this preprocess only once, on fixed literals, before all iterations.
@ AUTO
Automatically select the best configuration based on expected performance. Default option.
@ ALWAYS
Run this preprocess at every chance it gets. Usually combines ON_FIXED and ON_ITERATION.
PreprocessingRunningFrequency actual_bound_propagation_frequency() const
Get read-only access to the actual bound_propagation_frequency parameter of the configuration.
Definition Config.cpp:65
Config()=default
Construct a new Config object.
std::string filename_extension() const
Get read-only access to the filename extension of the configuration.
Definition Config.cpp:18
SatDefaultPhase
Phase for the SAT solver.
Definition Config.h:51
@ RandomInitialPhase
Randomly assign a value to non fixed decision literals.
@ True
Assign true to non fixed decision literals.
@ False
Assign false to non fixed decision literals.
LPMode actual_lp_mode() const
Get read-only access to the actual lp_mode parameter of the configuration.
Definition Config.cpp:25
bool needs_expansion() const
Definition Config.cpp:20
const T & get() const
Get read-only access to the internal stored value of the optional value.
Global namespace for the dlinear library.
std::string GetExtension(const std::string &name)
Get the extension of the file.
STL namespace.