| 191 | |
| 192 | template <size_t N, size_t M> |
| 193 | Cost Exchange<N, M>::evaluate(Route::Node *U, |
| 194 | Route::Node *V, |
| 195 | CostEvaluator const &costEvaluator) |
| 196 | { |
| 197 | stats_.numEvaluations++; |
| 198 | |
| 199 | if (containsDepot(U, N) || overlap(U, V)) |
| 200 | return 0; |
| 201 | |
| 202 | if constexpr (M > 0) |
| 203 | if (containsDepot(V, M)) |
| 204 | return 0; |
| 205 | |
| 206 | // We cannot easily evaluate across trips, so we cannot determine this move. |
| 207 | if (U->route() == V->route() && U->trip() != V->trip()) |
| 208 | return 0; |
| 209 | |
| 210 | if constexpr (M == 0) // special case where nothing in V is moved |
| 211 | { |
| 212 | if (U == n(V)) |
| 213 | return 0; |
| 214 | |
| 215 | return evalRelocateMove(U, V, costEvaluator); |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | if constexpr (N == M) // symmetric, so only have to evaluate this once |
| 220 | if (U->client() >= V->client()) |
| 221 | return 0; |
| 222 | |
| 223 | if (adjacent(U, V)) |
| 224 | return 0; |
| 225 | |
| 226 | return evalSwapMove(U, V, costEvaluator); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | template <size_t N, size_t M> |
| 231 | void Exchange<N, M>::apply(Route::Node *U, Route::Node *V) const |
no test coverage detected