* LoadSegment(delivery: int, pickup: int, load: int, excess_load: int = 0) * * Creates a new load segment for delivery and pickup loads in a single * dimension. These load segments can be efficiently concatenated, and track * statistics about capacity violations resulting from visiting clients in the * concatenated order. * * Parameters * ---------- * delivery * Total delivery amount
| 28 | * Cumulative excess load on this segment, possibly from earlier trips. |
| 29 | */ |
| 30 | class LoadSegment |
| 31 | { |
| 32 | Load delivery_ = 0; // of client demand on current trip |
| 33 | Load pickup_ = 0; // of client demand on current trip |
| 34 | Load load_ = 0; // on current trip |
| 35 | Load excessLoad_ = 0; // cumulative excess load over other trips in segment |
| 36 | |
| 37 | public: |
| 38 | [[nodiscard]] static inline LoadSegment merge(LoadSegment const &first, |
| 39 | LoadSegment const &second); |
| 40 | |
| 41 | /** |
| 42 | * Finalises the load on this segment, and returns a new segment where any |
| 43 | * excess load has been moved to the cumulative excess load field. This is |
| 44 | * useful with reloading, because the finalised segment can be concatenated |
| 45 | * with load segments of subsequent trips. |
| 46 | */ |
| 47 | [[nodiscard]] inline LoadSegment finalise(Load capacity) const; |
| 48 | |
| 49 | /** |
| 50 | * Returns the delivery amount, that is, the total amount of load delivered |
| 51 | * to clients on this segment. |
| 52 | */ |
| 53 | [[nodiscard]] Load delivery() const; |
| 54 | |
| 55 | /** |
| 56 | * Returns the amount picked up from clients on this segment. |
| 57 | */ |
| 58 | [[nodiscard]] Load pickup() const; |
| 59 | |
| 60 | /** |
| 61 | * Returns the maximum load encountered on this segment. |
| 62 | */ |
| 63 | [[nodiscard]] Load load() const; |
| 64 | |
| 65 | /** |
| 66 | * Returns the load violation on this segment. |
| 67 | * |
| 68 | * Parameters |
| 69 | * ---------- |
| 70 | * capacity |
| 71 | * Segment capacity, if any. |
| 72 | */ |
| 73 | [[nodiscard]] inline Load excessLoad(Load capacity) const; |
| 74 | |
| 75 | LoadSegment() = default; // default is all zero |
| 76 | |
| 77 | // Construct from load attributes of the given client and dimension. |
| 78 | LoadSegment(ProblemData::Client const &client, size_t dimension); |
| 79 | |
| 80 | // Construct from initial load attributes of the given vehicle type and |
| 81 | // dimension. |
| 82 | LoadSegment(ProblemData::VehicleType const &vehicleType, size_t dimension); |
| 83 | |
| 84 | // Construct from raw data. |
| 85 | inline LoadSegment(Load delivery, |
| 86 | Load pickup, |
| 87 | Load load, |
no outgoing calls