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

Function test_remove_cost_zero_when_not_allowed

tests/search/test_primitives.py:90–103  ·  view source on GitHub ↗

Tests that remove_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

88
89
90def test_remove_cost_zero_when_not_allowed(ok_small):
91 """
92 Tests that remove_cost() returns zero when a move is not possible. This is
93 the only case where it shortcuts to return a non-negative delta cost.
94 """
95 cost_eval = CostEvaluator([1], 1, 0)
96 route = make_search_route(ok_small, [1, 2])
97
98 # Removing the depot is not possible.
99 assert_equal(remove_cost(route[0], ok_small, cost_eval), 0)
100 assert_equal(remove_cost(route[3], ok_small, cost_eval), 0)
101
102 # Removing a node that's not in a route is not possible.
103 assert_equal(remove_cost(Node(loc=3), ok_small, cost_eval), 0)
104
105
106def test_remove(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