| 229 | } |
| 230 | |
| 231 | DurationSegment DurationSegment::finaliseBack() const |
| 232 | { |
| 233 | // We finalise this segment by taking into account the end time of the |
| 234 | // previous trip, and then merging with this segment, finalised at the |
| 235 | // start, because that accounts for release times and our earliest and |
| 236 | // latest start (and, as a consequence, end). |
| 237 | DurationSegment const prev = {0, 0, 0, prevEndLate_}; |
| 238 | DurationSegment const finalised = merge(prev, finaliseFront()); |
| 239 | |
| 240 | return {0, |
| 241 | 0, |
| 242 | finalised.endEarly(), |
| 243 | // The next trip is free to start at any time after this trip can |
| 244 | // end, so the latest start is not constrained. However, starting |
| 245 | // after our latest end will incur wait duration at the depot. |
| 246 | std::numeric_limits<Duration>::max(), |
| 247 | // The next trip cannot leave the depot before we return, so we |
| 248 | // impose our earliest end as a release time. |
| 249 | finalised.endEarly(), |
| 250 | cumDuration_ + finalised.duration(), |
| 251 | cumTimeWarp_ + finalised.timeWarp(), |
| 252 | finalised.endLate()}; |
| 253 | } |
| 254 | |
| 255 | DurationSegment DurationSegment::finaliseFront() const |
| 256 | { |