Google OR-Tools
v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
second_order_cone_constraint.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/constraints/second_order_cone/second_order_cone_constraint.h
"
15
16
#include <optional>
17
#include <sstream>
18
#include <string>
19
#include <utility>
20
#include <vector>
21
22
#include "absl/strings/string_view.h"
23
#include "
ortools/base/strong_int.h
"
24
#include "
ortools/math_opt/constraints/second_order_cone/storage.h
"
25
#include "
ortools/math_opt/constraints/util/model_util.h
"
26
#include "
ortools/math_opt/cpp/variable_and_expressions.h
"
27
#include "
ortools/math_opt/storage/linear_expression_data.h
"
28
#include "
ortools/math_opt/storage/model_storage.h
"
29
30
namespace
operations_research::math_opt
{
31
32
LinearExpression
SecondOrderConeConstraint::UpperBound
()
const
{
33
return
ToLinearExpression
(*
storage
(),
34
storage
()->constraint_data(id_).upper_bound);
35
}
36
37
std::vector<LinearExpression>
SecondOrderConeConstraint::ArgumentsToNorm
()
38
const
{
39
const
SecondOrderConeConstraintData
& data =
storage
()->constraint_data(id_);
40
std::vector<LinearExpression> args;
41
args.reserve(data.
arguments_to_norm
.size());
42
for
(
const
LinearExpressionData
& arg_data : data.
arguments_to_norm
) {
43
args.push_back(
ToLinearExpression
(*
storage
(), arg_data));
44
}
45
return
args;
46
}
47
48
std::string
SecondOrderConeConstraint::ToString
()
const
{
49
if
(!
storage
()->has_constraint(id_)) {
50
return
std::string(
kDeletedConstraintDefaultDescription
);
51
}
52
const
SecondOrderConeConstraintData
& data =
storage
()->constraint_data(id_);
53
std::stringstream str;
54
str <<
"||{"
;
55
bool
leading_comma =
false
;
56
for
(
const
LinearExpressionData
& arg_data : data.
arguments_to_norm
) {
57
if
(leading_comma) {
58
str <<
", "
;
59
}
60
leading_comma =
true
;
61
str <<
ToLinearExpression
(*
storage
(), arg_data);
62
}
63
str <<
"}||₂ ≤ "
<<
ToLinearExpression
(*
storage
(), data.
upper_bound
);
64
return
str.str();
65
}
66
67
}
// namespace operations_research::math_opt
operations_research::math_opt::LinearExpression
Definition
variable_and_expressions.h:207
operations_research::math_opt::ModelStorageItem::storage
ModelStorageCPtr storage() const
Definition
model_storage_item.h:33
operations_research::math_opt::SecondOrderConeConstraint::ToString
std::string ToString() const
Definition
second_order_cone_constraint.cc:48
operations_research::math_opt::SecondOrderConeConstraint::UpperBound
LinearExpression UpperBound() const
Definition
second_order_cone_constraint.cc:32
operations_research::math_opt::SecondOrderConeConstraint::ArgumentsToNorm
std::vector< LinearExpression > ArgumentsToNorm() const
Definition
second_order_cone_constraint.cc:37
linear_expression_data.h
model_storage.h
model_util.h
operations_research::math_opt
Definition
gurobi_isv.cc:28
operations_research::math_opt::kDeletedConstraintDefaultDescription
constexpr absl::string_view kDeletedConstraintDefaultDescription
Definition
model_util.h:30
operations_research::math_opt::ToLinearExpression
LinearExpression ToLinearExpression(const ModelStorage &storage, const LinearExpressionData &expr_data)
Definition
model_util.cc:25
storage.h
second_order_cone_constraint.h
strong_int.h
operations_research::math_opt::LinearExpressionData
Definition
linear_expression_data.h:29
operations_research::math_opt::SecondOrderConeConstraintData
Definition
storage.h:33
operations_research::math_opt::SecondOrderConeConstraintData::upper_bound
LinearExpressionData upper_bound
Definition
storage.h:46
operations_research::math_opt::SecondOrderConeConstraintData::arguments_to_norm
std::vector< LinearExpressionData > arguments_to_norm
Definition
storage.h:47
variable_and_expressions.h
ortools
math_opt
constraints
second_order_cone
second_order_cone_constraint.cc
Generated by
1.15.0