Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs @ 4272

Last change on this file since 4272 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 3.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using HeuristicLab.Core;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
30  /// <summary>
31  /// Represents a solution for a symbolic regression problem which can be visualized in the GUI.
32  /// </summary>
33  [Item("SymbolicRegressionSolution", "Represents a solution for a symbolic regression problem which can be visualized in the GUI.")]
34  [StorableClass]
35  public sealed class SymbolicRegressionSolution : DataAnalysisSolution {
36    public SymbolicRegressionSolution() : base() { }
37    public SymbolicRegressionSolution(DataAnalysisProblemData problemData, SymbolicRegressionModel model, double lowerEstimationLimit, double upperEstimationLimit)
38      : base(problemData, lowerEstimationLimit, upperEstimationLimit) {
39      this.Model = model;
40    }
41
42    public override Image ItemImage {
43      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; }
44    }
45
46    public new SymbolicRegressionModel Model {
47      get { return (SymbolicRegressionModel)base.Model; }
48      set { base.Model = value; }
49    }
50
51    protected override void RecalculateEstimatedValues() {
52      estimatedValues = (from x in Model.GetEstimatedValues(ProblemData, 0, ProblemData.Dataset.Rows)
53                         let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, x))
54                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
55      OnEstimatedValuesChanged();
56    }
57
58    private List<double> estimatedValues;
59    public override IEnumerable<double> EstimatedValues {
60      get {
61        if (estimatedValues == null) RecalculateEstimatedValues();
62        return estimatedValues.AsEnumerable();
63      }
64    }
65
66    public override IEnumerable<double> EstimatedTrainingValues {
67      get {
68        if (estimatedValues == null) RecalculateEstimatedValues();
69        int start = ProblemData.TrainingSamplesStart.Value;
70        int n = ProblemData.TrainingSamplesEnd.Value - start;
71        return estimatedValues.Skip(start).Take(n).ToList();
72      }
73    }
74
75    public override IEnumerable<double> EstimatedTestValues {
76      get {
77        if (estimatedValues == null) RecalculateEstimatedValues();
78        int start = ProblemData.TestSamplesStart.Value;
79        int n = ProblemData.TestSamplesEnd.Value - start;
80        return estimatedValues.Skip(start).Take(n).ToList();
81      }
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.