1 // Copyright 2010-2021 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 14 #include "ortools/lp_data/lp_types.h" 15 16 namespace operations_research { 17 namespace glop { 18 19 std::string GetProblemStatusString(ProblemStatus problem_status) { 20 switch (problem_status) { 21 case ProblemStatus::OPTIMAL: 22 return "OPTIMAL"; 23 case ProblemStatus::PRIMAL_INFEASIBLE: 24 return "PRIMAL_INFEASIBLE"; 25 case ProblemStatus::DUAL_INFEASIBLE: 26 return "DUAL_INFEASIBLE"; 27 case ProblemStatus::INFEASIBLE_OR_UNBOUNDED: 28 return "INFEASIBLE_OR_UNBOUNDED"; 29 case ProblemStatus::PRIMAL_UNBOUNDED: 30 return "PRIMAL_UNBOUNDED"; 31 case ProblemStatus::DUAL_UNBOUNDED: 32 return "DUAL_UNBOUNDED"; 33 case ProblemStatus::INIT: 34 return "INIT"; 35 case ProblemStatus::PRIMAL_FEASIBLE: 36 return "PRIMAL_FEASIBLE"; 37 case ProblemStatus::DUAL_FEASIBLE: 38 return "DUAL_FEASIBLE"; 39 case ProblemStatus::ABNORMAL: 40 return "ABNORMAL"; 41 case ProblemStatus::INVALID_PROBLEM: 42 return "INVALID_PROBLEM"; 43 case ProblemStatus::IMPRECISE: 44 return "IMPRECISE"; 45 } 46 // Fallback. We don't use "default:" so the compiler will return an error 47 // if we forgot one enum case above. 48 LOG(DFATAL) << "Invalid ProblemStatus " << static_cast<int>(problem_status); 49 return "UNKNOWN ProblemStatus"; 50 } 51 52 std::string GetVariableTypeString(VariableType variable_type) { 53 switch (variable_type) { 54 case VariableType::UNCONSTRAINED: 55 return "UNCONSTRAINED"; 56 case VariableType::LOWER_BOUNDED: 57 return "LOWER_BOUNDED"; 58 case VariableType::UPPER_BOUNDED: 59 return "UPPER_BOUNDED"; 60 case VariableType::UPPER_AND_LOWER_BOUNDED: 61 return "UPPER_AND_LOWER_BOUNDED"; 62 case VariableType::FIXED_VARIABLE: 63 return "FIXED_VARIABLE"; 64 } 65 // Fallback. We don't use "default:" so the compiler will return an error 66 // if we forgot one enum case above. 67 LOG(DFATAL) << "Invalid VariableType " << static_cast<int>(variable_type); 68 return "UNKNOWN VariableType"; 69 } 70 71 std::string GetVariableStatusString(VariableStatus status) { 72 switch (status) { 73 case VariableStatus::FREE: 74 return "FREE"; 75 case VariableStatus::AT_LOWER_BOUND: 76 return "AT_LOWER_BOUND"; 77 case VariableStatus::AT_UPPER_BOUND: 78 return "AT_UPPER_BOUND"; 79 case VariableStatus::FIXED_VALUE: 80 return "FIXED_VALUE"; 81 case VariableStatus::BASIC: 82 return "BASIC"; 83 } 84 // Fallback. We don't use "default:" so the compiler will return an error 85 // if we forgot one enum case above. 86 LOG(DFATAL) << "Invalid VariableStatus " << static_cast<int>(status); 87 return "UNKNOWN VariableStatus"; 88 } 89 90 std::string GetConstraintStatusString(ConstraintStatus status) { 91 switch (status) { 92 case ConstraintStatus::FREE: 93 return "FREE"; 94 case ConstraintStatus::AT_LOWER_BOUND: 95 return "AT_LOWER_BOUND"; 96 case ConstraintStatus::AT_UPPER_BOUND: 97 return "AT_UPPER_BOUND"; 98 case ConstraintStatus::FIXED_VALUE: 99 return "FIXED_VALUE"; 100 case ConstraintStatus::BASIC: 101 return "BASIC"; 102 } 103 // Fallback. We don't use "default:" so the compiler will return an error 104 // if we forgot one enum case above. 105 LOG(DFATAL) << "Invalid ConstraintStatus " << static_cast<int>(status); 106 return "UNKNOWN ConstraintStatus"; 107 } 108 109 ConstraintStatus VariableToConstraintStatus(VariableStatus status) { 110 switch (status) { 111 case VariableStatus::FREE: 112 return ConstraintStatus::FREE; 113 case VariableStatus::AT_LOWER_BOUND: 114 return ConstraintStatus::AT_LOWER_BOUND; 115 case VariableStatus::AT_UPPER_BOUND: 116 return ConstraintStatus::AT_UPPER_BOUND; FindCOMWindow()117 case VariableStatus::FIXED_VALUE: 118 return ConstraintStatus::FIXED_VALUE; 119 case VariableStatus::BASIC: 120 return ConstraintStatus::BASIC; 121 } 122 // Fallback. We don't use "default:" so the compiler will return an error 123 // if we forgot one enum case above. 124 LOG(DFATAL) << "Invalid VariableStatus " << static_cast<int>(status); 125 // This will never be reached and is here only to guarantee compilation. 126 return ConstraintStatus::FREE; 127 } 128 129 } // namespace glop 130 } // namespace operations_research 131