dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
Sense.cpp
1
6#include "dlinear/parser/mps/Sense.h"
7
8#include <cctype>
9#include <cstddef>
10#include <iostream>
11
12#include "dlinear/util/exception.h"
13
14namespace dlinear::mps {
15
16Sense ParseSense(const std::string &sense) {
17 std::size_t pos = sense.find_first_not_of(' ');
18 return ParseSense(sense[pos]);
19}
20Sense ParseSense(const char sense[]) {
21 while (*sense == ' ') ++sense;
22 return ParseSense(*sense);
23}
24Sense ParseSense(char sense) {
25 sense = std::tolower(sense);
26 switch (sense) {
27 case 'l':
28 return Sense::L;
29 case 'e':
30 return Sense::E;
31 case 'g':
32 return Sense::G;
33 case 'n':
34 return Sense::N;
35 default:
36 DLINEAR_UNREACHABLE();
37 }
38}
39
40std::ostream &operator<<(std::ostream &os, const Sense &sense) {
41 switch (sense) {
42 case Sense::L:
43 return os << "L";
44 case Sense::E:
45 return os << "E";
46 case Sense::G:
47 return os << "G";
48 case Sense::N:
49 return os << "N";
50 default:
51 DLINEAR_UNREACHABLE();
52 }
53}
54
55} // namespace dlinear::mps
Namespace for the MPS parser of the dlinear library.
Definition BoundType.cpp:13
Sense
Sense of a constraint row.
Definition Sense.h:23
@ N
No sense, used for the objective function.
@ L
Less or equal to.
@ G
Greater or equal to.
Sense ParseSense(const std::string &sense)
Parse a sense from a string.
Definition Sense.cpp:16