Skip to content
Snippets Groups Projects
Commit 0bda6263 authored by Romain BERNARD's avatar Romain BERNARD
Browse files

only increment vehicle id if insertion was a success (introduces side effect in while condition)

parent aabba5f7
No related branches found
No related tags found
1 merge request!2Route manipulation API with automatic constraint propagation
...@@ -37,10 +37,9 @@ size_t BestInsertionHeuristic::doBestRequestInsertionForRoute(size_t requestId, ...@@ -37,10 +37,9 @@ size_t BestInsertionHeuristic::doBestRequestInsertionForRoute(size_t requestId,
size_t vehicleId = 0; size_t vehicleId = 0;
bool insertionSuccess{false}; bool insertionSuccess{false};
//Iteratively try inserting in every active vehicle and the first inactive vehicle //Iteratively try inserting in every active vehicle and the first inactive vehicle
while(vehicleId <= route.getLastActiveVehicleId() + 1 && !insertionSuccess) { do {
insertionSuccess = tryVehicleBestInsertion(requestId, vehicleId, route); insertionSuccess = tryVehicleBestInsertion(requestId, vehicleId, route);
++vehicleId; } while(!insertionSuccess && ++vehicleId <= route.getLastActiveVehicleId() + 1);
}
//Update last active vehicle ID //Update last active vehicle ID
if(vehicleId > route.getLastActiveVehicleId()) { if(vehicleId > route.getLastActiveVehicleId()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment