MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / test_model_solves_multi_trip_instance

Function test_model_solves_multi_trip_instance

tests/test_Model.py:1046–1076  ·  view source on GitHub ↗

Smoke test to check that the model can solve an instance with multiple trips / reloading.

()

Source from the content-addressed store, hash-verified

1044
1045
1046def test_model_solves_multi_trip_instance():
1047 """
1048 Smoke test to check that the model can solve an instance with multiple
1049 trips / reloading.
1050 """
1051 m = Model()
1052 depot1 = m.add_depot(0, 0)
1053 depot2 = m.add_depot(0, 0)
1054
1055 m.add_vehicle_type(capacity=[5], reload_depots=[depot1, depot2])
1056
1057 for idx in range(3): # all locations are on a horizontal line
1058 m.add_client(idx, 0, delivery=[5])
1059
1060 for frm in m.locations:
1061 for to in m.locations:
1062 m.add_edge(frm, to, distance=abs(frm.x - to.x))
1063
1064 res = m.solve(stop=MaxIterations(10))
1065 assert_(res.is_feasible())
1066 assert_equal(res.cost(), 6)
1067
1068 routes = res.best.routes()
1069 assert_equal(len(routes), 1)
1070
1071 # This route transports the full 15 client delivery demand using a vehicle
1072 # with capacity of just 5 because it reloads twice along the route.
1073 route = routes[0]
1074 assert_equal(route.excess_load(), [0])
1075 assert_equal(route.delivery(), [15])
1076 assert_equal(route.num_trips(), 3)
1077
1078
1079def test_instance_with_multi_trip_and_release_times(mtvrptw_release_times):

Callers

nothing calls this directly

Calls 10

add_depotMethod · 0.95
add_vehicle_typeMethod · 0.95
add_clientMethod · 0.95
add_edgeMethod · 0.95
solveMethod · 0.95
ModelClass · 0.90
MaxIterationsClass · 0.90
is_feasibleMethod · 0.80
deliveryMethod · 0.80
costMethod · 0.45

Tested by

no test coverage detected