Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 20:36:25 (14 years ago)
Author:
gkronber
Message:

Refactored cloning in HeuristicLab.Problems.VehicleRouting. #922

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Tour.cs

    r4174 r4692  
    3232    public List<int> Cities { get; private set; }
    3333
     34    [StorableConstructor]
     35    protected Tour(bool deserializing) : base(deserializing) { }
     36    protected Tour(Tour original, Cloner cloner)
     37      : base(original, cloner) {
     38      Cities = new List<int>(original.Cities);
     39    }
    3440    public Tour() {
    3541      Cities = new List<int>();
     
    3743
    3844    public override IDeepCloneable Clone(Cloner cloner) {
    39       Tour clone = base.Clone(cloner) as Tour;
    40       clone.Cities = new List<int>(Cities);
    41 
    42       return clone;
     45      return new Tour(this, cloner);
    4346    }
    4447
     
    6366      return eval.Overload < double.Epsilon && eval.Tardiness < double.Epsilon;
    6467    }
    65    
    66     public double GetLength(DoubleMatrix coordinates, 
    67       ILookupParameter<DoubleMatrix> distanceMatrix, 
     68
     69    public double GetLength(DoubleMatrix coordinates,
     70      ILookupParameter<DoubleMatrix> distanceMatrix,
    6871      BoolValue useDistanceMatrix) {
    6972      double length = 0;
     
    7982        for (int i = 1; i < cities.Count; i++) {
    8083          length += VRPUtilities.GetDistance(
    81             cities[i - 1], cities[i], coordinates, distanceMatrix, useDistanceMatrix); 
     84            cities[i - 1], cities[i], coordinates, distanceMatrix, useDistanceMatrix);
    8285        }
    8386      }
Note: See TracChangeset for help on using the changeset viewer.