C++ Reference
C++ Reference: Routing
Detailed Description
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:
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.
Public Types | |
typedef RoutingNodeIndex | NodeIndex |
Public Member Functions | |
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 |
Static Public Attributes | |
static const int64 | kUnassigned |
Member Typedef Documentation
◆ NodeIndex
typedef RoutingNodeIndex NodeIndex |
Definition at line 50 of file routing_index_manager.h.
Constructor & Destructor Documentation
◆ RoutingIndexManager() [1/3]
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.
If used, any start/end arrays have to have exactly 'num_vehicles' elements.
◆ RoutingIndexManager() [2/3]
RoutingIndexManager | ( | int | num_nodes, |
int | num_vehicles, | ||
const std::vector< NodeIndex > & | starts, | ||
const std::vector< NodeIndex > & | ends | ||
) |
◆ RoutingIndexManager() [3/3]
RoutingIndexManager | ( | int | num_nodes, |
int | num_vehicles, | ||
const std::vector< std::pair< NodeIndex, NodeIndex > > & | starts_ends | ||
) |
◆ ~RoutingIndexManager()
|
inline |
Definition at line 64 of file routing_index_manager.h.
Member Function Documentation
◆ GetEndIndex()
|
inline |
Definition at line 74 of file routing_index_manager.h.
◆ GetIndexToNodeMap()
|
inline |
Definition at line 100 of file routing_index_manager.h.
◆ GetNodeToIndexMap()
|
inline |
Definition at line 101 of file routing_index_manager.h.
◆ GetStartIndex()
|
inline |
Definition at line 73 of file routing_index_manager.h.
◆ IndexToNode()
|
inline |
Definition at line 88 of file routing_index_manager.h.
◆ IndicesToNodes()
std::vector< NodeIndex > IndicesToNodes | ( | const std::vector< int64 > & | indices | ) | const |
◆ NodesToIndices()
std::vector< int64 > NodesToIndices | ( | const std::vector< NodeIndex > & | nodes | ) | const |
◆ NodeToIndex()
|
inline |
Definition at line 79 of file routing_index_manager.h.
◆ num_indices()
|
inline |
Definition at line 71 of file routing_index_manager.h.
◆ num_nodes()
|
inline |
Definition at line 67 of file routing_index_manager.h.
◆ num_unique_depots()
|
inline |
complete.
Definition at line 99 of file routing_index_manager.h.
◆ num_vehicles()
|
inline |
Definition at line 69 of file routing_index_manager.h.
Member Data Documentation
◆ kUnassigned
|
static |
Definition at line 51 of file routing_index_manager.h.
The documentation for this class was generated from the following file: