yorak / VeRyPy

A python library with implementations of 15 classical heuristics for the capacitated vehicle routing problem.
MIT License
263 stars 55 forks source link

Syntax for .vrp file format #17

Open SuwonLee-KMU opened 2 years ago

SuwonLee-KMU commented 2 years ago

Hello,

I found an example script which imports a .vrp format file and returns the optimal routing result in this repo.

I want to know how can I write the .vrp file as I want. That is, I want to specify customer nodes positions and so on. Actually, I have opened the .vrp file with a text editor, and I don't understand the syntax.

When I google it with some keywords like vrp file expansions syntax but I cannot reach what I want.

Thank you in advance!

yorak commented 2 years ago

Hi Suwon Lee,

nice to learn that you have found VeRyPy.

I added an example script to illustrate .vrp file generation. I had used this script to convert van Breedam VRP problem instances to TSPLIB95 .vrp format. As you can see, the script can be used as an outline for your own .vrp writer. One can encode full distance matrices in .vrp files. See the TSPLIB95 specification for details.

However, if you already have the data in a format that you can provide the distance matrix as a Numpy 2D matrix D and the demands as a Python list d, you can also use the VeRyPy Python API to solve the problems without going through the .vrp file format. There is few alternatives on how to do that. If you want to run only one algorithm, use that init-function directly (e.g., Clarke and Wright savings implementation). Or, if you want to try to solve the problem using all of the algorithms in VeRyPy, one can just pickle problem instance details to a .pickle file using Python pickle module. This is not well documented feature, but VeRyPy is capable of reading such pickled problems (see the relevant code).

VeRyPy reader expects following tuple inside the pickle file: (N, points, dd_points, **d, D, C**, ewt, K, L, st),

Note that only the bold entries are required, others can be None. Detailed explanations: