Changeset 16845


Ignore:
Timestamp:
04/19/19 12:59:43 (4 months ago)
Author:
chaider
Message:

#2971 Changed nodeIntervals in InteractiveSymbolicDataAnalysisSolutionSimlifierView

Location:
branches/2971_named_intervals
Files:
2 edited

Legend:

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

    r16823 r16845  
    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 IDictionary<ISymbolicExpressionTreeNode, Interval> intervals;
    40     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>();
    4141
    4242    private readonly ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator;
     
    5050    protected InteractiveSymbolicDataAnalysisSolutionSimplifierView(ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator) {
    5151      InitializeComponent();
    52       foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
    53       changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
    54       nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
    5552      this.Caption = "Interactive Solution Simplifier";
    5653      this.impactCalculator = impactCalculator;
     
    173170    protected override void OnContentChanged() {
    174171      base.OnContentChanged();
    175       foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
     172      foldedNodes.Clear();
     173      changedNodes.Clear();
     174      nodeIntervals.Clear();
     175      nodeImpacts.Clear();
    176176      UpdateView();
    177177      viewHost.Content = this.Content;
     
    195195      progress.CanBeStopped = true;
    196196      cancellationTokenSource = new CancellationTokenSource();
    197       var interpreter = new IntervalInterpreter();
    198197
    199198      var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));
    200       var variableRanges = (Content.ProblemData as RegressionProblemData).VariableRangesParameter.Value.VariableIntervals;
    201 
    202       var resultIntervals = interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals);
     199
    203200      try {
    204201        await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation
     
    208205        foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    209206      }
    210       nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
     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.VariableIntervals;
     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
    211224      progress.Finish();
    212225      progress.CanBeStopped = false;
     
    303316        }
    304317        if (visualTree != null) {
    305           if (intervals.ContainsKey(treeNode))
    306             visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{intervals[treeNode].LowerBound:G5} ... {intervals[treeNode].UpperBound:G5}]");
     318          if (nodeIntervals.ContainsKey(treeNode))
     319            visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{nodeIntervals[treeNode].LowerBound:G5} ... {nodeIntervals[treeNode].UpperBound:G5}]");
    307320          if (changedNodes.ContainsKey(treeNode)) {
    308321            visualTree.LineColor = Color.DodgerBlue;
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r16841 r16845  
    3030    NamedIntervals VariableRanges { get; set; }
    3131    ParsedConstraint IntervalConstraints { get; set; }
     32
    3233    IEnumerable<double> TargetVariableValues { get; }
    3334    IEnumerable<double> TargetVariableTrainingValues { get; }
Note: See TracChangeset for help on using the changeset viewer.