Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/20 13:10:50 (4 years ago)
Author:
mkommend
Message:

#2971: Merged trunk changes into branch, corrected project files (output path for all configurations, reference paths), resolved merge conflicts in InteractiveSymbolicDataAnalysisSolutionSimplifierView.

Location:
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r17207 r17501  
    166166    private void Content_Changed(object sender, EventArgs e) {
    167167      UpdateView();
     168      SetEnabledStateOfControls();
    168169    }
    169170
     
    193194
    194195      progress.Start("Calculate Impact and Replacement Values ...");
     196      cancellationTokenSource = new CancellationTokenSource();
    195197      progress.CanBeStopped = true;
    196       cancellationTokenSource = new CancellationTokenSource();
    197 
    198       var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));
    199 
    200198      try {
    201         await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation
    202       } catch (OperationCanceledException) { }
    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       foreach (var kvp in impactAndReplacementValues) {
    209         nodeImpacts[kvp.Key] = kvp.Value.Item1;
    210       }
    211 
    212       var regressionProblemData = Content.ProblemData as IRegressionProblemData;
    213       if (regressionProblemData != null) {
    214         var interpreter = new IntervalInterpreter();
    215         var variableRanges = regressionProblemData.VariableRanges.GetIntervals();
    216         IDictionary<ISymbolicExpressionTreeNode, Interval> intervals;
    217         interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals);
    218         foreach (var kvp in intervals) {
    219           nodeIntervals[kvp.Key] = kvp.Value;
    220         }
    221       }
    222      
    223 
    224       progress.Finish();
     199        var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));
     200        try {
     201          await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation
     202        } catch (OperationCanceledException) { }
     203
     204        var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
     205        foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
     206          foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
     207        }
     208       
     209        foreach (var pair in impactAndReplacementValues) {
     210          nodeImpacts[pair.Key] = pair.Value.Item1;
     211        }
     212
     213        var regressionProblemData = Content.ProblemData as IRegressionProblemData;
     214        if (regressionProblemData != null) {
     215          var interpreter = new IntervalInterpreter();
     216          var variableRanges = regressionProblemData.VariableRanges.GetIntervals();
     217          IDictionary<ISymbolicExpressionTreeNode, Interval> intervals;
     218          interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals);
     219          foreach (var kvp in intervals) {
     220            nodeIntervals[kvp.Key] = kvp.Value;
     221          }
     222        }
     223      } finally {
     224        progress.Finish();
     225      }
     226
    225227      progress.CanBeStopped = false;
    226228      PaintNodeImpacts();
     
    335337    private async void btnOptimizeConstants_Click(object sender, EventArgs e) {
    336338      progress.Start("Optimizing Constants ...");
    337       var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone();
    338       var newTree = await Task.Run(() => OptimizeConstants(tree, progress));
    339       await Task.Delay(500); // wait for progressbar to finish animation
    340       UpdateModel(newTree); // UpdateModel calls Progress.Finish (via Content_Changed)
     339      cancellationTokenSource = new CancellationTokenSource();
     340      progress.CanBeStopped = true;
     341      try {
     342        var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone();
     343
     344        var newTree = await Task.Run(() => OptimizeConstants(tree, progress));
     345        try {
     346          await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation
     347        } catch (OperationCanceledException) { }
     348        UpdateModel(newTree); // triggers progress.Finish after calculating the node impacts when model is changed
     349      } catch {
     350        progress.Finish();
     351      }
    341352    }
    342353  }
Note: See TracChangeset for help on using the changeset viewer.