Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
lp_types.cc
Go to the documentation of this file.
1// Copyright 2010-2024 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
19
20namespace operations_research {
21namespace glop {
22
23std::string GetProblemStatusString(ProblemStatus problem_status) {
24 switch (problem_status) {
26 return "OPTIMAL";
28 return "PRIMAL_INFEASIBLE";
30 return "DUAL_INFEASIBLE";
32 return "INFEASIBLE_OR_UNBOUNDED";
34 return "PRIMAL_UNBOUNDED";
36 return "DUAL_UNBOUNDED";
38 return "INIT";
40 return "PRIMAL_FEASIBLE";
42 return "DUAL_FEASIBLE";
44 return "ABNORMAL";
46 return "INVALID_PROBLEM";
48 return "IMPRECISE";
49 }
50 // Fallback. We don't use "default:" so the compiler will return an error
51 // if we forgot one enum case above.
52 LOG(DFATAL) << "Invalid ProblemStatus " << static_cast<int>(problem_status);
53 return "UNKNOWN ProblemStatus";
54}
55
56std::string GetVariableTypeString(VariableType variable_type) {
57 switch (variable_type) {
59 return "UNCONSTRAINED";
61 return "LOWER_BOUNDED";
63 return "UPPER_BOUNDED";
65 return "UPPER_AND_LOWER_BOUNDED";
67 return "FIXED_VARIABLE";
68 }
69 // Fallback. We don't use "default:" so the compiler will return an error
70 // if we forgot one enum case above.
71 LOG(DFATAL) << "Invalid VariableType " << static_cast<int>(variable_type);
72 return "UNKNOWN VariableType";
73}
74
76 switch (status) {
78 return "FREE";
80 return "AT_LOWER_BOUND";
82 return "AT_UPPER_BOUND";
84 return "FIXED_VALUE";
86 return "BASIC";
87 }
88 // Fallback. We don't use "default:" so the compiler will return an error
89 // if we forgot one enum case above.
90 LOG(DFATAL) << "Invalid VariableStatus " << static_cast<int>(status);
91 return "UNKNOWN VariableStatus";
92}
93
95 switch (status) {
97 return "FREE";
99 return "AT_LOWER_BOUND";
101 return "AT_UPPER_BOUND";
103 return "FIXED_VALUE";
105 return "BASIC";
106 }
107 // Fallback. We don't use "default:" so the compiler will return an error
108 // if we forgot one enum case above.
109 LOG(DFATAL) << "Invalid ConstraintStatus " << static_cast<int>(status);
110 return "UNKNOWN ConstraintStatus";
111}
112
114 switch (status) {
125 }
126 // Fallback. We don't use "default:" so the compiler will return an error
127 // if we forgot one enum case above.
128 LOG(DFATAL) << "Invalid VariableStatus " << static_cast<int>(status);
129 // This will never be reached and is here only to guarantee compilation.
131}
132
133} // namespace glop
134} // namespace operations_research
absl::Status status
Definition g_gurobi.cc:44
std::string GetVariableTypeString(VariableType variable_type)
Returns the string representation of the VariableType enum.
Definition lp_types.cc:56
std::string GetVariableStatusString(VariableStatus status)
Returns the string representation of the VariableStatus enum.
Definition lp_types.cc:75
VariableType
Different types of variables.
Definition lp_types.h:180
std::string GetConstraintStatusString(ConstraintStatus status)
Returns the string representation of the ConstraintStatus enum.
Definition lp_types.cc:94
ProblemStatus
Different statuses for a given problem.
Definition lp_types.h:107
@ ABNORMAL
An error occurred during the solving process.
@ INVALID_PROBLEM
The input problem was invalid (see LinearProgram.IsValid()).
@ INIT
The solver didn't had a chance to prove anything.
ConstraintStatus VariableToConstraintStatus(VariableStatus status)
Returns the ConstraintStatus corresponding to a given VariableStatus.
Definition lp_types.cc:113
std::string GetProblemStatusString(ProblemStatus problem_status)
Returns the string representation of the ProblemStatus enum.
Definition lp_types.cc:23
In SWIG mode, we don't want anything besides these top-level includes.