A VRPLIB instance contains problem specifications and problem data.
Specifications are key-value pairs separated by a colon. In the example above, NAME and EDGE_WEIGHT_TYPE are the two data specifications.
Data are explicit array-like values such as customer coordinates or service times.
Each data section should start with a header name that ends with _SECTION, e.g., NODE_COORD_SECTION and SERVICE_TIME_SECTION. Section names may also end with a colon, e.g., DEMAND_SECTION:. The name must be followed by rows of values and each row must start with an index representing the depot or customer.
There are two exceptions to this rule: values in EDGE_WEIGHT_SECTION and DEPOT_SECTION should not start with an index.
Besides the rules outlined above, vrplib is not strict about the naming of specifications or sections.
This means that you can use vrplib to read VRPLIB instances with custom specifications like MY_SPECIFICATION: SOME_VALUE and custom section names like MY_SECTION.
Reading the above example instance returns the following dictionary:
The depot section specifies which location index corresponds to the depot data.
The convention is to let index 1 represent the depot.
vrplib subtracts one from the depot value to make it easier to index.
Computing edge weights
Note that the example instance did not include any explicit information about the edge weights, yet the output includes edge weights data.
This is because vrplib automatically computes the edge weights based on the instance specifications, if applicable.
In the example, the edge weight type specification and node coordinates data are used to compute the Euclidean distance.
You can set the compute_distances argument in read_instance to disable this feature.
Following the VRPLIB conventions, the edge weights are computed based on the EDGE_WEIGHT_TYPE specification, and in some cases the EDGE_WEIGHT_FORMAT specification. vrplib currently supports two categories of edge weight types:
*_2D: Euclidean distances based on the node coordinates data.
EUC_2D: Double precision distances without rounding.
FLOOR_2D: Round down all distances to an integer.
CEIL_2D: Round up all distances to an integer.
EXACT_2D: Multiply the distances by 1000, round to the nearest integer.
EXPLICIT: the distance data is explicitly provided, in partial or full form. The EDGE_WEIGHT_FORMAT specification must be present. We support the following two edge weight formats:
LOWER_ROW: Lower row triangular matrix without diagonal entries.
FULL_MATRIX: Explicit full matrix representation.
Line comments
Lines starting with # are interpreted as comments and not parsed when reading the instance.
More information about VRPLIB
The VRPLIB format is an extension of the TSPLIB95 format.
Additional information about the VRPLIB format can be found here.
Solomon instance format
The Solomon format was used to introduce the Solomon instances for the Vehicle Routing Problem with Time Window (VRPTW) and also the extended instance set by Homberger and Gehring. A Solomon instance looks like this:
Example
VEHICLE
NUMBER CAPACITY
50 200
CUSTOMER
CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME
0 70 70 0 0 1351 0
1 33 78 20 750 809 90
Reading this Solomon instance returns the following dictionary:
The edge weights are computed by default using the Euclidean distances.
Solution format
Here's an example of a solution format:
Route #1: 1 2 3
Route #2: 4 5
Cost: 100
A solution is represented by a set of routes, where each route specifies the sequence of customers to visit.
Each route should start with "Route", followed by the route number, and followed by a colon.
The customers to be served on the route are then listed.
The solution file can also include other keywords like Cost, which will be separated on the first colon or whitespace.
The convention is that customer indices start counting from 1, but vrplib simply parses the file without strict requirements about those indices.
Reading the above example solution returns the following dictionary:
{'routes': [[1, 2, 3], [4, 5]], 'cost': 100}
Other remarks
In the literature, some instances use rounding conventions different from what is specified in the instance. For example, X instance set proposed by Uchoa et al. (2017) assumes that the distances are rounded to the nearest integer. When you use the vrplib package to read this instance, it will return non-rounded Euclidean distances because the instance specifies the EUC_2D edge weight type which implies no rounding. To adhere to the convention used in the literature, you can manually round the distances matrix.
For large instances (>5000 customers) it's recommended to set the compute_edge_weights argument to False in read_instance.
Works well with
Use together with vrplib: extensions, drivers, servers and companion tools.
ortoolsPythie’s Index: 74Google OR-Tools python libraries and modules9.2M downloads/mo
pyvrpPythie’s Index: 86A state-of-the-art vehicle routing problem solver.118.6K downloads/mo