Google OR-Tools v9.9
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-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
15
16#include <optional>
17#include <sstream>
18#include <string>
19#include <utility>
20#include <vector>
21
22#include "absl/strings/string_view.h"
29
31
33 return ToLinearExpression(*storage_,
34 storage()->constraint_data(id_).upper_bound);
35}
36
37std::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
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
double upper_bound
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
constexpr absl::string_view kDeletedConstraintDefaultDescription
Definition model_util.h:30
LinearExpression ToLinearExpression(const ModelStorage &storage, const LinearExpressionData &expr_data)
Definition model_util.cc:25
std::vector< LinearExpressionData > arguments_to_norm
Definition storage.h:46