Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/06/17 13:38:16 (7 years ago)
Author:
pfleck
Message:

#1666: Merged 15371-15372,15390,15400,15402 to stable

Location:
stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r15131 r15406  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2523using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     24using HeuristicLab.MainForm;
    2625using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
    2726
    2827namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
    2928  public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView {
    30     private readonly SymbolicRegressionSolutionImpactValuesCalculator calculator;
    31 
    3229    public new SymbolicRegressionSolution Content {
    3330      get { return (SymbolicRegressionSolution)base.Content; }
     
    3633
    3734    public InteractiveSymbolicRegressionSolutionSimplifierView()
    38       : base() {
     35      : base(new SymbolicRegressionSolutionImpactValuesCalculator()) {
    3936      InitializeComponent();
    4037      this.Caption = "Interactive Regression Solution Simplifier";
    41       calculator = new SymbolicRegressionSolutionImpactValuesCalculator();
    4238    }
    4339
     
    4844    }
    4945
    50 
    51     protected override Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree) {
    52       var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>();
    53       foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
    54         double impactValue, replacementValue, newQualityForImpactsCalculation;
    55         calculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, out impactValue, out replacementValue, out newQualityForImpactsCalculation);
    56         impactAndReplacementValues.Add(node, new Tuple<double, double>(impactValue, replacementValue));
    57       }
    58       return impactAndReplacementValues;
    59     }
    60 
    61     protected override void btnOptimizeConstants_Click(object sender, EventArgs e) {
     46    protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicExpressionTree tree, IProgress progress) {
     47      const int constOptIterations = 50;
     48      var regressionProblemData = Content.ProblemData;
    6249      var model = Content.Model;
    63       SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices,
    64         applyLinearScaling: true, maxIterations: 50, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit);
    65       UpdateModel(Content.Model.SymbolicExpressionTree);
     50      SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, tree, regressionProblemData, regressionProblemData.TrainingIndices,
     51        applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit,
     52        iterationCallback: (args, func, obj) => {
     53          double newProgressValue = progress.ProgressValue + 1.0 / (constOptIterations + 2); // (maxIterations + 2) iterations are reported
     54          progress.ProgressValue = Math.Min(newProgressValue, 1.0);
     55        });
     56      return tree;
    6657    }
    6758  }
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs

    r14186 r15406  
    5151    private void btn_SimplifyModel_Click(object sender, EventArgs e) {
    5252      var view = new InteractiveSymbolicRegressionSolutionSimplifierView();
     53      view.Show(); // open view first that a progress can be displayed when setting the content
    5354      view.Content = (SymbolicRegressionSolution)this.Content.Clone();
    54       view.Show();
    5555    }
    5656
Note: See TracChangeset for help on using the changeset viewer.