![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
Manager for any NodeIndex <-> variable index conversion. More...
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.
Definition at line 57 of file routing_index_manager.h.
#include <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. If used, any start/end arrays have to have exactly 'num_vehicles' elements. | |
| RoutingIndexManager (int num_nodes, int num_vehicles, const std::vector< NodeIndex > &starts, const std::vector< NodeIndex > &ends) | |
| Creates a NodeIndex to variable index mapping. | |
| RoutingIndexManager (int num_nodes, int num_vehicles, const std::vector< std::pair< NodeIndex, NodeIndex > > &starts_ends) | |
| Creates a NodeIndex to variable index mapping. | |
| int | num_nodes () const |
| int | num_vehicles () const |
| int | num_indices () const |
| int64_t | GetStartIndex (int vehicle) const |
| int64_t | GetEndIndex (int vehicle) const |
| int64_t | NodeToIndex (NodeIndex node) const |
| std::vector< int64_t > | NodesToIndices (const std::vector< NodeIndex > &nodes) const |
| NodeIndex | IndexToNode (int64_t index) const |
| std::vector< NodeIndex > | IndicesToNodes (absl::Span< const int64_t > indices) const |
| int | num_unique_depots () const |
| std::vector< NodeIndex > | GetIndexToNodeMap () const |
Static Public Attributes | |
| static const int64_t | kUnassigned = -1 |
| typedef RoutingNodeIndex operations_research::RoutingIndexManager::NodeIndex |
Definition at line 59 of file routing_index_manager.h.
| operations_research::RoutingIndexManager::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.
| num_nodes | Number of nodes in the problem. |
| num_vehicles | Number of vehicles in the problem. |
| depot | start and end NodeIndex for all vehicles. |
Definition at line 29 of file routing_index_manager.cc.
| operations_research::RoutingIndexManager::RoutingIndexManager | ( | int | num_nodes, |
| int | num_vehicles, | ||
| const std::vector< NodeIndex > & | starts, | ||
| const std::vector< NodeIndex > & | ends ) |
Creates a NodeIndex to variable index mapping.
| num_nodes | Number of nodes in the problem. |
| num_vehicles | Number of vehicles in the problem. |
| starts | Array containing the start NodeIndex for each vehicle. |
| ends | Array containing the end NodeIndex for each vehicle. |
Definition at line 35 of file routing_index_manager.cc.
| operations_research::RoutingIndexManager::RoutingIndexManager | ( | int | num_nodes, |
| int | num_vehicles, | ||
| const std::vector< std::pair< NodeIndex, NodeIndex > > & | starts_ends ) |
Creates a NodeIndex to variable index mapping.
| num_nodes | Number of nodes in the problem. |
| num_vehicles | Number of vehicles in the problem. |
| starts_ends | Array containing a pair [start,end] NodeIndex for each vehicle. |
Definition at line 47 of file routing_index_manager.cc.
|
inline |
Definition at line 102 of file routing_index_manager.h.
|
inline |
Definition at line 129 of file routing_index_manager.h.
|
inline |
Definition at line 99 of file routing_index_manager.h.
|
inline |
Definition at line 117 of file routing_index_manager.h.
| std::vector< RoutingIndexManager::NodeIndex > operations_research::RoutingIndexManager::IndicesToNodes | ( | absl::Span< const int64_t > | indices | ) | const |
Definition at line 138 of file routing_index_manager.cc.
| std::vector< int64_t > operations_research::RoutingIndexManager::NodesToIndices | ( | const std::vector< NodeIndex > & | nodes | ) | const |
Definition at line 126 of file routing_index_manager.cc.
|
inline |
Definition at line 107 of file routing_index_manager.h.
|
inline |
Definition at line 97 of file routing_index_manager.h.
|
inline |
Definition at line 93 of file routing_index_manager.h.
|
inline |
Definition at line 128 of file routing_index_manager.h.
|
inline |
Definition at line 95 of file routing_index_manager.h.
|
static |
Definition at line 60 of file routing_index_manager.h.