Tests the Solution's excess load calculation on a single-route case.
(ok_small)
| 434 | |
| 435 | |
| 436 | def test_excess_load_calculation(ok_small): |
| 437 | """ |
| 438 | Tests the Solution's excess load calculation on a single-route case. |
| 439 | """ |
| 440 | sol = Solution(ok_small, [[4, 3, 1, 2]]) |
| 441 | assert_(sol.has_excess_load()) |
| 442 | assert_(not sol.has_time_warp()) |
| 443 | |
| 444 | # All clients are visited on the same route/by the same vehicle. The total |
| 445 | # delivery demand is 18, but the vehicle capacity is only 10. |
| 446 | assert_equal(ok_small.num_load_dimensions, 1) |
| 447 | |
| 448 | needed = sum(client.delivery[0] for client in ok_small.clients()) |
| 449 | assert_equal(needed, 18) |
| 450 | |
| 451 | available = ok_small.vehicle_type(0).capacity[0] |
| 452 | assert_equal(available, 10) |
| 453 | |
| 454 | assert_equal(sol.excess_load(), [needed - available]) |
| 455 | |
| 456 | |
| 457 | @pytest.mark.parametrize( |