Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4683


Ignore:
Timestamp:
10/29/10 19:53:44 (12 years ago)
Author:
abeham
Message:

#922

  • Refactored HeuristicLab.Problems.TravelingSalesman
Location:
branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/BestTSPSolutionAnalyzer.cs

    r4068 r4683  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Common;
    3031
    3132namespace HeuristicLab.Problems.TravelingSalesman {
     
    6162    }
    6263
     64    [StorableConstructor]
     65    private BestTSPSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     66    private BestTSPSolutionAnalyzer(BestTSPSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
     67    public override IDeepCloneable Clone(Cloner cloner) {
     68      return new BestTSPSolutionAnalyzer(this, cloner);
     69    }
    6370    public BestTSPSolutionAnalyzer()
    6471      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPAlleleFrequencyAnalyzer.cs

    r4623 r4683  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Common;
    2930
    3031namespace HeuristicLab.Problems.TravelingSalesman {
     
    3940    }
    4041
     42    [StorableConstructor]
     43    private TSPAlleleFrequencyAnalyzer(bool deserializing) : base(deserializing) { }
     44    private TSPAlleleFrequencyAnalyzer(TSPAlleleFrequencyAnalyzer original, Cloner cloner)
     45      : base(original, cloner) {
     46    }
     47    public override IDeepCloneable Clone(Cloner cloner) {
     48      return new TSPAlleleFrequencyAnalyzer(this, cloner);
     49    }
    4150    public TSPAlleleFrequencyAnalyzer()
    4251      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs

    r4068 r4683  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.TravelingSalesman {
     
    4647    }
    4748
     49    [StorableConstructor]
     50    protected TSPCoordinatesPathEvaluator(bool deserializing) : base(deserializing) { }
     51    protected TSPCoordinatesPathEvaluator(TSPCoordinatesPathEvaluator original, Cloner cloner) : base(original, cloner) { }
    4852    protected TSPCoordinatesPathEvaluator()
    4953      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPEuclideanPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3132  [StorableClass]
    3233  public sealed class TSPEuclideanPathEvaluator : TSPCoordinatesPathEvaluator {
     34    [StorableConstructor]
     35    protected TSPEuclideanPathEvaluator(bool deserializing) : base(deserializing) { }
     36    protected TSPEuclideanPathEvaluator(TSPEuclideanPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     37    public TSPEuclideanPathEvaluator() : base() { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new TSPEuclideanPathEvaluator(this, cloner);
     41    }
     42   
    3343    /// <summary>
    3444    /// Calculates the distance between two points using the Euclidean distance metric.
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPEvaluator.cs

    r4068 r4683  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.TravelingSalesman {
     
    4142    }
    4243
     44    [StorableConstructor]
     45    protected TSPEvaluator(bool deserializing) : base(deserializing) { }
     46    protected TSPEvaluator(TSPEvaluator original, Cloner cloner) : base(original, cloner) { }
    4347    protected TSPEvaluator()
    4448      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPGeoPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3334    private const double PI = 3.141592;
    3435    private const double RADIUS = 6378.388;
     36
     37    [StorableConstructor]
     38    private TSPGeoPathEvaluator(bool deserializing) : base(deserializing) { }
     39    private TSPGeoPathEvaluator(TSPGeoPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     40    public TSPGeoPathEvaluator() : base() { }
     41
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new TSPGeoPathEvaluator(this, cloner);
     44    }
     45   
    3546
    3647    /// <summary>
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPRoundedEuclideanPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3132  [StorableClass]
    3233  public sealed class TSPRoundedEuclideanPathEvaluator : TSPCoordinatesPathEvaluator {
     34    [StorableConstructor]
     35    private TSPRoundedEuclideanPathEvaluator(bool deserializing) : base(deserializing) { }
     36    private TSPRoundedEuclideanPathEvaluator(TSPRoundedEuclideanPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     37    public TSPRoundedEuclideanPathEvaluator() : base() { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new TSPRoundedEuclideanPathEvaluator(this, cloner);
     41    }
     42   
    3343    /// <summary>
    3444    /// Calculates the distance between two points using the rounded Euclidean distance metric.
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TSPMoveEvaluator.cs

    r4068 r4683  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Common;
    2930
    3031namespace HeuristicLab.Problems.TravelingSalesman {
     
    4849    }
    4950
     51    [StorableConstructor]
     52    protected TSPMoveEvaluator(bool deserializing) : base(deserializing) { }
     53    protected TSPMoveEvaluator(TSPMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
    5054    protected TSPMoveEvaluator()
    5155      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TSPPathMoveEvaluator.cs

    r4068 r4683  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.TravelingSalesman {
     
    4647    }
    4748
     49    [StorableConstructor]
     50    protected TSPPathMoveEvaluator(bool deserializing) : base(deserializing) { }
     51    protected TSPPathMoveEvaluator(TSPPathMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
    4852    protected TSPPathMoveEvaluator()
    4953      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMoveEuclideanPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3132  [StorableClass]
    3233  public class TSPTranslocationMoveEuclideanPathEvaluator : TSPTranslocationMovePathEvaluator {
     34    [StorableConstructor]
     35    protected TSPTranslocationMoveEuclideanPathEvaluator(bool deserializing) : base(deserializing) { }
     36    protected TSPTranslocationMoveEuclideanPathEvaluator(TSPTranslocationMoveEuclideanPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     37    public TSPTranslocationMoveEuclideanPathEvaluator() : base() { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new TSPTranslocationMoveEuclideanPathEvaluator(this, cloner);
     41    }
     42   
    3343    public override Type EvaluatorType {
    3444      get { return typeof(TSPEuclideanPathEvaluator); }
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMoveGeoPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3738    private const double PI = 3.141592;
    3839    private const double RADIUS = 6378.388;
     40
     41    [StorableConstructor]
     42    protected TSPTranslocationMoveGeoPathEvaluator(bool deserializing) : base(deserializing) { }
     43    protected TSPTranslocationMoveGeoPathEvaluator(TSPTranslocationMoveGeoPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     44    public TSPTranslocationMoveGeoPathEvaluator() : base() { }
     45
     46    public override IDeepCloneable Clone(Cloner cloner) {
     47      return new TSPTranslocationMoveGeoPathEvaluator(this, cloner);
     48    }
     49   
    3950
    4051    /// <summary>
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs

    r4068 r4683  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.TravelingSalesman {
     
    3738    }
    3839
     40    [StorableConstructor]
     41    protected TSPTranslocationMovePathEvaluator(bool deserializing) : base(deserializing) { }
     42    protected TSPTranslocationMovePathEvaluator(TSPTranslocationMovePathEvaluator original, Cloner cloner) : base(original, cloner) { }
    3943    public TSPTranslocationMovePathEvaluator()
    4044      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMoveRoundedEuclideanPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3132  [StorableClass]
    3233  public class TSPTranslocationMoveRoundedEuclideanPathEvaluator : TSPTranslocationMovePathEvaluator {
     34    [StorableConstructor]
     35    protected TSPTranslocationMoveRoundedEuclideanPathEvaluator(bool deserializing) : base(deserializing) { }
     36    protected TSPTranslocationMoveRoundedEuclideanPathEvaluator(TSPTranslocationMoveRoundedEuclideanPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     37    public TSPTranslocationMoveRoundedEuclideanPathEvaluator() : base() { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new TSPTranslocationMoveRoundedEuclideanPathEvaluator(this, cloner);
     41    }
     42   
    3343    public override Type EvaluatorType {
    3444      get { return typeof(TSPRoundedEuclideanPathEvaluator); }
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMoveEuclideanPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3132  [StorableClass]
    3233  public class TSPInversionMoveEuclideanPathEvaluator : TSPInversionMovePathEvaluator {
     34    [StorableConstructor]
     35    protected TSPInversionMoveEuclideanPathEvaluator(bool deserializing) : base(deserializing) { }
     36    protected TSPInversionMoveEuclideanPathEvaluator(TSPInversionMoveEuclideanPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     37    public TSPInversionMoveEuclideanPathEvaluator() : base() { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new TSPInversionMoveEuclideanPathEvaluator(this, cloner);
     41    }
     42   
    3343    public override Type EvaluatorType {
    3444      get { return typeof(TSPEuclideanPathEvaluator); }
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMoveGeoPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3839    private const double RADIUS = 6378.388;
    3940
     41    [StorableConstructor]
     42    protected TSPInversionMoveGeoPathEvaluator(bool deserializing) : base(deserializing) { }
     43    protected TSPInversionMoveGeoPathEvaluator(TSPInversionMoveGeoPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     44    public TSPInversionMoveGeoPathEvaluator() : base() { }
     45
     46    public override IDeepCloneable Clone(Cloner cloner) {
     47      return new TSPInversionMoveGeoPathEvaluator(this, cloner);
     48    }
     49   
    4050    /// <summary>
    4151    /// Calculates the distance between two points using the GEO distance metric (globe coordinates).
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMovePathEvaluator.cs

    r4068 r4683  
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.Problems.TravelingSalesman {
     
    3738    }
    3839
     40    [StorableConstructor]
     41    protected TSPInversionMovePathEvaluator(bool deserializing) : base(deserializing) { }
     42    protected TSPInversionMovePathEvaluator(TSPInversionMovePathEvaluator original, Cloner cloner) : base(original, cloner) { }
    3943    public TSPInversionMovePathEvaluator()
    4044      : base() {
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMoveRoundedEuclideanPathEvaluator.cs

    r4068 r4683  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.Problems.TravelingSalesman {
     
    3132  [StorableClass]
    3233  public class TSPInversionMoveRoundedEuclideanPathEvaluator : TSPInversionMovePathEvaluator {
     34    [StorableConstructor]
     35    protected TSPInversionMoveRoundedEuclideanPathEvaluator(bool deserializing) : base(deserializing) { }
     36    protected TSPInversionMoveRoundedEuclideanPathEvaluator(TSPInversionMoveRoundedEuclideanPathEvaluator original, Cloner cloner) : base(original, cloner) { }
     37    public TSPInversionMoveRoundedEuclideanPathEvaluator() : base() { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new TSPInversionMoveRoundedEuclideanPathEvaluator(this, cloner);
     41    }
     42   
    3343    public override Type EvaluatorType {
    3444      get { return typeof(TSPRoundedEuclideanPathEvaluator); }
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/PathTSPTour.cs

    r4477 r4683  
    7979    }
    8080
     81    [StorableConstructor]
     82    private PathTSPTour(bool deserializing) : base(deserializing) { }
     83    private PathTSPTour(PathTSPTour original, Cloner cloner)
     84      : base(original, cloner) {
     85      this.coordinates = cloner.Clone(original.coordinates);
     86      this.permutation = cloner.Clone(original.permutation);
     87      this.quality = cloner.Clone(original.quality);
     88      Initialize();
     89    }
    8190    public PathTSPTour() : base() { }
    8291    public PathTSPTour(DoubleMatrix coordinates)
     
    98107      Initialize();
    99108    }
    100     [StorableConstructor]
    101     private PathTSPTour(bool deserializing) : base(deserializing) { }
     109
     110    public override IDeepCloneable Clone(Cloner cloner) {
     111      return new PathTSPTour(this, cloner);
     112    }
    102113
    103114    [StorableHook(HookType.AfterDeserialization)]
     115    private void AfterDeserialization() {
     116      Initialize();
     117    }
     118
    104119    private void Initialize() {
    105120      if (coordinates != null) RegisterCoordinatesEvents();
    106121      if (permutation != null) RegisterPermutationEvents();
    107122      if (quality != null) RegisterQualityEvents();
    108     }
    109 
    110     public override IDeepCloneable Clone(Cloner cloner) {
    111       PathTSPTour clone = new PathTSPTour();
    112       cloner.RegisterClonedObject(this, clone);
    113       clone.coordinates = (DoubleMatrix)cloner.Clone(coordinates);
    114       clone.permutation = (Permutation)cloner.Clone(permutation);
    115       clone.quality = (DoubleValue)cloner.Clone(quality);
    116       clone.Initialize();
    117       return clone;
    118123    }
    119124
  • branches/CloningRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r4641 r4683  
    138138    [StorableConstructor]
    139139    private TravelingSalesmanProblem(bool deserializing) : base(deserializing) { }
     140    private TravelingSalesmanProblem(TravelingSalesmanProblem original, Cloner cloner)
     141      : base(original, cloner) {
     142      this.operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
     143      this.DistanceMatrixParameter.Value = original.DistanceMatrixParameter.Value;
     144      AttachEventHandlers();
     145    }
     146    public override IDeepCloneable Clone(Cloner cloner) {
     147      return new TravelingSalesmanProblem(this, cloner);
     148    }
    140149    public TravelingSalesmanProblem()
    141150      : base() {
     
    168177    }
    169178
    170     public override IDeepCloneable Clone(Cloner cloner) {
    171       TravelingSalesmanProblem clone = (TravelingSalesmanProblem)base.Clone(cloner);
    172       clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    173       clone.DistanceMatrixParameter.Value = DistanceMatrixParameter.Value;
    174       clone.AttachEventHandlers();
    175       return clone;
    176     }
    177 
    178179    #region Events
    179180    public event EventHandler SolutionCreatorChanged;
     
    251252    #region Helpers
    252253    [StorableHook(HookType.AfterDeserialization)]
    253     private void AfterDeserializationHook() {
     254    private void AfterDeserialization() {
    254255      // BackwardsCompatibility3.3
    255256      #region Backwards compatible code (remove with 3.4)
Note: See TracChangeset for help on using the changeset viewer.