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

Method apply

pyvrp/cpp/search/RelocateWithDepot.cpp:212–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212void RelocateWithDepot::apply(Route::Node *U, Route::Node *V) const
213{
214 stats_.numApplications++;
215
216 auto *uRoute = U->route();
217 uRoute->remove(U->idx());
218
219 auto *vRoute = V->route();
220 Route::Node depot = {move_.depot};
221
222 if (move_.type == MoveType::DEPOT_U)
223 {
224 vRoute->insert(V->idx() + 1, U);
225 vRoute->insert(V->idx() + 1, &depot);
226 }
227
228 // We need to be careful to insert the depot last, because doing so could
229 // invalidate V (it might trigger an update to the route's internal data
230 // layout, which could invalidate V if V is a depot).
231 if (move_.type == MoveType::U_DEPOT)
232 {
233 vRoute->insert(V->idx() + 1, U);
234 vRoute->insert(V->idx() + 2, &depot);
235 }
236}
237
238template <>
239bool pyvrp::search::supports<RelocateWithDepot>(ProblemData const &data)

Calls 4

removeMethod · 0.80
idxMethod · 0.80
routeMethod · 0.45
insertMethod · 0.45