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

Location:
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings
Files:
5 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      }
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCreator.cs

    r4352 r4692  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings {
     
    4142    [StorableConstructor]
    4243    protected VRPCreator(bool deserializing) : base(deserializing) { }
    43 
     44    protected VRPCreator(VRPCreator original, Cloner cloner)
     45      : base(original, cloner) {
     46    }
    4447    public VRPCreator()
    4548      : base() {
    4649      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The new VRP tours."));
    4750    }
    48 
    4951    #endregion
    5052  }
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCrossover.cs

    r4179 r4692  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings {
     
    4445    [StorableConstructor]
    4546    protected VRPCrossover(bool deserializing) : base(deserializing) { }
    46 
     47    protected VRPCrossover(VRPCrossover original, Cloner cloner)
     48      : base(original, cloner) {
     49    }
    4750    public VRPCrossover()
    4851      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPManipulator.cs

    r4183 r4692  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings {
     
    4041    [StorableConstructor]
    4142    protected VRPManipulator(bool deserializing) : base(deserializing) { }
    42 
     43    protected VRPManipulator(VRPManipulator original, Cloner cloner)
     44      : base(original, cloner) {
     45    }
    4346    public VRPManipulator()
    4447      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPMoveOperator.cs

    r4179 r4692  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.VehicleRouting.Encodings {
     
    3536      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; }
    3637    }
    37    
     38
    3839    #endregion
    3940
    4041    [StorableConstructor]
    4142    protected VRPMoveOperator(bool deserializing) : base(deserializing) { }
    42 
     43    protected VRPMoveOperator(VRPMoveOperator original, Cloner cloner) : base(original, cloner) { }
    4344    public VRPMoveOperator()
    4445      : base() {
Note: See TracChangeset for help on using the changeset viewer.