Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8653


Ignore:
Timestamp:
09/14/12 10:09:29 (12 years ago)
Author:
svonolfe
Message:

vehicles were not assigned correctly when a solution includes empty trips (#1953)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs

    r8053 r8653  
    6969      foreach (Tour tour in toBeRemoved) {
    7070        int index = Tours.IndexOf(tour);
     71        Tours.Remove(tour);
    7172        if (index < VehicleAssignment.Length) {
    7273          int vehicle = VehicleAssignment[index];
    73 
    74           Tours.Remove(tour);
    75           for (int i = index; i < VehicleAssignment.Length - 1; i++) {
     74          int max = System.Math.Min(VehicleAssignment.Length - 1, Tours.Count);
     75
     76          for (int i = index; i < max; i++) {
    7677            VehicleAssignment[i] = VehicleAssignment[i + 1];
    7778          }
    78           VehicleAssignment[VehicleAssignment.Length - 1] = vehicle;
     79          VehicleAssignment[max] = vehicle;
    7980        }
    8081      }
Note: See TracChangeset for help on using the changeset viewer.