OR-Tools  9.3
enum_sets.cc
Go to the documentation of this file.
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
15
16#include <string>
17#include <tuple>
18#include <vector>
19
20#include "absl/strings/str_cat.h"
21#include "gtest/gtest.h"
22#include "ortools/math_opt/result.pb.h"
23#include "ortools/math_opt/solution.pb.h"
25
26namespace operations_research {
27namespace math_opt {
28
29// portable.
30std::vector<FeasibilityStatusProto> AllFeasibilityStatuses() {
31 std::vector<FeasibilityStatusProto> values;
32 for (int f = FeasibilityStatusProto_MIN; f <= FeasibilityStatusProto_MAX;
33 ++f) {
34 if (FeasibilityStatusProto_IsValid(f) &&
35 f != FEASIBILITY_STATUS_UNSPECIFIED) {
36 values.push_back(static_cast<FeasibilityStatusProto>(f));
37 }
38 }
39 return values;
40}
41
42std::vector<SolutionStatusProto> AllSolutionStatuses() {
43 std::vector<SolutionStatusProto> values;
44 for (int f = SolutionStatusProto_MIN; f <= SolutionStatusProto_MAX; ++f) {
45 if (SolutionStatusProto_IsValid(f) && f != SOLUTION_STATUS_UNSPECIFIED) {
46 values.push_back(static_cast<SolutionStatusProto>(f));
47 }
48 }
49 return values;
50}
51
52void PrintTo(const SolutionStatusProto& proto, std::ostream* os) {
54}
55
56void PrintTo(const FeasibilityStatusProto& proto, std::ostream* os) {
58}
59
60void PrintTo(const std::tuple<SolutionStatusProto, SolutionStatusProto>& proto,
61 std::ostream* os) {
62 *os << ProtoEnumToString(std::get<0>(proto)) << "_"
63 << ProtoEnumToString(std::get<1>(proto));
64}
65
67 const std::tuple<FeasibilityStatusProto, FeasibilityStatusProto>& proto,
68 std::ostream* os) {
69 *os << ProtoEnumToString(std::get<0>(proto)) << "_"
70 << ProtoEnumToString(std::get<1>(proto));
71}
72
74 const std::tuple<SolutionStatusProto, FeasibilityStatusProto>& proto,
75 std::ostream* os) {
76 *os << ProtoEnumToString(std::get<0>(proto)) << "_"
77 << ProtoEnumToString(std::get<1>(proto));
78}
79
80} // namespace math_opt
81} // namespace operations_research
CpModelProto proto
void PrintTo(const Termination &termination, std::ostream *os)
Definition: matchers.cc:78
std::vector< FeasibilityStatusProto > AllFeasibilityStatuses()
Definition: enum_sets.cc:30
std::vector< SolutionStatusProto > AllSolutionStatuses()
Definition: enum_sets.cc:42
Collection of objects used to extend the Constraint Solver library.
std::string ProtoEnumToString(ProtoEnumType enum_value)