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

Function test_small_example_from_cattaruzza_paper

tests/test_Route.py:706–774  ·  view source on GitHub ↗

Tests a small multi-trip VRP example. The data are from [1]_, corresponding to their Figure 1. References ---------- .. [1] D. Cattaruzza, N. Absi, and D. Feillet (2016). The Multi-Trip Vehicle Routing Problem with Time Windows and Release Dates. *Transpor

()

Source from the content-addressed store, hash-verified

704
705
706def test_small_example_from_cattaruzza_paper():
707 """
708 Tests a small multi-trip VRP example. The data are from [1]_, corresponding
709 to their Figure 1.
710
711 References
712 ----------
713 .. [1] D. Cattaruzza, N. Absi, and D. Feillet (2016). The Multi-Trip
714 Vehicle Routing Problem with Time Windows and Release Dates.
715 *Transportation Science* 50(2): 676-693.
716 https://doi.org/10.1287/trsc.2015.0608.
717 """
718 depot = Depot(0, 0, tw_early=0, tw_late=200, service_duration=20)
719 clients = [
720 # Figure 1 details release times for some clients. But release times
721 # are not actually binding in the example, so they are not needed.
722 Client(0, 0, tw_early=100, tw_late=120, service_duration=5),
723 Client(0, 0, tw_early=50, tw_late=75, service_duration=5),
724 Client(0, 0, tw_early=50, tw_late=75, service_duration=5),
725 Client(0, 0, tw_early=50, tw_late=100, service_duration=5),
726 Client(0, 0, tw_early=50, tw_late=100, service_duration=5),
727 ]
728
729 matrix = [
730 [0, 5, 15, 20, 10, 15],
731 [5, 0, 20, 20, 15, 15],
732 [15, 20, 0, 40, 20, 30],
733 [20, 20, 40, 0, 30, 10],
734 [10, 15, 20, 30, 0, 20],
735 [15, 15, 30, 10, 20, 0],
736 ]
737
738 data = ProblemData(
739 clients=clients,
740 depots=[depot],
741 vehicle_types=[VehicleType(reload_depots=[0])],
742 distance_matrices=[matrix],
743 duration_matrices=[matrix],
744 )
745
746 trip1 = Trip(data, [5, 3], 0)
747 trip2 = Trip(data, [1], 0)
748 trip3 = Trip(data, [4], 0)
749 trip4 = Trip(data, [2], 0)
750 route = Route(data, [trip1, trip2, trip3, trip4], 0)
751
752 # These values were verified from the paper, and where needed calculated
753 # manually. Note that the paper setting requires the first trip to start
754 # immediately, which results in 15 wait duration. We do not require this,
755 # instead starting a little later to avoid the wait duration. The other
756 # quantities reported below match the paper.
757 assert_equal(route.start_time(), 15)
758 assert_equal(route.end_time(), 95)
759 assert_equal(route.time_warp(), 75 + 55) # two time warp violations
760 assert_equal(route.slack(), 0) # there is time warp, so no slack
761 assert_equal(route.service_duration(), 25 + 80) # at clients and depots
762 assert_equal(route.travel_duration(), 105)
763

Callers

nothing calls this directly

Calls 7

slackMethod · 0.95
DepotClass · 0.90
ClientClass · 0.90
ProblemDataClass · 0.90
VehicleTypeClass · 0.90
TripClass · 0.90
RouteClass · 0.90

Tested by

no test coverage detected