From 3273c73a9d2faf2e6a38f5918f437b38b252223d Mon Sep 17 00:00:00 2001 From: Leon Lan Date: Wed, 13 Aug 2025 16:24:47 +0200 Subject: [PATCH 1/2] Add CEIL_2D --- README.md | 1 + tests/parse/test_parse_distances.py | 3 ++- vrplib/parse/parse_distances.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 79f54e27..529fb7b3 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ Following the VRPLIB conventions, the edge weights are computed based on the `ED - `*_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. + - `CEIL_2D`: Round up all distances to down 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 99bc0061..63f0a98b 100644 --- a/vrplib/parse/parse_distances.py +++ b/vrplib/parse/parse_distances.py @@ -57,6 +57,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 From 28eb976fa8bc8f6322624bb486ff4595ec169588 Mon Sep 17 00:00:00 2001 From: Leon Lan Date: Thu, 14 Aug 2025 15:43:46 +0200 Subject: [PATCH 2/2] Rephrase --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03738b65..45dba402 100644 --- a/README.md +++ b/README.md @@ -163,8 +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. - - `CEIL_2D`: Round up 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.