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

Function test_round_func_exact

tests/test_read.py:203–223  ·  view source on GitHub ↗

Tests rounding with the ``exact`` round function also works well for the RC208 instance. This test is similar to the one for ``round``, but all values are now multiplied by 1_000 before rounding.

()

Source from the content-addressed store, hash-verified

201
202
203def test_round_func_exact():
204 """
205 Tests rounding with the ``exact`` round function also works well for the
206 RC208 instance. This test is similar to the one for ``round``, but all
207 values are now multiplied by 1_000 before rounding.
208 """
209 data = read("data/RC208.vrp", "exact")
210
211 # We're going to test dist(0, 1) and dist(1, 0), which should be the same
212 # since the distances are symmetric/Euclidean.
213 assert_equal(data.location(0).x, 40_000)
214 assert_equal(data.location(0).y, 50_000)
215
216 assert_equal(data.location(1).x, 25_000)
217 assert_equal(data.location(1).y, 85_000)
218
219 # Compute the distance, and assert that it is indeed correctly rounded.
220 distances = data.distance_matrix(profile=0)
221 expected_dist = round(sqrt((40 - 25) ** 2 + (85 - 50) ** 2) * 1_000)
222 assert_equal(distances[0, 1], expected_dist)
223 assert_equal(distances[1, 0], expected_dist)
224
225
226def test_service_time_specification():

Callers

nothing calls this directly

Calls 2

readFunction · 0.90
locationMethod · 0.80

Tested by

no test coverage detected