Google OR-Tools
v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
inverted_bounds.cc
Go to the documentation of this file.
1
// Copyright 2010-2025 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/math_opt/core/inverted_bounds.h
"
15
16
#include <cstdint>
17
#include <string>
18
#include <string_view>
19
#include <vector>
20
21
#include "absl/status/status.h"
22
#include "absl/strings/str_join.h"
23
#include "absl/types/span.h"
24
#include "
ortools/base/status_builder.h
"
25
26
namespace
operations_research::math_opt
{
27
28
absl::Status
InvertedBounds::ToStatus
()
const
{
29
if
(
empty
()) {
30
return
absl::OkStatus();
31
}
32
33
auto
builder =
util::InvalidArgumentErrorBuilder
();
34
const
auto
format_bounds_ids = [&builder](
const
std::string_view name,
35
const
std::vector<int64_t>& ids) {
36
if
(ids.empty()) {
37
return
;
38
}
39
40
builder << name <<
" with ids "
41
<< absl::StrJoin(absl::MakeSpan(ids).subspan(0,
kMaxInvertedBounds
),
42
","
);
43
if
(ids.size() >
kMaxInvertedBounds
) {
44
builder <<
"..."
;
45
}
46
};
47
48
format_bounds_ids(
"variables"
,
variables
);
49
if
(!
variables
.empty() && !
linear_constraints
.empty()) {
50
builder <<
" and "
;
51
}
52
format_bounds_ids(
"linear constraints"
,
linear_constraints
);
53
builder <<
" have lower_bound > upper_bound"
;
54
55
return
builder;
56
}
57
58
}
// namespace operations_research::math_opt
inverted_bounds.h
operations_research::math_opt
Definition
gurobi_isv.cc:28
operations_research::math_opt::kMaxInvertedBounds
constexpr std::size_t kMaxInvertedBounds
Definition
inverted_bounds.h:26
util::InvalidArgumentErrorBuilder
StatusBuilder InvalidArgumentErrorBuilder()
Definition
status_builder.h:107
status_builder.h
operations_research::math_opt::InvertedBounds::linear_constraints
std::vector< int64_t > linear_constraints
Definition
inverted_bounds.h:46
operations_research::math_opt::InvertedBounds::empty
bool empty() const
Definition
inverted_bounds.h:35
operations_research::math_opt::InvertedBounds::variables
std::vector< int64_t > variables
Definition
inverted_bounds.h:43
operations_research::math_opt::InvertedBounds::ToStatus
absl::Status ToStatus() const
Definition
inverted_bounds.cc:28
ortools
math_opt
core
inverted_bounds.cc
Generated by
1.15.0