Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange
Files:
2 edited

Legend:

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

    r6773 r6909  
    6464
    6565      for (int i = 0; i < SampleSizeParameter.ActualValue.Value; i++) {
    66         result.Add(PotvinPDRearrangeSingleMoveGenerator.Apply(individual, ProblemInstance, RandomParameter.ActualValue));
     66        var move = PotvinPDRearrangeSingleMoveGenerator.Apply(individual, ProblemInstance, RandomParameter.ActualValue);
     67        if (move != null)
     68          result.Add(move);
    6769      }
    6870
  • 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.