VRPLIB
VRPLIB copied to clipboard
Reindex sections based on indices
Suppose my VRPLIB file has the following section:
NODE_SECTION
1 40 50
3 20 20
2 20 10
VRPLIB parses this as [[40, 50], [20, 20], [20, 10]]
, which ignores that the third and second node are provided in a different order in the data file. Thus, the parsed data are subtly wrong.
Additionally, the following
NODE_SECTION
1 40 50
2 20 20
4 20 10
is parsed in the same manner, despite node 3 never having been specified.
If we reindex the data based on the node indices, we get the correct order for free, and additionally, the second example will raise about 4
being out of range for the actual data. That means such an issue no longer fails silently.