Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.constraint_solver.pywrapcp.RoutingIndexManager Class Reference

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:

  .. code-block:: c++

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

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 4731 of file pywrapcp.py.

Inheritance diagram for ortools.constraint_solver.pywrapcp.RoutingIndexManager:

Public Member Functions

 __init__ (self, *args)
 GetNumberOfNodes (self)
 GetNumberOfVehicles (self)
 GetNumberOfIndices (self)
 GetStartIndex (self, vehicle)
 GetEndIndex (self, vehicle)
 NodeToIndex (self, node)
 IndexToNode (self, index)

Properties

 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

Constructor & Destructor Documentation

◆ __init__()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.__init__ ( self,
* args )
*Overload 1:*
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.
:type num_nodes: int
:param num_nodes: Number of nodes in the problem.
:type num_vehicles: int
:param num_vehicles: Number of vehicles in the problem.
:type depot: operations_research::RoutingIndexManager::NodeIndex
:param depot: 'start' and 'end'
    NodeIndex for all vehicles.

|

*Overload 2:*
Creates a NodeIndex to variable index mapping.
:type num_nodes: int
:param num_nodes: Number of nodes in the problem.
:type num_vehicles: int
:param num_vehicles: Number of vehicles in the problem.
:type starts: std::vector< operations_research::RoutingIndexManager::NodeIndex >
:param starts: Array containing the start NodeIndex for each vehicle.
:type ends: std::vector< operations_research::RoutingIndexManager::NodeIndex >
:param ends: Array containing the end NodeIndex for each vehicle.
Notes: **starts** and **ends** arrays must have **exactly** 'num_vehicles'
elements.

Definition at line 4762 of file pywrapcp.py.

Member Function Documentation

◆ GetEndIndex()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.GetEndIndex ( self,
vehicle )

Definition at line 4806 of file pywrapcp.py.

◆ GetNumberOfIndices()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.GetNumberOfIndices ( self)

Definition at line 4800 of file pywrapcp.py.

◆ GetNumberOfNodes()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.GetNumberOfNodes ( self)

Definition at line 4794 of file pywrapcp.py.

◆ GetNumberOfVehicles()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.GetNumberOfVehicles ( self)

Definition at line 4797 of file pywrapcp.py.

◆ GetStartIndex()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.GetStartIndex ( self,
vehicle )

Definition at line 4803 of file pywrapcp.py.

◆ IndexToNode()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.IndexToNode ( self,
index )

Definition at line 4812 of file pywrapcp.py.

◆ NodeToIndex()

ortools.constraint_solver.pywrapcp.RoutingIndexManager.NodeToIndex ( self,
node )

Definition at line 4809 of file pywrapcp.py.

Property Documentation

◆ thisown

ortools.constraint_solver.pywrapcp.RoutingIndexManager.thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
static

Definition at line 4759 of file pywrapcp.py.


The documentation for this class was generated from the following file: