Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (13 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.VehicleRouting

  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs

    r4352 r4722  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Data;
    25 using HeuristicLab.Encodings.PermutationEncoding;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using System.Drawing;
    28 using System.Collections.Generic;
    2927using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    3028
     
    3230  [Item("PotvinEncoding", "Represents a potvin encoding of VRP solutions. It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")]
    3331  [StorableClass]
    34   public class PotvinEncoding : TourEncoding {   
     32  public class PotvinEncoding : TourEncoding {
    3533    [Storable]
    3634    public List<int> Unrouted { get; set; }
    3735
    38     public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
    39       PotvinEncoding clone = new PotvinEncoding();
    40       cloner.RegisterClonedObject(this, clone);
    41       clone.Tours = (ItemList<Tour>)cloner.Clone(this.Tours);
    42       clone.Unrouted = new List<int>(Unrouted);
    43       return clone;
     36    [StorableConstructor]
     37    protected PotvinEncoding(bool deserializing) : base(deserializing) { }
     38    protected PotvinEncoding(PotvinEncoding original, Cloner cloner)
     39      : base(original, cloner) {
     40      Tours = cloner.Clone(original.Tours);
     41      Unrouted = new List<int>(original.Unrouted);
    4442    }
    45 
    46     public PotvinEncoding(): base() {
     43    public PotvinEncoding()
     44      : base() {
    4745      Unrouted = new List<int>();
    4846    }
    4947
    50     [StorableConstructor]
    51     private PotvinEncoding(bool serializing)
    52       : base() {
     48    public override IDeepCloneable Clone(Cloner cloner) {
     49      return new PotvinEncoding(this, cloner);
    5350    }
    54    
     51
    5552    public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter<DoubleMatrix> distanceMatrix) {
    5653      PotvinEncoding solution = new PotvinEncoding();
     
    8582            Tours[tour].Cities.Insert(i, city);
    8683
    87             if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, 
     84            if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
    8885              capacity, coordinates, distanceMatrix, useDistanceMatrix)) {
    89                 double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     86              double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
    9087
    9188              double detour = newLength - length;
Note: See TracChangeset for help on using the changeset viewer.