Tests that the modelling interface warns when an edge is added whose distance or duration values are too large. This situation is likely caused by scaling issues, so a warning is appropriate.
(recwarn)
| 436 | |
| 437 | |
| 438 | def test_data_warns_about_scaling_issues(recwarn): |
| 439 | """ |
| 440 | Tests that the modelling interface warns when an edge is added whose |
| 441 | distance or duration values are too large. This situation is likely caused |
| 442 | by scaling issues, so a warning is appropriate. |
| 443 | """ |
| 444 | model = Model() |
| 445 | model.add_vehicle_type(capacity=0, num_available=1) |
| 446 | depot = model.add_depot(0, 0) |
| 447 | client = model.add_client(1, 1) |
| 448 | |
| 449 | # Normal distance sizes; should all be OK. |
| 450 | for distance in [1, 10, 100, 1_000, 10_000, 100_000, MAX_VALUE]: |
| 451 | model.add_edge(client, depot, distance=distance) |
| 452 | assert_equal(len(recwarn), 0) |
| 453 | |
| 454 | # But a value exceeding the maximum value is not OK. This should warn (both |
| 455 | # for distance and/or duration). |
| 456 | with pytest.warns(ScalingWarning): |
| 457 | model.add_edge(depot, client, distance=MAX_VALUE + 1) |
| 458 | |
| 459 | with pytest.warns(ScalingWarning): |
| 460 | model.add_edge(depot, client, distance=0, duration=MAX_VALUE + 1) |
| 461 | |
| 462 | |
| 463 | def test_model_solves_instance_with_zero_or_one_clients(): |
nothing calls this directly
no test coverage detected