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

Method evalDepotBefore

pyvrp/cpp/search/RelocateWithDepot.cpp:54–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52} // namespace
53
54void RelocateWithDepot::evalDepotBefore(Cost fixedCost,
55 Route::Node *U,
56 Route::Node *V,
57 CostEvaluator const &costEvaluator)
58{
59 auto const *uRoute = U->route();
60 auto const *vRoute = V->route();
61 auto const &vehType = data.vehicleType(vRoute->vehicleType());
62
63 if (uRoute != vRoute)
64 {
65 auto const uProposal = Route::Proposal(uRoute->before(U->idx() - 1),
66 uRoute->after(U->idx() + 1));
67
68 for (auto const depot : vehType.reloadDepots)
69 {
70 auto deltaCost = fixedCost;
71 costEvaluator.deltaCost(
72 deltaCost,
73 uProposal,
74 Route::Proposal(vRoute->before(V->idx()),
75 ReloadDepotSegment(data, depot),
76 uRoute->at(U->idx()),
77 vRoute->after(V->idx() + 1)));
78
79 if (deltaCost < move_.cost)
80 move_ = {deltaCost, MoveType::DEPOT_U, depot};
81 }
82 }
83 else // within same route
84 {
85 auto const *route = vRoute;
86 for (auto const depot : vehType.reloadDepots)
87 {
88 auto deltaCost = fixedCost;
89 if (U->idx() < V->idx())
90 costEvaluator.deltaCost(
91 deltaCost,
92 Route::Proposal(route->before(U->idx() - 1),
93 route->between(U->idx() + 1, V->idx()),
94 ReloadDepotSegment(data, depot),
95 route->at(U->idx()),
96 route->after(V->idx() + 1)));
97 else
98 costEvaluator.deltaCost(
99 deltaCost,
100 Route::Proposal(route->before(V->idx()),
101 ReloadDepotSegment(data, depot),
102 route->at(U->idx()),
103 route->between(V->idx() + 1, U->idx() - 1),
104 route->after(U->idx() + 1)));
105
106 if (deltaCost < move_.cost)
107 move_ = {deltaCost, MoveType::DEPOT_U, depot};
108 }
109 }
110}
111

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