Tests that insert_cost() adds the fixed vehicle cost if the route is empty.
()
| 120 | |
| 121 | |
| 122 | def test_insert_fixed_vehicle_cost(): |
| 123 | """ |
| 124 | Tests that insert_cost() adds the fixed vehicle cost if the route is empty. |
| 125 | """ |
| 126 | cost_eval = CostEvaluator([], 0, 0) |
| 127 | data = ProblemData( |
| 128 | clients=[Client(x=1, y=1), Client(x=1, y=0)], |
| 129 | depots=[Depot(x=0, y=0)], |
| 130 | vehicle_types=[VehicleType(fixed_cost=7), VehicleType(fixed_cost=13)], |
| 131 | distance_matrices=[np.zeros((3, 3), dtype=int)], |
| 132 | duration_matrices=[np.zeros((3, 3), dtype=int)], |
| 133 | ) |
| 134 | |
| 135 | # All distances, durations, and loads are equal. So the only cost change |
| 136 | # can happen due to vehicle changes. In this, case we evaluate inserting a |
| 137 | # client into an empty route. That adds the fixed vehicle cost of 7 for |
| 138 | # this vehicle type. |
| 139 | route = Route(data, idx=0, vehicle_type=0) |
| 140 | assert_equal(insert_cost(Node(loc=1), route[0], data, cost_eval), 7) |
| 141 | |
| 142 | # Same story for this route, but now we have a different vehicle type with |
| 143 | # fixed cost 13. |
| 144 | route = Route(data, idx=0, vehicle_type=1) |
| 145 | assert_equal(insert_cost(Node(loc=1), route[0], data, cost_eval), 13) |
| 146 | |
| 147 | |
| 148 | def test_remove_fixed_vehicle_cost(): |
nothing calls this directly
no test coverage detected