Tests that solutions and routes calculate overtime correctly.
(ok_small_overtime)
| 889 | |
| 890 | |
| 891 | def test_overtime(ok_small_overtime): |
| 892 | """ |
| 893 | Tests that solutions and routes calculate overtime correctly. |
| 894 | """ |
| 895 | # The vehicle has a shift duration of 5_000, and allows another 1_000 |
| 896 | # overtime, if needed. This route takes 5'229 to complete, so the route |
| 897 | # should have 229 units of overtime. |
| 898 | route = Route(ok_small_overtime, [2, 4], 0) |
| 899 | |
| 900 | assert_(not route.has_time_warp()) |
| 901 | assert_equal(route.duration(), 5_229) |
| 902 | assert_equal(route.overtime(), 229) |
| 903 | |
| 904 | # Duration cost includes the cost of overtime. |
| 905 | assert_equal(route.duration_cost(), 1 * 5_229 + 10 * 229) |
| 906 | |
| 907 | # Test that a solution consisting of this single route agrees on these |
| 908 | # statistics. |
| 909 | sol = Solution(ok_small_overtime, [route]) |
| 910 | assert_(not sol.has_time_warp()) |
| 911 | assert_equal(sol.overtime(), route.overtime()) |
| 912 | assert_equal(sol.duration(), route.duration()) |
| 913 | assert_equal(sol.duration_cost(), route.duration_cost()) |