MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / test_feasibility_max_distance

Function test_feasibility_max_distance

tests/test_Solution.py:381–406  ·  view source on GitHub ↗

Tests that the maximum distance constraint affects solution and route feasibility when it is violated.

(ok_small)

Source from the content-addressed store, hash-verified

379
380
381def 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
409def test_distance_calculation(ok_small):

Callers

nothing calls this directly

Calls 5

SolutionClass · 0.90
VehicleTypeClass · 0.90
is_feasibleMethod · 0.80
replaceMethod · 0.80
distanceMethod · 0.45

Tested by

no test coverage detected