Ignore:
Timestamp:
05/30/20 22:00:12 (2 years ago)
Author:
mkommend
Message:

#2971: Merged branch into trunk.

File:
1 edited

Legend:

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

    r17430 r17579  
    3535namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    3636  public abstract partial class InteractiveSymbolicDataAnalysisSolutionSimplifierView : AsynchronousContentView {
    37     private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes;
    38     private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes;
    39     private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts;
     37    private readonly Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
     38    private readonly Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
     39    private readonly Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>();
     40    private readonly Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
    4041
    4142    private readonly ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator;
     
    4950    protected InteractiveSymbolicDataAnalysisSolutionSimplifierView(ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator) {
    5051      InitializeComponent();
    51       foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
    52       changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
    53       nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
    5452      this.Caption = "Interactive Solution Simplifier";
    5553      this.impactCalculator = impactCalculator;
     
    173171    protected override void OnContentChanged() {
    174172      base.OnContentChanged();
    175       foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
     173      foldedNodes.Clear();
     174      changedNodes.Clear();
     175      nodeIntervals.Clear();
     176      nodeImpacts.Clear();
    176177      UpdateView();
    177178      viewHost.Content = this.Content;
     
    205206          foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    206207        }
    207 
    208         nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
     208       
     209        foreach (var pair in impactAndReplacementValues) {
     210          nodeImpacts[pair.Key] = pair.Value.Item1;
     211        }
     212
     213        if (IntervalInterpreter.IsCompatible(tree)) {
     214          var regressionProblemData = Content.ProblemData as IRegressionProblemData;
     215          if (regressionProblemData != null) {
     216            var interpreter = new IntervalInterpreter();
     217            var variableRanges = regressionProblemData.VariableRanges.GetReadonlyDictionary();
     218            IDictionary<ISymbolicExpressionTreeNode, Interval> intervals;
     219            interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals);
     220            foreach (var kvp in intervals) {
     221              nodeIntervals[kvp.Key] = kvp.Value;
     222            }
     223          }
     224        }
    209225      } finally {
    210226        progress.Finish();
     
    303319          }
    304320        }
    305         if (visualTree != null)
     321        if (visualTree != null) {
     322          if (nodeIntervals.ContainsKey(treeNode))
     323            visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{nodeIntervals[treeNode].LowerBound:G5} ... {nodeIntervals[treeNode].UpperBound:G5}]");
    306324          if (changedNodes.ContainsKey(treeNode)) {
    307325            visualTree.LineColor = Color.DodgerBlue;
     
    309327            visualTree.LineColor = Color.DarkOrange;
    310328          }
     329        }
    311330      }
    312331      treeChart.RepaintNodes();
Note: See TracChangeset for help on using the changeset viewer.