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

Method makeSchedule

pyvrp/cpp/Route.cpp:132–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void Route::makeSchedule(ProblemData const &data)
133{
134 schedule_.clear();
135 schedule_.reserve(size() + numTrips() + 1); // clients and depots
136
137 auto const &vehData = data.vehicleType(vehicleType_);
138 auto const &durations = data.durationMatrix(vehData.profile);
139
140 auto now = startTime_;
141 auto const handle = [&](size_t location,
142 size_t trip,
143 Duration early,
144 Duration late,
145 Duration service)
146 {
147 auto const wait = std::max<Duration>(early - now, 0);
148 auto const tw = std::max<Duration>(now - late, 0);
149
150 now += wait;
151 now -= tw;
152
153 schedule_.emplace_back(location, trip, now, now + service, wait, tw);
154
155 now += service;
156 };
157
158 for (size_t tripIdx = 0; tripIdx != trips_.size(); ++tripIdx)
159 {
160 auto const &trip = trips_[tripIdx];
161 ProblemData::Depot const &start = data.location(trip.startDepot());
162
163 auto const earliestStart = std::max(
164 start.twEarly, std::min(trip.releaseTime(), start.twLate));
165 auto const latestStart = tripIdx == 0 // first trip also accounts for
166 // the latest start constraint
167 ? std::min(start.twLate, vehData.startLate)
168 : start.twLate;
169
170 handle(trip.startDepot(),
171 tripIdx,
172 earliestStart,
173 latestStart,
174 start.serviceDuration);
175
176 size_t prevClient = trip.startDepot();
177 for (auto const client : trip)
178 {
179 now += durations(prevClient, client);
180
181 ProblemData::Client const &clientData = data.location(client);
182 handle(client,
183 tripIdx,
184 clientData.twEarly,
185 clientData.twLate,
186 clientData.serviceDuration);
187
188 prevClient = client;
189 }

Callers

nothing calls this directly

Calls 8

reserveMethod · 0.80
locationMethod · 0.80
clearMethod · 0.45
vehicleTypeMethod · 0.45
sizeMethod · 0.45
startDepotMethod · 0.45
releaseTimeMethod · 0.45
endDepotMethod · 0.45

Tested by

no test coverage detected