Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/16 15:51:04 (8 years ago)
Author:
bburlacu
Message:

#2672: Implement online calculator cloning.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/ClassificationPerformanceMeasuresCalculator.cs

    r14185 r14293  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Problems.DataAnalysis.OnlineCalculators;
    2625
    2726namespace HeuristicLab.Problems.DataAnalysis {
    28   public class ClassificationPerformanceMeasuresCalculator {
     27  public class ClassificationPerformanceMeasuresCalculator : IDeepCloneable {
    2928
    3029    public ClassificationPerformanceMeasuresCalculator(string positiveClassName, double positiveClassValue) {
     
    3231      this.positiveClassValue = positiveClassValue;
    3332      Reset();
     33    }
     34
     35    // private constructor used internally by the Clone() method
     36    private ClassificationPerformanceMeasuresCalculator(ClassificationPerformanceMeasuresCalculator other) {
     37      // copy everything including the errorState
     38      positiveClassName = other.positiveClassName;
     39      positiveClassValue = other.positiveClassValue;
     40      truePositiveCount = other.truePositiveCount;
     41      falsePositiveCount = other.falsePositiveCount;
     42      trueNegativeCount = other.trueNegativeCount;
     43      falseNegativeCount = other.falseNegativeCount;
     44      errorState = other.errorState;
    3445    }
    3546
     
    138149      errorState = ErrorState;
    139150    }
     151
     152    // IDeepCloneable interface members
     153    public object Clone() {
     154      return new ClassificationPerformanceMeasuresCalculator(this);
     155    }
     156
     157    public IDeepCloneable Clone(Cloner cloner) {
     158      var clone = cloner.GetClone(this);
     159      if (clone == null) {
     160        clone = (IDeepCloneable)this.Clone();
     161        cloner.RegisterClonedObject(this, clone);
     162      }
     163      return clone;
     164    }
    140165  }
    141166}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineAccuracyCalculator.cs

    r14185 r14293  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlineAccuracyCalculator : IOnlineCalculator {
     27  public class OnlineAccuracyCalculator : IOnlineCalculator, IDeepCloneable {
    2828
    2929    private int correctlyClassified;
     
    3737    public OnlineAccuracyCalculator() {
    3838      Reset();
     39    }
     40
     41    // private constructor used internally by the Clone() method
     42    private OnlineAccuracyCalculator(OnlineAccuracyCalculator other) {
     43      correctlyClassified = other.correctlyClassified;
     44      n = other.n;
     45      errorState = other.errorState;
    3946    }
    4047
     
    9097      }
    9198    }
     99
     100    // IDeepCloneable interface members
     101    public object Clone() {
     102      return new OnlineAccuracyCalculator(this);
     103    }
     104
     105    public IDeepCloneable Clone(Cloner cloner) {
     106      var clone = cloner.GetClone(this);
     107      if (clone == null) {
     108        clone = (IDeepCloneable)this.Clone();
     109        cloner.RegisterClonedObject(this, clone);
     110      }
     111      return clone;
     112    }
    92113  }
    93114}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineBoundedMeanSquaredErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineBoundedMeanSquaredErrorCalculator : IOnlineCalculator {
     27  public class OnlineBoundedMeanSquaredErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private double errorSum;
     
    3839
    3940
    40     public OnlineBoundedMeanSquaredErrorCalculator(double lowerBound, double upperbound) {
     41    public OnlineBoundedMeanSquaredErrorCalculator(double lowerBound, double upperBound) {
    4142      LowerBound = lowerBound;
    42       UpperBound = upperbound;
     43      UpperBound = upperBound;
    4344      Reset();
     45    }
     46
     47    // private constructor used internally by the Clone() method
     48    private OnlineBoundedMeanSquaredErrorCalculator(OnlineBoundedMeanSquaredErrorCalculator other) {
     49      LowerBound = other.LowerBound;
     50      UpperBound = other.UpperBound;
     51      n = other.n;
     52      errorSum = other.errorSum;
     53      errorState = other.ErrorState;
    4454    }
    4555
     
    96106      }
    97107    }
     108
     109    // IDeepCloneable interface members
     110    public object Clone() {
     111      return new OnlineBoundedMeanSquaredErrorCalculator(this);
     112    }
     113
     114    public IDeepCloneable Clone(Cloner cloner) {
     115      var clone = cloner.GetClone(this);
     116      if (clone == null) {
     117        clone = (IDeepCloneable)this.Clone();
     118        cloner.RegisterClonedObject(this, clone);
     119      }
     120      return clone;
     121    }
    98122  }
    99123}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineCovarianceCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineCovarianceCalculator : IOnlineCalculator {
     27  public class OnlineCovarianceCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private double xMean, yMean, Cn;
     
    3637    public OnlineCovarianceCalculator() {
    3738      Reset();
     39    }
     40
     41    // private constructor used internally by the Clone() method
     42    private OnlineCovarianceCalculator(OnlineCovarianceCalculator other) : this() {
     43      Cn = other.Cn;
     44      xMean = other.xMean;
     45      yMean = other.yMean;
     46      n = other.n;
     47      errorState = other.errorState;
    3848    }
    3949
     
    94104      }
    95105    }
     106
     107    // IDeepCloneable interface members
     108    public object Clone() {
     109      return new OnlineCovarianceCalculator(this);
     110    }
     111
     112    public IDeepCloneable Clone(Cloner cloner) {
     113      var clone = cloner.GetClone(this);
     114      if (clone == null) {
     115        clone = (IDeepCloneable)this.Clone();
     116        cloner.RegisterClonedObject(this, clone);
     117      }
     118      return clone;
     119    }
    96120  }
    97121}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineDirectionalSymmetryCalculator.cs

    r14185 r14293  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis {
    28   public class OnlineDirectionalSymmetryCalculator : IOnlineTimeSeriesCalculator {
     28  public class OnlineDirectionalSymmetryCalculator : IOnlineTimeSeriesCalculator, IDeepCloneable {
    2929    private int n;
    3030    private int nCorrect;
     
    3939    public OnlineDirectionalSymmetryCalculator() {
    4040      Reset();
     41    }
     42
     43    // private constructor used internally by the Clone() method
     44    private OnlineDirectionalSymmetryCalculator(OnlineDirectionalSymmetryCalculator other) {
     45      n = other.n;
     46      nCorrect = other.nCorrect;
     47      errorState = other.errorState;
    4148    }
    4249
     
    94101      return dsCalculator.DirectionalSymmetry;
    95102    }
    96    
     103
    97104    public static double Calculate(IEnumerable<double> startValues, IEnumerable<IEnumerable<double>> actualContinuations, IEnumerable<IEnumerable<double>> predictedContinuations, out OnlineCalculatorError errorState) {
    98105      IEnumerator<double> startValueEnumerator = startValues.GetEnumerator();
     
    116123      }
    117124    }
     125
     126    // IDeepCloneable interface members
     127    public object Clone() {
     128      return new OnlineDirectionalSymmetryCalculator(this);
     129    }
     130
     131    public IDeepCloneable Clone(Cloner cloner) {
     132      var clone = cloner.GetClone(this);
     133      if (clone == null) {
     134        clone = (IDeepCloneable)this.Clone();
     135        cloner.RegisterClonedObject(this, clone);
     136      }
     137      return clone;
     138    }
    118139  }
    119140}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineLinearScalingParameterCalculator.cs

    r14185 r14293  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlineLinearScalingParameterCalculator {
     27  public class OnlineLinearScalingParameterCalculator : IDeepCloneable {
    2828
    2929    /// <summary>
     
    6565      Reset();
    6666    }
     67
     68    // private constructor used internally by the Clone() method
     69    private OnlineLinearScalingParameterCalculator(OnlineMeanAndVarianceCalculator targetMeanCalculator, OnlineMeanAndVarianceCalculator originalMeanAndVarianceCalculator, OnlineCovarianceCalculator originalTargetCovarianceCalculator) {
     70      this.targetMeanCalculator = targetMeanCalculator;
     71      this.originalMeanAndVarianceCalculator = originalMeanAndVarianceCalculator;
     72      this.originalTargetCovarianceCalculator = originalTargetCovarianceCalculator;
     73      // do not reset the calculators here
     74    }
     75
    6776
    6877    public void Reset() {
     
    117126      }
    118127    }
     128
     129    // IDeepCloneable interface members
     130    public object Clone() {
     131      var targetMeanCalculatorClone = (OnlineMeanAndVarianceCalculator)targetMeanCalculator.Clone();
     132      var originalMeanAndVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)originalMeanAndVarianceCalculator.Clone();
     133      var originalTargetCovarianceCalculatorClone = (OnlineCovarianceCalculator)originalTargetCovarianceCalculator.Clone();
     134      return new OnlineLinearScalingParameterCalculator(targetMeanCalculatorClone, originalMeanAndVarianceCalculatorClone, originalTargetCovarianceCalculatorClone);
     135    }
     136
     137    public IDeepCloneable Clone(Cloner cloner) {
     138      var clone = cloner.GetClone(this);
     139      if (clone == null) {
     140        var targetMeanCalculatorClone = (OnlineMeanAndVarianceCalculator)targetMeanCalculator.Clone(cloner);
     141        var originalMeanAndVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)originalMeanAndVarianceCalculator.Clone(cloner);
     142        var originalTargetCovarianceCalculatorClone = (OnlineCovarianceCalculator)originalTargetCovarianceCalculator.Clone(cloner);
     143        clone = new OnlineLinearScalingParameterCalculator(targetMeanCalculatorClone, originalMeanAndVarianceCalculatorClone, originalTargetCovarianceCalculatorClone);
     144        cloner.RegisterClonedObject(this, clone);
     145      }
     146      return clone;
     147    }
    119148  }
    120149}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMaxAbsoluteErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMaxAbsoluteErrorCalculator : IOnlineCalculator {
     27  public class OnlineMaxAbsoluteErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private double mae;
     
    3637    public OnlineMaxAbsoluteErrorCalculator() {
    3738      Reset();
     39    }
     40
     41    // private constructor used internally by the Clone() method
     42    private OnlineMaxAbsoluteErrorCalculator(OnlineMaxAbsoluteErrorCalculator other) {
     43      mae = other.mae;
     44      n = other.n;
     45      errorState = other.errorState;
    3846    }
    3947
     
    8896      }
    8997    }
     98
     99    // IDeepCloneable interface members
     100    public object Clone() {
     101      return new OnlineMaxAbsoluteErrorCalculator(this);
     102    }
     103
     104    public IDeepCloneable Clone(Cloner cloner) {
     105      var clone = cloner.GetClone(this);
     106      if (clone == null) {
     107        clone = (IDeepCloneable)this.Clone();
     108        cloner.RegisterClonedObject(this, clone);
     109      }
     110      return clone;
     111    }
    90112  }
    91113}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsoluteErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanAbsoluteErrorCalculator : IOnlineCalculator {
     27  public class OnlineMeanAbsoluteErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private double sae;
     
    3637    public OnlineMeanAbsoluteErrorCalculator() {
    3738      Reset();
     39    }
     40
     41    private OnlineMeanAbsoluteErrorCalculator(OnlineMeanAbsoluteErrorCalculator other) {
     42      sae = other.sae;
     43      n = other.n;
     44      errorState = other.errorState;
    3845    }
    3946
     
    8794      }
    8895    }
     96
     97    // IDeepCloneable interface members
     98    public object Clone() {
     99      return new OnlineMeanAbsoluteErrorCalculator(this);
     100    }
     101
     102    public IDeepCloneable Clone(Cloner cloner) {
     103      var clone = cloner.GetClone(this);
     104      if (clone == null) {
     105        clone = (IDeepCloneable)this.Clone();
     106        cloner.RegisterClonedObject(this, clone);
     107      }
     108      return clone;
     109    }
    89110  }
    90111}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsolutePercentageErrorCalculator.cs

    r14185 r14293  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlineMeanAbsolutePercentageErrorCalculator : IOnlineCalculator {
     27  public class OnlineMeanAbsolutePercentageErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2828
    2929    private double sre;
     
    3737    public OnlineMeanAbsolutePercentageErrorCalculator() {
    3838      Reset();
     39    }
     40
     41    // private constructor used internally by the Clone() method
     42    private OnlineMeanAbsolutePercentageErrorCalculator(OnlineMeanAbsolutePercentageErrorCalculator other) {
     43      sre = other.sre;
     44      n = other.n;
     45      errorState = other.errorState;
    3946    }
    4047
     
    8996      }
    9097    }
     98
     99    // IDeepCloneable interface members
     100    public object Clone() {
     101      return new OnlineMeanAbsolutePercentageErrorCalculator(this);
     102    }
     103
     104    public IDeepCloneable Clone(Cloner cloner) {
     105      var clone = cloner.GetClone(this);
     106      if (clone == null) {
     107        clone = (IDeepCloneable)this.Clone();
     108        cloner.RegisterClonedObject(this, clone);
     109      }
     110      return clone;
     111    }
    91112  }
    92113}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAndVarianceCalculator.cs

    r14292 r14293  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324
    2425namespace HeuristicLab.Problems.DataAnalysis {
    25   public class OnlineMeanAndVarianceCalculator {
     26  public class OnlineMeanAndVarianceCalculator : IDeepCloneable {
    2627
    2728    private double m_oldM, m_newM, m_oldS, m_newS;
     
    6667    }
    6768
     69    private OnlineMeanAndVarianceCalculator(OnlineMeanAndVarianceCalculator other) : this() {
     70      m_oldS = other.m_oldS;
     71      m_oldM = other.m_oldM;
     72      m_newS = other.m_newS;
     73      m_newM = other.m_newM;
     74      n = other.n;
     75      errorState = other.errorState;
     76      varianceErrorState = other.varianceErrorState;
     77    }
     78
    6879    public void Reset() {
    6980      n = 0;
     
    106117      varianceErrorState = meanAndVarianceCalculator.VarianceErrorState;
    107118    }
     119
     120    // IDeepCloneable members
     121    public object Clone() {
     122      return new OnlineMeanAndVarianceCalculator(this);
     123    }
     124
     125    public IDeepCloneable Clone(Cloner cloner) {
     126      var clone = cloner.GetClone(this);
     127      if (clone == null) {
     128        clone = (IDeepCloneable)this.Clone();
     129        cloner.RegisterClonedObject(this, clone);
     130      }
     131      return clone;
     132    }
    108133  }
    109134}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanErrorCalculator : IOnlineCalculator {
     27  public class OnlineMeanErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private readonly OnlineMeanAndVarianceCalculator meanAndVarianceCalculator;
     
    3435      meanAndVarianceCalculator = new OnlineMeanAndVarianceCalculator();
    3536      Reset();
     37    }
     38
     39    private OnlineMeanErrorCalculator(OnlineMeanAndVarianceCalculator meanAndVarianceCalculator) {
     40      this.meanAndVarianceCalculator = meanAndVarianceCalculator;
    3641    }
    3742
     
    7479      }
    7580    }
     81
     82    // IDeepCloneable members
     83    public object Clone() {
     84      var meanAndVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)meanAndVarianceCalculator.Clone();
     85      return new OnlineMeanErrorCalculator(meanAndVarianceCalculatorClone);
     86    }
     87
     88    public IDeepCloneable Clone(Cloner cloner) {
     89      var clone = cloner.GetClone(this);
     90      if (clone == null) {
     91        var meanAndVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)meanAndVarianceCalculator.Clone(cloner);
     92        clone = new OnlineMeanErrorCalculator(meanAndVarianceCalculatorClone);
     93        cloner.RegisterClonedObject(this, clone);
     94      }
     95      return clone;
     96    }
    7697  }
    7798}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanSquaredErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanSquaredErrorCalculator : IOnlineCalculator {
     27  public class OnlineMeanSquaredErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private double sse;
     
    3637    public OnlineMeanSquaredErrorCalculator() {
    3738      Reset();
     39    }
     40
     41    // private constructor used internally by the Clone() method
     42    private OnlineMeanSquaredErrorCalculator(OnlineMeanSquaredErrorCalculator other) {
     43      sse = other.sse;
     44      n = other.n;
     45      errorState = other.errorState;
    3846    }
    3947
     
    8795      }
    8896    }
     97
     98    // IDeepCloneable members
     99    public object Clone() {
     100      return new OnlineMeanSquaredErrorCalculator(this);
     101    }
     102
     103    public IDeepCloneable Clone(Cloner cloner) {
     104      var clone = cloner.GetClone(this);
     105      if (clone == null) {
     106        clone = (IDeepCloneable)this.Clone();
     107        cloner.RegisterClonedObject(this, clone);
     108      }
     109      return clone;
     110    }
    89111  }
    90112}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineNormalizedMeanSquaredErrorCalculator.cs

    r14226 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineNormalizedMeanSquaredErrorCalculator : IOnlineCalculator {
     27  public class OnlineNormalizedMeanSquaredErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728    private OnlineMeanAndVarianceCalculator meanSquaredErrorCalculator;
    2829    private OnlineMeanAndVarianceCalculator originalVarianceCalculator;
     
    4041      originalVarianceCalculator = new OnlineMeanAndVarianceCalculator();
    4142      Reset();
     43    }
     44
     45    // private constructor used internally by the Clone() method
     46    public OnlineNormalizedMeanSquaredErrorCalculator(OnlineMeanAndVarianceCalculator meanSquaredErrorCalculator, OnlineMeanAndVarianceCalculator originalVarianceCalculator) {
     47      this.meanSquaredErrorCalculator = meanSquaredErrorCalculator;
     48      this.originalVarianceCalculator = originalVarianceCalculator;
    4249    }
    4350
     
    9299      }
    93100    }
     101
     102    // IDeepCloneable members
     103    public object Clone() {
     104      var meanSquaredErrorCalculatorClone = (OnlineMeanAndVarianceCalculator)meanSquaredErrorCalculator.Clone();
     105      var originalVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)originalVarianceCalculator.Clone();
     106      return new OnlineNormalizedMeanSquaredErrorCalculator(meanSquaredErrorCalculatorClone, originalVarianceCalculatorClone);
     107    }
     108
     109    public IDeepCloneable Clone(Cloner cloner) {
     110      var clone = cloner.GetClone(this);
     111      if (clone == null) {
     112        var meanSquaredErrorCalculatorClone = (OnlineMeanAndVarianceCalculator)meanSquaredErrorCalculator.Clone(cloner);
     113        var originalVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)originalVarianceCalculator.Clone(cloner);
     114        clone = new OnlineNormalizedMeanSquaredErrorCalculator(meanSquaredErrorCalculatorClone, originalVarianceCalculatorClone);
     115        cloner.RegisterClonedObject(this, clone);
     116      }
     117      return clone;
     118    }
    94119  }
    95120}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRCalculator.cs

    r14185 r14293  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlinePearsonsRCalculator : IOnlineCalculator {
     27  public class OnlinePearsonsRCalculator : IOnlineCalculator, IDeepCloneable {
    2828    private OnlineCovarianceCalculator covCalculator = new OnlineCovarianceCalculator();
    2929    private OnlineMeanAndVarianceCalculator sxCalculator = new OnlineMeanAndVarianceCalculator();
     
    4646
    4747    public OnlinePearsonsRCalculator() { }
     48
     49    // private constructor used internally by the Clone() method
     50    private OnlinePearsonsRCalculator(OnlineCovarianceCalculator covCalculator, OnlineMeanAndVarianceCalculator sxCalculator, OnlineMeanAndVarianceCalculator syCalculator) {
     51      this.covCalculator = covCalculator;
     52      this.sxCalculator = sxCalculator;
     53      this.syCalculator = syCalculator;
     54    }
    4855
    4956    #region IOnlineCalculator Members
     
    9198      }
    9299    }
     100
     101    // IDeepCloneable members
     102    public object Clone() {
     103      var covCalculatorClone = (OnlineCovarianceCalculator)covCalculator.Clone();
     104      var sxCalculatorClone = (OnlineMeanAndVarianceCalculator)sxCalculator.Clone();
     105      var syCalculatorClone = (OnlineMeanAndVarianceCalculator)syCalculator.Clone();
     106      return new OnlinePearsonsRCalculator(covCalculatorClone, sxCalculatorClone, syCalculatorClone);
     107    }
     108
     109    public IDeepCloneable Clone(Cloner cloner) {
     110      var clone = cloner.GetClone(this);
     111      if (clone == null) {
     112        var covCalculatorClone = (OnlineCovarianceCalculator)covCalculator.Clone(cloner);
     113        var sxCalculatorClone = (OnlineMeanAndVarianceCalculator)sxCalculator.Clone(cloner);
     114        var syCalculatorClone = (OnlineMeanAndVarianceCalculator)syCalculator.Clone(cloner);
     115        clone = new OnlinePearsonsRCalculator(covCalculatorClone, sxCalculatorClone, syCalculatorClone);
     116        cloner.RegisterClonedObject(this, clone);
     117      }
     118      return clone;
     119    }
    93120  }
    94121}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRSquaredCalculator.cs

    r14185 r14293  
    2626namespace HeuristicLab.Problems.DataAnalysis {
    2727  [Obsolete("Use OnlinePearsonsRCalculator directly")]
    28   public class OnlinePearsonsRSquaredCalculator : IOnlineCalculator {
     28  public class OnlinePearsonsRSquaredCalculator : IOnlineCalculator, IDeepCloneable {
    2929    private readonly OnlinePearsonsRCalculator rCalculator = new OnlinePearsonsRCalculator();
    3030
     
    3737
    3838    public OnlinePearsonsRSquaredCalculator() { }
     39
     40    private OnlinePearsonsRSquaredCalculator(OnlinePearsonsRCalculator rCalculator) {
     41      this.rCalculator = rCalculator;
     42    }
    3943
    4044    #region IOnlineCalculator Members
     
    5963      return r * r;
    6064    }
     65
     66    // IDeepCloneable members
     67    public object Clone() {
     68      var rCalculatorClone = (OnlinePearsonsRCalculator)rCalculator.Clone();
     69      return new OnlinePearsonsRSquaredCalculator(rCalculatorClone);
     70    }
     71
     72    public IDeepCloneable Clone(Cloner cloner) {
     73      var clone = cloner.GetClone(this);
     74      if (clone == null) {
     75        var rCalculatorClone = (OnlinePearsonsRCalculator)rCalculator.Clone(cloner);
     76        clone = new OnlinePearsonsRSquaredCalculator(rCalculatorClone);
     77        cloner.RegisterClonedObject(this, clone);
     78      }
     79      return clone;
     80    }
    6181  }
    6282}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineTheilsUStatisticCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineTheilsUStatisticCalculator : IOnlineTimeSeriesCalculator {
     27  public class OnlineTheilsUStatisticCalculator : IOnlineTimeSeriesCalculator, IDeepCloneable {
    2728    private OnlineMeanAndVarianceCalculator squaredErrorMeanCalculator;
    2829    private OnlineMeanAndVarianceCalculator unbiasedEstimatorMeanCalculator;
     
    4344      unbiasedEstimatorMeanCalculator = new OnlineMeanAndVarianceCalculator();
    4445      Reset();
     46    }
     47
     48    // private constructor used internally by the Clone() method
     49    private OnlineTheilsUStatisticCalculator(OnlineMeanAndVarianceCalculator squaredErrorMeanCalculator, OnlineMeanAndVarianceCalculator unbiasedEstimatorMeanCalculator) {
     50      this.squaredErrorMeanCalculator = squaredErrorMeanCalculator;
     51      this.unbiasedEstimatorMeanCalculator = unbiasedEstimatorMeanCalculator;
    4552    }
    4653
     
    125132      }
    126133    }
     134
     135    // IDeepCloneable members
     136    public object Clone() {
     137      var squaredErrorMeanCalculatorClone = (OnlineMeanAndVarianceCalculator)squaredErrorMeanCalculator.Clone();
     138      var unbiasedEstimatorMeanCalculatorClone = (OnlineMeanAndVarianceCalculator)unbiasedEstimatorMeanCalculator.Clone();
     139      return new OnlineTheilsUStatisticCalculator(squaredErrorMeanCalculatorClone, unbiasedEstimatorMeanCalculatorClone);
     140    }
     141
     142    public IDeepCloneable Clone(Cloner cloner) {
     143      var clone = cloner.GetClone(this);
     144      if (clone == null) {
     145        var squaredErrorMeanCalculatorClone = (OnlineMeanAndVarianceCalculator)squaredErrorMeanCalculator.Clone(cloner);
     146        var unbiasedEstimatorMeanCalculatorClone = (OnlineMeanAndVarianceCalculator)unbiasedEstimatorMeanCalculator.Clone(cloner);
     147        clone = new OnlineTheilsUStatisticCalculator(squaredErrorMeanCalculatorClone, unbiasedEstimatorMeanCalculatorClone);
     148        cloner.RegisterClonedObject(this, clone);
     149      }
     150      return clone;
     151    }
    127152  }
    128153}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineWeightedDirectionalSymmetryCalculator.cs

    r14185 r14293  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis {
    28   public class OnlineWeightedDirectionalSymmetryCalculator : IOnlineTimeSeriesCalculator {
     28  public class OnlineWeightedDirectionalSymmetryCalculator : IOnlineTimeSeriesCalculator, IDeepCloneable {
    2929    private int n;
    3030    private double correctSum;
     
    4040    public OnlineWeightedDirectionalSymmetryCalculator() {
    4141      Reset();
     42    }
     43
     44    // private constructor used internally by the Clone() method
     45    private OnlineWeightedDirectionalSymmetryCalculator(OnlineWeightedDirectionalSymmetryCalculator other) {
     46      n = other.n;
     47      correctSum = other.correctSum;
     48      incorrectSum = other.incorrectSum;
     49      errorState = other.errorState;
    4250    }
    4351
     
    118126      }
    119127    }
     128
     129    // IDeepCloneable members
     130    public object Clone() {
     131      return new OnlineWeightedDirectionalSymmetryCalculator(this);
     132    }
     133
     134    public IDeepCloneable Clone(Cloner cloner) {
     135      var clone = cloner.GetClone(this);
     136      if (clone == null) {
     137        clone = (IDeepCloneable)this.Clone();
     138        cloner.RegisterClonedObject(this, clone);
     139      }
     140      return clone;
     141    }
    120142  }
    121143}
Note: See TracChangeset for help on using the changeset viewer.