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

Method update

pyvrp/cpp/search/Route.cpp:229–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229void Route::update()
230{
231 visits.clear();
232 for (auto const *node : nodes)
233 visits.emplace_back(node->client());
234
235 centroid_ = {0, 0};
236 for (auto const *node : nodes)
237 {
238 if (node->isDepot())
239 continue;
240
241 ProblemData::Client const &clientData = data.location(node->client());
242 centroid_.first += static_cast<double>(clientData.x) / numClients();
243 centroid_.second += static_cast<double>(clientData.y) / numClients();
244 }
245
246 // Distance.
247 auto const &distMat = data.distanceMatrix(profile());
248
249 cumDist.resize(nodes.size());
250 cumDist[0] = 0;
251 for (size_t idx = 1; idx != nodes.size(); ++idx)
252 cumDist[idx] = cumDist[idx - 1] + distMat(visits[idx - 1], visits[idx]);
253
254 // Duration.
255 durAt.resize(nodes.size());
256
257 ProblemData::Depot const &start = data.location(startDepot());
258 DurationSegment const vehStart(vehicleType_, vehicleType_.startLate);
259 DurationSegment const depotStart(start, start.serviceDuration);
260 durAt[0] = DurationSegment::merge(vehStart, depotStart);
261
262 ProblemData::Depot const &end = data.location(endDepot());
263 DurationSegment const depotEnd(end, 0);
264 DurationSegment const vehEnd(vehicleType_, vehicleType_.twLate);
265 durAt[nodes.size() - 1] = DurationSegment::merge(depotEnd, vehEnd);
266
267 for (size_t idx = 1; idx != nodes.size() - 1; ++idx)
268 {
269 auto const *node = nodes[idx];
270
271 if (!node->isReloadDepot())
272 {
273 ProblemData::Client const &client = data.location(node->client());
274 durAt[idx] = {client};
275 }
276 else
277 {
278 ProblemData::Depot const &depot = data.location(node->client());
279 durAt[idx] = {depot, 0};
280 }
281 }
282
283 auto const &durations = data.durationMatrix(profile());
284
285 durBefore.resize(nodes.size());
286 durBefore[0] = durAt[0];

Calls 15

clientMethod · 0.80
isDepotMethod · 0.80
locationMethod · 0.80
isReloadDepotMethod · 0.80
finaliseBackMethod · 0.80
finaliseFrontMethod · 0.80
numLoadDimensionsMethod · 0.80
finaliseMethod · 0.80
idxMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
excessLoadMethod · 0.45