Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
routing_parameters_utils.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
15
16#include <vector>
17
18#include "absl/types/span.h"
19#include "ortools/util/optional_boolean.pb.h"
20
21namespace operations_research {
22
23std::vector<RoutingSearchParameters::InsertionSortingProperty>
25 absl::Span<const int> lci_insertion_sorting_properties) {
26 std::vector<RoutingSearchParameters::InsertionSortingProperty>
27 sorting_properties;
28
29 for (const int property : lci_insertion_sorting_properties) {
30 sorting_properties.push_back(
31 static_cast<RoutingSearchParameters::InsertionSortingProperty>(
32 property));
33 }
34
35 // For historical reasons if no insertion order is specified, we fallback to
36 // selecting nodes with the least number of allowed vehicles first, then the
37 // ones with the highest penalty.
38 if (sorting_properties.empty()) {
39 sorting_properties.push_back(
40 RoutingSearchParameters::SORTING_PROPERTY_ALLOWED_VEHICLES);
41 sorting_properties.push_back(
42 RoutingSearchParameters::SORTING_PROPERTY_PENALTY);
43 }
44 return sorting_properties;
45}
46
48 RoutingSearchParameters::LocalSearchNeighborhoodOperators* operators) {
49 const auto* reflection = operators->GetReflection();
50 const auto* descriptor = operators->GetDescriptor();
51 const auto* false_enum =
52 OptionalBoolean_descriptor()->FindValueByName("BOOL_FALSE");
53 for (int /*this is NOT the field's tag number*/ field_index = 0;
54 field_index < descriptor->field_count(); ++field_index) {
55 const auto* field = descriptor->field(field_index);
56 reflection->SetEnum(operators, field, false_enum);
57 }
58}
59
60} // namespace operations_research
In SWIG mode, we don't want anything besides these top-level includes.
std::vector< RoutingSearchParameters::InsertionSortingProperty > GetLocalCheapestInsertionSortingProperties(absl::Span< const int > lci_insertion_sorting_properties)
void DisableAllLocalSearchOperators(RoutingSearchParameters::LocalSearchNeighborhoodOperators *operators)