Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <routing_neighborhoods.h>
Public Member Functions | |
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) | |
~MakePairActiveOperator () override | |
bool | MakeNeighbor () override |
std::string | DebugString () const override |
Public Member Functions inherited from operations_research::PathOperator | |
PathOperator (const std::vector< IntVar * > &next_vars, const std::vector< IntVar * > &path_vars, IterationParameters iteration_parameters) | |
Builds an instance of PathOperator from next and path variables. | |
PathOperator (const std::vector< IntVar * > &next_vars, const std::vector< IntVar * > &path_vars, int number_of_base_nodes, bool skip_locally_optimal_paths, bool accept_path_end_base, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors) | |
~PathOperator () override | |
void | Reset () override |
bool | SkipUnchanged (int index) const override |
int64_t | Next (int64_t node) const |
Returns the node after node in the current delta. | |
int64_t | Prev (int64_t node) const |
Returns the node before node in the current delta. | |
int64_t | Path (int64_t node) const |
int | number_of_nexts () const |
Number of next variables. | |
Public Member Functions inherited from operations_research::IntVarLocalSearchOperator | |
IntVarLocalSearchOperator (const std::vector< IntVar * > &vars, bool keep_inverse_values=false) | |
~IntVarLocalSearchOperator () override | |
bool | HoldsDelta () const override |
void | Start (const Assignment *assignment) override |
virtual bool | IsIncremental () const |
int | Size () const |
int64_t | Value (int64_t index) const |
IntVar * | Var (int64_t index) const |
Returns the variable of given index. | |
int64_t | OldValue (int64_t index) const |
int64_t | PrevValue (int64_t index) const |
void | SetValue (int64_t index, int64_t value) |
bool | Activated (int64_t index) const |
void | Activate (int64_t index) |
void | Deactivate (int64_t index) |
bool | ApplyChanges (Assignment *delta, Assignment *deltadelta) const |
void | RevertChanges (bool change_was_incremental) |
void | AddVars (const std::vector< IntVar * > &vars) |
bool | MakeNextNeighbor (Assignment *delta, Assignment *deltadelta) override |
--— Base operator class for operators manipulating IntVars --— | |
Public Member Functions inherited from operations_research::LocalSearchOperator | |
LocalSearchOperator () | |
~LocalSearchOperator () override | |
virtual const LocalSearchOperator * | Self () const |
virtual bool | HasFragments () const |
Public Member Functions inherited from operations_research::BaseObject | |
BaseObject () | |
BaseObject (const BaseObject &)=delete | |
This type is neither copyable nor movable. | |
BaseObject & | operator= (const BaseObject &)=delete |
virtual | ~BaseObject () |
Protected Member Functions | |
bool | MakeOneNeighbor () override |
bool | OnSamePathAsPreviousBase (int64_t) override |
int64_t | GetBaseNodeRestartPosition (int base_index) override |
bool | RestartAtPathStartOnSynchronize () override |
Protected Member Functions inherited from operations_research::PathOperator | |
bool | MakeOneNeighbor () override |
This method should not be overridden. Override MakeNeighbor() instead. | |
int64_t | BaseNode (int i) const |
Returns the ith base node of the operator. | |
int | BaseAlternative (int i) const |
Returns the alternative for the ith base node. | |
int64_t | BaseAlternativeNode (int i) const |
Returns the alternative node for the ith base node. | |
int | BaseSiblingAlternative (int i) const |
Returns the alternative for the sibling of the ith base node. | |
int64_t | BaseSiblingAlternativeNode (int i) const |
Returns the alternative node for the sibling of the ith base node. | |
int64_t | StartNode (int i) const |
Returns the start node of the ith base node. | |
int64_t | EndNode (int i) const |
Returns the end node of the ith base node. | |
const std::vector< int64_t > & | path_starts () const |
Returns the vector of path start nodes. | |
int | PathClass (int i) const |
Returns the class of the path of the ith base node. | |
int | PathClassFromStartNode (int64_t start_node) const |
virtual void | SetNextBaseToIncrement (int64_t base_index) |
virtual bool | ConsiderAlternatives (int64_t base_index) const |
int64_t | OldNext (int64_t node) const |
int64_t | PrevNext (int64_t node) const |
int64_t | OldPrev (int64_t node) const |
int64_t | OldPath (int64_t node) const |
int | CurrentNodePathStart (int64_t node) const |
int | CurrentNodePathEnd (int64_t node) const |
bool | MoveChain (int64_t before_chain, int64_t chain_end, int64_t destination) |
bool | ReverseChain (int64_t before_chain, int64_t after_chain, int64_t *chain_last) |
bool | MakeActive (int64_t node, int64_t destination) |
Insert the inactive node after destination. | |
bool | MakeChainInactive (int64_t before_chain, int64_t chain_end) |
bool | SwapActiveAndInactive (int64_t active, int64_t inactive) |
Replaces active by inactive in the current path, making active inactive. | |
void | SetNext (int64_t from, int64_t to, int64_t path) |
Sets 'to' to be the node after 'from' on the given path. | |
bool | IsPathEnd (int64_t node) const |
bool | IsPathStart (int64_t node) const |
Returns true if node is the first node on the path. | |
bool | IsInactive (int64_t node) const |
Returns true if node is inactive. | |
virtual bool | InitPosition () const |
void | ResetPosition () |
int | AddAlternativeSet (const std::vector< int64_t > &alternative_set) |
template<typename PairType > | |
void | AddPairAlternativeSets (const std::vector< PairType > &pair_alternative_sets) |
int64_t | GetActiveInAlternativeSet (int alternative_index) const |
Returns the active node in the given alternative set. | |
int64_t | GetActiveAlternativeNode (int node) const |
Returns the active node in the alternative set of the given node. | |
int | GetSiblingAlternativeIndex (int node) const |
Returns the index of the alternative set of the sibling of node. | |
int64_t | GetActiveAlternativeSibling (int node) const |
bool | CheckChainValidity (int64_t before_chain, int64_t chain_end, int64_t exclude) const |
bool | HasNeighbors () const |
int | GetNeighborForBaseNode (int64_t base_index) const |
Protected Member Functions inherited from operations_research::IntVarLocalSearchOperator | |
int64_t | InverseValue (int64_t index) const |
int64_t | OldInverseValue (int64_t index) const |
void | AddToAssignment (IntVar *var, int64_t value, bool active, std::vector< int > *assignment_indices, int64_t index, Assignment *assignment) const |
Additional Inherited Members | |
Protected Attributes inherited from operations_research::PathOperator | |
const int | number_of_nexts_ |
const bool | ignore_path_vars_ |
Pair-based neighborhood operators, designed to move nodes by pairs (pairs are static and given). These neighborhoods are very useful for Pickup and Delivery problems where pickup and delivery nodes must remain on the same route.
(user): Add option to prune neighbords where the order of node pairs is violated (ie precedence between pickup and delivery nodes).
(user): Move this to local_search.cc if it's generic enough.
(user): Detect pairs automatically by parsing the constraint model; we could then get rid of the pair API in the RoutingModel class.
Operator which inserts pairs of inactive nodes into a path. Possible neighbors for the path 1 -> 2 -> 3 with pair (A, B) inactive (where 1 and 3 are first and last nodes of the path) are: 1 -> [A] -> [B] -> 2 -> 3 1 -> [B] -> 2 -> [A] -> 3 1 -> [A] -> 2 -> [B] -> 3 1 -> 2 -> [A] -> [B] -> 3
Definition at line 163 of file routing_neighborhoods.h.
operations_research::MakePairActiveOperator::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 ) |
Definition at line 240 of file routing_neighborhoods.cc.
|
inlineoverride |
Definition at line 169 of file routing_neighborhoods.h.
|
inlineoverridevirtual |
Reimplemented from operations_research::BaseObject.
Definition at line 171 of file routing_neighborhoods.h.
|
overrideprotectedvirtual |
Returns the index of the node to which the base node of index base_index must be set to when it reaches the end of a path. By default, it is set to the start of the current path. When this method is called, one can only assume that base nodes with indices < base_index have their final position.
Base node 1 must be after base node 0 if they are both on the same path.
Reimplemented from operations_research::PathOperator.
Definition at line 287 of file routing_neighborhoods.cc.
|
overridevirtual |
Inserting the second node of the pair before the first one which ensures that the only solutions where both nodes are next to each other have the first node before the second (the move is not symmetric and doing it this way ensures that a potential precedence constraint between the nodes of the pair is not violated).
Implements operations_research::PathOperator.
Definition at line 272 of file routing_neighborhoods.cc.
|
overrideprotectedvirtual |
Creates a new neighbor. It returns false when the neighborhood is completely explored.
Reimplemented from operations_research::IntVarLocalSearchOperator.
Definition at line 252 of file routing_neighborhoods.cc.
|
inlineoverrideprotectedvirtual |
Returns true if a base node has to be on the same path as the "previous" base node (base node of index base_index - 1). Useful to limit neighborhood exploration to nodes on the same path.
Both base nodes have to be on the same path since they represent the nodes after which unactive node pairs will be moved.
Reimplemented from operations_research::PathOperator.
Definition at line 175 of file routing_neighborhoods.h.
|
inlineoverrideprotectedvirtual |
Required to ensure that after synchronization the operator is in a state compatible with GetBaseNodeRestartPosition.
Reimplemented from operations_research::PathOperator.
Definition at line 185 of file routing_neighborhoods.h.