Free cookie consent management tool by TermsFeed Policy Generator

source: branches/SimplifierViewsProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs @ 15321

Last change on this file since 15321 was 15321, checked in by pfleck, 7 years ago

#1666

  • Moved CalculateImpactAndReplacementValues into base-class.
  • Use SymRegImpactCalculator for SymTimeSeriesPrognosis.
  • Unified CalculateImpactAndReplacementValues for all SimplifierViews.
File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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.Threading.Tasks;
24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
25using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
26
27namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
28  public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView {
29    private readonly SymbolicRegressionSolutionImpactValuesCalculator calculator;
30
31    public new SymbolicRegressionSolution Content {
32      get { return (SymbolicRegressionSolution)base.Content; }
33      set { base.Content = value; }
34    }
35
36    protected override ISymbolicDataAnalysisSolutionImpactValuesCalculator ImpactCalculator {
37      get { return calculator; }
38    }
39
40    public InteractiveSymbolicRegressionSolutionSimplifierView()
41      : base() {
42      InitializeComponent();
43      this.Caption = "Interactive Regression Solution Simplifier";
44      calculator = new SymbolicRegressionSolutionImpactValuesCalculator();
45    }
46
47    protected override void UpdateModel(ISymbolicExpressionTree tree) {
48      var model = new SymbolicRegressionModel(Content.ProblemData.TargetVariable, tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);
49      model.Scale(Content.ProblemData);
50      Content.Model = model;
51    }
52
53    protected override async void btnOptimizeConstants_Click(object sender, EventArgs e) {
54      const int constOptIterations = 50;
55      var model = Content.Model;
56      Progress.Start("Optimizing Constants ...", 0);
57      await Task.Run(() => {
58        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices,
59          applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit,
60          iterationReport: (args, func, iter) => {
61            Progress.ProgressValue = (double)iter / (constOptIterations + 1); // (maxIterations + 1) iterations are reported
62          });
63      });
64      UpdateModel(Content.Model.SymbolicExpressionTree); // UpdateModel calls Progress.Finish
65    }
66  }
67}
Note: See TracBrowser for help on using the repository browser.