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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[null,null,["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eRoutingIndexManager\u003c/code\u003e simplifies variable index usage in the routing solver by allowing the use of \u003ccode\u003eNodeIndex\u003c/code\u003e instead.\u003c/p\u003e\n"],["\u003cp\u003eIt manages the conversion between \u003ccode\u003eNodeIndex\u003c/code\u003e and variable indices, which can be complex due to nodes appearing multiple times in the model.\u003c/p\u003e\n"],["\u003cp\u003eUsers can obtain the variable index corresponding to a \u003ccode\u003eNodeIndex\u003c/code\u003e using the \u003ccode\u003eNodeToIndex\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003en\u003c/code\u003e represents the total number of variables, calculated as (number of vehicles * 2) + (number of non-start/end nodes).\u003c/p\u003e\n"]]],["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"],null,["# routing_index_manager\n\nC++ Reference: routing_index_manager\n====================================\n\n\nNote: This documentation is automatically generated.\n\n\u003cbr /\u003e\n\nManager for any NodeIndex \\\u003c-\\\u003e 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. \n\nUsage: \n\n```\n auto starts_ends = ...; /// These are NodeIndex.\n RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles.\n RoutingModel model(manager);\n```\n\n\u003cbr /\u003e\n\nThen, use 'manager.NodeToIndex(node)' whenever model requires a variable index. \n\nNote: 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. \n\n| Classes ------- ||\n|------------------------------------------------------------------------------------------------------------|---|\n| [RoutingIndexManager](/optimization/reference/constraint_solver/routing_index_manager/RoutingIndexManager) |"]]