Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 15:03:46 (12 years ago)
Author:
gkronber
Message:

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

Location:
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3
Files:
2 added
1 deleted
63 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs

    r4461 r5275  
    3535  public class DataAnalysisProblem : ParameterizedNamedItem, IDataAnalysisProblem, IStorableContent {
    3636    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
     37
     38    public string Filename { get; set; }
     39
    3740    public override Image ItemImage {
    3841      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
    3942    }
    40 
    41     public string Filename { get; set; }
    4243
    4344    #region Parameter Properties
     
    5455    [StorableConstructor]
    5556    protected DataAnalysisProblem(bool deserializing) : base(deserializing) { }
     57    protected DataAnalysisProblem(DataAnalysisProblem original, Cloner cloner)
     58      : base(original, cloner) {
     59      RegisterParameterEvents();
     60      RegisterParameterValueEvents();
     61    }
     62
    5663    public DataAnalysisProblem()
    5764      : base() {
     
    6269
    6370    [StorableHook(HookType.AfterDeserialization)]
    64     private void AfterDeserializationHook() {
     71    private void AfterDeserialization() {
    6572      RegisterParameterEvents();
    6673      RegisterParameterValueEvents();
     
    9097
    9198    public override IDeepCloneable Clone(Cloner cloner) {
    92       DataAnalysisProblem clone = (DataAnalysisProblem)base.Clone(cloner);
    93       clone.RegisterParameterEvents();
    94       clone.RegisterParameterValueEvents();
    95       return clone;
     99      return new DataAnalysisProblem(this, cloner);
    96100    }
    97101
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs

    r4457 r5275  
    3434  [StorableClass]
    3535  public class DataAnalysisProblemData : ParameterizedNamedItem, IStorableContent {
    36     private bool suppressEvents = false;
    37 
     36    protected bool suppressEvents = false;
    3837    #region IStorableContent Members
    3938    public string Filename { get; set; }
    4039    #endregion
    41 
    4240    #region default data
    4341    // y = x^4 + x^3 + x^2 + x
     
    7169    #endregion
    7270    #region parameter properties
    73     public IValueParameter<Dataset> DatasetParameter {
    74       get { return (IValueParameter<Dataset>)Parameters["Dataset"]; }
     71    public ValueParameter<Dataset> DatasetParameter {
     72      get { return (ValueParameter<Dataset>)Parameters["Dataset"]; }
    7573    }
    7674    public IValueParameter<StringValue> TargetVariableParameter {
     
    9290      get { return (IValueParameter<IntValue>)Parameters["TestSamplesEnd"]; }
    9391    }
     92    public IValueParameter<PercentValue> ValidationPercentageParameter {
     93      get { return (IValueParameter<PercentValue>)Parameters["ValidationPercentage"]; }
     94    }
    9495    #endregion
    9596
    9697    #region properties
    9798    public Dataset Dataset {
    98       get { return (Dataset)DatasetParameter.Value; }
     99      get { return DatasetParameter.Value; }
    99100      set {
    100101        if (value != Dataset) {
     
    105106    }
    106107    public StringValue TargetVariable {
    107       get { return (StringValue)TargetVariableParameter.Value; }
     108      get { return TargetVariableParameter.Value; }
    108109      set {
    109110        if (value != TargetVariableParameter.Value) {
     
    115116    }
    116117    public ICheckedItemList<StringValue> InputVariables {
    117       get { return (ICheckedItemList<StringValue>)InputVariablesParameter.Value; }
     118      get { return InputVariablesParameter.Value; }
    118119      set {
    119120        if (value != InputVariables) {
     
    125126    }
    126127    public IntValue TrainingSamplesStart {
    127       get { return (IntValue)TrainingSamplesStartParameter.Value; }
     128      get { return TrainingSamplesStartParameter.Value; }
    128129      set {
    129130        if (value != TrainingSamplesStart) {
     
    135136    }
    136137    public IntValue TrainingSamplesEnd {
    137       get { return (IntValue)TrainingSamplesEndParameter.Value; }
     138      get { return TrainingSamplesEndParameter.Value; }
    138139      set {
    139140        if (value != TrainingSamplesEnd) {
     
    145146    }
    146147    public IntValue TestSamplesStart {
    147       get { return (IntValue)TestSamplesStartParameter.Value; }
     148      get { return TestSamplesStartParameter.Value; }
    148149      set {
    149150        if (value != TestSamplesStart) {
     
    155156    }
    156157    public IntValue TestSamplesEnd {
    157       get { return (IntValue)TestSamplesEndParameter.Value; }
     158      get { return TestSamplesEndParameter.Value; }
    158159      set {
    159160        if (value != TestSamplesEnd) {
     
    164165      }
    165166    }
    166     #endregion
    167 
     167    public PercentValue ValidationPercentage {
     168      get { return ValidationPercentageParameter.Value; }
     169      set {
     170        if (value != ValidationPercentage) {
     171          if (value == null) throw new ArgumentNullException();
     172          if (value.Value < 0 || value.Value > 1) throw new ArgumentException("ValidationPercentage must be between 0 and 1.");
     173          if (ValidationPercentage != null) DeregisterValueTypeEventHandlers(ValidationPercentage);
     174          ValidationPercentageParameter.Value = value;
     175        }
     176      }
     177    }
     178
     179    public IEnumerable<int> TrainingIndizes {
     180      get {
     181        return Enumerable.Range(TrainingSamplesStart.Value, TrainingSamplesEnd.Value - TrainingSamplesStart.Value)
     182                         .Where(i => i >= 0 && i < Dataset.Rows && (i < TestSamplesStart.Value || TestSamplesEnd.Value <= i));
     183      }
     184    }
     185    public IEnumerable<int> TestIndizes {
     186      get {
     187        return Enumerable.Range(TestSamplesStart.Value, TestSamplesEnd.Value - TestSamplesStart.Value)
     188           .Where(i => i >= 0 && i < Dataset.Rows);
     189      }
     190    }
     191    #endregion
     192
     193    [StorableConstructor]
     194    protected DataAnalysisProblemData(bool deserializing) : base(deserializing) { }
     195    protected DataAnalysisProblemData(DataAnalysisProblemData original, Cloner cloner)
     196      : base(original, cloner) {
     197      RegisterParameterEventHandlers();
     198      RegisterParameterValueEventHandlers();
     199    }
    168200    public DataAnalysisProblemData()
    169201      : base() {
     
    181213      Parameters.Add(new ValueParameter<IntValue>("TestSamplesStart", new IntValue(15)));
    182214      Parameters.Add(new ValueParameter<IntValue>("TestSamplesEnd", new IntValue(25)));
     215      Parameters.Add(new ValueParameter<PercentValue>("ValidationPercentage", "The relative amount of the training samples that should be used as validation set.", new PercentValue(0.5)));
     216
     217      DatasetParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    183218      RegisterParameterEventHandlers();
    184219      RegisterParameterValueEventHandlers();
     
    187222    public DataAnalysisProblemData(Dataset dataset, IEnumerable<string> inputVariables, string targetVariable,
    188223      int trainingSamplesStart, int trainingSamplesEnd, int testSamplesStart, int testSamplesEnd) {
    189       var inputVariablesList = new CheckedItemList<StringValue>(inputVariables.Select(x => new StringValue(x)));
     224      var inputVariablesList = new CheckedItemList<StringValue>(inputVariables.Select(x => new StringValue(x)).ToList());
    190225      StringValue targetVariableValue = new StringValue(targetVariable);
    191226      var validTargetVariables = new ItemSet<StringValue>();
     
    201236      Parameters.Add(new ValueParameter<IntValue>("TestSamplesStart", new IntValue(testSamplesStart)));
    202237      Parameters.Add(new ValueParameter<IntValue>("TestSamplesEnd", new IntValue(testSamplesEnd)));
     238      Parameters.Add(new ValueParameter<PercentValue>("ValidationPercentage", "The relative amount of the training samples that should be used as validation set.", new PercentValue(0.5)));
     239
     240      DatasetParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    203241      RegisterParameterEventHandlers();
    204242      RegisterParameterValueEventHandlers();
    205243    }
    206244
    207     [StorableConstructor]
    208     private DataAnalysisProblemData(bool deserializing) : base(deserializing) { }
     245    public override IDeepCloneable Clone(Cloner cloner) {
     246      return new DataAnalysisProblemData(this, cloner);
     247    }
    209248
    210249    [StorableHook(HookType.AfterDeserialization)]
    211     private void AfterDeserializationHook() {
     250    private void AfterDeserialization() {
     251      if (!Parameters.ContainsKey("ValidationPercentage"))
     252        Parameters.Add(new ValueParameter<PercentValue>("ValidationPercentage", "The relative amount of the training samples that should be used as validation set.", new PercentValue(0.5)));
     253
     254      DatasetParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    212255      RegisterParameterEventHandlers();
    213256      RegisterParameterValueEventHandlers();
     
    217260    public event EventHandler ProblemDataChanged;
    218261    protected virtual void OnProblemDataChanged(EventArgs e) {
    219       if (!suppressEvents) {
     262      if (TrainingSamplesStart.Value < 0) TrainingSamplesStart.Value = 0;
     263      else if (TestSamplesStart.Value < 0) TestSamplesStart.Value = 0;
     264      else if (TrainingSamplesEnd.Value > Dataset.Rows - 1) TrainingSamplesEnd.Value = Dataset.Rows - 1;
     265      else if (TestSamplesEnd.Value > Dataset.Rows - 1) TestSamplesEnd.Value = Dataset.Rows - 1;
     266      else if (TrainingSamplesStart.Value > TrainingSamplesEnd.Value) TrainingSamplesStart.Value = TestSamplesEnd.Value;
     267      else if (TestSamplesStart.Value > TestSamplesEnd.Value) TestSamplesStart.Value = TestSamplesEnd.Value;
     268      else if (ValidationPercentage.Value < 0) ValidationPercentage.Value = 0;
     269      else if (ValidationPercentage.Value > 1) ValidationPercentage.Value = 1;
     270      else if (!TrainingIndizes.Any()) throw new ArgumentException("No training samples are available.");
     271      else if (!suppressEvents) {
    220272        var listeners = ProblemDataChanged;
    221273        if (listeners != null) listeners(this, e);
     
    231283      TestSamplesStartParameter.ValueChanged += new EventHandler(TestSamplesStartParameter_ValueChanged);
    232284      TestSamplesEndParameter.ValueChanged += new EventHandler(TestSamplesEndParameter_ValueChanged);
     285      ValidationPercentageParameter.ValueChanged += new EventHandler(ValidationPercentageParameter_ValueChanged);
    233286    }
    234287
     
    240293      RegisterValueTypeEventHandlers(TestSamplesStart);
    241294      RegisterValueTypeEventHandlers(TestSamplesEnd);
     295      RegisterValueTypeEventHandlers(ValidationPercentage);
    242296    }
    243297
     
    271325    private void TestSamplesEndParameter_ValueChanged(object sender, EventArgs e) {
    272326      RegisterValueTypeEventHandlers(TestSamplesEnd);
     327      OnProblemDataChanged(EventArgs.Empty);
     328    }
     329    private void ValidationPercentageParameter_ValueChanged(object sender, EventArgs e) {
     330      RegisterValueTypeEventHandlers(ValidationPercentage);
    273331      OnProblemDataChanged(EventArgs.Empty);
    274332    }
     
    338396
    339397    public virtual void ImportFromFile(string fileName) {
    340       var csvFileParser = new CsvFileParser();
     398      var csvFileParser = new TableFileParser();
    341399      csvFileParser.Parse(fileName);
    342400      suppressEvents = true;
     
    352410      InputVariables.SetItemCheckedState(variableNames.First(), false);
    353411      int middle = (int)(csvFileParser.Rows * 0.5);
     412      TrainingSamplesEnd = new IntValue(middle);
    354413      TrainingSamplesStart = new IntValue(0);
    355       TrainingSamplesEnd = new IntValue(middle);
     414      TestSamplesEnd = new IntValue(csvFileParser.Rows);
    356415      TestSamplesStart = new IntValue(middle);
    357       TestSamplesEnd = new IntValue(csvFileParser.Rows);
    358416      suppressEvents = false;
    359417      OnProblemDataChanged(EventArgs.Empty);
    360     }
    361 
    362     public override IDeepCloneable Clone(Cloner cloner) {
    363       DataAnalysisProblemData clone = (DataAnalysisProblemData)base.Clone(cloner);
    364       clone.RegisterParameterEventHandlers();
    365       clone.RegisterParameterValueEventHandlers();
    366       return clone;
    367418    }
    368419  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisSolution.cs

    r4457 r5275  
    3838    #endregion
    3939
    40 
     40    [StorableConstructor]
     41    protected DataAnalysisSolution(bool deserializing) : base(deserializing) { }
     42    protected DataAnalysisSolution(DataAnalysisSolution original, Cloner cloner)
     43      : base(original, cloner) {
     44      problemData = (DataAnalysisProblemData)cloner.Clone(original.problemData);
     45      model = (IDataAnalysisModel)cloner.Clone(original.model);
     46      lowerEstimationLimit = original.lowerEstimationLimit;
     47      upperEstimationLimit = original.upperEstimationLimit;
     48      AfterDeserialization();
     49    }
    4150    protected DataAnalysisSolution()
    4251      : base() { }
     
    4756      this.lowerEstimationLimit = lowerEstimationLimit;
    4857      this.upperEstimationLimit = upperEstimationLimit;
    49       Initialize();
     58      AfterDeserialization();
    5059    }
    5160
    52     [StorableConstructor]
    53     protected DataAnalysisSolution(bool deserializing) : base(deserializing) { }
    5461    [StorableHook(HookType.AfterDeserialization)]
    55     private void Initialize() {
     62    private void AfterDeserialization() {
    5663      if (problemData != null)
    5764        RegisterProblemDataEvents();
     
    134141    public event EventHandler ProblemDataChanged;
    135142    protected virtual void OnProblemDataChanged() {
    136       RecalculateEstimatedValues();
    137143      var listeners = ProblemDataChanged;
    138144      if (listeners != null)
     
    142148    public event EventHandler ModelChanged;
    143149    protected virtual void OnModelChanged() {
    144       EventHandler handler = ModelChanged;
    145       if (handler != null)
    146         handler(this, EventArgs.Empty);
     150      EventHandler listeners = ModelChanged;
     151      if (listeners != null)
     152        listeners(this, EventArgs.Empty);
    147153    }
    148154
     
    155161    #endregion
    156162
    157     public override IDeepCloneable Clone(Cloner cloner) {
    158       DataAnalysisSolution clone = (DataAnalysisSolution)base.Clone(cloner);
    159       clone.problemData = (DataAnalysisProblemData)cloner.Clone(problemData);
    160       clone.model = (IDataAnalysisModel)cloner.Clone(model);
    161       clone.lowerEstimationLimit = lowerEstimationLimit;
    162       clone.upperEstimationLimit = upperEstimationLimit;
    163       clone.Initialize();
    164 
    165       return clone;
    166     }
    167163  }
    168164}
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/DataFormatException.cs

    r4341 r5275  
    2121
    2222using System;
     23using System.Runtime.Serialization;
    2324
    2425namespace HeuristicLab.Problems.DataAnalysis {
     26  [Serializable]
    2527  public class DataFormatException : Exception {
    2628    private int line;
     
    3739      this.line = line;
    3840    }
     41
     42    public DataFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    3943  }
    4044}
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Dataset.cs

    r4341 r5275  
    3232  [StorableClass]
    3333  public sealed class Dataset : NamedItem, IStringConvertibleMatrix {
    34     // empty constructor for cloning
    35     private Dataset()
    36       : base() {
    37     }
    38 
    3934    [StorableConstructor]
    40     private Dataset(bool deserializing)
    41       : base(deserializing) {
    42     }
    43 
     35    private Dataset(bool deserializing) : base(deserializing) { }
     36    private Dataset(Dataset original, Cloner cloner)
     37      : base(original, cloner) {
     38      variableNames = original.variableNames;
     39      data = original.data;
     40    }
    4441    public Dataset(IEnumerable<string> variableNames, double[,] data)
    4542      : base() {
     
    122119    }
    123120
    124 
    125 
    126121    public string GetVariableName(int variableIndex) {
    127122      return variableNames[variableIndex];
     
    140135
    141136    public override IDeepCloneable Clone(Cloner cloner) {
    142       Dataset clone = (Dataset)base.Clone(cloner);
    143       clone.variableNames = variableNames;
    144       clone.data = data;
    145       return clone;
     137      return new Dataset(this, cloner);
    146138    }
    147139
     
    195187    }
    196188
     189    public event EventHandler ColumnsChanged;
     190    private void OnColumnsChanged() {
     191      var handler = ColumnsChanged;
     192      if (handler != null) handler(this, EventArgs.Empty);
     193    }
     194    public event EventHandler RowsChanged;
     195    private void OnRowsChanged() {
     196      var handler = RowsChanged;
     197      if (handler != null) handler(this, EventArgs.Empty);
     198    }
    197199    public event EventHandler ColumnNamesChanged;
    198200    private void OnColumnNamesChanged() {
    199       EventHandler handler = ColumnNamesChanged;
    200       if (handler != null)
    201         handler(this, EventArgs.Empty);
     201      EventHandler listeners = ColumnNamesChanged;
     202      if (listeners != null)
     203        listeners(this, EventArgs.Empty);
    202204    }
    203205    public event EventHandler RowNamesChanged;
    204206    private void OnRowNamesChanged() {
    205       EventHandler handler = RowNamesChanged;
    206       if (handler != null)
    207         handler(this, EventArgs.Empty);
     207      EventHandler listeners = RowNamesChanged;
     208      if (listeners != null)
     209        listeners(this, EventArgs.Empty);
    208210    }
    209211    public event EventHandler SortableViewChanged;
    210212    private void OnSortableViewChanged() {
    211       EventHandler handler = SortableViewChanged;
    212       if (handler != null)
    213         handler(this, EventArgs.Empty);
     213      EventHandler listeners = SortableViewChanged;
     214      if (listeners != null)
     215        listeners(this, EventArgs.Empty);
    214216    }
    215217    public event EventHandler<EventArgs<int, int>> ItemChanged;
    216218    private void OnItemChanged(int rowIndex, int columnIndex) {
    217       if (ItemChanged != null)
    218         ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));
     219      var listeners = ItemChanged;
     220      if (listeners != null)
     221        listeners(this, new EventArgs<int, int>(rowIndex, columnIndex));
    219222      OnToStringChanged();
    220223    }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/OnlineCovarianceEvaluator.cs

    r4233 r5275  
    2525  public class OnlineCovarianceEvaluator : IOnlineEvaluator {
    2626
    27     private double xMean, yMean, Cn;
     27    private double originalMean, estimatedMean, Cn;
    2828    private int n;
    2929    public double Covariance {
     
    4747      n = 0;
    4848      Cn = 0.0;
    49       xMean = 0.0;
    50       yMean = 0.0;
     49      originalMean = 0.0;
     50      estimatedMean = 0.0;
    5151    }
    5252
    53     public void Add(double x, double y) {
    54       if (double.IsNaN(x) || double.IsInfinity(x) ||
    55           double.IsNaN(y) || double.IsInfinity(y)) {
     53    public void Add(double original, double estimated) {
     54      if (double.IsNaN(estimated) || double.IsInfinity(estimated) ||
     55          double.IsNaN(original) || double.IsInfinity(original)) {
    5656        throw new ArgumentException("Covariance is not defined for series containing NaN or infinity elements");
    5757      } else {
    5858        n++;
    5959        // online calculation of tMean
    60 
    61         xMean = xMean + (x - xMean) / n;
    62         double deltaY = y - yMean; // delta = (y - yMean(n-1))
    63         yMean = yMean + deltaY / n;
     60        originalMean = originalMean + (original - originalMean) / n;
     61        double delta = estimated - estimatedMean; // delta = (y - yMean(n-1))
     62        estimatedMean = estimatedMean + delta / n;
    6463
    6564        // online calculation of covariance
    66         Cn = Cn + deltaY * (x - xMean); // C(n) = C(n-1) + (y - yMean(n-1)) (x - xMean(n))
     65        Cn = Cn + delta * (original - originalMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n))       
    6766      }
    6867    }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleEvaluator.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
    2425using HeuristicLab.Operators;
    2526using HeuristicLab.Parameters;
     27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2628
    2729namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    3234    public ILookupParameter<DoubleMatrix> ValuesParameter {
    3335      get { return (ILookupParameter<DoubleMatrix>)Parameters["Values"]; }
     36    }
     37    [StorableConstructor]
     38    protected SimpleEvaluator(bool deserializing) : base(deserializing) { }
     39    protected SimpleEvaluator(SimpleEvaluator original, Cloner cloner)
     40      : base(original, cloner) {
    3441    }
    3542    public SimpleEvaluator()
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleMSEEvaluator.cs

    r4341 r5275  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
    2931namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    3436    }
    3537
     38    [StorableConstructor]
     39    protected SimpleMSEEvaluator(bool deserializing) : base(deserializing) { }
     40    protected SimpleMSEEvaluator(SimpleMSEEvaluator original, Cloner cloner)
     41      : base(original, cloner) {
     42    }
     43    public override IDeepCloneable Clone(Cloner cloner) {
     44      return new SimpleMSEEvaluator(this, cloner);
     45    }
    3646    public SimpleMSEEvaluator() {
    3747      Parameters.Add(new LookupParameter<DoubleValue>("MeanSquaredError", "The mean squared error of estimated values."));
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleMeanAbsolutePercentageErrorEvaluator.cs

    r4068 r5275  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
    2931namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    3335    }
    3436
     37    [StorableConstructor]
     38    protected SimpleMeanAbsolutePercentageErrorEvaluator(bool deserializing) : base(deserializing) { }
     39    protected SimpleMeanAbsolutePercentageErrorEvaluator(SimpleMeanAbsolutePercentageErrorEvaluator original, Cloner cloner)
     40      : base(original, cloner) {
     41    }
    3542    public SimpleMeanAbsolutePercentageErrorEvaluator() {
    3643      Parameters.Add(new LookupParameter<PercentValue>("AverageRelativeError", "The average relative error of estimated values."));
     
    4350                      select values[i, ESTIMATION_INDEX];
    4451      AverageRelativeErrorParameter.ActualValue = new PercentValue(Calculate(original, estimated));
     52    }
     53
     54    public override IDeepCloneable Clone(Cloner cloner) {
     55      return new SimpleMeanAbsolutePercentageErrorEvaluator(this, cloner);
    4556    }
    4657
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.cs

    r4068 r5275  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
    3031namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    3536    }
    3637
     38    [StorableConstructor]
     39    protected SimpleMeanAbsolutePercentageOfRangeErrorEvaluator(bool deserializing) : base(deserializing) { }
     40    protected SimpleMeanAbsolutePercentageOfRangeErrorEvaluator(SimpleMeanAbsolutePercentageOfRangeErrorEvaluator original, Cloner cloner)
     41      : base(original, cloner) {
     42    }
    3743    public SimpleMeanAbsolutePercentageOfRangeErrorEvaluator() {
    3844      Parameters.Add(new LookupParameter<PercentValue>("AveragePercentageOfRangeError", "The average relative (percentage of range) error of estimated values."));
     
    4551                      select values[i, ESTIMATION_INDEX];
    4652      AveragePercentageOfRangeErrorParameter.ActualValue = new PercentValue(Calculate(original, estimated));
     53    }
     54
     55    public override IDeepCloneable Clone(Cloner cloner) {
     56      return new SimpleMeanAbsolutePercentageOfRangeErrorEvaluator(this, cloner);
    4757    }
    4858
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleNMSEEvaluator.cs

    r4068 r5275  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
    2931namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    3436    }
    3537
     38    [StorableConstructor]
     39    protected SimpleNMSEEvaluator(bool deserializing) : base(deserializing) { }
     40    protected SimpleNMSEEvaluator(SimpleNMSEEvaluator original, Cloner cloner)
     41      : base(original, cloner) {
     42    }
     43    public override IDeepCloneable Clone(Cloner cloner) {
     44      return new SimpleNMSEEvaluator(this, cloner);
     45    }
    3646    public SimpleNMSEEvaluator() {
    3747      Parameters.Add(new LookupParameter<DoubleValue>("NormalizedMeanSquaredError", "The normalized mean squared error (divided by variance) of estimated values."));
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleRSquaredEvaluator.cs

    r4068 r5275  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
    2931namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    3234      get { return (ILookupParameter<DoubleValue>)Parameters["RSquared"]; }
    3335    }
    34 
     36    [StorableConstructor]
     37    protected SimpleRSquaredEvaluator(bool deserializing) : base(deserializing) { }
     38    protected SimpleRSquaredEvaluator(SimpleRSquaredEvaluator original, Cloner cloner)
     39      : base(original, cloner) {
     40    }
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new SimpleRSquaredEvaluator(this, cloner);
     43    }
    3544    public SimpleRSquaredEvaluator() {
    3645      Parameters.Add(new LookupParameter<DoubleValue>("RSquared", "The squared Pearson's Product Moment Correlation (R²) of estimated values and original values."));
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Evaluators/SimpleVarianceAccountedForEvaluator.cs

    r4068 r5275  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
    3031namespace HeuristicLab.Problems.DataAnalysis.Evaluators {
     
    4041    }
    4142
     43    [StorableConstructor]
     44    protected SimpleVarianceAccountedForEvaluator(bool deserializing) : base(deserializing) { }
     45    protected SimpleVarianceAccountedForEvaluator(SimpleVarianceAccountedForEvaluator original, Cloner cloner)
     46      : base(original, cloner) {
     47    }
     48    public override IDeepCloneable Clone(Cloner cloner) {
     49      return new SimpleVarianceAccountedForEvaluator(this, cloner);
     50    }
    4251    public SimpleVarianceAccountedForEvaluator() {
    4352      Parameters.Add(new LookupParameter<DoubleValue>("VarianceAccountedFor", "The variance of the original values accounted for by the estimated values (VAF(y,y') = 1 - var(y-y') / var(y) )."));
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj

    r5265 r5275  
    107107      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    108108    </Reference>
     109    <Reference Include="HeuristicLab.Common.Resources-3.3">
     110      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     111    </Reference>
    109112    <Reference Include="HeuristicLab.Core-3.3">
    110113      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
     
    158161  </ItemGroup>
    159162  <ItemGroup>
     163    <Compile Include="Interfaces\ISingleObjectiveDataAnalysisProblem.cs" />
     164    <Compile Include="TableFileParser.cs" />
    160165    <None Include="HeuristicLab.snk" />
    161166    <None Include="HeuristicLabProblemsDataAnalysisPlugin.cs.frame" />
     
    166171    <Compile Include="Evaluators\OnlineNormalizedMeanSquaredErrorEvaluator.cs" />
    167172    <Compile Include="DataAnalysisSolution.cs" />
    168     <Compile Include="CsvFileParser.cs" />
    169173    <Compile Include="DataAnalysisProblem.cs" />
    170174    <Compile Include="DataAnalysisProblemData.cs" />
     
    269273SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\HeuristicLabProblemsDataAnalysisPlugin.cs.frame" "%25ProjectDir%25\HeuristicLabProblemsDataAnalysisPlugin.cs"</PreBuildEvent>
    270274  </PropertyGroup>
     275  <PropertyGroup>
     276    <PostBuildEvent>
     277    </PostBuildEvent>
     278  </PropertyGroup>
    271279</Project>
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLabProblemsDataAnalysisPlugin.cs.frame

    r4044 r5275  
    2828  [Plugin("HeuristicLab.Problems.DataAnalysis","3.3.0.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis-3.3.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.ALGLIB", "2.5")]
     30  [PluginDependency("HeuristicLab.ALGLIB", "3.1")]
    3131  [PluginDependency("HeuristicLab.Collections", "3.3.0.0")]
    3232  [PluginDependency("HeuristicLab.Common", "3.3.0.0")]
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Interfaces/IDataAnalysisProblem.cs

    r4068 r5275  
    2424namespace HeuristicLab.Problems.DataAnalysis {
    2525  public interface IDataAnalysisProblem : IProblem {
     26    DataAnalysisProblemData DataAnalysisProblemData { get; }
    2627  }
    2728}
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/CovariantParsimonyPressure.cs

    r5265 r5275  
    3232using HeuristicLab.Problems.DataAnalysis.Evaluators;
    3333using HeuristicLab.Analysis;
     34using HeuristicLab.Common;
    3435
    3536namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    8081    }
    8182
    82     public CovariantParsimonyPressure(bool deserializing) : base(deserializing) { }
     83    protected CovariantParsimonyPressure(bool deserializing) : base(deserializing) { }
     84    protected CovariantParsimonyPressure(CovariantParsimonyPressure original, Cloner clone) : base(original, clone) { }
    8385    public CovariantParsimonyPressure()
    8486      : base() {
     
    98100      Parameters.Add(new ValueLookupParameter<BoolValue>("InvertComplexityAdaption"));
    99101    }
     102
     103    public override IDeepCloneable Clone(Cloner cloner) {
     104      return new CovariantParsimonyPressure(this, cloner);
     105    }
     106
    100107
    101108    [StorableHook(Persistence.Default.CompositeSerializers.Storable.HookType.AfterDeserialization)]
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/CovariantParsimonyPressureAdder.cs

    r5265 r5275  
    3232using HeuristicLab.Problems.DataAnalysis.Evaluators;
    3333using HeuristicLab.Analysis;
     34using HeuristicLab.Common;
    3435
    3536namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    6667
    6768    [StorableConstructor]
    68     public CovariantParsimonyPressureAdder(bool deserializing) : base(deserializing) { }
     69    protected CovariantParsimonyPressureAdder(bool deserializing) : base(deserializing) { }
     70    protected CovariantParsimonyPressureAdder(CovariantParsimonyPressureAdder original, Cloner cloner) : base(original, cloner) { }
    6971    public CovariantParsimonyPressureAdder()
    7072      : base() {
     
    7981      Parameters.Add(new ValueLookupParameter<BoolValue>("ApplyParsimonyPressure"));
    8082    }
    81 
     83    public override IDeepCloneable Clone(Cloner cloner) {
     84      return new CovariantParsimonyPressureAdder(this, cloner);
     85    }
    8286    [StorableHook(Persistence.Default.CompositeSerializers.Storable.HookType.AfterDeserialization)]
    8387    private void AfterDeserialization() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/DynOpEqComparator.cs

    r5265 r5275  
    3030using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3131using System.Collections.Generic;
     32using HeuristicLab.Common;
    3233
    3334namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    8182    }
    8283
     84    [StorableConstructor]
     85    protected DynOpEqComparator(bool deserializing) : base(deserializing) { }
     86    protected DynOpEqComparator(DynOpEqComparator original, Cloner cloner)
     87      : base(original, cloner) {
     88    }
    8389    public DynOpEqComparator()
    8490      : base() {
     
    100106    }
    101107
     108    public override IDeepCloneable Clone(Cloner cloner) {
     109      return new DynOpEqComparator(this, cloner);
     110    }
    102111    public override IOperation Apply() {
    103112      if (ResultParameter.ActualValue == null || ResultParameter.ActualValue.Value == true) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/DynOpEqHistogramInitializer.cs

    r5265 r5275  
    3030using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3131using System.Collections.Generic;
     32using HeuristicLab.Common;
    3233
    3334namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    6364    }
    6465
     66    [StorableConstructor]
     67    protected DynOpEqHistogramInitializer(bool deserializing) : base(deserializing) { }
     68    protected DynOpEqHistogramInitializer(DynOpEqHistogramInitializer original, Cloner cloner)
     69      : base(original, cloner) {
     70    }
    6571    public DynOpEqHistogramInitializer()
    6672      : base() {
     
    7581      Parameters.Add(new LookupParameter<BoolValue>("Maximization"));
    7682    }
    77 
     83    public override IDeepCloneable Clone(Cloner cloner) {
     84      return new DynOpEqHistogramInitializer(this, cloner);
     85    }
    7886    public override IOperation Apply() {
    7987      if (BinCapacityParameter.ActualValue == null) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/DynamicDepthLimitComparator.cs

    r5265 r5275  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     31using HeuristicLab.Common;
    3132
    3233namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    6566    }
    6667
     68    [StorableConstructor]
     69    protected DynamicDepthLimitComparator(bool deserializing) : base(deserializing) { }
     70    protected DynamicDepthLimitComparator(DynamicDepthLimitComparator original, Cloner cloner)
     71      : base(original, cloner) {
     72    }
     73
    6774    public DynamicDepthLimitComparator()
    6875      : base() {
     
    7784      Parameters.Add(new ValueParameter<DoubleValue>("cLower", "", new DoubleValue(0.03)));
    7885      Parameters.Add(new ValueParameter<DoubleValue>("cRaise", "", new DoubleValue(0.015)));
     86    }
     87
     88    public override IDeepCloneable Clone(Cloner cloner) {
     89      return new DynamicDepthLimitComparator(this, cloner);
    7990    }
    8091
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/DynamicDepthLimitInitializer.cs

    r5265 r5275  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     31using HeuristicLab.Common;
    3132
    3233namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    4142    }
    4243
     44    [StorableConstructor]
     45    protected DynamicDepthLimitInitializer(bool deserializing) : base(deserializing) { }
     46    protected DynamicDepthLimitInitializer(DynamicDepthLimitInitializer original, Cloner cloner)
     47      : base(original, cloner) {
     48    }
    4349    public DynamicDepthLimitInitializer()
    4450      : base() {
    4551      Parameters.Add(new ValueLookupParameter<IntValue>("DynamicDepthLimit", "The current depth limit."));
    4652      Parameters.Add(new ValueLookupParameter<IntValue>("InitialDepthLimit", "The initial depth limit."));
     53    }
     54    public override IDeepCloneable Clone(Cloner cloner) {
     55      return new DynamicDepthLimitInitializer(this, cloner);
    4756    }
    4857
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/WeightedParentsQualityVarianceComparator.cs

    r5265 r5275  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Common;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis.Operators {
     
    6162    }
    6263
     64    [StorableConstructor]
     65    protected WeightedParentsQualityVarianceComparator(bool deserializing) : base(deserializing) { }
     66    protected WeightedParentsQualityVarianceComparator(WeightedParentsQualityVarianceComparator original, Cloner cloner)
     67      : base(original, cloner) {
     68    }
    6369    public WeightedParentsQualityVarianceComparator()
    6470      : base() {
     
    7581      Parameters.Add(new ScopeTreeLookupParameter<IntValue>("RightSideSamples", "The number of samples used to calculate the quality of the parent."));
    7682    }
    77 
     83    public override IDeepCloneable Clone(Cloner cloner) {
     84      return new WeightedParentsQualityVarianceComparator(this, cloner);
     85    }
    7886    public override IOperation Apply() {
    7987      double leftQuality = LeftSideParameter.ActualValue.Value;
     
    114122      double stat = (xmean - ymean) / Math.Sqrt(xvar / n + yvar / m);
    115123      double c = xvar / n / (xvar / n + yvar / m);
    116       double df = (n - 1) * (m - 1) / ((m - 1) * AP.Math.Sqr(c) + (n - 1) * (1 - AP.Math.Sqr(c)));
     124      double df = (n - 1) * (m - 1) / ((m - 1) * alglib.math.sqr(c) + (n - 1) * (1 - alglib.math.sqr(c)));
    117125      if ((double)(stat) > (double)(0))
    118         p = 1 - 0.5 * ibetaf.incompletebeta(df / 2, 0.5, df / (df + AP.Math.Sqr(stat)));
     126        p = 1 - 0.5 * alglib.ibetaf.incompletebeta(df / 2, 0.5, df / (df + alglib.math.sqr(stat)));
    119127      else
    120         p = 0.5 * ibetaf.incompletebeta(df / 2, 0.5, df / (df + AP.Math.Sqr(stat)));
     128        p = 0.5 * alglib.ibetaf.incompletebeta(df / 2, 0.5, df / (df + alglib.math.sqr(stat)));
    121129      double bothtails = 2 * Math.Min(p, 1 - p);
    122130      double lefttail = p;
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/ParameterAdjustmentProblem/SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer.cs

    r4068 r5275  
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3131using HeuristicLab.Problems.DataAnalysis.Evaluators;
     32using HeuristicLab.Common;
    3233
    3334namespace HeuristicLab.Problems.DataAnalysis.SupportVectorMachine.ParameterAdjustmentProblem {
     
    8990
    9091    #endregion
    91 
     92    [StorableConstructor]
     93    protected SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     94    protected SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer(SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer original, Cloner cloner)
     95      : base(original, cloner) {
     96    }
    9297    public SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer()
    9398      : base() {
     
    103108      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the best support vector solution should be stored."));
    104109    }
    105 
     110    public override IDeepCloneable Clone(Cloner cloner) {
     111      return new SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer(this, cloner);
     112    }
    106113    public override IOperation Apply() {
    107114      var points = ParameterVectorParameter.ActualValue;
     
    124131      if (bestModel == null) {
    125132        bestModel = SupportVectorMachineModelCreator.TrainModel(DataAnalysisProblemData,
    126           DataAnalysisProblemData.TrainingSamplesStart.Value, DataAnalysisProblemData.TrainingSamplesEnd.Value,
     133          DataAnalysisProblemData.TrainingIndizes,
    127134          SvmType.Value, KernelType.Value, cost, nu, gamma, 0.0);
    128135        BestSolutionParameter.ActualValue = bestModel;
     
    153160        if (BestSolutionQualityParameter.ActualValue.Value > bestQuality) {
    154161          bestModel = SupportVectorMachineModelCreator.TrainModel(DataAnalysisProblemData,
    155             DataAnalysisProblemData.TrainingSamplesStart.Value, DataAnalysisProblemData.TrainingSamplesEnd.Value,
     162            DataAnalysisProblemData.TrainingIndizes,
    156163            SvmType.Value, KernelType.Value, cost, nu, gamma, 0.0);
    157164          BestSolutionParameter.ActualValue = bestModel;
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/ParameterAdjustmentProblem/SupportVectorMachineParameterAdjustmentEvaluator.cs

    r4068 r5275  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Common;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis.SupportVectorMachine.ParameterAdjustmentProblem {
     
    107108    }
    108109    #endregion
    109 
     110    [StorableConstructor]
     111    protected SupportVectorMachineParameterAdjustmentEvaluator(bool deserializing) : base(deserializing) { }
     112    protected SupportVectorMachineParameterAdjustmentEvaluator(SupportVectorMachineParameterAdjustmentEvaluator original, Cloner cloner)
     113      : base(original, cloner) {
     114    }
    110115    public SupportVectorMachineParameterAdjustmentEvaluator()
    111116      : base() {
     
    130135      evaluator.Successor = null;
    131136    }
     137    public override IDeepCloneable Clone(Cloner cloner) {
     138      return new SupportVectorMachineParameterAdjustmentEvaluator(this, cloner);
     139    }
    132140
    133141    public override IOperation Apply() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/ParameterAdjustmentProblem/SupportVectorMachineParameterAdjustmentProblem.cs

    r4118 r5275  
    130130    [StorableConstructor]
    131131    private SupportVectorMachineParameterAdjustmentProblem(bool deserializing) : base(deserializing) { }
     132    private SupportVectorMachineParameterAdjustmentProblem(SupportVectorMachineParameterAdjustmentProblem original, Cloner cloner)
     133      : base(original, cloner) {
     134      operators = original.operators.Where(x => IsNotFieldReferenced(x)).Select(x => (IOperator)cloner.Clone(x)).ToList();
     135      strategyVectorCreator = (StdDevStrategyVectorCreator)cloner.Clone(original.strategyVectorCreator);
     136      operators.Add(strategyVectorCreator);
     137      strategyVectorCrossover = (StdDevStrategyVectorCrossover)cloner.Clone(original.strategyVectorCrossover);
     138      operators.Add(strategyVectorCrossover);
     139      strategyVectorManipulator = (StdDevStrategyVectorManipulator)cloner.Clone(original.strategyVectorManipulator);
     140      operators.Add(strategyVectorManipulator);
     141      AttachEventHandlers();
     142    }
    132143    public SupportVectorMachineParameterAdjustmentProblem()
    133144      : base() {
     
    167178
    168179    public override IDeepCloneable Clone(Cloner cloner) {
    169       SupportVectorMachineParameterAdjustmentProblem clone = (SupportVectorMachineParameterAdjustmentProblem)base.Clone(cloner);
    170       clone.operators = operators.Where(x => IsNotFieldReferenced(x)).Select(x => (IOperator)cloner.Clone(x)).ToList();
    171       clone.strategyVectorCreator = (StdDevStrategyVectorCreator)cloner.Clone(strategyVectorCreator);
    172       clone.operators.Add(clone.strategyVectorCreator);
    173       clone.strategyVectorCrossover = (StdDevStrategyVectorCrossover)cloner.Clone(strategyVectorCrossover);
    174       clone.operators.Add(strategyVectorCrossover);
    175       clone.strategyVectorManipulator = (StdDevStrategyVectorManipulator)cloner.Clone(strategyVectorManipulator);
    176       clone.operators.Add(strategyVectorManipulator);
    177       clone.AttachEventHandlers();
    178       return clone;
    179     }
    180 
     180      return new SupportVectorMachineParameterAdjustmentProblem(this, cloner);
     181    }
    181182    private bool IsNotFieldReferenced(IOperator x) {
    182183      return !(x == strategyVectorCreator
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineCrossValidationEvaluator.cs

    r4068 r5275  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    2527using HeuristicLab.Data;
     
    125127    #endregion
    126128
     129    [StorableConstructor]
     130    protected SupportVectorMachineCrossValidationEvaluator(bool deserializing) : base(deserializing) { }
     131
     132    protected SupportVectorMachineCrossValidationEvaluator(SupportVectorMachineCrossValidationEvaluator original,
     133      Cloner cloner)
     134      : base(original, cloner) { }
    127135    public SupportVectorMachineCrossValidationEvaluator()
    128136      : base() {
     
    142150    }
    143151
     152    public override IDeepCloneable Clone(Cloner cloner) {
     153      return new SupportVectorMachineCrossValidationEvaluator(this, cloner);
     154    }
     155
    144156    public override IOperation Apply() {
    145       double reductionRatio = 1.0;
     157      double reductionRatio = 1.0; // TODO: make parameter
    146158      if (ActualSamplesParameter.ActualValue != null)
    147159        reductionRatio = ActualSamplesParameter.ActualValue.Value;
    148 
    149       int reducedRows = (int)((SamplesEnd.Value - SamplesStart.Value) * reductionRatio);
     160      IEnumerable<int> rows =
     161        Enumerable.Range(SamplesStart.Value, SamplesEnd.Value - SamplesStart.Value)
     162        .Where(i => i < DataAnalysisProblemData.TestSamplesStart.Value || DataAnalysisProblemData.TestSamplesEnd.Value <= i);
     163
     164      // create a new DataAnalysisProblemData instance
    150165      DataAnalysisProblemData reducedProblemData = (DataAnalysisProblemData)DataAnalysisProblemData.Clone();
    151       reducedProblemData.Dataset = CreateReducedDataset(RandomParameter.ActualValue, reducedProblemData.Dataset, reductionRatio, SamplesStart.Value, SamplesEnd.Value);
     166      reducedProblemData.Dataset =
     167        CreateReducedDataset(RandomParameter.ActualValue, reducedProblemData.Dataset, rows, reductionRatio);
     168      reducedProblemData.TrainingSamplesStart.Value = 0;
     169      reducedProblemData.TrainingSamplesEnd.Value = reducedProblemData.Dataset.Rows;
     170      reducedProblemData.TestSamplesStart.Value = reducedProblemData.Dataset.Rows;
     171      reducedProblemData.TestSamplesEnd.Value = reducedProblemData.Dataset.Rows;
     172      reducedProblemData.ValidationPercentage.Value = 0;
    152173
    153174      double quality = PerformCrossValidation(reducedProblemData,
    154                              SamplesStart.Value, SamplesStart.Value + reducedRows,
    155175                             SvmType.Value, KernelType.Value,
    156176                             Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value, NumberOfFolds.Value);
     
    160180    }
    161181
    162     private Dataset CreateReducedDataset(IRandom random, Dataset dataset, double reductionRatio, int start, int end) {
    163       int n = (int)((end - start) * reductionRatio);
     182    private Dataset CreateReducedDataset(IRandom random, Dataset dataset, IEnumerable<int> rowIndices, double reductionRatio) {
     183
    164184      // must not make a fink:
    165185      // => select n rows randomly from start..end
     
    168188
    169189      // all possible rowIndexes from start..end
    170       int[] rowIndexes = Enumerable.Range(start, end - start).ToArray();
     190      int[] rowIndexArr = rowIndices.ToArray();
     191      int n = (int)Math.Max(1.0, rowIndexArr.Length * reductionRatio);
    171192
    172193      // knuth shuffle
    173       for (int i = rowIndexes.Length - 1; i > 0; i--) {
     194      for (int i = rowIndexArr.Length - 1; i > 0; i--) {
    174195        int j = random.Next(0, i);
    175196        // swap
    176         int tmp = rowIndexes[i];
    177         rowIndexes[i] = rowIndexes[j];
    178         rowIndexes[j] = tmp;
     197        int tmp = rowIndexArr[i];
     198        rowIndexArr[i] = rowIndexArr[j];
     199        rowIndexArr[j] = tmp;
    179200      }
    180201
    181202      // take the first n indexes (selected n rowIndexes from start..end)
    182203      // now order by index
    183       var orderedRandomIndexes = rowIndexes.Take(n).OrderBy(x => x).ToArray();
    184 
    185       // now build a dataset collecting the rows from orderedRandomIndexes into the dataset starting at index start
    186       double[,] reducedData = dataset.GetClonedData();
     204      int[] orderedRandomIndexes =
     205        rowIndexArr.Take(n)
     206        .OrderBy(x => x)
     207        .ToArray();
     208
     209      // now build a dataset containing only rows from orderedRandomIndexes
     210      double[,] reducedData = new double[n, dataset.Columns];
    187211      for (int i = 0; i < n; i++) {
    188212        for (int column = 0; column < dataset.Columns; column++) {
    189           reducedData[start + i, column] = dataset[orderedRandomIndexes[i], column];
     213          reducedData[i, column] = dataset[orderedRandomIndexes[i], column];
    190214        }
    191215      }
     
    198222      double cost, double nu, double gamma, double epsilon,
    199223      int nFolds) {
    200       return PerformCrossValidation(problemData, problemData.TrainingSamplesStart.Value, problemData.TrainingSamplesEnd.Value, svmType, kernelType, cost, nu, gamma, epsilon, nFolds);
     224      return PerformCrossValidation(problemData, problemData.TrainingIndizes, svmType, kernelType, cost, nu, gamma, epsilon, nFolds);
    201225    }
    202226
    203227    public static double PerformCrossValidation(
    204228      DataAnalysisProblemData problemData,
    205       int start, int end,
     229      IEnumerable<int> rowIndices,
    206230      string svmType, string kernelType,
    207231      double cost, double nu, double gamma, double epsilon,
     
    221245
    222246
    223       SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);
     247      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, rowIndices);
    224248      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
    225249      SVM.Problem scaledProblem = Scaling.Scale(rangeTransform, problem);
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModel.cs

    r4068 r5275  
    3636  [StorableClass]
    3737  [Item("SupportVectorMachineModel", "Represents a support vector machine model.")]
    38   public class SupportVectorMachineModel : NamedItem, IDataAnalysisModel {
    39     public SupportVectorMachineModel()
    40       : base() {
     38  public sealed class SupportVectorMachineModel : NamedItem, IDataAnalysisModel {
     39    [StorableConstructor]
     40    private SupportVectorMachineModel(bool deserializing) : base(deserializing) { }
     41    private SupportVectorMachineModel(SupportVectorMachineModel original, Cloner cloner)
     42      : base(original, cloner) {
     43      // only using a shallow copy here! (gkronber)
     44      this.model = original.model;
     45      this.rangeTransform = original.rangeTransform;
    4146    }
     47    public SupportVectorMachineModel() : base() { }
    4248
    4349    private SVM.Model model;
     
    7278
    7379    public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, int start, int end) {
    74       SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);
     80      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, Enumerable.Range(start, end - start));
    7581      SVM.Problem scaledProblem = Scaling.Scale(RangeTransform, problem);
    7682
    7783      return (from row in Enumerable.Range(0, scaledProblem.Count)
    78               select SVM.Prediction.Predict(Model, scaledProblem.X[row])).ToList();
     84              select SVM.Prediction.Predict(Model, scaledProblem.X[row]))
     85              .ToList();
    7986    }
    8087
     
    130137
    131138    public override IDeepCloneable Clone(Cloner cloner) {
    132       SupportVectorMachineModel clone = (SupportVectorMachineModel)base.Clone(cloner);
    133       // beware we are only using a shallow copy here! (gkronber)
    134       clone.model = model;
    135       clone.rangeTransform = rangeTransform;
    136       return clone;
     139      return new SupportVectorMachineModel(this, cloner);
    137140    }
    138141
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModelCreator.cs

    r4068 r5275  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
     25using HeuristicLab.Common;
    2326using HeuristicLab.Core;
    2427using HeuristicLab.Data;
     
    3437  [StorableClass]
    3538  [Item("SupportVectorMachineModelCreator", "Represents an operator that creates a support vector machine model.")]
    36   public class SupportVectorMachineModelCreator : SingleSuccessorOperator {
     39  public sealed class SupportVectorMachineModelCreator : SingleSuccessorOperator {
    3740    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
    3841    private const string SvmTypeParameterName = "SvmType";
     
    108111    #endregion
    109112
     113    [StorableConstructor]
     114    private SupportVectorMachineModelCreator(bool deserializing) : base(deserializing) { }
     115    private SupportVectorMachineModelCreator(SupportVectorMachineModelCreator original, Cloner cloner) : base(original, cloner) { }
     116    public override IDeepCloneable Clone(Cloner cloner) {
     117      return new SupportVectorMachineModelCreator(this, cloner);
     118    }
    110119    public SupportVectorMachineModelCreator()
    111120      : base() {
     
    125134
    126135    public override IOperation Apply() {
     136      int start = SamplesStart.Value;
     137      int end = SamplesEnd.Value;
     138      IEnumerable<int> rows =
     139        Enumerable.Range(start, end - start)
     140        .Where(i => i < DataAnalysisProblemData.TestSamplesStart.Value || DataAnalysisProblemData.TestSamplesEnd.Value <= i);
     141
    127142      SupportVectorMachineModel model = TrainModel(DataAnalysisProblemData,
    128                              SamplesStart.Value, SamplesEnd.Value,
     143                             rows,
    129144                             SvmType.Value, KernelType.Value,
    130145                             Cost.Value, Nu.Value, Gamma.Value, Epsilon.Value);
     
    138153      string svmType, string kernelType,
    139154      double cost, double nu, double gamma, double epsilon) {
    140       return TrainModel(problemData, problemData.TrainingSamplesStart.Value, problemData.TrainingSamplesEnd.Value, svmType, kernelType, cost, nu, gamma, epsilon);
     155      return TrainModel(problemData, problemData.TrainingIndizes, svmType, kernelType, cost, nu, gamma, epsilon);
    141156    }
    142157
    143158    public static SupportVectorMachineModel TrainModel(
    144159      DataAnalysisProblemData problemData,
    145       int start, int end,
     160      IEnumerable<int> trainingIndizes,
    146161      string svmType, string kernelType,
    147162      double cost, double nu, double gamma, double epsilon) {
     
    160175
    161176
    162       SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);
     177      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, trainingIndizes);
    163178      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
    164179      SVM.Problem scaledProblem = Scaling.Scale(rangeTransform, problem);
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineModelEvaluator.cs

    r4068 r5275  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
     24using HeuristicLab.Common;
    2225using HeuristicLab.Core;
    2326using HeuristicLab.Data;
     
    6871    }
    6972    #endregion
     73
     74    [StorableConstructor]
     75    protected SupportVectorMachineModelEvaluator(bool deserializing) : base(deserializing) { }
     76    protected SupportVectorMachineModelEvaluator(SupportVectorMachineModelEvaluator original, Cloner cloner) : base(original, cloner) { }
     77    public override IDeepCloneable Clone(Cloner cloner) {
     78      return new SupportVectorMachineModelEvaluator(this, cloner);
     79    }
    7080    public SupportVectorMachineModelEvaluator()
    7181      : base() {
     
    8090      int start = SamplesStart.Value;
    8191      int end = SamplesEnd.Value;
     92      IEnumerable<int> rows =
     93        Enumerable.Range(start, end - start)
     94        .Where(i => i < DataAnalysisProblemData.TestSamplesStart.Value || DataAnalysisProblemData.TestSamplesEnd.Value <= i);
    8295
    83       ValuesParameter.ActualValue = new DoubleMatrix(Evaluate(SupportVectorMachineModel, DataAnalysisProblemData, start, end));
     96      ValuesParameter.ActualValue = new DoubleMatrix(Evaluate(SupportVectorMachineModel, DataAnalysisProblemData, rows));
    8497      return base.Apply();
    8598    }
    8699
    87     public static double[,] Evaluate(SupportVectorMachineModel model, DataAnalysisProblemData problemData, int start, int end) {
    88       SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, start, end);
     100    public static double[,] Evaluate(SupportVectorMachineModel model, DataAnalysisProblemData problemData, IEnumerable<int> rowIndices) {
     101      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(problemData, rowIndices);
    89102      SVM.Problem scaledProblem = model.RangeTransform.Scale(problem);
    90103
     
    92105
    93106      double[,] values = new double[scaledProblem.Count, 2];
     107      var rowEnumerator = rowIndices.GetEnumerator();
    94108      for (int i = 0; i < scaledProblem.Count; i++) {
    95         values[i, 0] = problemData.Dataset[start + i, targetVariableIndex];
     109        rowEnumerator.MoveNext();
     110        values[i, 0] = problemData.Dataset[rowEnumerator.Current, targetVariableIndex];
    96111        values[i, 1] = SVM.Prediction.Predict(model.Model, scaledProblem.X[i]);
    97112      }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineUtil.cs

    r4068 r5275  
    2929    /// </summary>
    3030    /// <param name="problemData">The problem data to transform</param>
    31     /// <param name="start">The index of the first row of <paramref name="problemData"/> to copy to the output.</param>
    32     /// <param name="end">The last of the first row of <paramref name="problemData"/> to copy to the output.</param>
     31    /// <param name="rowIndices">The rows of the dataset that should be contained in the resulting SVM-problem</param>
    3332    /// <returns>A problem data type that can be used to train a support vector machine.</returns>
    34     public static SVM.Problem CreateSvmProblem(DataAnalysisProblemData problemData, int start, int end) {
    35       int rowCount = end - start;
    36       var targetVector = problemData.Dataset.GetVariableValues(problemData.TargetVariable.Value, start, end);
     33    public static SVM.Problem CreateSvmProblem(DataAnalysisProblemData problemData, IEnumerable<int> rowIndices) {
     34      double[] targetVector =
     35        problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable.Value, rowIndices)
     36        .ToArray();
    3737
    3838      SVM.Node[][] nodes = new SVM.Node[targetVector.Length][];
    3939      List<SVM.Node> tempRow;
    4040      int maxNodeIndex = 0;
    41       for (int row = 0; row < rowCount; row++) {
     41      int svmProblemRowIndex = 0;
     42      foreach (int row in rowIndices) {
    4243        tempRow = new List<SVM.Node>();
    4344        foreach (var inputVariable in problemData.InputVariables.CheckedItems) {
    4445          int col = problemData.Dataset.GetVariableIndex(inputVariable.Value.Value);
    45           double value = problemData.Dataset[start + row, col];
     46          double value = problemData.Dataset[row, col];
    4647          if (!double.IsNaN(value)) {
    47             int nodeIndex = col + 1; // make sure the smallest nodeIndex = 1
     48            int nodeIndex = col + 1; // make sure the smallest nodeIndex is 1 (libSVM convention)
    4849            tempRow.Add(new SVM.Node(nodeIndex, value));
    4950            if (nodeIndex > maxNodeIndex) maxNodeIndex = nodeIndex;
    5051          }
    5152        }
    52         nodes[row] = tempRow.OrderBy(x => x.Index).ToArray(); // make sure the values are sorted by node index
     53        nodes[svmProblemRowIndex++] = tempRow.OrderBy(x => x.Index).ToArray(); // make sure the values are sorted by node index
    5354      }
    5455
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ArithmeticExpressionGrammar.cs

    r4341 r5275  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3031  [Item("ArithmeticExpressionGrammar", "Represents a grammar for functional expressions using only arithmetic operations.")]
    3132  public class ArithmeticExpressionGrammar : DefaultSymbolicExpressionGrammar {
     33
     34    [StorableConstructor]
     35    protected ArithmeticExpressionGrammar(bool deserializing) : base(deserializing) { }
     36    protected ArithmeticExpressionGrammar(ArithmeticExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
    3237    public ArithmeticExpressionGrammar()
    3338      : base() {
    3439      Initialize();
    3540    }
    36 
    37     [StorableConstructor]
    38     protected ArithmeticExpressionGrammar(bool deserializing) : base(deserializing) { }
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new ArithmeticExpressionGrammar(this, cloner);
     43    }
    3944
    4045    private void Initialize() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/BasicExpressionGrammar.cs

    r4193 r5275  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
     28using HeuristicLab.Common;
    2829namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2930  [StorableClass]
     
    3334    private HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable variableSymbol;
    3435
     36    [StorableConstructor]
     37    protected BasicExpressionGrammar(bool deserializing) : base(deserializing) { }
     38    protected BasicExpressionGrammar(BasicExpressionGrammar original, Cloner cloner)
     39      : base(original, cloner) {
     40      foreach (var symb in Symbols) {
     41        var varSym = symb as HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable;
     42        if (varSym != null) this.variableSymbol = varSym;
     43        break;
     44      }
     45    }
    3546    public BasicExpressionGrammar()
    3647      : base() {
     
    3849    }
    3950
    40     [StorableConstructor]
    41     protected BasicExpressionGrammar(bool deserializing) : base(deserializing) { }
     51    public override IDeepCloneable Clone(Cloner cloner) {
     52      return new BasicExpressionGrammar(this, cloner);
     53    }
    4254
    4355    private void Initialize() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs

    r4341 r5275  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3031  [Item("FullFunctionalExpressionGrammar", "Represents a grammar for functional expressions using all available functions.")]
    3132  public class FullFunctionalExpressionGrammar : DefaultSymbolicExpressionGrammar {
     33    [StorableConstructor]
     34    protected FullFunctionalExpressionGrammar(bool deserializing) : base(deserializing) { }
     35    protected FullFunctionalExpressionGrammar(FullFunctionalExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
    3236    public FullFunctionalExpressionGrammar()
    3337      : base() {
    3438      Initialize();
    3539    }
    36     [StorableConstructor]
    37     protected FullFunctionalExpressionGrammar(bool deserializing) : base(deserializing) { }
     40
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new FullFunctionalExpressionGrammar(this, cloner);
     43    }
    3844
    3945    private void Initialize() {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r4193 r5275  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3233  [StorableClass]
    3334  [Item("SimpleArithmeticExpressionInterpreter", "Interpreter for arithmetic symbolic expression trees including function calls.")]
    34   // not thread safe!
    35   public class SimpleArithmeticExpressionInterpreter : NamedItem, ISymbolicExpressionTreeInterpreter {
     35  public sealed class SimpleArithmeticExpressionInterpreter : NamedItem, ISymbolicExpressionTreeInterpreter {
    3636    private class OpCodes {
    3737      public const byte Add = 1;
     
    6565      public const byte Constant = 20;
    6666      public const byte Arg = 21;
    67       public const byte Differential = 22;
    6867    }
    6968
     
    9089      { typeof(Constant), OpCodes.Constant },
    9190      { typeof(Argument), OpCodes.Arg },
    92       { typeof(DifferentialVariable), OpCodes.Differential},
    9391    };
    9492    private const int ARGUMENT_STACK_SIZE = 1024;
    9593
    96     private Dataset dataset;
    97     private int row;
    98     private Instruction[] code;
    99     private int pc;
    100     private double[] argumentStack = new double[ARGUMENT_STACK_SIZE];
    101     private int argStackPointer;
    102 
    10394    public override bool CanChangeName {
    10495      get { return false; }
     
    10899    }
    109100
     101    [StorableConstructor]
     102    private SimpleArithmeticExpressionInterpreter(bool deserializing) : base(deserializing) { }
     103    private SimpleArithmeticExpressionInterpreter(SimpleArithmeticExpressionInterpreter original, Cloner cloner) : base(original, cloner) { }
     104    public override IDeepCloneable Clone(Cloner cloner) {
     105      return new SimpleArithmeticExpressionInterpreter(this, cloner);
     106    }
     107
    110108    public SimpleArithmeticExpressionInterpreter()
    111109      : base() {
     
    113111
    114112    public IEnumerable<double> GetSymbolicExpressionTreeValues(SymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) {
    115       this.dataset = dataset;
    116113      var compiler = new SymbolicExpressionTreeCompiler();
    117       compiler.AddInstructionPostProcessingHook(PostProcessInstruction);
    118       code = compiler.Compile(tree, MapSymbolToOpCode);
    119       foreach (var row in rows) {
    120         this.row = row;
    121         pc = 0;
    122         argStackPointer = 0;
    123         yield return Evaluate();
    124       }
    125     }
    126 
    127     private Instruction PostProcessInstruction(Instruction instr) {
    128       if (instr.opCode == OpCodes.Variable) {
    129         var variableTreeNode = instr.dynamicNode as VariableTreeNode;
    130         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    131       } else if (instr.opCode == OpCodes.LagVariable) {
    132         var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
    133         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    134       } else if (instr.opCode == OpCodes.Differential) {
    135         var variableTreeNode = instr.dynamicNode as DifferentialVariableTreeNode;
    136         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
    137       }
    138       return instr;
     114      Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode);
     115
     116      for (int i = 0; i < code.Length; i++) {
     117        Instruction instr = code[i];
     118        if (instr.opCode == OpCodes.Variable) {
     119          var variableTreeNode = instr.dynamicNode as VariableTreeNode;
     120          instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     121          code[i] = instr;
     122        } else if (instr.opCode == OpCodes.LagVariable) {
     123          var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode;
     124          instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
     125          code[i] = instr;
     126        }
     127      }
     128
     129      double[] argumentStack = new double[ARGUMENT_STACK_SIZE];
     130      foreach (var rowEnum in rows) {
     131        int row = rowEnum;
     132        int pc = 0;
     133        int argStackPointer = 0;
     134        yield return Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     135      }
     136    }
     137
     138    private double Evaluate(Dataset dataset, ref int row, Instruction[] code, ref int pc, double[] argumentStack, ref int argStackPointer) {
     139      Instruction currentInstr = code[pc++];
     140      switch (currentInstr.opCode) {
     141        case OpCodes.Add: {
     142            double s = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     143            for (int i = 1; i < currentInstr.nArguments; i++) {
     144              s += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     145            }
     146            return s;
     147          }
     148        case OpCodes.Sub: {
     149            double s = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     150            for (int i = 1; i < currentInstr.nArguments; i++) {
     151              s -= Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     152            }
     153            if (currentInstr.nArguments == 1) s = -s;
     154            return s;
     155          }
     156        case OpCodes.Mul: {
     157            double p = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     158            for (int i = 1; i < currentInstr.nArguments; i++) {
     159              p *= Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     160            }
     161            return p;
     162          }
     163        case OpCodes.Div: {
     164            double p = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     165            for (int i = 1; i < currentInstr.nArguments; i++) {
     166              p /= Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     167            }
     168            if (currentInstr.nArguments == 1) p = 1.0 / p;
     169            return p;
     170          }
     171        case OpCodes.Average: {
     172            double sum = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     173            for (int i = 1; i < currentInstr.nArguments; i++) {
     174              sum += Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     175            }
     176            return sum / currentInstr.nArguments;
     177          }
     178        case OpCodes.Cos: {
     179            return Math.Cos(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     180          }
     181        case OpCodes.Sin: {
     182            return Math.Sin(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     183          }
     184        case OpCodes.Tan: {
     185            return Math.Tan(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     186          }
     187        case OpCodes.Exp: {
     188            return Math.Exp(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     189          }
     190        case OpCodes.Log: {
     191            return Math.Log(Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer));
     192          }
     193        case OpCodes.IfThenElse: {
     194            double condition = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     195            double result;
     196            if (condition > 0.0) {
     197              result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer); SkipBakedCode(code, ref pc);
     198            } else {
     199              SkipBakedCode(code, ref pc); result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     200            }
     201            return result;
     202          }
     203        case OpCodes.AND: {
     204            double result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     205            for (int i = 1; i < currentInstr.nArguments; i++) {
     206              if (result <= 0.0) SkipBakedCode(code, ref pc);
     207              else {
     208                result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     209              }
     210            }
     211            return result <= 0.0 ? -1.0 : 1.0;
     212          }
     213        case OpCodes.OR: {
     214            double result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     215            for (int i = 1; i < currentInstr.nArguments; i++) {
     216              if (result > 0.0) SkipBakedCode(code, ref pc);
     217              else {
     218                result = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     219              }
     220            }
     221            return result > 0.0 ? 1.0 : -1.0;
     222          }
     223        case OpCodes.NOT: {
     224            return -Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     225          }
     226        case OpCodes.GT: {
     227            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     228            double y = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     229            if (x > y) return 1.0;
     230            else return -1.0;
     231          }
     232        case OpCodes.LT: {
     233            double x = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     234            double y = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     235            if (x < y) return 1.0;
     236            else return -1.0;
     237          }
     238        case OpCodes.Call: {
     239            // evaluate sub-trees
     240            // push on argStack in reverse order
     241            for (int i = 0; i < currentInstr.nArguments; i++) {
     242              argumentStack[argStackPointer + currentInstr.nArguments - i] = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     243            }
     244            argStackPointer += currentInstr.nArguments;
     245
     246            // save the pc
     247            int nextPc = pc;
     248            // set pc to start of function 
     249            pc = currentInstr.iArg0;
     250            // evaluate the function
     251            double v = Evaluate(dataset, ref row, code, ref pc, argumentStack, ref argStackPointer);
     252
     253            // decrease the argument stack pointer by the number of arguments pushed
     254            // to set the argStackPointer back to the original location
     255            argStackPointer -= currentInstr.nArguments;
     256
     257            // restore the pc => evaluation will continue at point after my subtrees 
     258            pc = nextPc;
     259            return v;
     260          }
     261        case OpCodes.Arg: {
     262            return argumentStack[argStackPointer - currentInstr.iArg0];
     263          }
     264        case OpCodes.Variable: {
     265            var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
     266            return dataset[row, currentInstr.iArg0] * variableTreeNode.Weight;
     267          }
     268        case OpCodes.LagVariable: {
     269            var laggedVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
     270            int actualRow = row + laggedVariableTreeNode.Lag;
     271            if (actualRow < 0 || actualRow >= dataset.Rows) throw new ArgumentException("Out of range access to dataset row: " + row);
     272            return dataset[actualRow, currentInstr.iArg0] * laggedVariableTreeNode.Weight;
     273          }
     274        case OpCodes.Constant: {
     275            var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
     276            return constTreeNode.Value;
     277          }
     278        default: throw new NotSupportedException();
     279      }
    139280    }
    140281
     
    146287    }
    147288
    148     private double Evaluate() {
    149       Instruction currentInstr = code[pc++];
    150       switch (currentInstr.opCode) {
    151         case OpCodes.Add: {
    152             double s = Evaluate();
    153             for (int i = 1; i < currentInstr.nArguments; i++) {
    154               s += Evaluate();
    155             }
    156             return s;
    157           }
    158         case OpCodes.Sub: {
    159             double s = Evaluate();
    160             for (int i = 1; i < currentInstr.nArguments; i++) {
    161               s -= Evaluate();
    162             }
    163             if (currentInstr.nArguments == 1) s = -s;
    164             return s;
    165           }
    166         case OpCodes.Mul: {
    167             double p = Evaluate();
    168             for (int i = 1; i < currentInstr.nArguments; i++) {
    169               p *= Evaluate();
    170             }
    171             return p;
    172           }
    173         case OpCodes.Div: {
    174             double p = Evaluate();
    175             for (int i = 1; i < currentInstr.nArguments; i++) {
    176               p /= Evaluate();
    177             }
    178             if (currentInstr.nArguments == 1) p = 1.0 / p;
    179             return p;
    180           }
    181         case OpCodes.Average: {
    182             double sum = Evaluate();
    183             for (int i = 1; i < currentInstr.nArguments; i++) {
    184               sum += Evaluate();
    185             }
    186             return sum / currentInstr.nArguments;
    187           }
    188         case OpCodes.Cos: {
    189             return Math.Cos(Evaluate());
    190           }
    191         case OpCodes.Sin: {
    192             return Math.Sin(Evaluate());
    193           }
    194         case OpCodes.Tan: {
    195             return Math.Tan(Evaluate());
    196           }
    197         case OpCodes.Exp: {
    198             return Math.Exp(Evaluate());
    199           }
    200         case OpCodes.Log: {
    201             return Math.Log(Evaluate());
    202           }
    203         case OpCodes.IfThenElse: {
    204             double condition = Evaluate();
    205             double result;
    206             if (condition > 0.0) {
    207               result = Evaluate(); SkipBakedCode();
    208             } else {
    209               SkipBakedCode(); result = Evaluate();
    210             }
    211             return result;
    212           }
    213         case OpCodes.AND: {
    214             double result = Evaluate();
    215             for (int i = 1; i < currentInstr.nArguments; i++) {
    216               if (result <= 0.0) SkipBakedCode();
    217               else {
    218                 result = Evaluate();
    219               }
    220             }
    221             return result <= 0.0 ? -1.0 : 1.0;
    222           }
    223         case OpCodes.OR: {
    224             double result = Evaluate();
    225             for (int i = 1; i < currentInstr.nArguments; i++) {
    226               if (result > 0.0) SkipBakedCode();
    227               else {
    228                 result = Evaluate();
    229               }
    230             }
    231             return result > 0.0 ? 1.0 : -1.0;
    232           }
    233         case OpCodes.NOT: {
    234             return -Evaluate();
    235           }
    236         case OpCodes.GT: {
    237             double x = Evaluate();
    238             double y = Evaluate();
    239             if (x > y) return 1.0;
    240             else return -1.0;
    241           }
    242         case OpCodes.LT: {
    243             double x = Evaluate();
    244             double y = Evaluate();
    245             if (x < y) return 1.0;
    246             else return -1.0;
    247           }
    248         case OpCodes.Call: {
    249             // evaluate sub-trees
    250             // push on argStack in reverse order
    251             for (int i = 0; i < currentInstr.nArguments; i++) {
    252               argumentStack[argStackPointer + currentInstr.nArguments - i] = Evaluate();
    253             }
    254             argStackPointer += currentInstr.nArguments;
    255 
    256             // save the pc
    257             int nextPc = pc;
    258             // set pc to start of function 
    259             pc = currentInstr.iArg0;
    260             // evaluate the function
    261             double v = Evaluate();
    262 
    263             // decrease the argument stack pointer by the number of arguments pushed
    264             // to set the argStackPointer back to the original location
    265             argStackPointer -= currentInstr.nArguments;
    266 
    267             // restore the pc => evaluation will continue at point after my subtrees 
    268             pc = nextPc;
    269             return v;
    270           }
    271         case OpCodes.Arg: {
    272             return argumentStack[argStackPointer - currentInstr.iArg0];
    273           }
    274         case OpCodes.Variable: {
    275             var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
    276             return dataset[row, currentInstr.iArg0] * variableTreeNode.Weight;
    277           }
    278         case OpCodes.LagVariable: {
    279             var lagVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
    280             int actualRow = row + lagVariableTreeNode.Lag;
    281             if (actualRow < 0 || actualRow >= dataset.Rows) throw new ArgumentException("Out of range access to dataset row: " + row);
    282             return dataset[actualRow, currentInstr.iArg0] * lagVariableTreeNode.Weight;
    283           }
    284         case OpCodes.Differential: {
    285             var diffTreeNode = currentInstr.dynamicNode as DifferentialVariableTreeNode;
    286             if (row < 2 || row >= dataset.Rows - 2) throw new ArgumentException("Out of range access to dataset row: " + row);
    287             return (-dataset[row + 2, currentInstr.iArg0] + 8 * dataset[row + 1, currentInstr.iArg0] - 8 * dataset[row - 1, currentInstr.iArg0] + dataset[row - 2, currentInstr.iArg0]) * (1.0/12.0) * diffTreeNode.Weight;
    288           }
    289 
    290         case OpCodes.Constant: {
    291             var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
    292             return constTreeNode.Value;
    293           }
    294         default: throw new NotSupportedException();
    295       }
    296     }
    297 
    298289    // skips a whole branch
    299     protected void SkipBakedCode() {
     290    private void SkipBakedCode(Instruction[] code, ref int pc) {
    300291      int i = 1;
    301292      while (i > 0) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SymbolicSimplifier.cs

    r4554 r5275  
    354354      while (sum.SubTrees.Count > 0) sum.RemoveSubTree(0);
    355355      var groupedVarNodes = from node in subtrees.OfType<VariableTreeNode>()
    356                             where node.Symbol.Name == "Variable"
    357356                            group node by node.VariableName into g
    358357                            select g;
    359       var unchangedSubTrees = subtrees.Where(t => t.Symbol.Name != "Variable");
     358      var unchangedSubTrees = subtrees.Where(t => !(t is VariableTreeNode));
    360359
    361360      foreach (var variableNodeGroup in groupedVarNodes) {
     
    430429      while (prod.SubTrees.Count > 0) prod.RemoveSubTree(0);
    431430      var groupedVarNodes = from node in subtrees.OfType<VariableTreeNode>()
    432                             where node.Symbol.Name == "Variable"
    433431                            group node by node.VariableName into g
    434432                            orderby g.Count()
    435433                            select g;
    436434      var constantProduct = (from node in subtrees.OfType<VariableTreeNode>()
    437                              where node.Symbol.Name == "Variable"
    438435                             select node.Weight)
    439436                            .Concat(from node in subtrees.OfType<ConstantTreeNode>()
     
    443440
    444441      var unchangedSubTrees = from tree in subtrees
    445                               where !(tree is VariableTreeNode && tree.Symbol.Name == "Variable")
     442                              where !(tree is VariableTreeNode)
    446443                              where !(tree is ConstantTreeNode)
    447444                              select tree;
     
    485482      } else if (IsAddition(x)) {
    486483        // (x0 + x1 + .. + xn) * -1 => (-x0 + -x1 + .. + -xn)       
    487         foreach (var subTree in x.SubTrees) {
    488           Negate(subTree);
    489         }
     484        for (int i = 0; i < x.SubTrees.Count; i++)
     485          x.SubTrees[i] = Negate(x.SubTrees[i]);
    490486      } else if (IsMultiplication(x) || IsDivision(x)) {
    491487        // x0 * x1 * .. * xn * -1 => x0 * x1 * .. * -xn
    492         Negate(x.SubTrees.Last()); // last is maybe a constant, prefer to negate the constant
     488        x.SubTrees[x.SubTrees.Count - 1] = Negate(x.SubTrees.Last()); // last is maybe a constant, prefer to negate the constant
    493489      } else {
    494490        // any other function
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Addition.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Addition", "Symbol that represents the + operator.")]
    2829  public sealed class Addition : Symbol {
     30    [StorableConstructor]
     31    private Addition(bool deserializing) : base(deserializing) { }
     32    private Addition(Addition original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Addition(this, cloner);
     35    }
    2936    public Addition() : base("Addition", "Symbol that represents the + operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/And.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("And", "Symbol that represents the boolean AND operator.")]
    2829  public sealed class And : Symbol {
     30    [StorableConstructor]
     31    private And(bool deserializing) : base(deserializing) { }
     32    private And(And original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new And(this, cloner);
     35    }
    2936    public And() : base("And", "Symbol that represents the boolean AND operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Average.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Average", "Symbol that represents the average (arithmetic mean) function.")]
    2829  public sealed class Average : Symbol {
     30    [StorableConstructor]
     31    private Average(bool deserializing) : base(deserializing) { }
     32    private Average(Average original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Average(this, cloner);
     35    }
    2936    public Average() : base("Average", "Symbol that represents the average (arithmetic mean) function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Constant.cs

    r4068 r5275  
    5454    }
    5555    [Storable]
    56     private double manipulatorNu;
    57     public double ManipulatorNu {
    58       get { return manipulatorNu; }
     56    private double manipulatorMu;
     57    public double ManipulatorMu {
     58      get { return manipulatorMu; }
    5959      set {
    60         if (value != manipulatorNu) {
    61           manipulatorNu = value;
     60        if (value != manipulatorMu) {
     61          manipulatorMu = value;
    6262          OnChanged(EventArgs.Empty);
    6363        }
     
    7777    }
    7878    #endregion
     79    [StorableConstructor]
     80    private Constant(bool deserializing) : base(deserializing) { }
     81    private Constant(Constant original, Cloner cloner)
     82      : base(original, cloner) {
     83      minValue = original.minValue;
     84      maxValue = original.maxValue;
     85      manipulatorMu = original.manipulatorMu;
     86      manipulatorSigma = original.manipulatorSigma;
     87    }
    7988    public Constant()
    8089      : base("Constant", "Represents a constant value.") {
    81       manipulatorNu = 0.0;
     90      manipulatorMu = 0.0;
    8291      manipulatorSigma = 1.0;
    8392      minValue = -20.0;
     
    9099
    91100    public override IDeepCloneable Clone(Cloner cloner) {
    92       Constant clone = (Constant)base.Clone(cloner);
    93       clone.minValue = minValue;
    94       clone.maxValue = maxValue;
    95       clone.manipulatorNu = manipulatorNu;
    96       clone.manipulatorSigma = manipulatorSigma;
    97       return clone;
     101      return new Constant(this, cloner);
    98102    }
    99103  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3839    }
    3940
    40     private ConstantTreeNode() : base() { }
     41    [StorableConstructor]
     42    private ConstantTreeNode(bool deserializing) : base(deserializing) { }
    4143
    42     // copy constructor
    43     private ConstantTreeNode(ConstantTreeNode original)
    44       : base(original) {
     44    private ConstantTreeNode(ConstantTreeNode original, Cloner cloner)
     45      : base(original, cloner) {
    4546      constantValue = original.constantValue;
    4647    }
    4748
     49    private ConstantTreeNode() : base() { }
    4850    public ConstantTreeNode(Constant constantSymbol) : base(constantSymbol) { }
    4951
     
    6163    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    6264      base.ShakeLocalParameters(random, shakingFactor);
    63       double x = NormalDistributedRandom.NextDouble(random, Symbol.ManipulatorNu, Symbol.ManipulatorSigma);
     65      double x = NormalDistributedRandom.NextDouble(random, Symbol.ManipulatorMu, Symbol.ManipulatorSigma);
    6466      Value = Value + x * shakingFactor;
    6567    }
    6668
    67     public override object Clone() {
    68       return new ConstantTreeNode(this);
     69    public override IDeepCloneable Clone(Cloner cloner) {
     70      return new ConstantTreeNode(this, cloner);
    6971    }
    7072
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Cosine.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Cosine", "Symbol that represents the cosine function.")]
    2829  public sealed class Cosine : Symbol {
     30    [StorableConstructor]
     31    private Cosine(bool deserializing) : base(deserializing) { }
     32    private Cosine(Cosine original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Cosine(this, cloner);
     35    }
    2936    public Cosine() : base("Cosine", "Symbol that represents the cosine function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/DifferentialVariable.cs

    r4193 r5275  
    2828  [Item("DifferentialVariable", "Represents the differential of a variable value.")]
    2929  public sealed class DifferentialVariable : Variable {
     30    [StorableConstructor]
     31    private DifferentialVariable(bool deserializing) : base(deserializing) { }
     32    private DifferentialVariable(DifferentialVariable original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
    3035    public DifferentialVariable()
    3136      : base("DifferentialVariable", "Represents the differential of a variable value.") {
     
    3540      return new DifferentialVariableTreeNode(this);
    3641    }
    37 
    3842    public override IDeepCloneable Clone(Cloner cloner) {
    39       DifferentialVariable clone = (DifferentialVariable)base.Clone(cloner);
    40       return clone;
     43      return new DifferentialVariable(this, cloner);
    4144    }
    4245  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/DifferentialVariableTreeNode.cs

    r4193 r5275  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;
    2526namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
    2627  [StorableClass]
     
    3031    }
    3132
     33    [StorableConstructor]
     34    protected DifferentialVariableTreeNode(bool deserializing) : base(deserializing) { }
     35    protected DifferentialVariableTreeNode(DifferentialVariableTreeNode original, Cloner cloner)
     36      : base(original, cloner) {
     37    }
    3238    private DifferentialVariableTreeNode() { }
    33 
    34     // copy constructor
    35     private DifferentialVariableTreeNode(DifferentialVariableTreeNode original)
    36       : base(original) {
    37     }
    3839
    3940    public DifferentialVariableTreeNode(DifferentialVariable differentialSymbol) : base(differentialSymbol) { }
    4041
    4142
    42     public override object Clone() {
    43       return new DifferentialVariableTreeNode(this);
     43    public override IDeepCloneable Clone(Cloner cloner) {
     44      return new DifferentialVariableTreeNode(this, cloner);
    4445    }
    45 
    4646  }
    4747}
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Division.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Division", "Symbol that represents the / operator.")]
    2829  public sealed class Division : Symbol {
     30    [StorableConstructor]
     31    private Division(bool deserializing) : base(deserializing) { }
     32    private Division(Division original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Division(this, cloner);
     35    }
    2936    public Division() : base("Division", "Symbol that represents the / operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Exponential.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Exponential", "Symbol that represents the exponential function.")]
    2829  public sealed class Exponential : Symbol {
     30    [StorableConstructor]
     31    private Exponential(bool deserializing) : base(deserializing) { }
     32    private Exponential(Exponential original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Exponential(this, cloner);
     35    }
    2936    public Exponential() : base("Exponential", "Symbol that represents the exponential function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/GreaterThan.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("GreaterThan", "Symbol that represents a greater than relation.")]
    2829  public sealed class GreaterThan : Symbol {
     30    [StorableConstructor]
     31    private GreaterThan(bool deserializing) : base(deserializing) { }
     32    private GreaterThan(GreaterThan original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new GreaterThan(this, cloner);
     35    }
    2936    public GreaterThan() : base("GreaterThan", "Symbol that represents a greater than relation.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/IfThenElse.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("IfThenElse", "Symbol that represents a conditional operator.")]
    2829  public sealed class IfThenElse : Symbol {
     30    [StorableConstructor]
     31    private IfThenElse(bool deserializing) : base(deserializing) { }
     32    private IfThenElse(IfThenElse original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new IfThenElse(this, cloner);
     35    }
    2936    public IfThenElse() : base("IfThenElse", "Symbol that represents a conditional operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LaggedVariable.cs

    r4068 r5275  
    4040      set { maxLag = value; }
    4141    }
     42    [StorableConstructor]
     43    private LaggedVariable(bool deserializing) : base(deserializing) { }
     44    private LaggedVariable(LaggedVariable original, Cloner cloner)
     45      : base(original, cloner) {
     46      minLag = original.minLag;
     47      maxLag = original.maxLag;
     48    }
    4249    public LaggedVariable()
    4350      : base("LaggedVariable", "Represents a variable value with a time offset.") {
     
    5057
    5158    public override IDeepCloneable Clone(Cloner cloner) {
    52       LaggedVariable clone = (LaggedVariable)base.Clone(cloner);
    53       clone.minLag = minLag;
    54       clone.maxLag = maxLag;
    55       return clone;
     59      return new LaggedVariable(this, cloner);
    5660    }
    5761  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LaggedVariableTreeNode.cs

    r4068 r5275  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3637    }
    3738
    38     private LaggedVariableTreeNode() { }
    39 
    40     // copy constructor
    41     private LaggedVariableTreeNode(LaggedVariableTreeNode original)
    42       : base(original) {
     39    [StorableConstructor]
     40    private LaggedVariableTreeNode(bool deserializing) : base(deserializing) { }
     41    private LaggedVariableTreeNode(LaggedVariableTreeNode original, Cloner cloner)
     42      : base(original, cloner) {
    4343      lag = original.lag;
    4444    }
     45    private LaggedVariableTreeNode() { }
    4546
    4647    public LaggedVariableTreeNode(LaggedVariable variableSymbol) : base(variableSymbol) { }
     
    6263    }
    6364
    64 
    65     public override object Clone() {
    66       return new LaggedVariableTreeNode(this);
     65    public override IDeepCloneable Clone(Cloner cloner) {
     66      return new LaggedVariableTreeNode(this, cloner);
    6767    }
    6868
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/LessThan.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("LessThan", "Symbol that represents a less than relation.")]
    2829  public sealed class LessThan : Symbol {
     30    [StorableConstructor]
     31    private LessThan(bool deserializing) : base(deserializing) { }
     32    private LessThan(LessThan original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new LessThan(this, cloner);
     35    }
    2936    public LessThan() : base("LessThan", "Symbol that represents a less than relation.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Logarithm.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Logarithm", "Symbol that represents the logarithm function.")]
    2829  public sealed class Logarithm : Symbol {
     30    [StorableConstructor]
     31    private Logarithm(bool deserializing) : base(deserializing) { }
     32    private Logarithm(Logarithm original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Logarithm(this, cloner);
     35    }
    2936    public Logarithm() : base("Logarithm", "Symbol that represents the logarithm function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Multiplication.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Multiplication", "Symbol that represents the * operator.")]
    2829  public sealed class Multiplication : Symbol {
     30    [StorableConstructor]
     31    private Multiplication(bool deserializing) : base(deserializing) { }
     32    private Multiplication(Multiplication original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Multiplication(this, cloner);
     35    }
    2936    public Multiplication() : base("Multiplication", "Symbol that represents the * operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Not.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Not", "Symbol that represents the boolean NOT operator.")]
    2829  public sealed class Not : Symbol {
     30    [StorableConstructor]
     31    private Not(bool deserializing) : base(deserializing) { }
     32    private Not(Not original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Not(this, cloner);
     35    }
    2936    public Not() : base("Not", "Symbol that represents the boolean NOT operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Or.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Or", "Symbol that represents the boolean OR operator.")]
    2829  public sealed class Or : Symbol {
     30    [StorableConstructor]
     31    private Or(bool deserializing) : base(deserializing) { }
     32    private Or(Or original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Or(this, cloner);
     35    }
    2936    public Or() : base("Or", "Symbol that represents the boolean OR operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Sine.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Sine", "Symbol that represents the sine function.")]
    2829  public sealed class Sine : Symbol {
     30    [StorableConstructor]
     31    private Sine(bool deserializing) : base(deserializing) { }
     32    private Sine(Sine original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Sine(this, cloner);
     35    }
    2936    public Sine() : base("Sine", "Symbol that represents the sine function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Subtraction.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Subtraction", "Symbol that represents the - operator.")]
    2829  public sealed class Subtraction : Symbol {
     30    [StorableConstructor]
     31    private Subtraction(bool deserializing) : base(deserializing) { }
     32    private Subtraction(Subtraction original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Subtraction(this, cloner);
     35    }
    2936    public Subtraction() : base("Subtraction", "Symbol that represents the - operator.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Tangent.cs

    r4068 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2728  [Item("Tangent", "Symbol that represents the tangent trigonometric function.")]
    2829  public sealed class Tangent : Symbol {
     30    [StorableConstructor]
     31    private Tangent(bool deserializing) : base(deserializing) { }
     32    private Tangent(Tangent original, Cloner cloner) : base(original, cloner) { }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new Tangent(this, cloner);
     35    }
    2936    public Tangent() : base("Tangent", "Symbol that represents the tangent trigonometric function.") { }
    3037  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs

    r4068 r5275  
    3333    #region Properties
    3434    [Storable]
    35     private double weightNu;
    36     public double WeightNu {
    37       get { return weightNu; }
     35    private double weightMu;
     36    public double WeightMu {
     37      get { return weightMu; }
    3838      set {
    39         if (value != weightNu) {
    40           weightNu = value;
     39        if (value != weightMu) {
     40          weightMu = value;
    4141          OnChanged(EventArgs.Empty);
    4242        }
     
    5656    }
    5757    [Storable]
    58     private double weightManipulatorNu;
    59     public double WeightManipulatorNu {
    60       get { return weightManipulatorNu; }
     58    private double weightManipulatorMu;
     59    public double WeightManipulatorMu {
     60      get { return weightManipulatorMu; }
    6161      set {
    62         if (value != weightManipulatorNu) {
    63           weightManipulatorNu = value;
     62        if (value != weightManipulatorMu) {
     63          weightManipulatorMu = value;
    6464          OnChanged(EventArgs.Empty);
    6565        }
     
    9090    }
    9191    #endregion
     92    [StorableConstructor]
     93    protected Variable(bool deserializing) : base(deserializing) {
     94      variableNames = new List<string>();
     95    }
     96    protected Variable(Variable original, Cloner cloner)
     97      : base(original, cloner) {
     98      weightMu = original.weightMu;
     99      weightSigma = original.weightSigma;
     100      variableNames = new List<string>(original.variableNames);
     101      weightManipulatorMu = original.weightManipulatorMu;
     102      weightManipulatorSigma = original.weightManipulatorSigma;
     103    }
    92104    public Variable() : this("Variable", "Represents a variable value.") { }
    93105    public Variable(string name, string description)
    94106      : base(name, description) {
    95       weightNu = 1.0;
     107      weightMu = 1.0;
    96108      weightSigma = 1.0;
    97       weightManipulatorNu = 0.0;
     109      weightManipulatorMu = 0.0;
    98110      weightManipulatorSigma = 1.0;
    99111      variableNames = new List<string>();
     
    105117
    106118    public override IDeepCloneable Clone(Cloner cloner) {
    107       Variable clone = (Variable)base.Clone(cloner);
    108       clone.weightNu = weightNu;
    109       clone.weightSigma = weightSigma;
    110       clone.variableNames = new List<string>(variableNames);
    111       clone.weightManipulatorNu = weightManipulatorNu;
    112       clone.weightManipulatorSigma = weightManipulatorSigma;
    113       return clone;
     119      return new Variable(this, cloner);
    114120    }
    115121  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs

    r4220 r5275  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    23 using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4444    }
    4545
    46 
    47     protected VariableTreeNode() { }
    48 
    49     // copy constructor
    50     protected VariableTreeNode(VariableTreeNode original)
    51       : base(original) {
     46    [StorableConstructor]
     47    protected VariableTreeNode(bool deserializing) : base(deserializing) { }
     48    protected VariableTreeNode(VariableTreeNode original, Cloner cloner)
     49      : base(original, cloner) {
    5250      weight = original.weight;
    5351      variableName = original.variableName;
    5452    }
    55 
     53    protected VariableTreeNode() { }
    5654    public VariableTreeNode(Variable variableSymbol) : base(variableSymbol) { }
    5755
     
    6462    public override void ResetLocalParameters(IRandom random) {
    6563      base.ResetLocalParameters(random);
    66       weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightNu, Symbol.WeightSigma);
     64      weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightMu, Symbol.WeightSigma);
    6765      variableName = Symbol.VariableNames.SelectRandom(random);
    6866    }
     
    7068    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
    7169      base.ShakeLocalParameters(random, shakingFactor);
    72       double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorNu, Symbol.WeightManipulatorSigma);
     70      double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu, Symbol.WeightManipulatorSigma);
    7371      weight = weight + x * shakingFactor;
    7472      variableName = Symbol.VariableNames.SelectRandom(random);
    7573    }
    7674
    77 
    78     public override object Clone() {
    79       return new VariableTreeNode(this);
     75    public override IDeepCloneable Clone(Cloner cloner) {
     76      return new VariableTreeNode(this, cloner);
    8077    }
    8178
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/VariableFrequencyAnalyser.cs

    r4125 r5275  
    2222using System.Collections.Generic;
    2323using System.Linq;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
     
    6162    }
    6263    #endregion
     64    [StorableConstructor]
     65    protected VariableFrequencyAnalyser(bool deserializing) : base(deserializing) { }
     66    protected VariableFrequencyAnalyser(VariableFrequencyAnalyser original, Cloner cloner)
     67      : base(original, cloner) {
     68    }
    6369    public VariableFrequencyAnalyser()
    6470      : base() {
     
    6975
    7076    public override IOperation Apply() {
    71       var inputVariables = DataAnalysisProblemData.InputVariables.Select(x => x.Value);
     77      var inputVariables = DataAnalysisProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value);
    7278      if (VariableFrequencies == null) {
    7379        VariableFrequencies = new DoubleMatrix(0, 1, inputVariables);
     
    8086        VariableFrequencies[lastRowIndex, columnIndex] = pair.Value;
    8187      }
    82       return null;
     88      return base.Apply();
    8389    }
    8490
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Tests/HeuristicLab.Problems.DataAnalysis.Tests-3.3.csproj

    r5265 r5275  
    102102  </PropertyGroup>
    103103  <ItemGroup>
     104    <Reference Include="ALGLIB-3.1.0">
     105      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\ALGLIB-3.1.0.dll</HintPath>
     106    </Reference>
     107    <Reference Include="HeuristicLab.ALGLIB-3.1.0">
     108      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.ALGLIB-3.1.0.dll</HintPath>
     109    </Reference>
     110    <Reference Include="HeuristicLab.Common-3.3">
     111      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     112    </Reference>
     113    <Reference Include="HeuristicLab.Core-3.3">
     114      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
     115    </Reference>
     116    <Reference Include="HeuristicLab.Data-3.3">
     117      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data-3.3.dll</HintPath>
     118    </Reference>
     119    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3">
     120      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.dll</HintPath>
     121    </Reference>
     122    <Reference Include="HeuristicLab.Operators-3.3">
     123      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath>
     124    </Reference>
     125    <Reference Include="HeuristicLab.Optimization-3.3">
     126      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
     127    </Reference>
     128    <Reference Include="HeuristicLab.Random-3.3">
     129      <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath>
     130    </Reference>
    104131    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    105132    <Reference Include="System" />
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Tests/StatisticCalculatorsTest.cs

    r4459 r5275  
    7777          double tmp = 0;
    7878
    79           alglib.descriptivestatistics.calculatemoments(ref xs, n, ref mean_alglib, ref variance_alglib, ref tmp, ref tmp);
     79          alglib.basestat.samplemoments(xs, n, ref mean_alglib, ref variance_alglib, ref tmp, ref tmp);
    8080
    8181          var calculator = new OnlineMeanAndVarianceCalculator();
     
    108108            double[] xs = x.ToArray();
    109109            double[] ys = y.ToArray();
    110             double r2_alglib = alglib.correlation.pearsoncorrelation(ref xs, ref ys, n);
     110            double r2_alglib = alglib.pearsoncorr2(xs, ys, n);
    111111            r2_alglib *= r2_alglib;
    112112
Note: See TracChangeset for help on using the changeset viewer.