Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs @ 4202

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

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

File size: 3.4 KB
RevLine 
[3442]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;
[4068]23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
[3442]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() { }
[3513]37    public SymbolicRegressionSolution(DataAnalysisProblemData problemData, SymbolicRegressionModel model, double lowerEstimationLimit, double upperEstimationLimit)
38      : base(problemData, lowerEstimationLimit, upperEstimationLimit) {
[3884]39      this.Model = model;
[3442]40    }
[3462]41
[3884]42    public override Image ItemImage {
43      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; }
[3462]44    }
45
[3884]46    public new SymbolicRegressionModel Model {
47      get { return (SymbolicRegressionModel)base.Model; }
48      set { base.Model = value; }
[3462]49    }
50
[3884]51    protected override void RecalculateEstimatedValues() {
52      estimatedValues = (from x in Model.GetEstimatedValues(ProblemData, 0, ProblemData.Dataset.Rows)
[3513]53                         let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, x))
54                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
[3884]55      OnEstimatedValuesChanged();
[3462]56    }
57
58    private List<double> estimatedValues;
59    public override IEnumerable<double> EstimatedValues {
60      get {
[3485]61        if (estimatedValues == null) RecalculateEstimatedValues();
[3462]62        return estimatedValues.AsEnumerable();
63      }
64    }
65
66    public override IEnumerable<double> EstimatedTrainingValues {
67      get {
[3485]68        if (estimatedValues == null) RecalculateEstimatedValues();
[3462]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 {
[3485]77        if (estimatedValues == null) RecalculateEstimatedValues();
[3462]78        int start = ProblemData.TestSamplesStart.Value;
79        int n = ProblemData.TestSamplesEnd.Value - start;
80        return estimatedValues.Skip(start).Take(n).ToList();
81      }
82    }
[3442]83  }
84}
Note: See TracBrowser for help on using the repository browser.