dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
LpRowSense.cpp
1
6#include "LpRowSense.h"
7
8#include "dlinear/util/exception.h"
9
10namespace dlinear {
11
13 DLINEAR_ASSERT(is_relational(f), "Expected a relational formula");
14 if (is_equal_to(f)) return LpRowSense::EQ;
15 if (is_greater_than(f)) return LpRowSense::GT;
16 if (is_greater_than_or_equal_to(f)) return LpRowSense::GE;
17 if (is_less_than(f)) return LpRowSense::LT;
18 if (is_less_than_or_equal_to(f)) return LpRowSense::LE;
19 if (is_not_equal_to(f)) return LpRowSense::NQ;
20 DLINEAR_UNREACHABLE();
21}
22
24 switch (sense) {
25 case 'g':
26 case '>':
27 return LpRowSense::GT;
28 case 'G':
29 return LpRowSense::GE;
30 case '=':
31 case 'E':
32 return LpRowSense::EQ;
33 case 'N':
34 return LpRowSense::NQ;
35 case 'L':
36 return LpRowSense::LE;
37 case '<':
38 case 'l':
39 return LpRowSense::LT;
40 case 'I':
41 return LpRowSense::IN;
42 default:
43 DLINEAR_UNREACHABLE();
44 }
45}
46
47char toChar(LpRowSense sense) {
48 switch (sense) {
49 case LpRowSense::GT:
50 return 'g';
51 case LpRowSense::GE:
52 return 'G';
53 case LpRowSense::EQ:
54 return 'E';
55 case LpRowSense::NQ:
56 return 'N';
57 case LpRowSense::LE:
58 return 'L';
59 case LpRowSense::LT:
60 return 'l';
61 case LpRowSense::IN:
62 return 'I';
63 default:
64 DLINEAR_UNREACHABLE();
65 }
66}
67
69 switch (sense) {
70 case LpRowSense::GT:
71 return LpRowSense::LE;
72 case LpRowSense::GE:
73 return LpRowSense::LT;
74 case LpRowSense::EQ:
75 return LpRowSense::NQ;
76 case LpRowSense::NQ:
77 return LpRowSense::EQ;
78 case LpRowSense::LE:
79 return LpRowSense::GT;
80 case LpRowSense::LT:
81 return LpRowSense::GE;
82 case LpRowSense::IN:
83 return LpRowSense::IN;
84 default:
85 DLINEAR_UNREACHABLE();
86 }
87}
88
90 switch (sense) {
91 case LpRowSense::GE:
92 return LpRowSense::LE;
93 case LpRowSense::EQ:
94 return LpRowSense::NQ;
95 case LpRowSense::LE:
96 return LpRowSense::GE;
97 case LpRowSense::IN:
98 return LpRowSense::IN;
99 default:
100 DLINEAR_UNREACHABLE();
101 }
102}
103
105 switch (sense) {
106 case LpRowSense::GT:
107 return LpRowSense::GE;
108 case LpRowSense::LT:
109 return LpRowSense::LE;
110 default:
111 return sense;
112 }
113}
114
115std::ostream &operator<<(std::ostream &os, const LpRowSense &lp_result) { return os << toChar(lp_result); }
116
117} // namespace dlinear
Represents a symbolic form of a first-order logic formula.
Global namespace for the dlinear library.
LpColBound operator~(LpColBound bound)
Relax the bound.
char toChar(LpColBound bound)
Convert the bound to a character.
LpColBound operator!(LpColBound bound)
Invert the bound with delta == 0.
LpColBound operator-(LpColBound bound)
Invert the bound with delta > 0.
LpRowSense parseLpSense(const Formula &f)
Parse the sense from a formula.
LpRowSense
Sense of a linear programming row describing a constraint.
Definition LpRowSense.h:23
@ NQ
Not equal to.
@ GT
Greater than.
@ LE
Less than or equal to.
@ GE
Greater than or equal to.