dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
Infinity.cpp
1
6#include "Infinity.h"
7
8#include "exception.h"
9
10#ifdef DLINEAR_ENABLED_QSOPTEX
11#include "dlinear/libs/libqsopt_ex.h"
12#endif
13#ifdef DLINEAR_ENABLED_SOPLEX
14#include "dlinear/libs/libsoplex.h"
15#endif
16
17namespace dlinear {
18
19bool Infinity::initialised_{false};
20
21#ifdef DLINEAR_ENABLED_QSOPTEX
22mpq_class Infinity::qsoptex_ninfinity_{0};
23mpq_class Infinity::qsoptex_infinity_{0};
24#endif
25#ifdef DLINEAR_ENABLED_SOPLEX
26mpq_class Infinity::soplex_ninfinity_{-soplex::infinity};
27mpq_class Infinity::soplex_infinity_{soplex::infinity};
28#endif
29
30const mpq_class& Infinity::infinity(const Config& config) { return infinity(config.lp_solver()); }
31const mpq_class& Infinity::ninfinity(const Config& config) { return ninfinity(config.lp_solver()); }
32
33inline void Infinity::Initialise() {
34 if (initialised_) return;
35#ifdef DLINEAR_ENABLED_QSOPTEX
36 Infinity::qsoptex_ninfinity_ = gmp::ToMpqClass(mpq_NINFTY);
37 Infinity::qsoptex_infinity_ = gmp::ToMpqClass(mpq_INFTY);
38#endif
39#ifdef DLINEAR_ENABLED_SOPLEX
40 Infinity::soplex_ninfinity_ = -soplex::infinity;
41 Infinity::soplex_infinity_ = soplex::infinity;
42#endif
43 initialised_ = true;
44}
45
46const mpq_class& Infinity::infinity(const Config::LPSolver lp_solver) {
47 Initialise();
48 switch (lp_solver) {
49#ifdef DLINEAR_ENABLED_QSOPTEX
51 return qsoptex_infinity_;
52#endif
53#ifdef DLINEAR_ENABLED_SOPLEX
55 return soplex_infinity_;
56#endif
57 default:
58 DLINEAR_UNREACHABLE();
59 }
60}
61
62const mpq_class& Infinity::ninfinity(const Config::LPSolver lp_solver) {
63 Initialise();
64 switch (lp_solver) {
65#ifdef DLINEAR_ENABLED_QSOPTEX
67 return qsoptex_ninfinity_;
68#endif
69#ifdef DLINEAR_ENABLED_SOPLEX
71 return soplex_ninfinity_;
72#endif
73 default:
74 DLINEAR_UNREACHABLE();
75 }
76}
77
78} // namespace dlinear
Simple dataclass used to store the configuration of the program.
Definition Config.h:38
LPSolver
Underlying LP solver used by the theory solver.
Definition Config.h:41
@ QSOPTEX
Qsoptex Solver.
@ SOPLEX
Soplex Solver. Default option.
const LPSolver & lp_solver() const
Get read-write access to the lp_solver parameter of the configuration.
Definition Config.h:184
static const mpq_class & ninfinity(const Config &config)
Get the negative infinity value for the given LP solver in the config.
Definition Infinity.cpp:31
static const mpq_class & infinity(const Config &config)
Get the positive infinity value for the given LP solver in the config.
Definition Infinity.cpp:30
static void Initialise()
Lazy initialisation of the infinity values.
Definition Infinity.cpp:33
Global namespace for the dlinear library.