OR-Tools  9.6
bop_types.h
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 
14 #ifndef OR_TOOLS_BOP_BOP_TYPES_H_
15 #define OR_TOOLS_BOP_BOP_TYPES_H_
16 
17 #include <cstdint>
18 #include <ostream>
19 #include <string>
20 
24 
25 namespace operations_research {
26 namespace bop {
27 DEFINE_STRONG_INDEX_TYPE(ConstraintIndex);
31 DEFINE_STRONG_INDEX_TYPE(VariableIndex);
32 DEFINE_STRONG_INT64_TYPE(SolverTimeStamp);
33 
34 // Status of the solve of Bop.
35 enum class BopSolveStatus {
36  // The solver found the proven optimal solution.
38 
39  // The solver found a solution, but it is not proven to be the optimal
40  // solution.
42 
43  // The solver didn't find any solution.
45 
46  // The problem is infeasible.
48 
49  // The problem is invalid.
51 };
52 
54  switch (status) {
56  return "OPTIMAL_SOLUTION_FOUND";
58  return "FEASIBLE_SOLUTION_FOUND";
60  return "NO_SOLUTION_FOUND";
62  return "INFEASIBLE_PROBLEM";
64  return "INVALID_PROBLEM";
65  }
66  // Fallback. We don't use "default:" so the compiler will return an error
67  // if we forgot one enum case above.
68  return "UNKNOWN Status";
69 }
70 inline std::ostream& operator<<(std::ostream& os, BopSolveStatus status) {
72  return os;
73 }
74 
75 // TODO(user): Remove.
78  BopConstraintTerm(VariableIndex _var_id, int64_t _weight)
79  : var_id(_var_id), search_id(0), weight(_weight) {}
80 
81  VariableIndex var_id;
82  SearchIndex search_id;
83  int64_t weight;
84 
85  bool operator<(const BopConstraintTerm& other) const {
86  return search_id < other.search_id;
87  }
88 };
90 
91 } // namespace bop
92 } // namespace operations_research
93 #endif // OR_TOOLS_BOP_BOP_TYPES_H_
absl::Status status
Definition: g_gurobi.cc:41
std::ostream & operator<<(std::ostream &os, BopOptimizerBase::Status status)
Definition: bop_base.h:109
std::string GetSolveStatusString(BopSolveStatus status)
Definition: bop_types.h:53
DEFINE_STRONG_INDEX_TYPE(OptimizerIndex)
absl::StrongVector< SparseIndex, BopConstraintTerm > BopConstraintTerms
Definition: bop_types.h:89
DEFINE_STRONG_INT64_TYPE(SolverTimeStamp)
Collection of objects used to extend the Constraint Solver library.
BopConstraintTerm(VariableIndex _var_id, int64_t _weight)
Definition: bop_types.h:78
bool operator<(const BopConstraintTerm &other) const
Definition: bop_types.h:85