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

Method evaluate

pyvrp/cpp/search/Exchange.h:193–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192template <size_t N, size_t M>
193Cost 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
230template <size_t N, size_t M>
231void Exchange<N, M>::apply(Route::Node *U, Route::Node *V) const

Callers 2

applyNodeOpsMethod · 0.45
applyRouteOpsMethod · 0.45

Calls 4

nFunction · 0.85
tripMethod · 0.80
clientMethod · 0.80
routeMethod · 0.45

Tested by

no test coverage detected