Smoke test to check that the model can solve an instance with multiple trips / reloading.
()
| 1044 | |
| 1045 | |
| 1046 | def 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 | |
| 1079 | def test_instance_with_multi_trip_and_release_times(mtvrptw_release_times): |
nothing calls this directly
no test coverage detected