OR-Tools  8.2
bop_types.h
Go to the documentation of this file.
1 // Copyright 2010-2018 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 
20 #include "ortools/base/int_type.h"
22 
23 namespace operations_research {
24 namespace bop {
25 DEFINE_INT_TYPE(ConstraintIndex, int);
26 DEFINE_INT_TYPE(EntryIndex, int);
27 DEFINE_INT_TYPE(SearchIndex, int);
28 DEFINE_INT_TYPE(TermIndex, int);
29 DEFINE_INT_TYPE(VariableIndex, int);
30 DEFINE_INT_TYPE(SolverTimeStamp, int64_t);
31 
32 // Status of the solve of Bop.
33 enum class BopSolveStatus {
34  // The solver found the proven optimal solution.
36 
37  // The solver found a solution, but it is not proven to be the optimal
38  // solution.
40 
41  // The solver didn't find any solution.
43 
44  // The problem is infeasible.
46 
47  // The problem is invalid.
49 };
50 
51 inline std::string GetSolveStatusString(BopSolveStatus status) {
52  switch (status) {
54  return "OPTIMAL_SOLUTION_FOUND";
56  return "FEASIBLE_SOLUTION_FOUND";
58  return "NO_SOLUTION_FOUND";
60  return "INFEASIBLE_PROBLEM";
62  return "INVALID_PROBLEM";
63  }
64  // Fallback. We don't use "default:" so the compiler will return an error
65  // if we forgot one enum case above.
66  return "UNKNOWN Status";
67 }
68 inline std::ostream& operator<<(std::ostream& os, BopSolveStatus status) {
69  os << GetSolveStatusString(status);
70  return os;
71 }
72 
73 // TODO(user): Remove.
74 DEFINE_INT_TYPE(SparseIndex, int);
76  BopConstraintTerm(VariableIndex _var_id, int64_t _weight)
77  : var_id(_var_id), search_id(0), weight(_weight) {}
78 
79  VariableIndex var_id;
80  SearchIndex search_id;
81  int64_t weight;
82 
83  bool operator<(const BopConstraintTerm& other) const {
84  return search_id < other.search_id;
85  }
86 };
88 
89 } // namespace bop
90 } // namespace operations_research
91 #endif // OR_TOOLS_BOP_BOP_TYPES_H_
DEFINE_INT_TYPE(OptimizerIndex, int)
std::ostream & operator<<(std::ostream &os, BopOptimizerBase::Status status)
Definition: bop_base.h:106
std::string GetSolveStatusString(BopSolveStatus status)
Definition: bop_types.h:51
absl::StrongVector< SparseIndex, BopConstraintTerm > BopConstraintTerms
Definition: bop_types.h:87
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
BopConstraintTerm(VariableIndex _var_id, int64_t _weight)
Definition: bop_types.h:76
bool operator<(const BopConstraintTerm &other) const
Definition: bop_types.h:83