ben-hudson / pylkh

A super simple Python wrapper for the constrained traveling salesman and vehicle routing problem solver LKH-3.
https://pypi.org/project/lkh/
Other
32 stars 8 forks source link

Data of VRPTW #6

Closed RachaBen closed 11 months ago

RachaBen commented 1 year ago

I encountered difficulties when dealing with data for solving VRPTW. IndexError: list index out of range for all VRPTW data

ben-hudson commented 1 year ago

Could you please provide a code snippet and an example of the problem you're trying to solve?

For example, is it a benchmark instance (e.g. the Solomon benchmark defined here http://vrp.atd-lab.inf.puc-rio.br/index.php/en/) or custom data?

RachaBen commented 1 year ago

Here is a text file containing data inspired by Solomon's benchmark : NAME : me COMMENT : drilling TYPE : CVRPTW DIMENSION: 10 EDGE_WEIGHT_TYPE : EUC_2D CAPACITY : 30 NODE_COORD_SECTION 1 45 68 2 45 70 3 42 66 4 42 68 5 42 65 6 40 69 7 40 66 8 38 68 9 38 70 10 35 66 DEMAND_SECTION 1 0 2 10 3 30 4 10 5 10 6 10 7 20 8 20 9 20 10 10 SERVICE_TIME_SECTION 1 0 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TIME_WINDOW_SECTION 1 0 1236 2 912 967 3 825 870 4 65 146 5 727 782 6 15 67 7 621 702 8 170 225 9 255 324 10 534 605 DEPOT_SECTION 1 -1

ben-hudson commented 1 year ago

That error appears when LKH does not find a solution to your instance. I will push a change that makes the error more user-friendly

In the mean time, you can try running LKH manually by making a file test.param like this:

PROBLEM_FILE=path/to/your/instance
TOUR_FILE=path/to/a/solution/file

For example,

PROBLEM_FILE=test.vrptw
TOUR_FILE=test.tour

And then run LKH manually via LKH test.param. You will know that LKH found a solution to your instance if the solution file (test.tour) is created.

ben-hudson commented 11 months ago

I've released v2.0.0 on PyPi which adds a user-friendly error message when LKH does not find a solution