Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6796 for branches


Ignore:
Timestamp:
09/19/11 14:24:19 (13 years ago)
Author:
svonolfe
Message:

Fixed issue related to incremental evaluation (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators
Files:
2 edited

Legend:

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

    r6607 r6796  
    5252        individual.Tours[selectedIndex];
    5353
    54       List<int> replaced = new List<int>();
    55       for (int i = 0; i < route1.Stops.Count; i++) {
     54      int count = route1.Stops.Count;
     55      int i = 0;
     56      while(i < count) {
    5657        int insertedRoute, insertedPlace;
    5758
    58         if (FindInsertionPlace(individual, route1.Stops[i], selectedIndex, allowInfeasible, out insertedRoute, out insertedPlace)) {
    59           individual.Tours[insertedRoute].Stops.Insert(insertedPlace, route1.Stops[i]);
    60           replaced.Add(route1.Stops[i]);
     59        int city = route1.Stops[i];
     60        route1.Stops.Remove(city);
     61
     62        if (FindInsertionPlace(individual, city, selectedIndex, allowInfeasible, out insertedRoute, out insertedPlace)) {
     63          individual.Tours[insertedRoute].Stops.Insert(insertedPlace, city);
     64        } else {
     65          route1.Stops.Insert(i, city);
     66          i++;
    6167        }
     68
     69        count = route1.Stops.Count;
    6270      }
    6371
    64       route1.Stops.RemoveAll(
    65         new System.Predicate<int>(
    66           delegate(int val) {
    67             return (replaced.Contains(val));
    68           }
    69         )
    70       );
    71 
    72       if (route1.Stops.Count == 0)
    73         individual.Tours.Remove(route1);
    7472    }
    7573  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs

    r6607 r6796  
    6464              //customer1 can be feasibly inserted at the location of customer2
    6565              tour.Stops[customer2Position] = customer1;
     66              route1.Stops.RemoveAt(customer1Position);
     67
    6668              if (ProblemInstance.Feasible(tour)) {
    6769                int routeIdx, place;
     
    6971                  customer2, selectedIndex, allowInfeasible, out routeIdx, out place)) {
    7072                  individual.Tours[routeIdx].Stops.Insert(place, customer2);
    71                   route1.Stops.RemoveAt(customer1Position);
    72 
    73                   if (route1.Stops.Count == 0)
    74                     individual.Tours.Remove(route1);
    7573
    7674                  //two-level exchange has been performed
     
    7977                } else {
    8078                  tour.Stops[customer2Position] = customer2;
     79                  route1.Stops.Insert(customer1Position, customer1);
    8180                }
    8281              } else {
    8382                tour.Stops[customer2Position] = customer2;
     83                route1.Stops.Insert(customer1Position, customer1);
    8484              }
    8585            }
Note: See TracChangeset for help on using the changeset viewer.