Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
bop_types.h
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
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
23
24namespace operations_research {
25namespace bop {
26DEFINE_STRONG_INDEX_TYPE(ConstraintIndex);
31DEFINE_STRONG_INT64_TYPE(SolverTimeStamp);
32
33// Status of the solve of Bop.
34enum class BopSolveStatus {
35 // The solver found the proven optimal solution.
37
38 // The solver found a solution, but it is not proven to be the optimal
39 // solution.
41
42 // The solver didn't find any solution.
44
45 // The problem is infeasible.
47
48 // The problem is invalid.
50};
51
53 switch (status) {
55 return "OPTIMAL_SOLUTION_FOUND";
57 return "FEASIBLE_SOLUTION_FOUND";
59 return "NO_SOLUTION_FOUND";
61 return "INFEASIBLE_PROBLEM";
63 return "INVALID_PROBLEM";
64 }
65 // Fallback. We don't use "default:" so the compiler will return an error
66 // if we forgot one enum case above.
67 return "UNKNOWN Status";
68}
69inline std::ostream& operator<<(std::ostream& os, BopSolveStatus status) {
71 return os;
72}
73
74// TODO(user): Remove.
77 BopConstraintTerm(VariableIndex _var_id, int64_t _weight)
78 : var_id(_var_id), search_id(0), weight(_weight) {}
79
80 VariableIndex var_id;
81 SearchIndex search_id;
82 int64_t weight;
83
84 bool operator<(const BopConstraintTerm& other) const {
85 return search_id < other.search_id;
86 }
87};
90
91} // namespace bop
92} // namespace operations_research
93#endif // OR_TOOLS_BOP_BOP_TYPES_H_
absl::Status status
Definition g_gurobi.cc:44
util_intops::StrongVector< SparseIndex, BopConstraintTerm > BopConstraintTerms
Definition bop_types.h:89
std::ostream & operator<<(std::ostream &os, BopOptimizerBase::Status status)
Definition bop_base.h:111
BopSolveStatus
Status of the solve of Bop.
Definition bop_types.h:34
@ NO_SOLUTION_FOUND
The solver didn't find any solution.
@ OPTIMAL_SOLUTION_FOUND
The solver found the proven optimal solution.
@ INFEASIBLE_PROBLEM
The problem is infeasible.
@ INVALID_PROBLEM
The problem is invalid.
std::string GetSolveStatusString(BopSolveStatus status)
Definition bop_types.h:52
In SWIG mode, we don't want anything besides these top-level includes.
#define DEFINE_STRONG_INT64_TYPE(integer_type_name)
#define DEFINE_STRONG_INDEX_TYPE(index_type_name)
BopConstraintTerm(VariableIndex _var_id, int64_t _weight)
Definition bop_types.h:77
bool operator<(const BopConstraintTerm &other) const
Definition bop_types.h:84