C++ Reference: class RoutingIndexManager
Note: This documentation is automatically generated.
Manager for any NodeIndex <-> variable index conversion. The routing solver uses variable indices internally and through its API. These variable indices are tricky to manage directly because one Node can correspond to a multitude of variables, depending on the number of times they appear in the model, and if they're used as start and/or end points. This class aims to simplify variable index usage, allowing users to use NodeIndex instead.Usage:
auto starts_ends = ...; /// These are NodeIndex. RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles. RoutingModel model(manager);
Then, use 'manager.NodeToIndex(node)' whenever model requires a variable index.
Note: the mapping between node indices and variables indices is subject to change so no assumption should be made on it. The only guarantee is that indices range between 0 and n-1, where n = number of vehicles * 2 (for start and end nodes) + number of non-start or end nodes.
Method | |
---|---|
GetEndIndex | Return type: Arguments: |
GetIndexToNodeMap | Return type: |
GetNodeToIndexMap | Return type: |
GetStartIndex | Return type: Arguments: Returns start and end indices of the given vehicle. |
IndexToNode | Return type: Arguments: Returns the node corresponding to an index. A node may appear more than once if it is used as the start or the end node of multiple vehicles. |
IndicesToNodes | Return type: Arguments: Same as IndexToNode but for a given vector of indices. |
NodesToIndices | Return type: Arguments: Same as NodeToIndex but for a given vector of nodes. |
NodeToIndex | Return type: Arguments: Returns the index of a node. A node can correspond to multiple indices if it's a start or end node. As of 03/2020, kUnassigned will be returned for all end nodes. If a node appears more than once as a start node, the index of the first node in the list of start nodes is returned. |
num_indices | Return type: Returns the number of indices mapped to nodes. |
num_nodes | Return type: Returns the number of nodes in the manager. |
num_unique_depots | Return type: TODO(user) Add unit tests for NodesToIndices and IndicesToNodes. TODO(user): Remove when removal of NodeIndex from RoutingModel is complete. |
num_vehicles | Return type: Returns the number of vehicles in the manager. |
RoutingIndexManager | Arguments: Creates a NodeIndex to variable index mapping for a problem containing 'num_nodes', 'num_vehicles' and the given starts and ends for each vehicle. If used, any start/end arrays have to have exactly 'num_vehicles' elements. |
RoutingIndexManager | Arguments: |
RoutingIndexManager | Arguments: |
~RoutingIndexManager |