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

Method validate

pyvrp/cpp/Route.cpp:101–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void 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
132void Route::makeSchedule(ProblemData const &data)
133{

Callers

nothing calls this directly

Calls 5

vehicleTypeMethod · 0.45
sizeMethod · 0.45
maxTripsMethod · 0.45
startDepotMethod · 0.45
endDepotMethod · 0.45

Tested by

no test coverage detected