PyVRP / VRPLIB

Python package to read and write vehicle routing problem instances.
https://github.com/PyVRP/VRPLIB
MIT License
82 stars 7 forks source link

Write VRP instances #14

Closed leonlan closed 11 months ago

leonlan commented 1 year ago

It would be nice to have a function that could also write VRP instances. This was provided in the EURO-NeurIPS competition.

leonlan commented 1 year ago

I made a start for writing instances.

leonlan commented 1 year ago

See http://www.bernabe.dorronsoro.es/vrp/index.html?/Problem_Instances/VRPLIBDesc.html for the original VRPLIB descrption.

leonlan commented 1 year ago

LKH-3 VRPLIB convention

LKH-3 is very well maintained, so I think it's good to support reading those files as well (perhaps long term but not now?)

leonlan commented 1 year ago

The VRPLIB format consists of a problem specification part and a data part.

leonlan commented 1 year ago

Both for reading and writing files, we should follow the LKH-3 VRPLIB format.

But the Solomon and GH instances on CVRPLIB do not follow the VRPLIB format. What do I want to do with that? The LKH3 instances do follow the VRPLIB format.

leonlan commented 1 year ago

https://www.sintef.no/projectweb/top/vrptw/100-customers/

LKH-3 calls this "Sintef solution style"

leonlan commented 1 year ago

I have removed the write module because this wasn't ready yet, and I want to speed up the release of V1. So this is an open issue again.

leonlan commented 1 year ago

See this commit for the (removed) write module https://github.com/leonlan/VRPLIB/commit/885f9cce19bb5440a6c4c1ee899754d3b0c42728#diff-6fa8cb67482a47a8390d40bcd32b10d53f6ffd7a723f412d71a486039267557f.

N-Wouda commented 11 months ago

This is periodically useful for the PyVRP instances as well (I'm running into this now with multi-depot VRP). Do you want to be really strict about what's written? A simple dict -> specification/section type writer is easy enough: every value that's iterable becomes a section, and every value that's not becomes a specification. The onus would then be on the user to ensure that data encodes a valid VRPLIB instances, but to be fair, that's on the user anyway when they're writing instances.

leonlan commented 11 months ago

Yeah that seems like a good solution to me. I'll try to make this feature later this week.

leonlan commented 11 months ago

@N-Wouda I implemented the write_instance and write_solution functions. Hopefully, they are useful!