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

Method clear

pyvrp/cpp/search/Route.cpp:113–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void Route::clear()
114{
115 if (nodes.size() == 2) // then the route is already empty and we have
116 return; // nothing to do.
117
118 for (auto *node : nodes) // only unassign if in route; node may not
119 if (node->route() == this) // be if it's been assigned to another route
120 node->unassign(); // while loading a new solution into the LS
121
122 nodes.clear();
123 depots_.clear();
124
125 depots_.emplace_back(vehicleType_.startDepot);
126 depots_.emplace_back(vehicleType_.endDepot);
127
128 for (size_t idx : {0, 1})
129 {
130 nodes.push_back(&depots_[idx]);
131 depots_[idx].assign(this, idx, idx);
132 }
133
134 update();
135 assert(empty());
136}
137
138void Route::reserve(size_t size) { nodes.reserve(size); }
139

Callers 5

loadMethod · 0.45
unloadMethod · 0.45
updateMethod · 0.45

Calls 5

unassignMethod · 0.80
push_backMethod · 0.80
assignMethod · 0.80
sizeMethod · 0.45
routeMethod · 0.45