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 = ...;
RoutingModel
model(manager);
RoutingIndexManager(int num_nodes, int num_vehicles, NodeIndex depot)
Creates a NodeIndex to variable index mapping for a problem containing 'num_nodes',...
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.
Definition at line 48 of file routing_index_manager.h.
|
| RoutingIndexManager (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. More...
|
|
| RoutingIndexManager (int num_nodes, int num_vehicles, const std::vector< NodeIndex > &starts, const std::vector< NodeIndex > &ends) |
|
| RoutingIndexManager (int num_nodes, int num_vehicles, const std::vector< std::pair< NodeIndex, NodeIndex > > &starts_ends) |
|
| ~RoutingIndexManager () |
|
int | num_nodes () const |
|
int | num_vehicles () const |
|
int | num_indices () const |
|
int64 | GetStartIndex (int vehicle) const |
|
int64 | GetEndIndex (int vehicle) const |
|
int64 | NodeToIndex (NodeIndex node) const |
|
std::vector< int64 > | NodesToIndices (const std::vector< NodeIndex > &nodes) const |
|
NodeIndex | IndexToNode (int64 index) const |
|
std::vector< NodeIndex > | IndicesToNodes (const std::vector< int64 > &indices) const |
|
int | num_unique_depots () const |
| complete. More...
|
|
std::vector< NodeIndex > | GetIndexToNodeMap () const |
|
absl::StrongVector< NodeIndex, int64 > | GetNodeToIndexMap () const |
|