14#ifndef OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_SEARCH_H_
15#define OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_SEARCH_H_
29#include "absl/container/flat_hash_set.h"
43class IntVarFilteredHeuristic;
52 : vehicle_type_container_(&vehicle_type_container) {}
56 int Type(
int vehicle)
const {
return vehicle_type_container_->
Type(vehicle); }
60 void Reset(
const std::function<
bool(
int)>& store_vehicle);
64 void Update(
const std::function<
bool(
int)>& remove_vehicle);
68 const std::set<VehicleClassEntry>& vehicle_classes =
69 sorted_vehicle_classes_per_type_[type];
70 if (vehicle_classes.empty()) {
80 std::vector<int>& vehicles = vehicles_per_vehicle_class_[
vehicle_class];
81 if (vehicles.empty()) {
84 std::set<VehicleClassEntry>& vehicle_classes =
85 sorted_vehicle_classes_per_type_[
Type(vehicle)];
86 const auto& insertion =
90 vehicles.push_back(vehicle);
96 int type,
const std::function<
bool(
int)>& vehicle_is_compatible)
const;
106 int type, std::function<
bool(
int)> vehicle_is_compatible,
107 std::function<
bool(
int)> stop_and_return_vehicle);
110 using VehicleClassEntry =
114 std::vector<std::set<VehicleClassEntry> > sorted_vehicle_classes_per_type_;
115 std::vector<std::vector<int> > vehicles_per_vehicle_class_;
123 bool has_node_precedences,
124 bool has_single_vehicle_node);
145 std::unique_ptr<IntVarFilteredHeuristic> heuristic);
158 const std::unique_ptr<IntVarFilteredHeuristic> heuristic_;
165 const std::vector<IntVar*>& secondary_vars,
179 virtual std::string
DebugString()
const {
return "IntVarFilteredHeuristic"; }
195 std::optional<int64_t>
Evaluate(
bool commit);
201 if (!is_in_delta_[
index]) {
203 delta_indices_.push_back(
index);
204 is_in_delta_[
index] =
true;
220 int Size()
const {
return vars_.size(); }
226 return index + base_vars_size_;
243 std::vector<IntVar*> vars_;
244 const int base_vars_size_;
246 std::vector<int> delta_indices_;
247 std::vector<bool> is_in_delta_;
250 int64_t objective_upper_bound_;
252 int64_t number_of_decisions_;
253 int64_t number_of_rejects_;
261 bool omit_secondary_vars =
true);
265 const std::function<int64_t(int64_t)>& next_accessor);
292 bool InitializeSolution()
override;
295 std::vector<int64_t> start_chain_ends_;
296 std::vector<int64_t> end_chain_starts_;
304 std::function<int64_t(int64_t, int64_t, int64_t)> evaluator,
305 std::function<int64_t(int64_t)> penalty_evaluator,
339 std::vector<std::vector<StartEndValue> >
346 template <
class Queue>
348 std::vector<std::vector<StartEndValue> >* start_end_distances_per_node,
349 Queue* priority_queue);
357 void InsertBetween(int64_t node, int64_t predecessor, int64_t successor,
364 int64_t node_to_insert, int64_t
start, int64_t next_after_start,
365 int vehicle, std::vector<NodeInsertion>* node_insertions);
373 int64_t insert_after,
374 int64_t insert_before,
380 std::function<int64_t(int64_t, int64_t, int64_t)>
evaluator_;
421 std::function<int64_t(int64_t, int64_t, int64_t)> evaluator,
422 std::function<int64_t(int64_t)> penalty_evaluator,
428 return "GlobalCheapestInsertionFilteredHeuristic";
435 typedef absl::flat_hash_set<PairEntry*> PairEntries;
436 typedef absl::flat_hash_set<NodeEntry*> NodeEntries;
444 bool InsertPairsAndNodesByRequirementTopologicalOrder();
453 const std::map<int64_t, std::vector<int>>& pair_indices_by_bucket);
458 bool UseEmptyVehicleTypeCuratorForVehicle(
int vehicle,
459 bool all_vehicles =
true) {
469 bool InsertPairEntryUsingEmptyVehicleTypeCurator(
470 const std::vector<int>& pair_indices, PairEntry*
const pair_entry,
472 std::vector<PairEntries>* pickup_to_entries,
473 std::vector<PairEntries>* delivery_to_entries);
482 bool InsertNodesOnRoutes(
483 const std::map<int64_t, std::vector<int>>& nodes_by_bucket,
484 const absl::flat_hash_set<int>& vehicles);
493 bool InsertNodeEntryUsingEmptyVehicleTypeCurator(
494 const std::vector<int>&
nodes,
bool all_vehicles,
495 NodeEntry*
const node_entry,
497 std::vector<NodeEntries>* position_to_node_entries);
504 bool SequentialInsertNodes(
505 const std::map<int64_t, std::vector<int>>& nodes_by_bucket);
510 void DetectUsedVehicles(std::vector<bool>* is_vehicle_used,
511 std::vector<int>* unused_vehicles,
512 absl::flat_hash_set<int>* used_vehicles);
517 void InsertFarthestNodesAsSeeds();
527 template <
class Queue>
529 std::vector<std::vector<StartEndValue>>* start_end_distances_per_node,
530 Queue* priority_queue, std::vector<bool>* is_vehicle_used);
535 bool InitializePairPositions(
536 const std::vector<int>& pair_indices,
538 std::vector<PairEntries>* pickup_to_entries,
539 std::vector<PairEntries>* delivery_to_entries);
545 void InitializeInsertionEntriesPerformingPair(
546 int64_t pickup, int64_t delivery,
548 std::vector<PairEntries>* pickup_to_entries,
549 std::vector<PairEntries>* delivery_to_entries);
553 bool UpdateAfterPairInsertion(
554 const std::vector<int>& pair_indices,
int vehicle, int64_t pickup,
555 int64_t pickup_position, int64_t delivery, int64_t delivery_position,
557 std::vector<PairEntries>* pickup_to_entries,
558 std::vector<PairEntries>* delivery_to_entries);
561 bool UpdatePairPositions(
const std::vector<int>& pair_indices,
int vehicle,
562 int64_t insert_after,
564 std::vector<PairEntries>* pickup_to_entries,
565 std::vector<PairEntries>* delivery_to_entries) {
566 return UpdatePickupPositions(pair_indices, vehicle, insert_after,
567 priority_queue, pickup_to_entries,
568 delivery_to_entries) &&
569 UpdateDeliveryPositions(pair_indices, vehicle, insert_after,
570 priority_queue, pickup_to_entries,
571 delivery_to_entries);
575 bool UpdatePickupPositions(
const std::vector<int>& pair_indices,
int vehicle,
576 int64_t pickup_insert_after,
578 std::vector<PairEntries>* pickup_to_entries,
579 std::vector<PairEntries>* delivery_to_entries);
582 bool UpdateDeliveryPositions(
583 const std::vector<int>& pair_indices,
int vehicle,
584 int64_t delivery_insert_after,
586 std::vector<PairEntries>* pickup_to_entries,
587 std::vector<PairEntries>* delivery_to_entries);
590 void DeletePairEntry(PairEntry* entry,
592 std::vector<PairEntries>* pickup_to_entries,
593 std::vector<PairEntries>* delivery_to_entries);
598 void AddPairEntry(int64_t pickup, int64_t pickup_insert_after,
599 int64_t delivery, int64_t delivery_insert_after,
602 std::vector<PairEntries>* pickup_entries,
603 std::vector<PairEntries>* delivery_entries)
const;
606 void UpdatePairEntry(
607 PairEntry*
const pair_entry,
612 int64_t GetInsertionValueForPairAtPositions(int64_t pickup,
613 int64_t pickup_insert_after,
615 int64_t delivery_insert_after,
620 bool InitializePositions(
const std::vector<int>&
nodes,
621 const absl::flat_hash_set<int>& vehicles,
623 std::vector<NodeEntries>* position_to_node_entries);
629 void InitializeInsertionEntriesPerformingNode(
630 int64_t node,
const absl::flat_hash_set<int>& vehicles,
632 std::vector<NodeEntries>* position_to_node_entries);
635 bool UpdatePositions(
const std::vector<int>&
nodes,
int vehicle,
636 int64_t insert_after,
bool all_vehicles,
638 std::vector<NodeEntries>* node_entries);
641 void DeleteNodeEntry(NodeEntry* entry,
643 std::vector<NodeEntries>* node_entries);
648 void AddNodeEntry(int64_t node, int64_t insert_after,
int vehicle,
651 std::vector<NodeEntries>* node_entries)
const;
654 void UpdateNodeEntry(
655 NodeEntry*
const node_entry,
660 void ComputeNeighborhoods();
664 bool IsNeighborForCostClass(
int cost_class, int64_t node_index,
665 int64_t neighbor_index)
const;
668 const std::vector<int64_t>& GetNeighborsOfNodeForCostClass(
669 int cost_class, int64_t node_index)
const {
672 : node_index_to_neighbors_by_cost_class_[node_index][cost_class]
673 ->PositionsSetAtLeastOnce();
676 int64_t NumNonStartEndNodes()
const {
680 int64_t NumNeighbors()
const {
683 NumNonStartEndNodes()));
686 void ResetVehicleIndices()
override {
687 node_index_to_vehicle_.assign(node_index_to_vehicle_.size(), -1);
690 void SetVehicleIndex(int64_t node,
int vehicle)
override {
691 DCHECK_LT(node, node_index_to_vehicle_.size());
692 node_index_to_vehicle_[node] = vehicle;
697 bool CheckVehicleIndices()
const;
700 int64_t GetBucketOfNode(
int node)
const {
706 int64_t max_pickup_bucket = 0;
707 for (int64_t pickup : index_pair.first) {
708 max_pickup_bucket =
std::max(max_pickup_bucket, GetBucketOfNode(pickup));
710 int64_t max_delivery_bucket = 0;
711 for (int64_t delivery : index_pair.second) {
712 max_delivery_bucket =
713 std::max(max_delivery_bucket, GetBucketOfNode(delivery));
715 return std::min(max_pickup_bucket, max_delivery_bucket);
723 for (T*
const entry : *priority_queue->
Raw()) {
726 priority_queue->
Clear();
730 GlobalCheapestInsertionParameters gci_params_;
732 std::vector<int> node_index_to_vehicle_;
735 std::vector<std::vector<std::unique_ptr<SparseBitset<int64_t> > > >
736 node_index_to_neighbors_by_cost_class_;
739 std::unique_ptr<VehicleTypeCurator> empty_vehicle_type_curator_;
744 std::vector<int64_t> all_nodes_;
758 std::function<int64_t(int64_t, int64_t, int64_t)> evaluator,
759 bool evaluate_pickup_delivery_costs_independently,
764 return "LocalCheapestInsertionFilteredHeuristic";
768 struct PickupDeliveryInsertion {
769 int64_t insert_pickup_after;
770 int64_t insert_delivery_after;
774 bool operator<(
const PickupDeliveryInsertion& other)
const {
775 return std::tie(
value, insert_pickup_after, insert_delivery_after,
777 std::tie(other.value, other.insert_pickup_after,
778 other.insert_delivery_after, other.vehicle);
785 std::vector<NodeInsertion> ComputeEvaluatorSortedPositions(int64_t node);
790 std::vector<NodeInsertion> ComputeEvaluatorSortedPositionsOnRouteAfter(
791 int64_t node, int64_t
start, int64_t next_after_start,
int vehicle);
796 std::vector<PickupDeliveryInsertion> ComputeEvaluatorSortedPairPositions(
797 int64_t pickup, int64_t delivery);
799 std::vector<std::vector<StartEndValue>> start_end_distances_per_node_;
800 const bool evaluate_pickup_delivery_costs_independently_;
813 class PartialRoutesAndLargeVehicleIndicesFirst {
815 explicit PartialRoutesAndLargeVehicleIndicesFirst(
817 : builder_(builder) {}
818 bool operator()(
int vehicle1,
int vehicle2)
const;
824 template <
typename Iterator>
825 std::vector<int64_t> GetPossibleNextsFromIterator(int64_t node,
827 Iterator
end)
const {
829 std::vector<int64_t> nexts;
830 for (Iterator it =
start; it !=
end; ++it) {
831 const int64_t
next = *it;
833 nexts.push_back(
next);
839 virtual void SortSuccessors(int64_t node,
840 std::vector<int64_t>* successors) = 0;
841 virtual int64_t FindTopSuccessor(int64_t node,
842 const std::vector<int64_t>& successors) = 0;
856 return "EvaluatorCheapestAdditionFilteredHeuristic";
861 void SortSuccessors(int64_t node, std::vector<int64_t>* successors)
override;
862 int64_t FindTopSuccessor(int64_t node,
863 const std::vector<int64_t>& successors)
override;
865 std::function<int64_t(int64_t, int64_t)> evaluator_;
879 return "ComparatorCheapestAdditionFilteredHeuristic";
884 void SortSuccessors(int64_t node, std::vector<int64_t>* successors)
override;
885 int64_t FindTopSuccessor(int64_t node,
886 const std::vector<int64_t>& successors)
override;
922 typedef std::pair< int64_t, int64_t>
Saving;
924 template <
typename S>
933 return saving.second / size_squared_;
937 return (saving.second % size_squared_) /
Size();
941 return (saving.second % size_squared_) %
Size();
969 void AddSymmetricArcsToAdjacencyLists(
970 std::vector<std::vector<int64_t> >* adjacency_lists);
981 bool ComputeSavings();
983 Saving BuildSaving(int64_t saving,
int vehicle_type,
int before_node,
984 int after_node)
const {
985 return std::make_pair(saving, vehicle_type * size_squared_ +
986 before_node *
Size() + after_node);
992 int64_t MaxNumNeighborsPerNode(
int num_vehicle_types)
const;
994 const SavingsParameters savings_params_;
995 int64_t size_squared_;
1008 return "SequentialSavingsFilteredHeuristic";
1016 void BuildRoutesFromSavings()
override;
1017 double ExtraSavingsMemoryMultiplicativeFactor()
const override {
return 1.0; }
1028 return "ParallelSavingsFilteredHeuristic";
1042 void BuildRoutesFromSavings()
override;
1044 double ExtraSavingsMemoryMultiplicativeFactor()
const override {
return 2.0; }
1050 void MergeRoutes(
int first_vehicle,
int second_vehicle, int64_t before_node,
1051 int64_t after_node);
1054 std::vector<int64_t> first_node_on_route_;
1055 std::vector<int64_t> last_node_on_route_;
1059 std::vector<int> vehicle_of_first_or_last_node_;
1070 bool use_minimum_matching);
1074 return "ChristofidesFilteredHeuristic";
1078 const bool use_minimum_matching_;
1086 const std::vector<std::pair<int64_t, int64_t>>& points);
1092 std::vector<int> coordinates_;
1102 bool check_assignment);
#define DCHECK_LT(val1, val2)
#define DCHECK(condition)
const std::vector< T * > * Raw() const
const E & Element(const V *const var) const
An Assignment is a variable -> domains mapping, used to report solutions to the user.
void SetValue(const IntVar *const var, int64_t value)
const IntContainer & IntVarContainer() const
IntVarElement * FastAdd(IntVar *const var)
Adds without checking if variable has been previously added.
Filtered-base decision builder based on the addition heuristic, extending a path from its start node ...
bool BuildSolutionInternal() override
Virtual method to redefine how to build a solution.
~CheapestAdditionFilteredHeuristic() override
CheapestAdditionFilteredHeuristic(RoutingModel *model, LocalSearchFilterManager *filter_manager)
std::vector< std::vector< StartEndValue > > ComputeStartEndDistanceForVehicles(const std::vector< int > &vehicles)
Computes and returns the distance of each uninserted node to every vehicle in "vehicles" as a std::ve...
std::function< int64_t(int64_t, int64_t, int64_t)> evaluator_
void InitializePriorityQueue(std::vector< std::vector< StartEndValue > > *start_end_distances_per_node, Queue *priority_queue)
Initializes the priority_queue by inserting the best entry corresponding to each node,...
int64_t GetInsertionCostForNodeAtPosition(int64_t node_to_insert, int64_t insert_after, int64_t insert_before, int vehicle) const
Returns the cost of inserting 'node_to_insert' between 'insert_after' and 'insert_before' on the 'veh...
~CheapestInsertionFilteredHeuristic() override
int64_t GetUnperformedValue(int64_t node_to_insert) const
Returns the cost of unperforming node 'node_to_insert'.
std::function< int64_t(int64_t)> penalty_evaluator_
CheapestInsertionFilteredHeuristic(RoutingModel *model, std::function< int64_t(int64_t, int64_t, int64_t)> evaluator, std::function< int64_t(int64_t)> penalty_evaluator, LocalSearchFilterManager *filter_manager)
Takes ownership of evaluator.
void InsertBetween(int64_t node, int64_t predecessor, int64_t successor, int vehicle=-1)
Inserts 'node' just after 'predecessor', and just before 'successor' on the route of 'vehicle',...
void AppendInsertionPositionsAfter(int64_t node_to_insert, int64_t start, int64_t next_after_start, int vehicle, std::vector< NodeInsertion > *node_insertions)
Helper method to the ComputeEvaluatorSortedPositions* methods.
std::pair< StartEndValue, int > Seed
Christofides addition heuristic.
bool BuildSolutionInternal() override
Virtual method to redefine how to build a solution.
~ChristofidesFilteredHeuristic() override
std::string DebugString() const override
ChristofidesFilteredHeuristic(RoutingModel *model, LocalSearchFilterManager *filter_manager, bool use_minimum_matching)
A CheapestAdditionFilteredHeuristic where the notion of 'cheapest arc' comes from an arc comparator.
ComparatorCheapestAdditionFilteredHeuristic(RoutingModel *model, Solver::VariableValueComparator comparator, LocalSearchFilterManager *filter_manager)
Takes ownership of evaluator.
~ComparatorCheapestAdditionFilteredHeuristic() override
std::string DebugString() const override
A DecisionBuilder is responsible for creating the search tree.
A Decision represents a choice point in the search tree.
A CheapestAdditionFilteredHeuristic where the notion of 'cheapest arc' comes from an arc evaluator.
EvaluatorCheapestAdditionFilteredHeuristic(RoutingModel *model, std::function< int64_t(int64_t, int64_t)> evaluator, LocalSearchFilterManager *filter_manager)
Takes ownership of evaluator.
~EvaluatorCheapestAdditionFilteredHeuristic() override
std::string DebugString() const override
Filter-based decision builder which builds a solution by inserting nodes at their cheapest position o...
bool BuildSolutionInternal() override
Virtual method to redefine how to build a solution.
GlobalCheapestInsertionFilteredHeuristic(RoutingModel *model, std::function< int64_t(int64_t, int64_t, int64_t)> evaluator, std::function< int64_t(int64_t)> penalty_evaluator, LocalSearchFilterManager *filter_manager, GlobalCheapestInsertionParameters parameters)
Takes ownership of evaluators.
~GlobalCheapestInsertionFilteredHeuristic() override
std::string DebugString() const override
Decision builder building a solution using heuristics with local search filters to evaluate its feasi...
~IntVarFilteredDecisionBuilder() override
Decision * Next(Solver *solver) override
This is the main method of the decision builder class.
int64_t number_of_decisions() const
Returns statistics from its underlying heuristic.
IntVarFilteredDecisionBuilder(std::unique_ptr< IntVarFilteredHeuristic > heuristic)
std::string DebugString() const override
int64_t number_of_rejects() const
Generic filter-based heuristic applied to IntVars.
void SetValue(int64_t index, int64_t value)
Modifies the current solution by setting the variable of index 'index' to value 'value'.
virtual bool BuildSolutionInternal()=0
Virtual method to redefine how to build a solution.
int64_t SecondaryVarIndex(int64_t index) const
Returns the index of a secondary var.
int Size() const
Returns the number of variables the decision builder is trying to instantiate.
bool Contains(int64_t index) const
Returns true if the variable of index 'index' is in the current solution.
virtual ~IntVarFilteredHeuristic()
virtual bool StopSearch()
Returns true if the search must be stopped.
Assignment *const assignment_
void ResetSolution()
Resets the data members for a new solution.
void SynchronizeFilters()
Synchronizes filters with an assignment (the current solution).
virtual std::string DebugString() const
bool HasSecondaryVars() const
Returns true if there are secondary variables.
virtual bool InitializeSolution()
Virtual method to initialize the solution.
int64_t number_of_decisions() const
Returns statistics on search, number of decisions sent to filters, number of decisions rejected by fi...
IntVar * Var(int64_t index) const
Returns the variable of index 'index'.
int64_t Value(int64_t index) const
Returns the value of the variable of index 'index' in the last committed solution.
bool IsSecondaryVar(int64_t index) const
Returns true if 'index' is a secondary variable index.
std::optional< int64_t > Evaluate(bool commit)
Evaluates the modifications to the current solution.
Assignment *const BuildSolution()
Builds a solution.
IntVarFilteredHeuristic(Solver *solver, const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, LocalSearchFilterManager *filter_manager)
int64_t number_of_rejects() const
The class IntVar is a subset of IntExpr.
virtual uint64_t Size() const =0
This method returns the number of values in the domain of the variable.
Filter-base decision builder which builds a solution by inserting nodes at their cheapest position.
LocalCheapestInsertionFilteredHeuristic(RoutingModel *model, std::function< int64_t(int64_t, int64_t, int64_t)> evaluator, bool evaluate_pickup_delivery_costs_independently, LocalSearchFilterManager *filter_manager)
Takes ownership of evaluator.
bool BuildSolutionInternal() override
Virtual method to redefine how to build a solution.
~LocalCheapestInsertionFilteredHeuristic() override
std::string DebugString() const override
Filter manager: when a move is made, filters are executed to decide whether the solution is feasible ...
static int64_t FastInt64Round(double x)
ParallelSavingsFilteredHeuristic(RoutingModel *model, SavingsParameters parameters, LocalSearchFilterManager *filter_manager)
~ParallelSavingsFilteredHeuristic() override
std::string DebugString() const override
Filter-based heuristic dedicated to routing.
~RoutingFilteredHeuristic() override
int GetStartChainEnd(int vehicle) const
Returns the end of the start chain of vehicle,.
virtual void SetVehicleIndex(int64_t node, int vehicle)
int GetEndChainStart(int vehicle) const
Returns the start of the end chain of vehicle,.
RoutingModel * model() const
RoutingFilteredHeuristic(RoutingModel *model, LocalSearchFilterManager *filter_manager, bool omit_secondary_vars=true)
void MakeDisjunctionNodesUnperformed(int64_t node)
Make nodes in the same disjunction as 'node' unperformed.
bool StopSearch() override
Returns true if the search must be stopped.
void MakeUnassignedNodesUnperformed()
Make all unassigned nodes unperformed.
virtual void ResetVehicleIndices()
void MakePartiallyPerformedPairsUnperformed()
Make all partially performed pickup and delivery pairs unperformed.
bool VehicleIsEmpty(int vehicle) const
const Assignment * BuildSolutionFromRoutes(const std::function< int64_t(int64_t)> &next_accessor)
Builds a solution starting from the routes formed by the next accessor.
RoutingIndexPair IndexPair
bool CheckLimit()
Returns true if the search limit has been crossed.
IntVar * VehicleVar(int64_t index) const
Returns the vehicle variable of the node corresponding to index.
int64_t Size() const
Returns the number of next variables in the model.
int vehicles() const
Returns the number of vehicle routes in the model.
int64_t End(int vehicle) const
Returns the variable index of the ending node of a vehicle route.
Filter-based decision builder which builds a solution by using Clarke & Wright's Savings heuristic.
SavingsFilteredHeuristic(RoutingModel *model, SavingsParameters parameters, LocalSearchFilterManager *filter_manager)
int64_t GetVehicleTypeFromSaving(const Saving &saving) const
Returns the cost class from a saving.
std::unique_ptr< VehicleTypeCurator > vehicle_type_curator_
bool BuildSolutionInternal() override
Virtual method to redefine how to build a solution.
int64_t GetAfterNodeFromSaving(const Saving &saving) const
Returns the "after node" from a saving.
int64_t GetSavingValue(const Saving &saving) const
Returns the saving value from a saving.
std::pair< int64_t, int64_t > Saving
std::unique_ptr< SavingsContainer< Saving > > savings_container_
~SavingsFilteredHeuristic() override
virtual double ExtraSavingsMemoryMultiplicativeFactor() const =0
friend class SavingsFilteredHeuristicTestPeer
int64_t GetBeforeNodeFromSaving(const Saving &saving) const
Returns the "before node" from a saving.
int StartNewRouteWithBestVehicleOfType(int type, int64_t before_node, int64_t after_node)
Finds the best available vehicle of type "type" to start a new route to serve the arc before_node-->a...
virtual void BuildRoutesFromSavings()=0
~SequentialSavingsFilteredHeuristic() override
SequentialSavingsFilteredHeuristic(RoutingModel *model, SavingsParameters parameters, LocalSearchFilterManager *filter_manager)
std::string DebugString() const override
std::function< bool(int64_t, int64_t, int64_t)> VariableValueComparator
Class to arrange indices by their distance and their angle from the depot.
SweepArranger(const std::vector< std::pair< int64_t, int64_t > > &points)
void ArrangeIndices(std::vector< int64_t > *indices)
void SetSectors(int sectors)
Helper class that manages vehicles.
void Update(const std::function< bool(int)> &remove_vehicle)
Goes through all the currently stored vehicles and removes vehicles for which remove_vehicle() return...
bool HasCompatibleVehicleOfType(int type, const std::function< bool(int)> &vehicle_is_compatible) const
Searches a compatible vehicle of the given type; returns false if none was found.
std::pair< int, int > GetCompatibleVehicleOfType(int type, std::function< bool(int)> vehicle_is_compatible, std::function< bool(int)> stop_and_return_vehicle)
Searches for the best compatible vehicle of the given type, i.e.
VehicleTypeCurator(const RoutingModel::VehicleTypeContainer &vehicle_type_container)
void Reset(const std::function< bool(int)> &store_vehicle)
Resets the vehicles stored, storing only vehicles from the vehicle_type_container_ for which store_ve...
int Type(int vehicle) const
void ReinjectVehicleOfClass(int vehicle, int vehicle_class, int64_t fixed_cost)
int GetLowestFixedCostVehicleOfType(int type) const
std::function< int64_t(const Model &)> Value(IntegerVariable v)
Collection of objects used to extend the Constraint Solver library.
DecisionBuilder * MakeAllUnperformed(RoutingModel *model)
FirstSolutionStrategy::Value AutomaticFirstSolutionStrategy(bool has_pickup_deliveries, bool has_node_precedences, bool has_single_vehicle_node)
Returns the best value for the automatic first solution strategy, based on the given model parameters...
DecisionBuilder * MakeSweepDecisionBuilder(RoutingModel *model, bool check_assignment)
std::optional< int64_t > end
bool operator<(const NodeInsertion &other) const
bool operator<(const StartEndValue &other) const
int64_t num_allowed_vehicles
double neighbors_ratio
If neighbors_ratio < 1 then for each node only this ratio of its neighbors leading to the smallest ar...
bool is_sequential
Whether the routes are constructed sequentially or in parallel.
double farthest_seeds_ratio
The ratio of routes on which to insert farthest nodes as seeds before starting the cheapest insertion...
bool use_neighbors_ratio_for_initialization
If true, only closest neighbors (see neighbors_ratio and min_neighbors) are considered as insertion p...
bool add_unperformed_entries
If true, entries are created for making the nodes/pairs unperformed, and when the cost of making a no...
Struct used to sort and store vehicles by their type.
int Type(int vehicle) const
double neighbors_ratio
If neighbors_ratio < 1 then for each node only this ratio of its neighbors leading to the smallest ar...
double arc_coefficient
arc_coefficient is a strictly positive parameter indicating the coefficient of the arc being consider...
double max_memory_usage_bytes
The number of neighbors considered for each node is also adapted so that the stored Savings don't use...
bool add_reverse_arcs
If add_reverse_arcs is true, the neighborhood relationships are considered symmetrically.