Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
routing_neighborhoods.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_NEIGHBORHOODS_H_
15#define OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_NEIGHBORHOODS_H_
16
17#include <cstdint>
18#include <functional>
19#include <string>
20#include <utility>
21#include <vector>
22
23#include "absl/log/check.h"
24#include "absl/types/span.h"
28#include "ortools/util/bitset.h"
29
30namespace operations_research {
31
52// TODO(user): Consider merging with standard Relocate in local_search.cc.
54 public:
56 const std::vector<IntVar*>& vars,
57 const std::vector<IntVar*>& secondary_vars,
58 std::function<int(int64_t)> start_empty_path_class,
59 std::function<const std::vector<int>&(int, int)> get_neighbors,
60 RoutingTransitCallback2 arc_evaluator);
62 const std::vector<IntVar*>& vars,
63 const std::vector<IntVar*>& secondary_vars,
64 std::function<int(int64_t)> start_empty_path_class,
65 RoutingTransitCallback2 arc_evaluator)
66 : MakeRelocateNeighborsOperator(vars, secondary_vars,
67 std::move(start_empty_path_class),
68 nullptr, std::move(arc_evaluator)) {}
70
71 bool MakeNeighbor() override;
72 std::string DebugString() const override { return "RelocateNeighbors"; }
73
74 private:
81 bool MoveChainAndRepair(int64_t before_chain, int64_t chain_end,
82 int64_t destination);
83
91 int64_t Reposition(int64_t before_to_move, int64_t up_to);
92
93 RoutingTransitCallback2 arc_evaluator_;
94};
95
96// Swaps active nodes from node alternatives in sequence. Considers chains of
97// nodes with alternatives, builds a DAG from the chain, each "layer" of the DAG
98// being composed of the set of alternatives of the node at a given rank in the
99// chain, fully connected to the next layer. A neighbor is built from the
100// shortest path starting from the node before the chain (source), through the
101// DAG to the node following the chain. The path is valued with a given
102// callback.
103// Example:
104// Alternative sets: {1,2} and {3,4}
105// Current path: 0 -> 1 -> 3 -> 5
106// DAG + source and sink: -> 1 ---> 3 --
107// | \ / v
108// 0 X 5
109// | / \ ^
110// -> 2 ---> 4 --
111// Supposing the shortest path from 0 to 5 is 0, 2, 3, 5, the neighbor for the
112// chain will be: 0 -> 2 -> 3 -> 5.
113// TODO(user): Support vehicle-class-dependent arc_evaluators.
115 public:
117 const std::vector<IntVar*>& vars,
118 const std::vector<IntVar*>& secondary_vars,
119 std::function<int(int64_t)> start_empty_path_class,
120 std::vector<std::vector<int64_t>> alternative_sets,
121 RoutingTransitCallback2 arc_evaluator);
123 bool MakeNeighbor() override;
124 std::string DebugString() const override {
125 return "SwapActiveToShortestPath";
126 }
127
128 private:
129 const std::vector<int64_t>& GetShortestPath(
130 int source, int sink, const std::vector<int>& alternative_chain);
131
132 RoutingTransitCallback2 arc_evaluator_;
133 const std::vector<std::vector<int64_t>> alternative_sets_;
134 std::vector<int> to_alternative_set_;
135 std::vector<int64_t> path_predecessor_;
136 std::vector<int64_t> path_;
137 SparseBitset<int64_t> touched_;
138};
139
144// TODO(user): Add option to prune neighbords where the order of node pairs
145// is violated (ie precedence between pickup and delivery nodes).
146// TODO(user): Move this to local_search.cc if it's generic enough.
147// TODO(user): Detect pairs automatically by parsing the constraint model;
148// we could then get rid of the pair API in the RoutingModel
149// class.
150
164 public:
165 MakePairActiveOperator(const std::vector<IntVar*>& vars,
166 const std::vector<IntVar*>& secondary_vars,
167 std::function<int(int64_t)> start_empty_path_class,
168 const std::vector<PickupDeliveryPair>& pairs);
170 bool MakeNeighbor() override;
171 std::string DebugString() const override { return "MakePairActive"; }
172
173 protected:
174 bool MakeOneNeighbor() override;
175 bool OnSamePathAsPreviousBase(int64_t /*base_index*/) override {
178 return true;
179 }
180
181 int64_t GetBaseNodeRestartPosition(int base_index) override;
182
185 bool RestartAtPathStartOnSynchronize() override { return true; }
186
187 private:
188 void OnNodeInitialization() override;
189 int FindNextInactivePair(int pair_index) const;
190 bool ContainsActiveNodes(const std::vector<int64_t>& nodes) const;
191
192 int inactive_pair_;
193 int inactive_pair_first_index_;
194 int inactive_pair_second_index_;
195 const std::vector<PickupDeliveryPair> pairs_;
196};
197
200 public:
201 MakePairInactiveOperator(const std::vector<IntVar*>& vars,
202 const std::vector<IntVar*>& secondary_vars,
203 std::function<int(int64_t)> start_empty_path_class,
204 const std::vector<PickupDeliveryPair>& pairs);
205
206 bool MakeNeighbor() override;
207 std::string DebugString() const override { return "MakePairInActive"; }
208};
209
219 public:
220 PairRelocateOperator(const std::vector<IntVar*>& vars,
221 const std::vector<IntVar*>& secondary_vars,
222 std::function<int(int64_t)> start_empty_path_class,
223 const std::vector<PickupDeliveryPair>& pairs);
225
226 bool MakeNeighbor() override;
227 std::string DebugString() const override { return "PairRelocateOperator"; }
228
229 protected:
230 bool OnSamePathAsPreviousBase(int64_t base_index) override {
232 return base_index == kPairSecondNodeDestination;
233 }
234 int64_t GetBaseNodeRestartPosition(int base_index) override;
235
236 bool ConsiderAlternatives(int64_t base_index) const override {
237 return base_index == kPairFirstNode;
238 }
239
240 private:
241 bool RestartAtPathStartOnSynchronize() override { return true; }
242
243 static constexpr int kPairFirstNode = 0;
244 static constexpr int kPairFirstNodeDestination = 1;
245 static constexpr int kPairSecondNodeDestination = 2;
246};
247
251 public:
253 const std::vector<IntVar*>& vars,
254 const std::vector<IntVar*>& secondary_vars,
255 std::function<int(int64_t)> start_empty_path_class,
256 std::function<const std::vector<int>&(int, int)> get_neighbors,
257 const std::vector<PickupDeliveryPair>& pairs);
259 const std::vector<IntVar*>& vars,
260 const std::vector<IntVar*>& secondary_vars,
261 std::function<int(int64_t)> start_empty_path_class,
262 const std::vector<PickupDeliveryPair>& pairs)
263 : GroupPairAndRelocateOperator(vars, secondary_vars,
264 std::move(start_empty_path_class), nullptr,
265 pairs) {}
267
268 bool MakeNeighbor() override;
269 std::string DebugString() const override { return "GroupPairAndRelocate"; }
270};
271
281// TODO(user): Add a version which inserts the first node before the other
282// pair's first node; there are many redundant neighbors if done blindly.
284 public:
286 const std::vector<IntVar*>& vars,
287 const std::vector<IntVar*>& secondary_vars,
288 std::function<int(int64_t)> start_empty_path_class,
289 std::function<const std::vector<int>&(int, int)> get_neighbors,
290 const std::vector<PickupDeliveryPair>& pairs,
291 std::function<bool(int64_t)> force_lifo = nullptr);
292 LightPairRelocateOperator(const std::vector<IntVar*>& vars,
293 const std::vector<IntVar*>& secondary_vars,
294 std::function<int(int64_t)> start_empty_path_class,
295 const std::vector<PickupDeliveryPair>& pairs,
296 std::function<bool(int64_t)> force_lifo = nullptr);
298
299 bool MakeNeighbor() override;
300 std::string DebugString() const override {
301 return "LightPairRelocateOperator";
302 }
303
304 private:
305 std::function<bool(int64_t)> force_lifo_;
306};
307
315 public:
317 const std::vector<IntVar*>& vars,
318 const std::vector<IntVar*>& secondary_vars,
319 std::function<int(int64_t)> start_empty_path_class,
320 std::function<const std::vector<int>&(int, int)> get_neighbors,
321 const std::vector<PickupDeliveryPair>& pairs);
322 PairExchangeOperator(const std::vector<IntVar*>& vars,
323 const std::vector<IntVar*>& secondary_vars,
324 std::function<int(int64_t)> start_empty_path_class,
325 const std::vector<PickupDeliveryPair>& pairs)
326 : PairExchangeOperator(vars, secondary_vars,
327 std::move(start_empty_path_class), nullptr,
328 pairs) {}
330
331 bool MakeNeighbor() override;
332 std::string DebugString() const override { return "PairExchangeOperator"; }
333
334 private:
335 bool RestartAtPathStartOnSynchronize() override { return true; }
336 bool ConsiderAlternatives(int64_t /*base_index*/) const override {
337 return true;
338 }
339 bool GetPreviousAndSibling(int64_t node, int64_t* previous, int64_t* sibling,
340 int64_t* sibling_previous) const;
341};
342
357 public:
359 const std::vector<IntVar*>& vars,
360 const std::vector<IntVar*>& secondary_vars,
361 std::function<int(int64_t)> start_empty_path_class,
362 const std::vector<PickupDeliveryPair>& pairs);
364
365 bool MakeNeighbor() override;
366 std::string DebugString() const override {
367 return "PairExchangeRelocateOperator";
368 }
369
370 protected:
371 bool OnSamePathAsPreviousBase(int64_t base_index) override;
372 int64_t GetBaseNodeRestartPosition(int base_index) override;
373
374 private:
375 bool RestartAtPathStartOnSynchronize() override { return true; }
376 bool GetPreviousAndSibling(int64_t node, int64_t* previous, int64_t* sibling,
377 int64_t* sibling_previous) const;
378 bool MoveNode(int pair, int node, int64_t nodes[2][2], int64_t dest[2][2],
379 int64_t prev[2][2]);
380 bool LoadAndCheckDest(int pair, int node, int64_t base_node,
381 int64_t nodes[2][2], int64_t dest[2][2]) const;
382
383 static constexpr int kFirstPairFirstNode = 0;
384 static constexpr int kSecondPairFirstNode = 1;
385 static constexpr int kFirstPairFirstNodeDestination = 2;
386 static constexpr int kFirstPairSecondNodeDestination = 3;
387 static constexpr int kSecondPairFirstNodeDestination = 4;
388 static constexpr int kSecondPairSecondNodeDestination = 5;
389};
390
402 public:
403 SwapIndexPairOperator(const std::vector<IntVar*>& vars,
404 const std::vector<IntVar*>& path_vars,
405 const std::vector<PickupDeliveryPair>& pairs);
407
408 bool MakeNextNeighbor(Assignment* delta, Assignment* deltadelta) override;
409 void OnStart() override;
410 std::string DebugString() const override { return "SwapIndexPairOperator"; }
411
412 private:
415 bool UpdateActiveNodes();
417 void SetNext(int64_t from, int64_t to, int64_t path) {
418 DCHECK_LT(from, number_of_nexts_);
419 SetValue(from, to);
420 if (!ignore_path_vars_) {
421 DCHECK_LT(from + number_of_nexts_, Size());
422 SetValue(from + number_of_nexts_, path);
423 }
424 }
425
426 const std::vector<PickupDeliveryPair> pairs_;
427 int pair_index_;
428 int first_index_;
429 int second_index_;
430 int64_t first_active_;
431 int64_t second_active_;
432 std::vector<int64_t> prevs_;
433 const int number_of_nexts_;
434 const bool ignore_path_vars_;
435};
436
440 public:
442 const std::vector<IntVar*>& vars,
443 const std::vector<IntVar*>& secondary_vars,
444 std::function<int(int64_t)> start_empty_path_class,
445 const std::vector<PickupDeliveryPair>& pairs);
447
448 bool MakeNextNeighbor(Assignment* delta, Assignment* deltadelta) override;
449 bool MakeNeighbor() override;
450 std::string DebugString() const override {
451 return "IndexPairSwapActiveOperator";
452 }
453
454 private:
455 void OnNodeInitialization() override;
456
457 int inactive_node_;
458};
459
467class RelocateExpensiveChain : public PathOperator {
468 public:
469 RelocateExpensiveChain(const std::vector<IntVar*>& vars,
470 const std::vector<IntVar*>& secondary_vars,
471 std::function<int(int64_t)> start_empty_path_class,
472 int num_arcs_to_consider,
473 std::function<int64_t(int64_t, int64_t, int64_t)>
474 arc_cost_for_path_start);
475 ~RelocateExpensiveChain() override {}
476 bool MakeNeighbor() override;
477 bool MakeOneNeighbor() override;
478
479 std::string DebugString() const override { return "RelocateExpensiveChain"; }
480
481 private:
482 void OnNodeInitialization() override;
483 void IncrementCurrentPath();
484 bool IncrementCurrentArcIndices();
488 bool FindMostExpensiveChainsOnRemainingPaths();
489
490 int num_arcs_to_consider_;
491 int current_path_;
492 std::vector<std::pair<int64_t, int>> most_expensive_arc_starts_and_ranks_;
495 std::pair</*first_arc_index*/ int, /*second_arc_index*/ int>
496 current_expensive_arc_indices_;
497 std::function<int64_t(/*before_node*/ int64_t, /*after_node*/ int64_t,
498 /*path_start*/ int64_t)>
499 arc_cost_for_path_start_;
500 int end_path_;
503 bool has_non_empty_paths_to_explore_;
504};
505
513template <bool swap_first>
515 public:
516 PairNodeSwapActiveOperator(const std::vector<IntVar*>& vars,
517 const std::vector<IntVar*>& secondary_vars,
518 std::function<int(int64_t)> start_empty_path_class,
519 const std::vector<PickupDeliveryPair>& pairs);
520 ~PairNodeSwapActiveOperator() override {}
521
522 bool MakeNextNeighbor(Assignment* delta, Assignment* deltadelta) override;
523 bool MakeNeighbor() override;
524 std::string DebugString() const override {
525 return "PairNodeSwapActiveOperator";
527
528 protected:
529 bool OnSamePathAsPreviousBase(int64_t /*base_index*/) override {
532 return true;
533 }
534
535 int64_t GetBaseNodeRestartPosition(int base_index) override;
536
539 bool RestartAtPathStartOnSynchronize() override { return true; }
540
541 private:
542 void OnNodeInitialization() override;
543
544 int inactive_pair_;
545 std::vector<PickupDeliveryPair> pairs_;
546};
547
548// ==========================================================================
549// Section: Implementations of the template classes declared above.
550
551template <bool swap_first>
553 const std::vector<IntVar*>& vars,
554 const std::vector<IntVar*>& secondary_vars,
555 std::function<int(int64_t)> start_empty_path_class,
556 const std::vector<PickupDeliveryPair>& pairs)
557 : PathOperator(vars, secondary_vars, 2, false, false,
558 std::move(start_empty_path_class), nullptr),
559 inactive_pair_(0),
560 pairs_(pairs) {}
561
562template <bool swap_first>
564 int base_index) {
565 // Base node 1 must be after base node 0 if they are both on the same path.
566 if (base_index == 0 || StartNode(base_index) != StartNode(base_index - 1)) {
567 return StartNode(base_index);
568 } else {
569 return BaseNode(base_index - 1);
570 }
571}
572
573template <bool swap_first>
574void PairNodeSwapActiveOperator<swap_first>::OnNodeInitialization() {
575 for (int i = 0; i < pairs_.size(); ++i) {
576 if (IsInactive(pairs_[i].pickup_alternatives[0]) &&
577 IsInactive(pairs_[i].delivery_alternatives[0])) {
578 inactive_pair_ = i;
579 return;
580 }
581 }
582 inactive_pair_ = pairs_.size();
583}
584
585template <bool swap_first>
587 Assignment* delta, Assignment* deltadelta) {
588 while (inactive_pair_ < pairs_.size()) {
589 if (!IsInactive(pairs_[inactive_pair_].pickup_alternatives[0]) ||
590 !IsInactive(pairs_[inactive_pair_].delivery_alternatives[0]) ||
592 ResetPosition();
593 ++inactive_pair_;
594 } else {
595 return true;
596 }
597 }
598 return false;
599}
600
601template <bool swap_first>
603 const int64_t base = BaseNode(0);
604 if (IsPathEnd(base)) {
605 return false;
606 }
607 const int64_t pair_first = pairs_[inactive_pair_].pickup_alternatives[0];
608 const int64_t pair_second = pairs_[inactive_pair_].delivery_alternatives[0];
609 if (swap_first) {
610 return MakeActive(pair_second, BaseNode(1)) &&
611 MakeActive(pair_first, base) &&
612 MakeChainInactive(pair_first, Next(pair_first));
613 } else {
614 return MakeActive(pair_second, BaseNode(1)) &&
615 MakeActive(pair_first, base) &&
616 MakeChainInactive(pair_second, Next(pair_second));
617 }
618}
619
621class PickupAndDeliveryData {
622 public:
623 PickupAndDeliveryData(int num_nodes,
624 absl::Span<const PickupDeliveryPair> pairs);
625 bool IsPickupNode(int64_t node) const {
626 DCHECK_LT(node, is_pickup_node_.size());
627 return is_pickup_node_[node];
629 bool IsDeliveryNode(int64_t node) const {
630 DCHECK_LT(node, is_delivery_node_.size());
631 return is_delivery_node_[node];
633 int GetPairOfNode(int64_t node) const {
634 DCHECK_LT(node, pair_of_node_.size());
635 return pair_of_node_[node];
637
638 private:
639 std::vector<bool> is_pickup_node_;
640 std::vector<bool> is_delivery_node_;
641 std::vector<int> pair_of_node_;
642};
643
655class RelocateSubtrip : public PathOperator {
656 public:
658 const std::vector<IntVar*>& vars,
659 const std::vector<IntVar*>& secondary_vars,
660 std::function<int(int64_t)> start_empty_path_class,
661 std::function<const std::vector<int>&(int, int)> get_neighbors,
662 const std::vector<PickupDeliveryPair>& pairs);
663 RelocateSubtrip(const std::vector<IntVar*>& vars,
664 const std::vector<IntVar*>& secondary_vars,
665 std::function<int(int64_t)> start_empty_path_class,
666 const std::vector<PickupDeliveryPair>& pairs)
667 : RelocateSubtrip(vars, secondary_vars, std::move(start_empty_path_class),
668 nullptr, pairs) {}
669
670 std::string DebugString() const override { return "RelocateSubtrip"; }
671 bool MakeNeighbor() override;
672
673 private:
674 // Relocates the subtrip starting at chain_first_node. It must be a pickup.
675 bool RelocateSubTripFromPickup(int64_t chain_first_node,
676 int64_t insertion_node);
678 bool RelocateSubTripFromDelivery(int64_t chain_last_node,
679 int64_t insertion_node);
680 void SetPath(absl::Span<const int64_t> path, int path_id);
681
682 const PickupAndDeliveryData pd_data_;
683 // Represents the set of pairs that have been opened during a call to
684 // MakeNeighbor(). This vector must be all false before and after calling
685 // RelocateSubTripFromPickup() and RelocateSubTripFromDelivery().
686 std::vector<bool> opened_pairs_set_;
687
688 std::vector<int64_t> rejected_nodes_;
689 std::vector<int64_t> subtrip_nodes_;
690};
691
692class ExchangeSubtrip : public PathOperator {
693 public:
695 const std::vector<IntVar*>& vars,
696 const std::vector<IntVar*>& secondary_vars,
697 std::function<int(int64_t)> start_empty_path_class,
698 std::function<const std::vector<int>&(int, int)> get_neighbors,
699 const std::vector<PickupDeliveryPair>& pairs);
700 ExchangeSubtrip(const std::vector<IntVar*>& vars,
701 const std::vector<IntVar*>& secondary_vars,
702 std::function<int(int64_t)> start_empty_path_class,
703 const std::vector<PickupDeliveryPair>& pairs)
704 : ExchangeSubtrip(vars, secondary_vars, std::move(start_empty_path_class),
705 nullptr, pairs) {}
706
707 std::string DebugString() const override { return "ExchangeSubtrip"; }
708 bool MakeNeighbor() override;
709
710 private:
711 // Try to extract a subtrip from base_node (see below) and check that the move
712 // will be canonical.
713 // Given a pickup/delivery pair, this operator could generate the same move
714 // twice, the first time with base_node == pickup, the second time with
715 // base_node == delivery. This happens only when no nodes in the subtrip
716 // remain in the original path, i.e. when rejects is empty after
717 // chain extraction. In that case, we keep only a canonical move out of the
718 // two possibilities, the move where base_node is a pickup.
719 bool ExtractChainsAndCheckCanonical(int64_t base_node,
720 std::vector<int64_t>* rejects,
721 std::vector<int64_t>* subtrip);
722 // Reads the path from base_node forward, collecting subtrip nodes in
723 // subtrip and non-subtrip nodes in rejects.
724 // Non-subtrip nodes will be unmatched delivery nodes.
725 // base_node must be a pickup, and remaining/extracted_nodes must be empty.
726 // Returns true if such chains could be extracted.
727 bool ExtractChainsFromPickup(int64_t base_node, std::vector<int64_t>* rejects,
728 std::vector<int64_t>* subtrip);
729 // Reads the path from base_node backward, collecting subtrip nodes in
730 // subtrip and non-subtrip nodes in rejects.
731 // Non-subtrip nodes will be unmatched pickup nodes.
732 // base_node must be a delivery, and remaining/extracted_nodes must be empty.
733 // Returns true if such chains could be extracted.
734 bool ExtractChainsFromDelivery(int64_t base_node,
735 std::vector<int64_t>* rejects,
736 std::vector<int64_t>* subtrip);
737 void SetPath(const std::vector<int64_t>& path, int path_id);
738
739 const PickupAndDeliveryData pd_data_;
740 // Represents the set of opened pairs during ExtractChainsFromXXX().
741 std::vector<bool> opened_pairs_set_;
742 // Keep internal structures under hand to avoid reallocation.
743 std::vector<int64_t> rejects0_;
744 std::vector<int64_t> subtrip0_;
745 std::vector<int64_t> rejects1_;
746 std::vector<int64_t> subtrip1_;
747 std::vector<int64_t> path0_;
748 std::vector<int64_t> path1_;
749};
750
751} // namespace operations_research
752
753#endif // OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_NEIGHBORHOODS_H_
std::string DebugString() const override
ExchangeSubtrip(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors, const std::vector< PickupDeliveryPair > &pairs)
GroupPairAndRelocateOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors, const std::vector< PickupDeliveryPair > &pairs)
GroupPairAndRelocateOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
bool MakeNextNeighbor(Assignment *delta, Assignment *deltadelta) override
IndexPairSwapActiveOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
void SetValue(int64_t index, int64_t value)
LightPairRelocateOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors, const std::vector< PickupDeliveryPair > &pairs, std::function< bool(int64_t)> force_lifo=nullptr)
virtual bool MakeNextNeighbor(Assignment *delta, Assignment *deltadelta)=0
int64_t GetBaseNodeRestartPosition(int base_index) override
MakePairActiveOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
Operator which makes pairs of active nodes inactive.
MakePairInactiveOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
MakeRelocateNeighborsOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, RoutingTransitCallback2 arc_evaluator)
MakeRelocateNeighborsOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors, RoutingTransitCallback2 arc_evaluator)
PairExchangeOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
PairExchangeOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors, const std::vector< PickupDeliveryPair > &pairs)
int64_t GetBaseNodeRestartPosition(int base_index) override
bool OnSamePathAsPreviousBase(int64_t base_index) override
PairExchangeRelocateOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
bool MakeNextNeighbor(Assignment *delta, Assignment *deltadelta) override
--— Base operator class for operators manipulating IntVars --—
int64_t GetBaseNodeRestartPosition(int base_index) override
PairNodeSwapActiveOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
Section: Implementations of the template classes declared above.
bool ConsiderAlternatives(int64_t base_index) const override
int64_t GetBaseNodeRestartPosition(int base_index) override
PairRelocateOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, const std::vector< PickupDeliveryPair > &pairs)
bool OnSamePathAsPreviousBase(int64_t base_index) override
A utility class to maintain pickup and delivery information of nodes.
PickupAndDeliveryData(int num_nodes, absl::Span< const PickupDeliveryPair > pairs)
bool MakeOneNeighbor() override
This method should not be overridden. Override MakeNeighbor() instead.
RelocateExpensiveChain(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, int num_arcs_to_consider, std::function< int64_t(int64_t, int64_t, int64_t)> arc_cost_for_path_start)
RelocateSubtrip(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors, const std::vector< PickupDeliveryPair > &pairs)
std::string DebugString() const override
SwapActiveToShortestPathOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::vector< std::vector< int64_t > > alternative_sets, RoutingTransitCallback2 arc_evaluator)
SwapIndexPairOperator(const std::vector< IntVar * > &vars, const std::vector< IntVar * > &path_vars, const std::vector< PickupDeliveryPair > &pairs)
bool MakeNextNeighbor(Assignment *delta, Assignment *deltadelta) override
--— Base operator class for operators manipulating IntVars --—
In SWIG mode, we don't want anything besides these top-level includes.
std::function< int64_t(int64_t, int64_t)> RoutingTransitCallback2
STL namespace.
bool Next()
trees with all degrees equal to
int64_t delta
Definition resource.cc:1709
int nodes