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

Method bestInsertPoint

pyvrp/cpp/search/SwapStar.cpp:101–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101SwapStar::InsertPoint SwapStar::bestInsertPoint(
102 Route::Node *U, Route::Node *V, CostEvaluator const &costEvaluator)
103{
104 auto *route = V->route();
105
106 if (!isCached(route->idx(), U->client()))
107 updateInsertPoints(route, U, costEvaluator);
108
109 for (auto [cost, where] : insertCache(route->idx(), U->client()))
110 if (where && where != V && n(where) != V && V->trip() == where->trip())
111 // Only if V is not adjacent. We also require that V is in the same
112 // trip as the node we plan to remove, because we cannot currently
113 // evaluate segments with intermediate reloads in them.
114 return std::make_pair(cost, where);
115
116 // As a fallback option, we consider inserting in the place of V.
117 Cost deltaCost = 0;
118 costEvaluator.deltaCost<true, true>(
119 deltaCost,
120 Route::Proposal(route->before(V->idx() - 1),
121 U->route()->at(U->idx()),
122 route->after(V->idx() + 1)));
123
124 return std::make_pair(deltaCost, p(V));
125}
126
127Cost SwapStar::evaluateMove(Route::Node const *U,
128 Route::Node const *V,

Callers

nothing calls this directly

Calls 10

nFunction · 0.85
ProposalClass · 0.85
pFunction · 0.85
idxMethod · 0.80
clientMethod · 0.80
tripMethod · 0.80
beforeMethod · 0.80
atMethod · 0.80
afterMethod · 0.80
routeMethod · 0.45

Tested by

no test coverage detected