Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/30/11 11:36:05 (13 years ago)
Author:
svonolfe
Message:

Added support for the multi depot CVRP with time windows (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/ExtendedPotvin/Creators/PushForwardInsertionCreator.cs

    r6851 r6854  
    182182            double dueTime = 0;
    183183            if (problemInstance is ITimeWindowedProblemInstance)
    184               dueTime = (problemInstance as ITimeWindowedProblemInstance).DueTime[i];
     184              dueTime = (problemInstance as ITimeWindowedProblemInstance).DueTime[i + depots - 1];
    185185
    186186            cost = -alpha * distance + // distance 0 <-> City[i]
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinCustomerRelocationManipulator.cs

    r6851 r6854  
    146146          DoubleArray serviceTimes = vrptw.ServiceTime;
    147147
     148          int depot = 0;
     149          int depots = 1;
     150
     151          int tourIndex = individual.GetTourIndex(route1);
     152          int vehicle = individual.GetVehicleAssignment(tourIndex);
     153
     154          if (ProblemInstance is IMultiDepotProblemInstance) {
     155            depots = (ProblemInstance as IMultiDepotProblemInstance).Depots.Value;
     156            depot = (ProblemInstance as IMultiDepotProblemInstance).VehicleDepotAssignment[vehicle];
     157          }
     158
    148159          List<int> timeWindowViolations = new List<int>();
    149160          double time = 0;
    150161
    151162          for (int i = 0; i < route1.Stops.Count; i++) {
    152             int start = 0;
    153             if (i > 0)
    154               start = route1.Stops[i - 1];
    155             int end = 0;
    156             if (i < route1.Stops.Count)
    157               end = route1.Stops[i];
     163            int start = route1.Stops[i - 1];
     164            int end = route1.Stops[i];
    158165
    159166            //drive there
     
    161168            time += currentDistace;
    162169
     170            int endIndex = end + depots - 1;
     171
    163172            //check if it was serviced on time
    164             if (time > dueTime[end]) {
     173            if (time > dueTime[endIndex]) {
    165174              timeWindowViolations.Add(end);
    166175            }
     
    168177            //wait
    169178            double currentWaitingTime = 0.0;
    170             if (time < readyTime[end])
    171               currentWaitingTime = readyTime[end] - time;
     179            if (time < readyTime[endIndex])
     180              currentWaitingTime = readyTime[endIndex] - time;
    172181            time += currentWaitingTime;
    173182
    174183            //service
    175             double currentServiceTime = serviceTimes[end];
     184            double currentServiceTime = serviceTimes[end - 1];
    176185            time += currentServiceTime;
    177186          }
Note: See TracChangeset for help on using the changeset viewer.