Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1666:

  • Changed Progress interface (single parameterless ctor, overloads for Start-method).
  • Passed Impact-Calculator per ctor argument instead of virtual properties.
  • Created virtual OptimizeConstants-method instead of making the button-click event-handler virtual.
File size: 3.0 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 HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
24using HeuristicLab.MainForm;
25using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
26
27namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
28  public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView {
29    public new SymbolicRegressionSolution Content {
30      get { return (SymbolicRegressionSolution)base.Content; }
31      set { base.Content = value; }
32    }
33
34    public InteractiveSymbolicRegressionSolutionSimplifierView()
35      : base(new SymbolicRegressionSolutionImpactValuesCalculator()) {
36      InitializeComponent();
37      this.Caption = "Interactive Regression Solution Simplifier";
38    }
39
40    protected override void UpdateModel(ISymbolicExpressionTree tree) {
41      var model = new SymbolicRegressionModel(Content.ProblemData.TargetVariable, tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);
42      model.Scale(Content.ProblemData);
43      Content.Model = model;
44    }
45
46    protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicDataAnalysisModel model, IDataAnalysisProblemData problemData, IProgress progress) {
47      const int constOptIterations = 50;
48      var regressionModelModel = (ISymbolicDataAnalysisModel)model.Clone();
49      var regressionProblemData = (IRegressionProblemData)problemData;
50      SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(regressionModelModel.Interpreter, regressionModelModel.SymbolicExpressionTree, regressionProblemData, regressionProblemData.TrainingIndices,
51        applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: regressionModelModel.LowerEstimationLimit, upperEstimationLimit: regressionModelModel.UpperEstimationLimit,
52        iterationCallback: (args, func, obj) => {
53          // (maxIterations + 2) iterations are reported; Math.Min neccecary because of floating-point inaccuracies
54          progress.ProgressValue = Math.Min(progress.ProgressValue + 1.0 / (constOptIterations + 2), 1);
55        });
56      return model.SymbolicExpressionTree;
57    }
58  }
59}
Note: See TracBrowser for help on using the repository browser.