C++ Reference

C++ Reference: Routing

RoutingIndexManager

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:

auto starts_ends = ...;
RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles.
RoutingModel model(manager);

Then, use 'manager.NodeToIndex(node)' whenever model requires a variable index.

Definition at line 42 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
 
int num_unique_depots () const
 
std::vector< NodeIndexGetIndexToNodeMap () const
 
gtl::ITIVector< NodeIndex, int64 > GetNodeToIndexMap () const
 

Static Public Attributes

static const int64 kUnassigned
 

Member Typedef Documentation

◆ NodeIndex

typedef RoutingNodeIndex NodeIndex

Definition at line 44 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()

~RoutingIndexManager ( )
inline

Definition at line 58 of file routing_index_manager.h.

Member Function Documentation

◆ GetEndIndex()

int64 GetEndIndex ( int  vehicle) const
inline

Definition at line 64 of file routing_index_manager.h.

◆ GetIndexToNodeMap()

std::vector<NodeIndex> GetIndexToNodeMap ( ) const
inline

Definition at line 79 of file routing_index_manager.h.

◆ GetNodeToIndexMap()

gtl::ITIVector<NodeIndex, int64> GetNodeToIndexMap ( ) const
inline

Definition at line 80 of file routing_index_manager.h.

◆ GetStartIndex()

int64 GetStartIndex ( int  vehicle) const
inline

Definition at line 63 of file routing_index_manager.h.

◆ IndexToNode()

NodeIndex IndexToNode ( int64  index) const
inline

Definition at line 71 of file routing_index_manager.h.

◆ NodesToIndices()

std::vector<int64> NodesToIndices ( const std::vector< NodeIndex > &  nodes) const

◆ NodeToIndex()

int64 NodeToIndex ( NodeIndex  node) const
inline

Definition at line 65 of file routing_index_manager.h.

◆ num_indices()

int num_indices ( ) const
inline

Definition at line 62 of file routing_index_manager.h.

◆ num_nodes()

int num_nodes ( ) const
inline

Definition at line 60 of file routing_index_manager.h.

◆ num_unique_depots()

int num_unique_depots ( ) const
inline

Definition at line 78 of file routing_index_manager.h.

◆ num_vehicles()

int num_vehicles ( ) const
inline

Definition at line 61 of file routing_index_manager.h.

Member Data Documentation

◆ kUnassigned

const int64 kUnassigned
static

Definition at line 45 of file routing_index_manager.h.


The documentation for this class was generated from the following file:
RoutingIndexManager(int num_nodes, int num_vehicles, NodeIndex depot)
Creates a NodeIndex to variable index mapping for a problem containing 'num_nodes',...