Free cookie consent management tool by TermsFeed Policy Generator

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

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.VehicleRouting

  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/DefaultRepresentationCreator.cs

    r4183 r4722  
    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}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/MultiVRPSolutionCreator.cs

    r4352 r4722  
    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 {
     
    7879
    7980    [StorableConstructor]
    80     private MultiVRPSolutionCreator(bool deserializing) : base(deserializing) { }
     81    protected 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    }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs

    r4352 r4722  
    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    private 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()
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/RandomCreator.cs

    r4183 r4722  
    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()
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/MultiVRPSolutionCrossover.cs

    r4352 r4722  
    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 {
     
    8283
    8384    [StorableConstructor]
    84     private MultiVRPSolutionCrossover(bool deserializing) : base(deserializing) { }
     85    protected 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."));
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/RandomParentCloneCrossover.cs

    r4352 r4722  
    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    private RandomParentCloneCrossover(RandomParentCloneCrossover original, Cloner cloner) : base(original, cloner) { }
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new RandomParentCloneCrossover(this, cloner);
     41    }
     42
    4143
    4244    public RandomParentCloneCrossover()
     
    5456      Parameters.Remove("ServiceTime");
    5557    }
    56    
     58
    5759    public override IOperation Apply() {
    5860      if (RandomParameter.ActualValue.Next() < 0.5)
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Manipulators/MultiVRPSolutionManipulator.cs

    r4352 r4722  
    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 {
     
    7879
    7980    [StorableConstructor]
    80     private MultiVRPSolutionManipulator(bool deserializing) : base(deserializing) { }
     81    protected 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;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IMultiVRPMoveGenerator.cs

    r4205 r4722  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    2422using HeuristicLab.Optimization;
    2523
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IMultiVRPMoveOperator.cs

    r4205 r4722  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Optimization;
    2523
    2624namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IVRPMove.cs

    r4352 r4722  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Optimization;
    2523using HeuristicLab.Data;
    2624
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

    r4352 r4722  
    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,
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs

    r4352 r4722  
    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 {
     
    9798
    9899    [StorableConstructor]
    99     private MultiVRPMoveGenerator(bool deserializing) : base(deserializing) { }
     100    protected MultiVRPMoveGenerator(bool deserializing) : base(deserializing) { }
     101    protected 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() {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveMaker.cs

    r4416 r4722  
    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]
     
    8180
    8281    [StorableConstructor]
    83     private LambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { }
     82    protected 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();
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/PermutationEncoding.cs

    r4352 r4722  
    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) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/TourEncoding.cs

    r4352 r4722  
    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++) {
Note: See TracChangeset for help on using the changeset viewer.