Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <routing_index_manager.h>
Public Types | |
typedef RoutingNodeIndex | NodeIndex |
Public Member Functions | |
RoutingIndexManager (int num_nodes, int num_vehicles, NodeIndex depot) | |
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) | |
int | num_nodes () const |
Returns the number of nodes in the manager. | |
int | num_vehicles () const |
Returns the number of vehicles in the manager. | |
int | num_indices () const |
Returns the number of indices mapped to nodes. | |
int64_t | GetStartIndex (int vehicle) const |
Returns start and end indices of the given vehicle. | |
int64_t | GetEndIndex (int vehicle) const |
int64_t | NodeToIndex (NodeIndex node) const |
std::vector< int64_t > | NodesToIndices (const std::vector< NodeIndex > &nodes) const |
Same as NodeToIndex but for a given vector of nodes. | |
NodeIndex | IndexToNode (int64_t index) const |
std::vector< NodeIndex > | IndicesToNodes (const std::vector< int64_t > &indices) const |
Same as IndexToNode but for a given vector of indices. | |
int | num_unique_depots () const |
std::vector< NodeIndex > | GetIndexToNodeMap () const |
Static Public Attributes | |
static const int64_t | kUnassigned = -1 |
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 54 of file routing_index_manager.h.
RoutingNodeIndex operations_research::RoutingIndexManager::NodeIndex |
Definition at line 56 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.
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 ) |
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 ) |
Definition at line 47 of file routing_index_manager.cc.
|
inline |
Definition at line 81 of file routing_index_manager.h.
|
inline |
Definition at line 108 of file routing_index_manager.h.
|
inline |
Returns start and end indices of the given vehicle.
Definition at line 78 of file routing_index_manager.h.
|
inline |
Returns the node corresponding to an index. A node may appear more than once if it is used as the start or the end node of multiple vehicles.
Definition at line 96 of file routing_index_manager.h.
std::vector< RoutingIndexManager::NodeIndex > operations_research::RoutingIndexManager::IndicesToNodes | ( | const std::vector< int64_t > & | indices | ) | const |
Same as IndexToNode but for a given vector of indices.
Definition at line 138 of file routing_index_manager.cc.
std::vector< int64_t > operations_research::RoutingIndexManager::NodesToIndices | ( | const std::vector< NodeIndex > & | nodes | ) | const |
Same as NodeToIndex but for a given vector of nodes.
Definition at line 126 of file routing_index_manager.cc.
|
inline |
Returns the index of a node. A node can correspond to multiple indices if it's a start or end node. As of 03/2020, kUnassigned will be returned for all end nodes. If a node appears more than once as a start node, the index of the first node in the list of start nodes is returned.
Definition at line 86 of file routing_index_manager.h.
|
inline |
Returns the number of indices mapped to nodes.
Definition at line 76 of file routing_index_manager.h.
|
inline |
Returns the number of nodes in the manager.
Definition at line 72 of file routing_index_manager.h.
|
inline |
(user) Add unit tests for NodesToIndices and IndicesToNodes.
(user): Remove when removal of NodeIndex from RoutingModel is complete.
Definition at line 107 of file routing_index_manager.h.
|
inline |
Returns the number of vehicles in the manager.
Definition at line 74 of file routing_index_manager.h.
|
static |
Definition at line 57 of file routing_index_manager.h.