Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/19/10 14:37:48 (14 years ago)
Author:
svonolfe
Message:

Fixed a bug in the Local search manipulator (#1039)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/LocalSearchManipulator.cs

    r4206 r4265  
    3131  [StorableClass]
    3232  public sealed class LocalSearchManipulator : PotvinManipulator {
     33    public IValueParameter<IntValue> Iterations {
     34      get { return (IValueParameter<IntValue>)Parameters["Iterations"]; }
     35    }
     36
    3337    [StorableConstructor]
    3438    private LocalSearchManipulator(bool deserializing) : base(deserializing) { }
    3539
    36     public LocalSearchManipulator() : base() { }
     40    public LocalSearchManipulator() : base() {
     41      Parameters.Add(new ValueParameter<IntValue>("Iterations", "The number of max iterations.", new IntValue(100)));
     42    }
    3743
    3844    private bool FindBetterInsertionPlace(
     
    8086      if (Feasible(individual)) {
    8187        bool insertionFound;
     88        int iterations = 0;
    8289
    8390        do {
     
    99106                  individual.Tours[insertionTour].Cities.InsertRange(
    100107                    insertionPlace,
    101                     toBeInserted);
     108                    toBeInserted); 
    102109                }
    103110                city++;
     
    107114            length--;
    108115          }
    109         } while (insertionFound);
     116          iterations++;
     117        } while (insertionFound &&
     118          iterations < Iterations.Value.Value);
     119
     120        IList<Tour> toBeRemoved = new List<Tour>();
     121        foreach (Tour tour in individual.Tours) {
     122          if (tour.Cities.Count == 0)
     123            toBeRemoved.Add(tour);
     124        }
     125
     126        foreach (Tour tour in toBeRemoved) {
     127          individual.Tours.Remove(tour);
     128        }
    110129      }
    111130    }
Note: See TracChangeset for help on using the changeset viewer.