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

Method evalDepotAfter

pyvrp/cpp/search/RelocateWithDepot.cpp:112–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void RelocateWithDepot::evalDepotAfter(Cost fixedCost,
113 Route::Node *U,
114 Route::Node *V,
115 CostEvaluator const &costEvaluator)
116{
117 auto const *uRoute = U->route();
118 auto const *vRoute = V->route();
119 auto const &vehType = data.vehicleType(vRoute->vehicleType());
120
121 if (uRoute != vRoute)
122 {
123 auto const uProposal = Route::Proposal(uRoute->before(U->idx() - 1),
124 uRoute->after(U->idx() + 1));
125
126 for (auto const depot : vehType.reloadDepots)
127 {
128 Cost deltaCost = fixedCost;
129 costEvaluator.deltaCost(
130 deltaCost,
131 uProposal,
132 Route::Proposal(vRoute->before(V->idx()),
133 uRoute->at(U->idx()),
134 ReloadDepotSegment(data, depot),
135 vRoute->after(V->idx() + 1)));
136
137 if (deltaCost < move_.cost)
138 move_ = {deltaCost, MoveType::U_DEPOT, depot};
139 }
140 }
141 else // within same route
142 {
143 auto const *route = vRoute;
144 for (auto const depot : vehType.reloadDepots)
145 {
146 Cost deltaCost = fixedCost;
147 if (U->idx() < V->idx())
148 costEvaluator.deltaCost(
149 deltaCost,
150 Route::Proposal(route->before(U->idx() - 1),
151 route->between(U->idx() + 1, V->idx()),
152 route->at(U->idx()),
153 ReloadDepotSegment(data, depot),
154 route->after(V->idx() + 1)));
155 else
156 costEvaluator.deltaCost(
157 deltaCost,
158 Route::Proposal(route->before(V->idx()),
159 route->at(U->idx()),
160 ReloadDepotSegment(data, depot),
161 route->between(V->idx() + 1, U->idx() - 1),
162 route->after(U->idx() + 1)));
163
164 if (deltaCost < move_.cost)
165 move_ = {deltaCost, MoveType::U_DEPOT, depot};
166 }
167 }
168}
169

Callers

nothing calls this directly

Calls 10

ProposalClass · 0.85
ReloadDepotSegmentClass · 0.85
beforeMethod · 0.80
idxMethod · 0.80
afterMethod · 0.80
deltaCostMethod · 0.80
atMethod · 0.80
betweenMethod · 0.80
routeMethod · 0.45
vehicleTypeMethod · 0.45

Tested by

no test coverage detected