Tests that the maximum distance constraint affects solution and route feasibility when it is violated.
(ok_small)
| 379 | |
| 380 | |
| 381 | def test_feasibility_max_distance(ok_small): |
| 382 | """ |
| 383 | Tests that the maximum distance constraint affects solution and route |
| 384 | feasibility when it is violated. |
| 385 | """ |
| 386 | sol = Solution(ok_small, [[1, 2], [3, 4]]) |
| 387 | assert_(sol.is_feasible()) |
| 388 | |
| 389 | vehicle_type = VehicleType(4, capacity=[10], max_distance=5_000) |
| 390 | data = ok_small.replace(vehicle_types=[vehicle_type]) |
| 391 | |
| 392 | sol = Solution(data, [[1, 2], [3, 4]]) |
| 393 | routes = sol.routes() |
| 394 | |
| 395 | assert_equal(routes[0].distance(), 5501) |
| 396 | assert_equal(routes[0].excess_distance(), 501) |
| 397 | assert_(not routes[0].has_time_warp()) |
| 398 | assert_(not routes[0].is_feasible()) |
| 399 | |
| 400 | assert_equal(routes[1].distance(), 4224) |
| 401 | assert_equal(routes[1].excess_distance(), 0) |
| 402 | assert_(routes[1].is_feasible()) |
| 403 | |
| 404 | assert_equal(sol.excess_distance(), 501) |
| 405 | assert_(sol.has_excess_distance()) |
| 406 | assert_(not sol.is_feasible()) |
| 407 | |
| 408 | |
| 409 | def test_distance_calculation(ok_small): |
nothing calls this directly
no test coverage detected