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

Function test_mdvrptw_instance

tests/test_read.py:281–316  ·  view source on GitHub ↗

Tests that reading an MDVRPTW instance happens correctly, particularly the maximum route duration and multiple depot aspects.

()

Source from the content-addressed store, hash-verified

279
280
281def test_mdvrptw_instance():
282 """
283 Tests that reading an MDVRPTW instance happens correctly, particularly the
284 maximum route duration and multiple depot aspects.
285 """
286 data = read("data/PR11A.vrp", round_func="trunc")
287
288 assert_equal(data.num_locations, 364)
289 assert_equal(data.num_depots, 4)
290 assert_equal(data.num_clients, 360)
291
292 assert_equal(data.num_vehicles, 40)
293 assert_equal(data.num_vehicle_types, 4) # one vehicle type per depot
294
295 for idx, vehicle_type in enumerate(data.vehicle_types()):
296 # There should be ten vehicles for each depot, with the following
297 # capacities and maximum route durations.
298 assert_equal(vehicle_type.num_available, 10)
299 assert_equal(vehicle_type.start_depot, idx)
300 assert_equal(vehicle_type.end_depot, idx)
301 assert_equal(vehicle_type.capacity, [200])
302 assert_equal(vehicle_type.max_duration, 450)
303
304 # Essentially all vehicle indices for each depot, separated by a comma.
305 # Each depot has ten vehicles, and they are nicely grouped (so the
306 # first ten are assigned to the first depot, the second ten to the
307 # second depot, etc.).
308 expected_name = ",".join(str(10 * idx + veh) for veh in range(10))
309 assert_equal(vehicle_type.name, expected_name)
310
311 # We haven't seen many instances with negative coordinates, but this
312 # MDVRPTW instance has those. That should be allowed.
313 assert_(any(depot.x < 0) for depot in data.depots())
314 assert_(any(depot.y < 0) for depot in data.depots())
315 assert_(any(client.x < 0) for client in data.clients())
316 assert_(any(client.y < 0) for client in data.clients())
317
318
319def test_vrpspd_instance():

Callers

nothing calls this directly

Calls 4

readFunction · 0.90
vehicle_typesMethod · 0.80
depotsMethod · 0.80
clientsMethod · 0.80

Tested by

no test coverage detected