MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / test_round_func_round_nearest

Function test_round_func_round_nearest

tests/test_read.py:180–200  ·  view source on GitHub ↗

Tests rounding to the nearest integer works well for the RC208 instance, which has Euclidean distances computed from integer coordinates. Since the instance is large, we'll test one particular distance.

()

Source from the content-addressed store, hash-verified

178
179
180def test_round_func_round_nearest():
181 """
182 Tests rounding to the nearest integer works well for the RC208 instance,
183 which has Euclidean distances computed from integer coordinates. Since the
184 instance is large, we'll test one particular distance.
185 """
186 data = read("data/RC208.vrp", "round")
187
188 # We're going to test dist(0, 1) and dist(1, 0), which should be the same
189 # since the distances are symmetric/Euclidean.
190 assert_equal(data.location(0).x, 40)
191 assert_equal(data.location(0).y, 50)
192
193 assert_equal(data.location(1).x, 25)
194 assert_equal(data.location(1).y, 85)
195
196 # Compute the distance, and assert that it is indeed correctly rounded.
197 distances = data.distance_matrix(profile=0)
198 expected_dist = round(sqrt((40 - 25) ** 2 + (85 - 50) ** 2))
199 assert_equal(distances[0, 1], expected_dist)
200 assert_equal(distances[1, 0], expected_dist)
201
202
203def test_round_func_exact():

Callers

nothing calls this directly

Calls 2

readFunction · 0.90
locationMethod · 0.80

Tested by

no test coverage detected