| 84 | |
| 85 | template <size_t N, size_t M> |
| 86 | Cost Exchange<N, M>::evalRelocateMove(Route::Node *U, |
| 87 | Route::Node *V, |
| 88 | CostEvaluator const &costEvaluator) const |
| 89 | { |
| 90 | assert(U->idx() > 0); |
| 91 | |
| 92 | Cost deltaCost = 0; |
| 93 | |
| 94 | if (U->route() != V->route()) |
| 95 | { |
| 96 | auto const *uRoute = U->route(); |
| 97 | auto const *vRoute = V->route(); |
| 98 | |
| 99 | // We're going to incur V's fixed cost if V is currently empty. |
| 100 | if (V->isStartDepot() && vRoute->empty()) |
| 101 | deltaCost += vRoute->fixedVehicleCost(); |
| 102 | |
| 103 | // We lose U's fixed cost if we're moving all U's clients. |
| 104 | if (uRoute->numClients() == N) |
| 105 | deltaCost -= uRoute->fixedVehicleCost(); |
| 106 | |
| 107 | auto const uProposal = Route::Proposal(uRoute->before(U->idx() - 1), |
| 108 | uRoute->after(U->idx() + N)); |
| 109 | |
| 110 | auto const vProposal |
| 111 | = Route::Proposal(vRoute->before(V->idx()), |
| 112 | uRoute->between(U->idx(), U->idx() + N - 1), |
| 113 | vRoute->after(V->idx() + 1)); |
| 114 | |
| 115 | costEvaluator.deltaCost(deltaCost, uProposal, vProposal); |
| 116 | } |
| 117 | else // within same route |
| 118 | { |
| 119 | auto *route = U->route(); |
| 120 | |
| 121 | if (U->idx() < V->idx()) |
| 122 | costEvaluator.deltaCost( |
| 123 | deltaCost, |
| 124 | Route::Proposal(route->before(U->idx() - 1), |
| 125 | route->between(U->idx() + N, V->idx()), |
| 126 | route->between(U->idx(), U->idx() + N - 1), |
| 127 | route->after(V->idx() + 1))); |
| 128 | else |
| 129 | costEvaluator.deltaCost( |
| 130 | deltaCost, |
| 131 | Route::Proposal(route->before(V->idx()), |
| 132 | route->between(U->idx(), U->idx() + N - 1), |
| 133 | route->between(V->idx() + 1, U->idx() - 1), |
| 134 | route->after(U->idx() + N))); |
| 135 | } |
| 136 | |
| 137 | return deltaCost; |
| 138 | } |
| 139 | |
| 140 | template <size_t N, size_t M> |
| 141 | Cost Exchange<N, M>::evalSwapMove(Route::Node *U, |
nothing calls this directly
no test coverage detected