diff --git a/README.md b/README.md index 550a6285..45dba402 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tests/parse/test_parse_distances.py b/tests/parse/test_parse_distances.py index 109c0a80..50c4eef0 100644 --- a/tests/parse/test_parse_distances.py +++ b/tests/parse/test_parse_distances.py @@ -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): """ @@ -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]]), ], ) diff --git a/vrplib/parse/parse_distances.py b/vrplib/parse/parse_distances.py index 0530042d..c01b04c7 100644 --- a/vrplib/parse/parse_distances.py +++ b/vrplib/parse/parse_distances.py @@ -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