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

Function test_route_access_methods

tests/test_Route.py:65–96  ·  view source on GitHub ↗

Tests that accessing route statistics returns the correct numbers.

(ok_small)

Source from the content-addressed store, hash-verified

63
64
65def test_route_access_methods(ok_small):
66 """
67 Tests that accessing route statistics returns the correct numbers.
68 """
69 routes = [Route(ok_small, [1, 3], 0), Route(ok_small, [2, 4], 0)]
70
71 # Test route access: getting the route plan should return a simple list.
72 assert_equal(routes[0].visits(), [1, 3])
73 assert_equal(routes[1].visits(), [2, 4])
74
75 # There's no excess load, so all excess load should be zero.
76 assert_equal(routes[0].excess_load(), [0])
77 assert_equal(routes[1].excess_load(), [0])
78
79 # Total route delivery demand (and pickups, which are all zero for this
80 # instance).
81 deliveries = [0] + [client.delivery[0] for client in ok_small.clients()]
82 assert_equal(routes[0].delivery(), [deliveries[1] + deliveries[3]])
83 assert_equal(routes[1].delivery(), [deliveries[2] + deliveries[4]])
84
85 assert_equal(routes[0].pickup(), [0])
86 assert_equal(routes[1].pickup(), [0])
87
88 # The first route is not feasible due to time warp, but the second one is.
89 # See also the tests below.
90 assert_(not routes[0].is_feasible())
91 assert_(routes[1].is_feasible())
92
93 # Total service duration.
94 services = [0] + [client.service_duration for client in ok_small.clients()]
95 assert_equal(routes[0].service_duration(), services[1] + services[3])
96 assert_equal(routes[1].service_duration(), services[2] + services[4])
97
98
99def test_access_multiple_trips(ok_small_multiple_trips):

Callers

nothing calls this directly

Calls 6

RouteClass · 0.90
visitsMethod · 0.80
clientsMethod · 0.80
deliveryMethod · 0.80
pickupMethod · 0.80
is_feasibleMethod · 0.80

Tested by

no test coverage detected