Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6491


Ignore:
Timestamp:
06/28/11 09:25:10 (13 years ago)
Author:
svonolfe
Message:

Fixed compiler warnings (#1561)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinInsertionBasedCrossover.cs

    r6459 r6491  
    3434    public IValueParameter<IntValue> Length {
    3535      get { return (IValueParameter<IntValue>)Parameters["Length"]; }
    36     } 
     36    }
    3737
    3838    [StorableConstructor]
     
    4646    public PotvinInsertionBasedCrossover()
    4747      : base() {
    48         Parameters.Add(new ValueParameter<IntValue>("Length", "The maximum length of the replaced route.", new IntValue(1)));
    49     }
    50 
    51     protected static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {
     48      Parameters.Add(new ValueParameter<IntValue>("Length", "The maximum length of the replaced route.", new IntValue(1)));
     49    }
     50
     51    private static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {
    5252      int tourIndex = -1;
    5353
     
    119119        if (next >= tour.Cities.Count)
    120120          next = 0;
    121         else 
     121        else
    122122          next = tour.Cities[next];
    123123        double distance = VRPUtilities.GetDistance(
     
    192192    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    193193      PotvinEncoding child = new PotvinEncoding();
    194       bool success = true;
    195194
    196195      BoolValue useDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
     
    236235
    237236        //REPAIR - add cities from R2
    238         bool insertSuccess = true;
    239237        int maxCount = random.Next(1, Math.Min(5, R2.Count));
    240238        int count = 0;
     
    249247
    250248          int place = -1;
    251           if(FindRouteInsertionPlace(childTour, dueTime, serviceTime, readyTime,
     249          if (FindRouteInsertionPlace(childTour, dueTime, serviceTime, readyTime,
    252250            demand, capacity, distMatrix, city, allowInfeasible, out place)) {
    253251            childTour.Cities.Insert(place, city);
     
    255253            if (!Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible)) {
    256254              childTour.Cities.RemoveAt(place);
    257               insertSuccess = false;
    258255            } else {
    259256              count++;
    260             } 
    261           } 
     257            }
     258          }
    262259        }
    263260
    264261        child.Tours.Add(childTour);
    265         if (!Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible)) {
    266           /*success = false;
    267           break;*/
    268         }
    269       }
    270 
    271       if (success) {
    272         for (int i = 0; i < p1Clone.Tours.Count; i++) {
    273           Tour childTour = p1Clone.Tours[i].Clone() as Tour;
    274           child.Tours.Add(childTour);
    275           if (!Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible)) {
    276             /*success = false;
    277             break;*/
    278           }
    279         }
    280       }
    281 
    282       if (success) {
    283         //route unrouted customers
    284         for (int i = 1; i <= parent1.Cities; i++) {
    285           if (FindRoute(child, i) == null)
    286             child.Unrouted.Add(i);
    287         }
    288 
    289         if (!RouteUnrouted(child, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible)) {
    290           success = false;
    291         }
     262        Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible);
     263      }
     264
     265      for (int i = 0; i < p1Clone.Tours.Count; i++) {
     266        Tour childTour = p1Clone.Tours[i].Clone() as Tour;
     267        child.Tours.Add(childTour);
     268        Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible);
     269      }
     270
     271      //route unrouted customers
     272      for (int i = 1; i <= parent1.Cities; i++) {
     273        if (FindRoute(child, i) == null)
     274          child.Unrouted.Add(i);
     275      }
     276
     277      bool success = true;
     278      if (!RouteUnrouted(child, distMatrix, dueTime, readyTime, serviceTime, demand, capacity, allowInfeasible)) {
     279        success = false;
    292280      }
    293281
     
    298286          return parent1.Clone() as PotvinEncoding;
    299287        else
    300           return parent2.Clone() as PotvinEncoding;   
     288          return parent2.Clone() as PotvinEncoding;
    301289      }
    302290    }
Note: See TracChangeset for help on using the changeset viewer.