| | double costBestAssignment = CONST_BIG_NUMBER; |
| | //additionalVehicle is added if there are no enough vehicles in the fleet |
| | for(int i = 0; i < routes.size(); i++){ |
| | currentAssignment[i] = i; |
| | } |
| | do{ |
| | vector<Route∗> currentAssignment; |
| | for(int i = 0; i < routes.size(); i++){ |
| | if(currentAssignment[i] < vehicles.size()) |
| | currentSolution.push_back(new Route(routes[i]->customers, vehicles[currentAssignment[i]], true)); |
| | else |
| | currentSolution.push_back(new Route(routes[i]->customers, additionalVehicle, true)); |
| | } |
| | double currentCost = SolutionCost (currentSolution); |
| | if(currentCost < bestCost){ |
| | for(int i = 0; i < routes.size(); i++){ |
| | bestAssignment[i] = currentAssignment[i]; |
| | } |
| | costBestAssignment = currentCost; |
| | } |
| | for(int i = 0; i < routes.size(); i++){ |
| | for(int j = 0; j < routes[i]->customers.size(); j++){ |
| | delete currentSolution[i]->customers[j]; |
| | } |
| | delete currentSolution[i]; |
| | } |
| | } while(next_permutation (currentAssignment, currentAssignment + routes.size())); |
| | for(int i = 0; i < routes.size(); i++){ |
| | if(bestAssignment[i] < vehicles.size()) |
| | routes[i] = new Route(routes[i]->customers, vehicles[bestAssignment[i]], true); |
| | else |
| | routes[i] = new Route(routes[i]->customers, additionalVehicle, true); |
| | } |