Stay organized with collections
Save and categorize content based on your preferences.
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.
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.
Arguments: int num_nodes, int num_vehicles, NodeIndex depot
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe RoutingIndexManager class simplifies the use of variable indices in the routing solver by allowing users to work with NodeIndex instead.\u003c/p\u003e\n"],["\u003cp\u003eIt manages the conversion between NodeIndex and the internal variable indices used by the routing solver.\u003c/p\u003e\n"],["\u003cp\u003eUsers can create a RoutingIndexManager instance by specifying the number of nodes, vehicles, and start/end locations.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eNodeToIndex\u003c/code\u003e method provides the variable index corresponding to a given NodeIndex, while \u003ccode\u003eIndexToNode\u003c/code\u003e performs the reverse operation.\u003c/p\u003e\n"],["\u003cp\u003eThe mapping between NodeIndex and variable indices is dynamic, but guarantees indices within a specific range.\u003c/p\u003e\n"]]],["The `RoutingIndexManager` class manages the conversion between `NodeIndex` and variable indices used in routing solvers. It simplifies index usage, as a node can map to multiple variable indices. Key actions include creating a manager with node, vehicle, and start/end information. Users then use `NodeToIndex(node)` to get the variable index. The class provides methods to convert between nodes and indices (`NodeToIndex`, `IndexToNode`, `NodesToIndices`, `IndicesToNodes`) and to get information about the problem setup (`num_nodes`, `num_vehicles`, etc.).\n"],null,[]]