| 99 | } |
| 100 | |
| 101 | void Route::validate(ProblemData const &data) const |
| 102 | { |
| 103 | auto const &vehData = data.vehicleType(vehicleType_); |
| 104 | |
| 105 | if (trips_.size() > vehData.maxTrips()) |
| 106 | throw std::invalid_argument("Vehicle cannot perform this many trips."); |
| 107 | |
| 108 | if (trips_[0].startDepot() != startDepot_) |
| 109 | { |
| 110 | auto const *msg = "Route must start at vehicle's start_depot."; |
| 111 | throw std::invalid_argument(msg); |
| 112 | } |
| 113 | |
| 114 | if (trips_.back().endDepot() != endDepot_) |
| 115 | throw std::invalid_argument("Route must end at vehicle's end_depot."); |
| 116 | |
| 117 | for (auto const &trip : trips_) |
| 118 | if (trip.vehicleType() != vehicleType_) |
| 119 | { |
| 120 | auto const *msg = "Each trip must use the route's vehicle type."; |
| 121 | throw std::invalid_argument(msg); |
| 122 | } |
| 123 | |
| 124 | for (size_t idx = 0; idx + 1 != trips_.size(); ++idx) |
| 125 | if (trips_[idx].endDepot() != trips_[idx + 1].startDepot()) |
| 126 | { |
| 127 | auto *msg = "Consecutive trips must start at previous' end_depot."; |
| 128 | throw std::invalid_argument(msg); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | void Route::makeSchedule(ProblemData const &data) |
| 133 | { |
nothing calls this directly
no test coverage detected