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.
()
| 201 | |
| 202 | |
| 203 | def 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 | |
| 226 | def test_service_time_specification(): |