MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / unload

Method unload

pyvrp/cpp/search/Solution.cpp:88–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88pyvrp::Solution Solution::unload() const
89{
90 std::vector<pyvrp::Route> solRoutes;
91 solRoutes.reserve(data_.numVehicles());
92
93 std::vector<size_t> visits;
94
95 for (auto const &route : routes)
96 {
97 if (route.empty())
98 continue;
99
100 std::vector<Trip> trips;
101 trips.reserve(route.numTrips());
102
103 visits.clear();
104 visits.reserve(route.numClients());
105
106 auto const *prevDepot = route[0];
107 for (size_t idx = 1; idx != route.size(); ++idx)
108 {
109 auto const *node = route[idx];
110
111 if (!node->isDepot())
112 {
113 visits.push_back(node->client());
114 continue;
115 }
116
117 trips.emplace_back(data_,
118 visits,
119 route.vehicleType(),
120 prevDepot->client(),
121 node->client());
122
123 visits.clear();
124 prevDepot = node;
125 }
126
127 assert(trips.size() == route.numTrips());
128 solRoutes.emplace_back(data_, std::move(trips), route.vehicleType());
129 }
130
131 return {data_, std::move(solRoutes)};
132}
133
134bool Solution::insert(Route::Node *U,
135 SearchSpace const &searchSpace,

Callers 9

test_load_unloadFunction · 0.95
operator()Method · 0.80
searchMethod · 0.80
intensifyMethod · 0.80

Calls 11

reserveMethod · 0.80
numVehiclesMethod · 0.80
isDepotMethod · 0.80
push_backMethod · 0.80
clientMethod · 0.80
emptyMethod · 0.45
numTripsMethod · 0.45
clearMethod · 0.45
numClientsMethod · 0.45
sizeMethod · 0.45
vehicleTypeMethod · 0.45