Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
routing_decision_builders.h
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#ifndef ORTOOLS_CONSTRAINT_SOLVER_ROUTING_DECISION_BUILDERS_H_
15#define ORTOOLS_CONSTRAINT_SOLVER_ROUTING_DECISION_BUILDERS_H_
16
17#include <cstdint>
18#include <utility>
19#include <vector>
20
21#include "absl/container/flat_hash_map.h"
22#include "absl/container/flat_hash_set.h"
26
27namespace operations_research {
28
32 std::vector<IntVar*> variables,
33 std::vector<int64_t> targets);
34
37
41 Solver* solver, LocalDimensionCumulOptimizer* lp_optimizer,
42 LocalDimensionCumulOptimizer* mp_optimizer, bool optimize_and_pack = false,
43 std::vector<RoutingModel::RouteDimensionTravelInfo>
44 dimension_travel_info_per_route = {});
45
48 Solver* solver, GlobalDimensionCumulOptimizer* global_optimizer,
49 GlobalDimensionCumulOptimizer* global_mp_optimizer,
50 bool optimize_and_pack = false,
51 std::vector<RoutingModel::RouteDimensionTravelInfo>
52 dimension_travel_info_per_route = {});
53
65 RoutingModel* model);
66
71 public:
72 explicit FinalizerVariables(Solver* solver) : solver_(solver) {}
77 void AddVariableTarget(IntVar* var, int64_t target);
80 void AddWeightedVariableTarget(IntVar* var, int64_t target, int64_t cost);
86
87 private:
88 Solver* const solver_;
89#ifndef SWIG
90 struct VarTarget {
91 IntVar* var;
92 int64_t target;
93 };
94 std::vector<std::pair<VarTarget, int64_t>>
95 weighted_finalizer_variable_targets_;
96 std::vector<VarTarget> finalizer_variable_targets_;
97 absl::flat_hash_map<IntVar*, int> weighted_finalizer_variable_index_;
98 absl::flat_hash_set<IntVar*> finalizer_variable_target_set_;
99#endif
100};
101
102} // namespace operations_research
103#endif // ORTOOLS_CONSTRAINT_SOLVER_ROUTING_DECISION_BUILDERS_H_
void AddVariableTarget(IntVar *var, int64_t target)
void AddWeightedVariableTarget(IntVar *var, int64_t target, int64_t cost)
OR-Tools root namespace.
DecisionBuilder * MakeRestoreDimensionValuesForUnchangedRoutes(RoutingModel *model)
DecisionBuilder * MakeSetCumulsFromGlobalDimensionCosts(Solver *solver, GlobalDimensionCumulOptimizer *global_optimizer, GlobalDimensionCumulOptimizer *global_mp_optimizer, bool optimize_and_pack, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route)
Variant based on global optimizers, handling all routes together.
DecisionBuilder * MakeSetCumulsFromLocalDimensionCosts(Solver *solver, LocalDimensionCumulOptimizer *lp_optimizer, LocalDimensionCumulOptimizer *mp_optimizer, bool optimize_and_pack, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route)
DecisionBuilder * MakeSetValuesFromTargets(Solver *solver, std::vector< IntVar * > variables, std::vector< int64_t > targets)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...