Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax for .vrp file format #17

Open
SuwonLee-KMU opened this issue Aug 12, 2022 · 1 comment
Open

Syntax for .vrp file format #17

SuwonLee-KMU opened this issue Aug 12, 2022 · 1 comment
Labels
question Further information is requested

Comments

@SuwonLee-KMU
Copy link

SuwonLee-KMU commented Aug 12, 2022

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
Copy link
Owner

yorak commented Aug 12, 2022

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:

  • N is the number of customers, (not necessary)
  • points is None or the coordinates of the depot (index 0) and customers (index >0).
  • dd_points is None or the display coordinates (usually None)
  • d is a Python list of demands with d[0]=0 as it is the depot.
  • D is a Numpy 2D matrix of distances, one has to give this!
  • C is the scalar value of the vehicle capacity (all vehicles have the same capacity)
  • ewt is for a very special case. Can be anything or 'EXPLICIT'.
    Following three are additonal constraints
  • K number of vehicles, can be None as it is (mostly) ignored
  • L maximum route length/duration constraint using the same distance/time measure as D, usually None
  • st stopping times (or parking drive distance) at each customer (same for all), usually None

@yorak yorak added the question Further information is requested label Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants