Tests some statistics calculations on a small multi-trip example.
(ok_small_multiple_trips)
| 615 | |
| 616 | |
| 617 | def test_statistics_with_small_multi_trip_example(ok_small_multiple_trips): |
| 618 | """ |
| 619 | Tests some statistics calculations on a small multi-trip example. |
| 620 | """ |
| 621 | # Regular route, executed in a single trip. |
| 622 | route1 = Route(ok_small_multiple_trips, [1, 2, 3, 4], 0) |
| 623 | |
| 624 | # Same visits but executed over two trips. |
| 625 | trip1 = Trip(ok_small_multiple_trips, [1, 2], 0) |
| 626 | trip2 = Trip(ok_small_multiple_trips, [3, 4], 0) |
| 627 | route2 = Route(ok_small_multiple_trips, [trip1, trip2], 0) |
| 628 | |
| 629 | assert_equal(route2.visits(), route1.visits()) |
| 630 | assert_equal(len(route2), len(route1)) |
| 631 | assert_equal(route1.num_trips(), 1) |
| 632 | assert_equal(route2.num_trips(), 2) |
| 633 | |
| 634 | # Route structure and general statistics. |
| 635 | assert_equal(route2.prizes(), route1.prizes()) |
| 636 | assert_allclose(route2.centroid(), route1.centroid()) |
| 637 | assert_equal(route2.start_depot(), route1.start_depot()) |
| 638 | assert_equal(route2.end_depot(), route1.end_depot()) |
| 639 | |
| 640 | # First route has excess load, second does not. |
| 641 | assert_equal(route1.excess_load(), [8]) |
| 642 | assert_equal(route2.excess_load(), [0]) |
| 643 | |
| 644 | # First route takes 7'950, but the second route takes longer, because it |
| 645 | # has to reload at the depot. The difference is exactly the difference in |
| 646 | # arc travel time. |
| 647 | durs = ok_small_multiple_trips.duration_matrix(0) |
| 648 | diff = durs[2, 0] + durs[0, 3] - durs[2, 3] |
| 649 | |
| 650 | assert_equal(route1.duration(), 7_950) |
| 651 | assert_equal(route2.duration(), route1.duration() + diff) |
| 652 | assert_equal(route2.wait_duration(), route1.wait_duration()) |
| 653 | assert_equal(route2.service_duration(), route1.service_duration()) |
| 654 | |
| 655 | |
| 656 | def test_schedule_multi_trip_example(ok_small_multiple_trips): |