Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/12/11 15:45:48 (12 years ago)
Author:
svonolfe
Message:

Fixed more isses that occured in dynamic instances (#1177)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeSingleMoveGenerator.cs

    r6851 r6909  
    6262      IPickupAndDeliveryProblemInstance pdp = problemInstance as IPickupAndDeliveryProblemInstance;
    6363      for (int i = 1; i <= individual.Cities; i++) {
    64         if(pdp == null || pdp.GetDemand(i) >= 0)
     64        if (pdp == null || pdp.GetDemand(i) >= 0)
    6565          cities.Add(i);
    6666      }
    6767
    68       int city = cities[rand.Next(cities.Count)];
    69       int tour = individual.Tours.FindIndex(t => t.Stops.Contains(city));
    70       return new PotvinPDRearrangeMove(city, tour, individual);
     68      if (cities.Count > 0) {
     69        int city = cities[rand.Next(cities.Count)];
     70        int tour = individual.Tours.FindIndex(t => t.Stops.Contains(city));
     71        return new PotvinPDRearrangeMove(city, tour, individual);
     72      } else {
     73        return null;
     74      }
    7175    }
    7276
Note: See TracChangeset for help on using the changeset viewer.