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

Function test_insert_fixed_vehicle_cost

tests/search/test_primitives.py:122–145  ·  view source on GitHub ↗

Tests that insert_cost() adds the fixed vehicle cost if the route is empty.

()

Source from the content-addressed store, hash-verified

120
121
122def test_insert_fixed_vehicle_cost():
123 """
124 Tests that insert_cost() adds the fixed vehicle cost if the route is empty.
125 """
126 cost_eval = CostEvaluator([], 0, 0)
127 data = ProblemData(
128 clients=[Client(x=1, y=1), Client(x=1, y=0)],
129 depots=[Depot(x=0, y=0)],
130 vehicle_types=[VehicleType(fixed_cost=7), VehicleType(fixed_cost=13)],
131 distance_matrices=[np.zeros((3, 3), dtype=int)],
132 duration_matrices=[np.zeros((3, 3), dtype=int)],
133 )
134
135 # All distances, durations, and loads are equal. So the only cost change
136 # can happen due to vehicle changes. In this, case we evaluate inserting a
137 # client into an empty route. That adds the fixed vehicle cost of 7 for
138 # this vehicle type.
139 route = Route(data, idx=0, vehicle_type=0)
140 assert_equal(insert_cost(Node(loc=1), route[0], data, cost_eval), 7)
141
142 # Same story for this route, but now we have a different vehicle type with
143 # fixed cost 13.
144 route = Route(data, idx=0, vehicle_type=1)
145 assert_equal(insert_cost(Node(loc=1), route[0], data, cost_eval), 13)
146
147
148def test_remove_fixed_vehicle_cost():

Callers

nothing calls this directly

Calls 7

CostEvaluatorClass · 0.90
ProblemDataClass · 0.90
ClientClass · 0.90
DepotClass · 0.90
VehicleTypeClass · 0.90
NodeClass · 0.85
RouteClass · 0.50

Tested by

no test coverage detected