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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.