Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: routing_index_manager
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.
[[["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."],[[["The `RoutingIndexManager` simplifies variable index usage in the routing solver by allowing the use of `NodeIndex` instead."],["It manages the conversion between `NodeIndex` and variable indices, which can be complex due to nodes appearing multiple times in the model."],["Users can obtain the variable index corresponding to a `NodeIndex` using the `NodeToIndex` method."],["The mapping between node indices and variable indices is not fixed and can change, but all indices will fall within the range of 0 to n-1."],["`n` represents the total number of variables, calculated as (number of vehicles * 2) + (number of non-start/end nodes)."]]],["The `RoutingIndexManager` class handles the conversion between `NodeIndex` and variable indices within the routing solver. It simplifies variable index management by allowing users to utilize `NodeIndex` instead of directly managing variable indices. Users provide the number of nodes, vehicles, and start/end nodes to the `RoutingIndexManager` constructor. Subsequently, the `NodeToIndex` method is used when the model requires a variable index. The mapping between node and variable indices is internal and may change, but the guarantee is that variable indices are between 0 and n-1, where n is the number of vehicles\\*2 + number of non-start or end nodes.\n"]]