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

Function test_insert_cost_zero_when_not_allowed

tests/search/test_primitives.py:15–28  ·  view source on GitHub ↗

Tests that insert_cost() returns zero when a move is not possible. This is the only case where it shortcuts to return a non-negative delta cost.

(ok_small)

Source from the content-addressed store, hash-verified

13
14
15def test_insert_cost_zero_when_not_allowed(ok_small):
16 """
17 Tests that insert_cost() returns zero when a move is not possible. This is
18 the only case where it shortcuts to return a non-negative delta cost.
19 """
20 cost_eval = CostEvaluator([1], 1, 0)
21 route = make_search_route(ok_small, [1, 2])
22
23 # Inserting the depot is not possible.
24 assert_equal(insert_cost(route[0], route[1], ok_small, cost_eval), 0)
25 assert_equal(insert_cost(route[3], route[2], ok_small, cost_eval), 0)
26
27 # Inserting after a node that's not in a route is not possible.
28 assert_equal(insert_cost(route[1], Node(loc=3), ok_small, cost_eval), 0)
29
30
31def test_insert_cost(ok_small):

Callers

nothing calls this directly

Calls 3

CostEvaluatorClass · 0.90
make_search_routeFunction · 0.90
NodeClass · 0.85

Tested by

no test coverage detected