Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17430


Ignore:
Timestamp:
02/10/20 11:07:14 (4 years ago)
Author:
pfleck
Message:

#2973

  • Fixed progress calculation for InteractiveSymbolicDataAnalysisSolutionSimplifierView.
  • Added a minimum improvement (of 1E-10) to stop constant opt.
  • Added tooltips for Simplify and Optimize.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r17380 r17430  
    5353    protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicExpressionTree tree, IProgress progress) {
    5454      const int constOptIterations = 50;
    55       const int maxRepetitions = 1000;
     55      const int maxRepetitions = 100;
     56      const double minimumImprovement = 1e-10;
    5657      var regressionProblemData = Content.ProblemData;
    5758      var model = Content.Model;
    5859      progress.CanBeStopped = true;
    59       var prevResult = 0.0;
     60      double prevResult = 0.0, improvement = 0.0;
    6061      var result = 0.0;
    6162      int reps = 0;
     
    6667          applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit,
    6768          iterationCallback: (args, func, obj) => {
    68             double newProgressValue = progress.ProgressValue + 1.0 / (constOptIterations + 2); // (maxIterations + 2) iterations are reported
     69            double newProgressValue = progress.ProgressValue + (1.0 / (constOptIterations + 2) / maxRepetitions); // (constOptIterations + 2) iterations are reported
    6970            progress.ProgressValue = Math.Min(newProgressValue, 1.0);
    7071          });
    7172        reps++;
    72       } while (prevResult < result && reps < maxRepetitions &&
     73        improvement = result - prevResult;
     74      } while (improvement > minimumImprovement && reps < maxRepetitions &&
    7375               progress.ProgressState != ProgressState.StopRequested &&
    7476               progress.ProgressState != ProgressState.CancelRequested);
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs

    r17180 r17430  
    5757      this.grpViewHost = new System.Windows.Forms.GroupBox();
    5858      this.treeChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart();
     59      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5960      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    6061      this.splitContainer.Panel1.SuspendLayout();
     
    148149      this.btnSimplify.Text = "Simplify";
    149150      this.btnSimplify.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
     151      this.toolTip.SetToolTip(this.btnSimplify, "Simplifies the model structure based on mathematical simplification rules.");
    150152      this.btnSimplify.UseVisualStyleBackColor = true;
    151153      this.btnSimplify.Click += new System.EventHandler(this.btnSimplify_Click);
     
    162164      this.btnOptimizeConstants.Text = "Optimize";
    163165      this.btnOptimizeConstants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
     166      this.toolTip.SetToolTip(this.btnOptimizeConstants, "Optimizes the numerical constants of the model. \r\nIf the algorithm converges, opt" +
     167        "imization is stopped.");
    164168      this.btnOptimizeConstants.UseVisualStyleBackColor = true;
    165169      this.btnOptimizeConstants.Click += new System.EventHandler(this.btnOptimizeConstants_Click);
     
    226230    protected System.Windows.Forms.Button btnOptimizeConstants;
    227231    private System.Windows.Forms.Label treeStatusValue;
     232    private System.Windows.Forms.ToolTip toolTip;
    228233  }
    229234}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r17380 r17430  
    193193
    194194      progress.Start("Calculate Impact and Replacement Values ...");
     195      cancellationTokenSource = new CancellationTokenSource();
    195196      progress.CanBeStopped = true;
    196       cancellationTokenSource = new CancellationTokenSource();
    197       var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));
    198197      try {
    199         await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation
    200       } catch (OperationCanceledException) { }
    201       var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
    202       foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
    203         foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    204       }
    205       nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
    206       progress.Finish();
     198        var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));
     199        try {
     200          await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation
     201        } catch (OperationCanceledException) { }
     202
     203        var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
     204        foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
     205          foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
     206        }
     207
     208        nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
     209      } finally {
     210        progress.Finish();
     211      }
     212
    207213      progress.CanBeStopped = false;
    208214      PaintNodeImpacts();
     
    314320    private async void btnOptimizeConstants_Click(object sender, EventArgs e) {
    315321      progress.Start("Optimizing Constants ...");
     322      cancellationTokenSource = new CancellationTokenSource();
     323      progress.CanBeStopped = true;
    316324      try {
    317325        var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone();
     326
    318327        var newTree = await Task.Run(() => OptimizeConstants(tree, progress));
    319         await Task.Delay(500); // wait for progressbar to finish animation
    320         UpdateModel(newTree);
    321       } finally {
     328        try {
     329          await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation
     330        } catch (OperationCanceledException) { }
     331        UpdateModel(newTree); // triggers progress.Finish after calculating the node impacts when model is changed
     332      } catch {
    322333        progress.Finish();
    323334      }
Note: See TracChangeset for help on using the changeset viewer.