Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
names_removal.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 "ortools/math_opt/model.pb.h"
17#include "ortools/math_opt/model_update.pb.h"
18
20
21namespace {
22
23template <typename T>
24void RemoveMapNames(google::protobuf::Map<int64_t, T>& map) {
25 for (auto& [unused, value] : map) {
26 value.clear_name();
27 }
28}
29
30} // namespace
31
32void RemoveNames(ModelProto& model) {
33 model.clear_name();
34 model.mutable_variables()->clear_names();
35 model.mutable_linear_constraints()->clear_names();
36 RemoveMapNames(*model.mutable_auxiliary_objectives());
37 RemoveMapNames(*model.mutable_quadratic_constraints());
38 RemoveMapNames(*model.mutable_second_order_cone_constraints());
39 RemoveMapNames(*model.mutable_sos1_constraints());
40 RemoveMapNames(*model.mutable_sos2_constraints());
41 RemoveMapNames(*model.mutable_indicator_constraints());
42}
43
44void RemoveNames(ModelUpdateProto& update) {
45 update.mutable_new_variables()->clear_names();
46 update.mutable_new_linear_constraints()->clear_names();
47 RemoveMapNames(
48 *update.mutable_auxiliary_objectives_updates()->mutable_new_objectives());
49 RemoveMapNames(*update.mutable_quadratic_constraint_updates()
50 ->mutable_new_constraints());
51 RemoveMapNames(*update.mutable_second_order_cone_constraint_updates()
52 ->mutable_new_constraints());
53 RemoveMapNames(
54 *update.mutable_sos1_constraint_updates()->mutable_new_constraints());
55 RemoveMapNames(
56 *update.mutable_sos2_constraint_updates()->mutable_new_constraints());
57 RemoveMapNames(*update.mutable_indicator_constraint_updates()
58 ->mutable_new_constraints());
59}
60
61} // namespace operations_research::math_opt
int64_t value
GRBmodel * model
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
void RemoveNames(ModelProto &model)
Removes the model, variables and constraints names of the provided model.