Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/19/12 11:04:48 (12 years ago)
Author:
jkarder
Message:

#1331: made similarity calculators storable and cloneable

Location:
branches/ScatterSearch (trunk integration)
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization.Operators/3.3/SimilarityCalculator.cs

    r8299 r8303  
    4343    [StorableConstructor]
    4444    protected SimilarityCalculator(bool deserializing) : base(deserializing) { }
    45     protected SimilarityCalculator(SimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
     45    protected SimilarityCalculator(SimilarityCalculator original, Cloner cloner)
     46      : base(original, cloner) {
     47      if (original.Target != null)
     48        this.target = (string)original.Target.Clone();
     49    }
    4650    protected SimilarityCalculator() : base() { }
    4751
     
    5559
    5660    protected abstract double CalculateSimilarity(IScope left, IScope right);
    57 
    58     public override IDeepCloneable Clone(Cloner cloner) { return null; }
    5961  }
    6062}
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.Knapsack/3.3/SimilarityCalculators/KnapsackSimilarityCalculator.cs

    r8086 r8303  
    3636    public KnapsackSimilarityCalculator() : base() { }
    3737
     38    public override IDeepCloneable Clone(Cloner cloner) {
     39      return new KnapsackSimilarityCalculator(this, cloner);
     40    }
     41
    3842    public static double CalculateSimilarity(BinaryVector left, BinaryVector right) {
    3943      if (left == null || right == null)
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs

    r8086 r8303  
    2626using HeuristicLab.Encodings.RealVectorEncoding;
    2727using HeuristicLab.Optimization.Operators;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
    2930namespace HeuristicLab.Problems.TestFunctions {
     
    3233  /// </summary>
    3334  [Item("SingleObjectiveTestFunctionSimilarityCalculator", "An operator that performs similarity calculation between two test functions solutions.")]
     35  [StorableClass]
    3436  public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SimilarityCalculator {
    3537    #region Properties
     38    [Storable]
    3639    public DoubleMatrix Bounds { get; set; }
    3740    #endregion
    3841
     42    [StorableConstructor]
    3943    private SingleObjectiveTestFunctionSimilarityCalculator(bool deserializing) : base(deserializing) { }
    40     private SingleObjectiveTestFunctionSimilarityCalculator(SingleObjectiveTestFunctionSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
     44    private SingleObjectiveTestFunctionSimilarityCalculator(SingleObjectiveTestFunctionSimilarityCalculator original, Cloner cloner)
     45      : base(original, cloner) {
     46      this.Bounds = cloner.Clone(original.Bounds);
     47    }
    4148    public SingleObjectiveTestFunctionSimilarityCalculator() : base() { }
     49
     50    public override IDeepCloneable Clone(Cloner cloner) {
     51      return new SingleObjectiveTestFunctionSimilarityCalculator(this, cloner);
     52    }
    4253
    4354    public static double CalculateSimilarity(RealVector left, RealVector right, DoubleMatrix bounds) {
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TravelingSalesman/3.3/SimilarityCalculators/TSPSimilarityCalculator.cs

    r8086 r8303  
    3636    public TSPSimilarityCalculator() : base() { }
    3737
     38    public override IDeepCloneable Clone(Cloner cloner) {
     39      return new TSPSimilarityCalculator(this, cloner);
     40    }
     41
    3842    public static double CalculateSimilarity(Permutation left, Permutation right) {
    3943      if (left == null || right == null)
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.VehicleRouting/3.3/SimilarityCalculators/VRPSimilarityCalculator.cs

    r8086 r8303  
    3838    private VRPSimilarityCalculator(VRPSimilarityCalculator original, Cloner cloner) : base(original, cloner) { }
    3939    public VRPSimilarityCalculator() : base() { }
     40
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new VRPSimilarityCalculator(this, cloner);
     43    }
    4044
    4145    public static double CalculateSimilarity(PotvinEncoding left, PotvinEncoding right) {
Note: See TracChangeset for help on using the changeset viewer.