OR-Tools  9.6
lp_types.cc
Go to the documentation of this file.
1 // Copyright 2010-2022 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
15 
16 #include <string>
17 
18 namespace operations_research {
19 namespace glop {
20 
21 std::string GetProblemStatusString(ProblemStatus problem_status) {
22  switch (problem_status) {
24  return "OPTIMAL";
26  return "PRIMAL_INFEASIBLE";
28  return "DUAL_INFEASIBLE";
30  return "INFEASIBLE_OR_UNBOUNDED";
32  return "PRIMAL_UNBOUNDED";
34  return "DUAL_UNBOUNDED";
36  return "INIT";
38  return "PRIMAL_FEASIBLE";
40  return "DUAL_FEASIBLE";
42  return "ABNORMAL";
44  return "INVALID_PROBLEM";
46  return "IMPRECISE";
47  }
48  // Fallback. We don't use "default:" so the compiler will return an error
49  // if we forgot one enum case above.
50  LOG(DFATAL) << "Invalid ProblemStatus " << static_cast<int>(problem_status);
51  return "UNKNOWN ProblemStatus";
52 }
53 
54 std::string GetVariableTypeString(VariableType variable_type) {
55  switch (variable_type) {
57  return "UNCONSTRAINED";
59  return "LOWER_BOUNDED";
61  return "UPPER_BOUNDED";
63  return "UPPER_AND_LOWER_BOUNDED";
65  return "FIXED_VARIABLE";
66  }
67  // Fallback. We don't use "default:" so the compiler will return an error
68  // if we forgot one enum case above.
69  LOG(DFATAL) << "Invalid VariableType " << static_cast<int>(variable_type);
70  return "UNKNOWN VariableType";
71 }
72 
74  switch (status) {
76  return "FREE";
78  return "AT_LOWER_BOUND";
80  return "AT_UPPER_BOUND";
82  return "FIXED_VALUE";
84  return "BASIC";
85  }
86  // Fallback. We don't use "default:" so the compiler will return an error
87  // if we forgot one enum case above.
88  LOG(DFATAL) << "Invalid VariableStatus " << static_cast<int>(status);
89  return "UNKNOWN VariableStatus";
90 }
91 
93  switch (status) {
95  return "FREE";
97  return "AT_LOWER_BOUND";
99  return "AT_UPPER_BOUND";
101  return "FIXED_VALUE";
103  return "BASIC";
104  }
105  // Fallback. We don't use "default:" so the compiler will return an error
106  // if we forgot one enum case above.
107  LOG(DFATAL) << "Invalid ConstraintStatus " << static_cast<int>(status);
108  return "UNKNOWN ConstraintStatus";
109 }
110 
112  switch (status) {
114  return ConstraintStatus::FREE;
123  }
124  // Fallback. We don't use "default:" so the compiler will return an error
125  // if we forgot one enum case above.
126  LOG(DFATAL) << "Invalid VariableStatus " << static_cast<int>(status);
127  // This will never be reached and is here only to guarantee compilation.
128  return ConstraintStatus::FREE;
129 }
130 
131 } // namespace glop
132 } // namespace operations_research
absl::Status status
Definition: g_gurobi.cc:41
std::string GetProblemStatusString(ProblemStatus problem_status)
Definition: lp_types.cc:21
std::string GetConstraintStatusString(ConstraintStatus status)
Definition: lp_types.cc:92
ConstraintStatus VariableToConstraintStatus(VariableStatus status)
Definition: lp_types.cc:111
std::string GetVariableTypeString(VariableType variable_type)
Definition: lp_types.cc:54
std::string GetVariableStatusString(VariableStatus status)
Definition: lp_types.cc:73
Collection of objects used to extend the Constraint Solver library.