Ignore:
Timestamp:
11/08/11 12:46:51 (11 years ago)
Author:
svonolfe
Message:

Improved compatibility of pairwise operators (#1177)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseOneLevelExchangeManipulator.cs

    r6960 r6966  
    133133    protected override void Manipulate(IRandom random, PotvinEncoding individual) {
    134134      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     135      IPickupAndDeliveryProblemInstance pdp = ProblemInstance as IPickupAndDeliveryProblemInstance;
    135136
    136       int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
    137       if (selectedIndex >= 0) {
    138         Tour route1 =
    139           individual.Tours[selectedIndex];
     137      if (pdp != null) {
     138        int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
     139        if (selectedIndex >= 0) {
     140          Tour route1 =
     141            individual.Tours[selectedIndex];
    140142
    141         int count = route1.Stops.Count;
     143          int count = route1.Stops.Count;
    142144
    143         if (count > 0) {
    144           int i = random.Next(0, count);
    145           int city = route1.Stops[i];
     145          if (count > 0) {
     146            int i = random.Next(0, count);
     147            int city = route1.Stops[i];
    146148
    147           if (!PairwiseMove(individual, city, allowInfeasible))
    148             i++;
     149            if (!PairwiseMove(individual, city, allowInfeasible))
     150              i++;
    149151
    150           count = route1.Stops.Count;
     152            count = route1.Stops.Count;
     153          }
    151154        }
    152155      }
Note: See TracChangeset for help on using the changeset viewer.