Google OR-Tools v9.11
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-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
14#ifndef OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_DECISION_BUILDERS_H_
15#define OR_TOOLS_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
31DecisionBuilder* MakeSetValuesFromTargets(Solver* solver,
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, SearchMonitor* monitor,
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) {}
83 void AddWeightedVariableToMinimize(IntVar* var, int64_t cost);
86 void AddWeightedVariableToMaximize(IntVar* var, int64_t cost);
89 void AddVariableTarget(IntVar* var, int64_t target);
92 void AddWeightedVariableTarget(IntVar* var, int64_t target, int64_t cost);
95
96 private:
97 Solver* const solver_;
98#ifndef SWIG
99 struct VarTarget {
100 IntVar* var;
101 int64_t target;
102 };
103 std::vector<std::pair<VarTarget, int64_t>>
104 weighted_finalizer_variable_targets_;
105 std::vector<VarTarget> finalizer_variable_targets_;
106 absl::flat_hash_map<IntVar*, int> weighted_finalizer_variable_index_;
107 absl::flat_hash_set<IntVar*> finalizer_variable_target_set_;
108#endif
109};
110
111} // namespace operations_research
112#endif // OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_DECISION_BUILDERS_H_
void AddVariableTarget(IntVar *var, int64_t target)
void AddWeightedVariableToMinimize(IntVar *var, int64_t cost)
void AddWeightedVariableTarget(IntVar *var, int64_t target, int64_t cost)
FinalizerVariables.
void AddWeightedVariableToMaximize(IntVar *var, int64_t cost)
For the time being, Solver is neither MT_SAFE nor MT_HOT.
IntVar * var
GRBmodel * model
In SWIG mode, we don't want anything besides these top-level includes.
DecisionBuilder * MakeRestoreDimensionValuesForUnchangedRoutes(RoutingModel *model)
DecisionBuilder * MakeSetCumulsFromLocalDimensionCosts(Solver *solver, LocalDimensionCumulOptimizer *lp_optimizer, LocalDimensionCumulOptimizer *mp_optimizer, bool optimize_and_pack, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route)
DecisionBuilder * MakeSetCumulsFromGlobalDimensionCosts(Solver *solver, GlobalDimensionCumulOptimizer *global_optimizer, GlobalDimensionCumulOptimizer *global_mp_optimizer, SearchMonitor *monitor, bool optimize_and_pack, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route)
Variant based on global optimizers, handling all routes together.
DecisionBuilder * MakeSetValuesFromTargets(Solver *solver, std::vector< IntVar * > variables, std::vector< int64_t > targets)