Changeset 4687


Ignore:
Timestamp:
10/29/10 20:21:04 (9 years ago)
Author:
mkommend
Message:

Refactored VRP Encodings.General and Zhu (ticket #922).

Location:
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/DefaultRepresentationCreator.cs

    r4183 r4687  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    24 using HeuristicLab.Operators;
    25 using HeuristicLab.Parameters;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using System.Collections.Generic;
    28 using HeuristicLab.Problems.VehicleRouting.Encodings;
    29 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
    3026using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    3127
     
    3834    [StorableConstructor]
    3935    protected DefaultRepresentationCreator(bool deserializing) : base(deserializing) { }
     36    protected DefaultRepresentationCreator(DefaultRepresentationCreator original, Cloner cloner) : base(original, cloner) { }
    4037
    4138    public DefaultRepresentationCreator() : base() { }
     
    4643
    4744      return base.Apply();
    48     }   
     45    }
    4946  }
    5047}
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/MultiVRPSolutionCreator.cs

    r4352 r4687  
    2323using System.Linq;
    2424using HeuristicLab.Collections;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2628using HeuristicLab.Operators;
    2729using HeuristicLab.Optimization;
     
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3032using HeuristicLab.PluginInfrastructure;
    31 using HeuristicLab.Data;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    7980    [StorableConstructor]
    8081    private MultiVRPSolutionCreator(bool deserializing) : base(deserializing) { }
     82    protected MultiVRPSolutionCreator(MultiVRPSolutionCreator original, Cloner cloner) : base(original, cloner) { }
     83    public override IDeepCloneable Clone(Cloner cloner) {
     84      return new MultiVRPSolutionCreator(this, cloner);
     85    }
     86
    8187    public MultiVRPSolutionCreator()
    8288      : base() {
    83         Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The new VRP tours."));
     89      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The new VRP tours."));
    8490
    85         Parameters.Add(new ValueLookupParameter<IntValue>("Cities", "The city count."));
    86         Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
    87         Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    88         Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
    89         Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The number of vehicles."));
    90         Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle."));
    91         Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer."));
    92         Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer."));
    93         Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer."));
    94         Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
     91      Parameters.Add(new ValueLookupParameter<IntValue>("Cities", "The city count."));
     92      Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
     93      Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
     94      Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
     95      Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The number of vehicles."));
     96      Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle."));
     97      Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer."));
     98      Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer."));
     99      Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer."));
     100      Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer."));
    95101
    96         foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IVRPCreator)).OrderBy(op => op.Name)) {
    97           if (!typeof(MultiOperator<IVRPCreator>).IsAssignableFrom(type))
    98             Operators.Add((IVRPCreator)Activator.CreateInstance(type), true);
     102      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IVRPCreator)).OrderBy(op => op.Name)) {
     103        if (!typeof(MultiOperator<IVRPCreator>).IsAssignableFrom(type))
     104          Operators.Add((IVRPCreator)Activator.CreateInstance(type), true);
    99105      }
    100106    }
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs

    r4352 r4687  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    26 using HeuristicLab.Encodings.PermutationEncoding;
    2727using HeuristicLab.Optimization;
    2828using HeuristicLab.Parameters;
     
    6060    [StorableConstructor]
    6161    private PushForwardCreator(bool deserializing) : base(deserializing) { }
     62    protected PushForwardCreator(PushForwardCreator original, Cloner cloner) : base(original, cloner) { }
     63    public override IDeepCloneable Clone(Cloner cloner) {
     64      return new PushForwardCreator(this, cloner);
     65    }
    6266
    6367    public PushForwardCreator()
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/RandomCreator.cs

    r4183 r4687  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
     23using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Data;
    26 using HeuristicLab.Encodings.PermutationEncoding;
    2725using HeuristicLab.Optimization;
    2826using HeuristicLab.Parameters;
     
    4139    [StorableConstructor]
    4240    private RandomCreator(bool deserializing) : base(deserializing) { }
     41    private RandomCreator(RandomCreator original, Cloner cloner) : base(original, cloner) { }
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new RandomCreator(this, cloner);
     44    }
    4345
    4446    public RandomCreator()
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/MultiVRPSolutionCrossover.cs

    r4352 r4687  
    2323using System.Linq;
    2424using HeuristicLab.Collections;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2628using HeuristicLab.Operators;
    2729using HeuristicLab.Optimization;
     
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3032using HeuristicLab.PluginInfrastructure;
    31 using HeuristicLab.Data;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    8384    [StorableConstructor]
    8485    private MultiVRPSolutionCrossover(bool deserializing) : base(deserializing) { }
     86    protected MultiVRPSolutionCrossover(MultiVRPSolutionCrossover original, Cloner cloner) : base(original, cloner) { }
     87    public override IDeepCloneable Clone(Cloner cloner) {
     88      return new MultiVRPSolutionCrossover(this, cloner);
     89    }
    8590    public MultiVRPSolutionCrossover()
    8691      : base() {
    87        Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("Parents", "The parent permutations which should be crossed."));
     92      Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("Parents", "The parent permutations which should be crossed."));
    8893      ParentsParameter.ActualName = "VRPTours";
    8994      Parameters.Add(new LookupParameter<IVRPEncoding>("Child", "The child permutation resulting from the crossover."));
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/RandomParentCloneCrossover.cs

    r4352 r4687  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
     22using HeuristicLab.Common;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Optimization;
     
    3936    [StorableConstructor]
    4037    private RandomParentCloneCrossover(bool deserializing) : base(deserializing) { }
     38    protected RandomParentCloneCrossover(RandomParentCloneCrossover original, Cloner cloner) : base(original, cloner) { }
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new RandomParentCloneCrossover(this, cloner);
     41    }
    4142
    4243    public RandomParentCloneCrossover()
     
    5455      Parameters.Remove("ServiceTime");
    5556    }
    56    
     57
    5758    public override IOperation Apply() {
    5859      if (RandomParameter.ActualValue.Next() < 0.5)
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Manipulators/MultiVRPSolutionManipulator.cs

    r4352 r4687  
    2323using System.Linq;
    2424using HeuristicLab.Collections;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2628using HeuristicLab.Operators;
    2729using HeuristicLab.Optimization;
     
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3032using HeuristicLab.PluginInfrastructure;
    31 using HeuristicLab.Data;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    7980    [StorableConstructor]
    8081    private MultiVRPSolutionManipulator(bool deserializing) : base(deserializing) { }
     82    protected MultiVRPSolutionManipulator(MultiVRPSolutionManipulator original, Cloner cloner) : base(original, cloner) { }
     83    public override IDeepCloneable Clone(Cloner cloner) {
     84      return new MultiVRPSolutionManipulator(this, cloner);
     85    }
    8186    public MultiVRPSolutionManipulator()
    8287      : base() {
     
    97102        if (!typeof(MultiOperator<IVRPManipulator>).IsAssignableFrom(type)) {
    98103          IVRPManipulator op = (IVRPManipulator)Activator.CreateInstance(type);
    99           bool operatorChecked = true; 
    100           if(op is HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinLocalSearchManipulator ||
     104          bool operatorChecked = true;
     105          if (op is HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinLocalSearchManipulator ||
    101106            op is HeuristicLab.Problems.VehicleRouting.Encodings.Prins.PrinsLSManipulator)
    102107            operatorChecked = false;
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

    r4352 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    2424using HeuristicLab.Parameters;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3636    [StorableConstructor]
    3737    private MultiVRPMoveEvaluator(bool deserializing) : base(deserializing) { }
     38    private MultiVRPMoveEvaluator(MultiVRPMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new MultiVRPMoveEvaluator(this, cloner);
     41    }
    3842
    3943    public MultiVRPMoveEvaluator()
    4044      : base() {
    41         Parameters.Add(new LookupParameter<IVRPMove>("VRPMove", "The generated moves."));
     45      Parameters.Add(new LookupParameter<IVRPMove>("VRPMove", "The generated moves."));
    4246    }
    4347
     
    5357        CapacityParameter.ActualValue,
    5458        CoordinatesParameter.ActualValue,
    55         FleetUsageFactor.ActualValue, 
    56         TimeFactor.ActualValue, 
    57         DistanceFactor.ActualValue, 
    58         OverloadPenalty.ActualValue, 
     59        FleetUsageFactor.ActualValue,
     60        TimeFactor.ActualValue,
     61        DistanceFactor.ActualValue,
     62        OverloadPenalty.ActualValue,
    5963        TardinessPenalty.ActualValue,
    6064        DistanceMatrixParameter,
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs

    r4352 r4687  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using HeuristicLab.Collections;
     26using HeuristicLab.Common;
    2527using HeuristicLab.Core;
     28using HeuristicLab.Data;
    2629using HeuristicLab.Operators;
    2730using HeuristicLab.Optimization;
     
    2932using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3033using HeuristicLab.PluginInfrastructure;
    31 using HeuristicLab.Data;
    32 using System.Collections.Generic;
    3334
    3435namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    3536  [Item("MultiVRPMoveGenerator", "Randomly selects and applies its move generators.")]
    3637  [StorableClass]
    37   public class MultiVRPMoveGenerator : CheckedMultiOperator<IMultiVRPMoveGenerator>, IMultiVRPMoveOperator, 
     38  public class MultiVRPMoveGenerator : CheckedMultiOperator<IMultiVRPMoveGenerator>, IMultiVRPMoveOperator,
    3839    IStochasticOperator, IMultiMoveGenerator {
    3940    public override bool CanChangeName {
     
    9899    [StorableConstructor]
    99100    private MultiVRPMoveGenerator(bool deserializing) : base(deserializing) { }
     101    private MultiVRPMoveGenerator(MultiVRPMoveGenerator original, Cloner cloner) : base(original, cloner) { }
     102    public override IDeepCloneable Clone(Cloner cloner) {
     103      return new MultiVRPMoveGenerator(this, cloner);
     104    }
    100105    public MultiVRPMoveGenerator()
    101106      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveMaker.cs

    r4416 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
    24 using HeuristicLab.Operators;
    2525using HeuristicLab.Optimization;
    2626using HeuristicLab.Parameters;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using System.Collections.Generic;
    2928
    30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General{
     29namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    3130  [Item("MultiVRPMoveMaker", "Peforms multiple moves on a given VRP encoding and updates the quality.")]
    3231  [StorableClass]
     
    8281    [StorableConstructor]
    8382    private LambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { }
     83    protected LambdaInterchangeMoveMaker(LambdaInterchangeMoveMaker original, Cloner cloner) : base(original, cloner) { }
     84    public override IDeepCloneable Clone(Cloner cloner) {
     85      return new LambdaInterchangeMoveMaker(this, cloner);
     86    }
    8487
    8588    public LambdaInterchangeMoveMaker()
     
    112115      DoubleValue moveQuality = MoveQualityParameter.ActualValue;
    113116      DoubleValue quality = QualityParameter.ActualValue;
    114      
     117
    115118      //perform move
    116119      VRPToursParameter.ActualValue = move.MakeMove();
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/PermutationEncoding.cs

    r4352 r4687  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
     
    2527using HeuristicLab.Encodings.PermutationEncoding;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using System.Collections.Generic;
    28 using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    29 using System;
    3029
    3130namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    4847      : base() {
    4948    }
     49    protected PermutationEncoding(PermutationEncoding original, Cloner cloner)
     50      : base(original, cloner) {
     51    }
     52
    5053
    5154    public int IndexOf(int city) {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/TourEncoding.cs

    r4352 r4687  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Drawing;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.Data;
    25 using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using System.Drawing;
    28 using System.Collections.Generic;
    2928
    3029namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    3534      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; }
    3635    }
    37    
     36
    3837    #region IVRPEncoding Members
    3938    public virtual List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) {
     
    5150
    5251    public int Cities {
    53       get
    54       {
     52      get {
    5553        int cities = 0;
    5654
     
    7573      : base() {
    7674    }
     75    protected TourEncoding(TourEncoding original, Cloner cloner)
     76      : base(original, cloner) {
     77    }
    7778
    7879    public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, ILookupParameter<DoubleMatrix> distanceMatrix) {
     
    8283    public static void ConvertFrom(List<int> route, TourEncoding solution) {
    8384      solution.Tours = new ItemList<Tour>();
    84      
     85
    8586      Tour tour = new Tour();
    8687      for (int i = 0; i < route.Count; i++) {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuCrossover.cs

    r4352 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
     24using HeuristicLab.Optimization;
    2425using HeuristicLab.Parameters;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using HeuristicLab.Optimization;
    2827
    2928namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
     
    3433      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3534    }
    36    
     35
    3736    [StorableConstructor]
    3837    protected ZhuCrossover(bool deserializing) : base(deserializing) { }
     38    protected ZhuCrossover(ZhuCrossover original, Cloner cloner)
     39      : base(original, cloner) {
     40    }
    3941
    4042    public ZhuCrossover()
     
    5254        if (!(solution is ZhuEncoding)) {
    5355          parents[i] = ZhuEncoding.ConvertFrom(solution,
    54             Cities, 
     56            Cities,
    5557            DueTimeParameter.ActualValue,
    5658            ServiceTimeParameter.ActualValue,
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover1.cs

    r4352 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    2725
    2826namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
    2927  [Item("ZhuHeuristicCrossover1", "The Zhu Heuristic Crossover (Version 1). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")]
    3028  [StorableClass]
    31   public sealed class ZhuHeuristicCrossover1 : ZhuCrossover {   
     29  public sealed class ZhuHeuristicCrossover1 : ZhuCrossover {
    3230    [StorableConstructor]
    3331    private ZhuHeuristicCrossover1(bool deserializing) : base(deserializing) { }
    34 
     32    private ZhuHeuristicCrossover1(ZhuHeuristicCrossover1 original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
     35    public override IDeepCloneable Clone(Cloner cloner) {
     36      return new ZhuHeuristicCrossover1(this, cloner);
     37    }
    3538    public ZhuHeuristicCrossover1()
    3639      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover2.cs

    r4352 r4687  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using System.Collections.Generic;
    2826
    2927namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
    3028  [Item("ZhuHeuristicCrossover2", "The Zhu Heuristic Crossover (Version 2). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")]
    3129  [StorableClass]
    32   public sealed class ZhuHeuristicCrossover2 : ZhuCrossover {   
     30  public sealed class ZhuHeuristicCrossover2 : ZhuCrossover {
    3331    [StorableConstructor]
    3432    private ZhuHeuristicCrossover2(bool deserializing) : base(deserializing) { }
    35 
     33    private ZhuHeuristicCrossover2(ZhuHeuristicCrossover2 original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
     36    public override IDeepCloneable Clone(Cloner cloner) {
     37      return new ZhuHeuristicCrossover2(this, cloner);
     38    }
    3639    public ZhuHeuristicCrossover2()
    3740      : base() {
     
    4952      if (predecessor < 0)
    5053        predecessor = predecessor + child.Length;
    51      
     54
    5255      int parent1Index = i;
    5356      int parent2Index = i;
     
    5659        if (i == breakPoint) {
    5760          child[i] = p1[parent1Index];
    58          
     61
    5962          p1.Remove(child[i]);
    6063          if (parent1Index >= p1.Count)
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuMergeCrossover1.cs

    r4352 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2524using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    2725
    2826namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
    2927  [Item("ZhuMergeCrossover1", "The Zhu Merge Crossover (Version 1). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")]
    3028  [StorableClass]
    31   public sealed class ZhuMergeCrossover1 : ZhuCrossover {   
     29  public sealed class ZhuMergeCrossover1 : ZhuCrossover {
    3230    [StorableConstructor]
    3331    private ZhuMergeCrossover1(bool deserializing) : base(deserializing) { }
    34 
     32    private ZhuMergeCrossover1(ZhuMergeCrossover1 original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
     35    public override IDeepCloneable Clone(Cloner cloner) {
     36      return new ZhuMergeCrossover1(this, cloner);
     37    }
    3538    public ZhuMergeCrossover1()
    3639      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuMergeCrossover2.cs

    r4352 r4687  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using HeuristicLab.Common;
    2224using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Parameters;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using System.Collections.Generic;
    2826
    2927namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
    3028  [Item("ZhuMergeCrossover2", "The Zhu Merge Crossover (Version 2).  It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")]
    3129  [StorableClass]
    32   public sealed class ZhuMergeCrossover2 : ZhuCrossover {   
     30  public sealed class ZhuMergeCrossover2 : ZhuCrossover {
    3331    [StorableConstructor]
    3432    private ZhuMergeCrossover2(bool deserializing) : base(deserializing) { }
    35 
     33    private ZhuMergeCrossover2(ZhuMergeCrossover2 original, Cloner cloner)
     34      : base(original, cloner) {
     35    }
     36    public override IDeepCloneable Clone(Cloner cloner) {
     37      return new ZhuMergeCrossover2(this, cloner);
     38    }
    3639    public ZhuMergeCrossover2()
    3740      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs

    r4352 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.PermutationEncoding;
    2425using HeuristicLab.Parameters;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    2727
    2828namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
    2929  [Item("ZhuPermutationCrossover", "An operator which crosses two VRP representations using a standard permutation operator. It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")]
    3030  [StorableClass]
    31   public sealed class PrinsPermutationCrossover : ZhuCrossover {   
     31  public sealed class PrinsPermutationCrossover : ZhuCrossover {
    3232    public IValueLookupParameter<IPermutationCrossover> InnerCrossoverParameter {
    3333      get { return (IValueLookupParameter<IPermutationCrossover>)Parameters["InnerCrossover"]; }
     
    3636    [StorableConstructor]
    3737    private PrinsPermutationCrossover(bool deserializing) : base(deserializing) { }
    38 
     38    private PrinsPermutationCrossover(PrinsPermutationCrossover original, Cloner cloner)
     39      : base(original, cloner) {
     40    }
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new PrinsPermutationCrossover(this, cloner);
     43    }
    3944    public PrinsPermutationCrossover()
    4045      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Manipulators/ZhuManipulator.cs

    r4352 r4687  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
     24using HeuristicLab.Optimization;
    2425using HeuristicLab.Parameters;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Data;
    27 using HeuristicLab.Optimization;
    2827
    2928namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
     
    3433      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3534    }
    36 
    3735    [StorableConstructor]
    3836    protected ZhuManipulator(bool deserializing) : base(deserializing) { }
     37    protected ZhuManipulator(ZhuManipulator original, Cloner cloner)
     38      : base(original, cloner) {
     39    }
     40
    3941
    4042    public ZhuManipulator()
     
    4951      if (!(solution is ZhuEncoding)) {
    5052        VRPToursParameter.ActualValue = ZhuEncoding.ConvertFrom(solution,
    51             Cities, 
     53            Cities,
    5254            DueTimeParameter.ActualValue,
    5355            ServiceTimeParameter.ActualValue,
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Manipulators/ZhuPermutationManipulator.cs

    r4352 r4687  
    3636    [StorableConstructor]
    3737    private ZhuPermutationManipulator(bool deserializing) : base(deserializing) { }
    38 
     38    private ZhuPermutationManipulator(ZhuPermutationManipulator original, Cloner cloner)
     39      : base(original, cloner) {
     40    }
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new ZhuPermutationManipulator(this, cloner);
     43    }
    3944    public ZhuPermutationManipulator()
    4045      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/ZhuEncoding.cs

    r4352 r4687  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
     
    2527using HeuristicLab.Encodings.PermutationEncoding;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using System.Collections.Generic;
    2829using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    29 using System;
    3030
    3131namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu {
     
    4444    [Storable]
    4545    DoubleArray dueTimeArray;
    46    
     46
    4747    [Storable]
    4848    DoubleArray serviceTimeArray;
     
    5050    [Storable]
    5151    DoubleArray readyTimeArray;
    52    
     52
    5353    [Storable]
    5454    DoubleArray demandArray;
     
    7575          distanceMatrix,
    7676          useDistanceMatrix)) {
    77             newTour.Cities.Remove(city);
    78             if (newTour.Cities.Count > 0)
    79               result.Add(newTour);
     77          newTour.Cities.Remove(city);
     78          if (newTour.Cities.Count > 0)
     79            result.Add(newTour);
    8080
    81             newTour = new Tour();
    82             newTour.Cities.Add(city);
     81          newTour = new Tour();
     82          newTour.Cities.Add(city);
    8383        }
    8484      }
     
    124124    #endregion
    125125
    126     public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
    127       ZhuEncoding clone = new ZhuEncoding(
    128         new Permutation(this.PermutationType, this.array), cities,
    129         dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    130         coordinates, useDistanceMatrix);
    131 
    132       cloner.RegisterClonedObject(this, clone);
    133       clone.readOnly = readOnly;
    134       return clone;
    135     }
    136 
    137     public ZhuEncoding(Permutation permutation, int cities,
    138       DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    139       DoubleMatrix coordinates, BoolValue useDistanceMatrix)
    140       : base(permutation) {
    141         this.cities = cities;
    142         this.dueTimeArray = dueTimeArray;
    143         this.serviceTimeArray = serviceTimeArray;
    144         this.readyTimeArray = readyTimeArray;
    145         this.demandArray = demandArray;
    146         this.capacity = capacity;
    147         this.coordinates = coordinates;
    148         this.useDistanceMatrix = useDistanceMatrix;
    149     }
    150 
    151126    [StorableConstructor]
    152127    private ZhuEncoding(bool serializing)
    153128      : base(serializing) {
     129    }
     130
     131    protected ZhuEncoding(ZhuEncoding original, Cloner cloner)
     132      : base(original, cloner) {
     133      this.cities = original.cities;
     134      this.dueTimeArray = original.dueTimeArray;
     135      this.serviceTimeArray = original.serviceTimeArray;
     136      this.readyTimeArray = original.readyTimeArray;
     137      this.demandArray = original.demandArray;
     138      this.capacity = original.capacity;
     139      this.coordinates = original.coordinates;
     140      this.useDistanceMatrix = original.useDistanceMatrix;
     141    }
     142    public override IDeepCloneable Clone(Cloner cloner) {
     143      return new ZhuEncoding(this, cloner);
    154144    }
    155145
     
    171161    }
    172162
    173     public static ZhuEncoding ConvertFrom(List<int> routeParam, int cities, 
     163    public static ZhuEncoding ConvertFrom(List<int> routeParam, int cities,
    174164      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    175165      DoubleMatrix coordinates, BoolValue useDistanceMatrix) {
     
    183173
    184174      return new ZhuEncoding(
    185         new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), cities, 
     175        new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), cities,
    186176        dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    187177        coordinates, useDistanceMatrix);
Note: See TracChangeset for help on using the changeset viewer.