![]() |
Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
|
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 = ...; /// 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 36 of file RoutingIndexManager.java.
Public Member Functions | |
| RoutingIndexManager (long cPtr, boolean cMemoryOwn) | |
| synchronized void | delete () |
| RoutingIndexManager (int num_nodes, int num_vehicles, int depot) | |
| RoutingIndexManager (int num_nodes, int num_vehicles, int[] starts, int[] ends) | |
| int | getNumberOfNodes () |
| int | getNumberOfVehicles () |
| int | getNumberOfIndices () |
| long | getStartIndex (int vehicle) |
| long | getEndIndex (int vehicle) |
| long | nodeToIndex (int node) |
| long[] | nodesToIndices (int[] nodes) |
| int | indexToNode (long index) |
Static Public Member Functions | |
| static long | getCPtr (RoutingIndexManager obj) |
| static long | swigRelease (RoutingIndexManager obj) |
Protected Member Functions | |
| void | finalize () |
Protected Attributes | |
| transient boolean | swigCMemOwn |
| com.google.ortools.constraintsolver.RoutingIndexManager.RoutingIndexManager | ( | long | cPtr, |
| boolean | cMemoryOwn ) |
Definition at line 40 of file RoutingIndexManager.java.
| com.google.ortools.constraintsolver.RoutingIndexManager.RoutingIndexManager | ( | int | num_nodes, |
| int | num_vehicles, | ||
| int | 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 86 of file RoutingIndexManager.java.
| com.google.ortools.constraintsolver.RoutingIndexManager.RoutingIndexManager | ( | int | num_nodes, |
| int | num_vehicles, | ||
| int[] | starts, | ||
| int[] | 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. Note: starts and ends arrays must have exactly num_vehicles elements. |
Definition at line 99 of file RoutingIndexManager.java.
| synchronized void com.google.ortools.constraintsolver.RoutingIndexManager.delete | ( | ) |
Definition at line 66 of file RoutingIndexManager.java.
|
protected |
Definition at line 62 of file RoutingIndexManager.java.
|
static |
Definition at line 45 of file RoutingIndexManager.java.
| long com.google.ortools.constraintsolver.RoutingIndexManager.getEndIndex | ( | int | vehicle | ) |
Definition at line 119 of file RoutingIndexManager.java.
| int com.google.ortools.constraintsolver.RoutingIndexManager.getNumberOfIndices | ( | ) |
Definition at line 111 of file RoutingIndexManager.java.
| int com.google.ortools.constraintsolver.RoutingIndexManager.getNumberOfNodes | ( | ) |
Definition at line 103 of file RoutingIndexManager.java.
| int com.google.ortools.constraintsolver.RoutingIndexManager.getNumberOfVehicles | ( | ) |
Definition at line 107 of file RoutingIndexManager.java.
| long com.google.ortools.constraintsolver.RoutingIndexManager.getStartIndex | ( | int | vehicle | ) |
Definition at line 115 of file RoutingIndexManager.java.
| int com.google.ortools.constraintsolver.RoutingIndexManager.indexToNode | ( | long | index | ) |
Definition at line 131 of file RoutingIndexManager.java.
| long[] com.google.ortools.constraintsolver.RoutingIndexManager.nodesToIndices | ( | int[] | nodes | ) |
Definition at line 127 of file RoutingIndexManager.java.
| long com.google.ortools.constraintsolver.RoutingIndexManager.nodeToIndex | ( | int | node | ) |
Definition at line 123 of file RoutingIndexManager.java.
|
static |
Definition at line 49 of file RoutingIndexManager.java.
|
protected |
Definition at line 38 of file RoutingIndexManager.java.