Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ You can set the `compute_distances` argument in `read_instance` to disable this
Following the VRPLIB conventions, the edge weights are computed based on the `EDGE_WEIGHT_TYPE` specification, and in some cases the `EDGE_WEIGHT_FORMAT` specification. `vrplib` currently supports two categories of edge weight types:
- `*_2D`: Euclidean distances based on the node coordinates data.
- `EUC_2D`: Double precision distances without rounding.
- `FLOOR_2D`: Round down all distances to down to an integer.
- `FLOOR_2D`: Round down all distances to an integer.
- `CEIL_2D`: Round up all distances to an integer.
- `EXACT_2D`: Multiply the distances by 1000, round to the nearest integer.
- `EXPLICIT`: the distance data is explicitly provided, in partial or full form. The `EDGE_WEIGHT_FORMAT` specification must be present. We support the following two edge weight formats:
- `LOWER_ROW`: Lower row triangular matrix without diagonal entries.
Expand Down
3 changes: 2 additions & 1 deletion tests/parse/test_parse_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_unknown_edge_weight_type_and_format(


@pytest.mark.parametrize(
"edge_weight_type", ["EUC_2D", "FLOOR_2D", "EXACT_2D"]
"edge_weight_type", ["EUC_2D", "FLOOR_2D", "CEIL_2D", "EXACT_2D"]
)
def test_raise_no_coordinates_euclidean_distances(edge_weight_type):
"""
Expand All @@ -51,6 +51,7 @@ def test_raise_no_coordinates_euclidean_distances(edge_weight_type):
[
("EUC_2D", [[0, np.sqrt(2)], [np.sqrt(2), 0]]),
("FLOOR_2D", [[0, 1], [1, 0]]),
("CEIL_2D", [[0, 2], [2, 0]]),
("EXACT_2D", [[0, 1414], [1414, 0]]),
],
)
Expand Down
3 changes: 3 additions & 0 deletions vrplib/parse/parse_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def parse_distances(
if edge_weight_type == "EXACT_2D":
return np.round(distance * 1000)

if edge_weight_type == "CEIL_2D":
return np.ceil(distance)

if edge_weight_type == "EXPLICIT":
if edge_weight_format == "LOWER_ROW":
# TODO Eilon instances edge weight specifications are incorrect in
Expand Down