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:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.VehicleRouting

  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMove.cs

    r4352 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2325using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    24 using HeuristicLab.Encodings.PermutationEncoding;
    25 using HeuristicLab.Common;
    26 using System.Collections.Generic;
    2726using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    28 using HeuristicLab.Data;
    2927
    3028namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    3129  [Item("InversionMove", "Item that describes a lambda move on a VRP representation.  It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")]
    3230  [StorableClass]
    33   public class AlbaLambdaInterchangeMove: Item, IVRPMove {
     31  public class AlbaLambdaInterchangeMove : Item, IVRPMove {
    3432    [Storable]
    3533    public IVRPEncoding Individual { get; protected set; }
    36    
     34
    3735    [Storable]
    3836    public int Tour1 { get; protected set; }
     
    5250    [Storable]
    5351    public int Length2 { get; protected set; }
    54    
    55     public AlbaLambdaInterchangeMove(): base() {
     52
     53    [StorableConstructor]
     54    protected AlbaLambdaInterchangeMove(bool deserializing) : base(deserializing) { }
     55    protected AlbaLambdaInterchangeMove(AlbaLambdaInterchangeMove original, Cloner cloner)
     56      : base(original, cloner) {
     57      Tour1 = original.Tour1;
     58      Position1 = original.Position1;
     59      Length1 = original.Length1;
     60
     61      Tour2 = original.Tour2;
     62      Position2 = original.Position2;
     63      Length2 = original.Length2;
     64
     65      Individual = cloner.Clone(original.Individual);
     66    }
     67    public override IDeepCloneable Clone(Cloner cloner) {
     68      return new AlbaLambdaInterchangeMove(this, cloner);
     69    }
     70
     71    public AlbaLambdaInterchangeMove()
     72      : base() {
    5673      Tour1 = -1;
    5774      Position1 = -1;
     
    6582    }
    6683
    67     public AlbaLambdaInterchangeMove(int tour1, int position1, int length1, 
     84    public AlbaLambdaInterchangeMove(int tour1, int position1, int length1,
    6885      int tour2, int position2, int length2, AlbaEncoding permutation) {
    69         Tour1 = tour1;
    70         Position1 = position1;
    71         Length1 = length1;
     86      Tour1 = tour1;
     87      Position1 = position1;
     88      Length1 = length1;
    7289
    73         Tour2 = tour2;
    74         Position2 = position2;
    75         Length2 = length2;
     90      Tour2 = tour2;
     91      Position2 = position2;
     92      Length2 = length2;
    7693
    77         this.Individual = permutation.Clone() as AlbaEncoding;
    78     }
    79 
    80     public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
    81       AlbaLambdaInterchangeMove clone = new AlbaLambdaInterchangeMove();
    82 
    83       clone.Tour1 = Tour1;
    84       clone.Position1 = Position1;
    85       clone.Length1 = Length1;
    86 
    87       clone.Tour2 = Tour2;
    88       clone.Position2 = Position2;
    89       clone.Length2 = Length2;
    90 
    91       if (Individual != null)
    92         clone.Individual = (AlbaEncoding)cloner.Clone(Individual);
    93 
    94       cloner.RegisterClonedObject(this, clone);
    95       return clone;
     94      this.Individual = permutation.Clone() as AlbaEncoding;
    9695    }
    9796
     
    10099    public TourEvaluation GetMoveQuality(
    101100      IntValue vehicles,
    102       DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 
     101      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    103102      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
    104103      DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor,
    105104      DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    106105      ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
    107         return AlbaLambdaInterchangeMoveEvaluator.GetMoveQuality(Individual as AlbaEncoding, this, vehicles,
    108           dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    109           coordinates, fleetUsageFactor, timeFactor, distanceFactor,
    110           overloadPenalty, tardinessPenalty, distanceMatrix, useDistanceMatrix);
     106      return AlbaLambdaInterchangeMoveEvaluator.GetMoveQuality(Individual as AlbaEncoding, this, vehicles,
     107        dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
     108        coordinates, fleetUsageFactor, timeFactor, distanceFactor,
     109        overloadPenalty, tardinessPenalty, distanceMatrix, useDistanceMatrix);
    111110    }
    112111
Note: See TracChangeset for help on using the changeset viewer.