Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5699 for branches


Ignore:
Timestamp:
03/15/11 19:37:20 (13 years ago)
Author:
gkronber
Message:

#1418 added interactive simplifier view for symbolic regression models.

Location:
branches/DataAnalysis Refactoring
Files:
14 added
4 edited
6 copied

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab 3.3.sln

    r5693 r5699  
    115115    {DC3D7072-7999-4719-B65D-3997744D5DC1} = {DC3D7072-7999-4719-B65D-3997744D5DC1}
    116116    {FC841674-62A7-4055-BE91-E41944B6C606} = {FC841674-62A7-4055-BE91-E41944B6C606}
     117    {20831A74-D18F-42D9-A667-1CE3AF53DF93} = {20831A74-D18F-42D9-A667-1CE3AF53DF93}
    117118    {76945D76-CA61-4147-9DC2-0ACDCDDF87F9} = {76945D76-CA61-4147-9DC2-0ACDCDDF87F9}
    118119    {2E782078-FA81-4B70-B56F-74CE38DAC6C8} = {2E782078-FA81-4B70-B56F-74CE38DAC6C8}
     
    162163    {96AEBBEE-4203-45F3-BCF5-7B73BF256BDA} = {96AEBBEE-4203-45F3-BCF5-7B73BF256BDA}
    163164    {5A4679EF-A8F3-4647-B722-441A36B3BA6B} = {5A4679EF-A8F3-4647-B722-441A36B3BA6B}
     165    {BF1E4DF4-A4CC-451F-9D50-303F405E265E} = {BF1E4DF4-A4CC-451F-9D50-303F405E265E}
    164166    {23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE} = {23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}
    165167    {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937} = {BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}
     
    381383EndProject
    382384Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj", "{7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}"
     385EndProject
     386Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.csproj", "{BF1E4DF4-A4CC-451F-9D50-303F405E265E}"
     387EndProject
     388Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.csproj", "{20831A74-D18F-42D9-A667-1CE3AF53DF93}"
    383389EndProject
    384390Global
     
    17511757    {7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}.Release|x86.ActiveCfg = Release|x86
    17521758    {7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}.Release|x86.Build.0 = Release|x86
     1759    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     1760    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Debug|Any CPU.Build.0 = Debug|Any CPU
     1761    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Debug|x64.ActiveCfg = Debug|x64
     1762    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Debug|x64.Build.0 = Debug|x64
     1763    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Debug|x86.ActiveCfg = Debug|x86
     1764    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Debug|x86.Build.0 = Debug|x86
     1765    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Release|Any CPU.ActiveCfg = Release|Any CPU
     1766    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Release|Any CPU.Build.0 = Release|Any CPU
     1767    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Release|x64.ActiveCfg = Release|x64
     1768    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Release|x64.Build.0 = Release|x64
     1769    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Release|x86.ActiveCfg = Release|x86
     1770    {BF1E4DF4-A4CC-451F-9D50-303F405E265E}.Release|x86.Build.0 = Release|x86
     1771    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     1772    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Debug|Any CPU.Build.0 = Debug|Any CPU
     1773    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Debug|x64.ActiveCfg = Debug|x64
     1774    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Debug|x64.Build.0 = Debug|x64
     1775    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Debug|x86.ActiveCfg = Debug|x86
     1776    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Debug|x86.Build.0 = Debug|x86
     1777    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Release|Any CPU.ActiveCfg = Release|Any CPU
     1778    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Release|Any CPU.Build.0 = Release|Any CPU
     1779    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Release|x64.ActiveCfg = Release|x64
     1780    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Release|x64.Build.0 = Release|x64
     1781    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Release|x86.ActiveCfg = Release|x86
     1782    {20831A74-D18F-42D9-A667-1CE3AF53DF93}.Release|x86.Build.0 = Release|x86
    17531783  EndGlobalSection
    17541784  GlobalSection(SolutionProperties) = preSolution
  • branches/DataAnalysis Refactoring/HeuristicLab.Common/3.3/EnumerableStatisticExtensions.cs

    r5618 r5699  
    3232    /// <returns></returns>
    3333    public static double Median(this IEnumerable<double> values) {
    34       int n = values.Count();
     34      // iterate only once
     35      double[] valuesArr = values.ToArray();
     36      int n = valuesArr.Length;
    3537      if (n == 0) throw new InvalidOperationException("Enumeration contains no elements.");
    3638
    37       double[] sortedValues = new double[n];
    38       int i = 0;
    39       foreach (double x in values)
    40         sortedValues[i++] = x;
    41 
    42       Array.Sort(sortedValues);
     39      Array.Sort(valuesArr);
    4340
    4441      // return the middle element (if n is uneven) or the average of the two middle elements if n is even.
    4542      if (n % 2 == 1) {
    46         return sortedValues[n / 2];
     43        return valuesArr[n / 2];
    4744      } else {
    48         return (sortedValues[(n / 2) - 1] + sortedValues[n / 2]) / 2.0;
     45        return (valuesArr[(n / 2) - 1] + valuesArr[n / 2]) / 2.0;
    4946      }
    5047    }
     
    9289    /// </summary
    9390    public static double Percentile(this IEnumerable<double> values, double p) {
    94       if (values.Count() == 0) throw new InvalidOperationException("Enumeration contains no elements.");
    95       if (values.Count() == 1) return values.ElementAt(0);
     91      // iterate only once
     92      double[] valuesArr = values.ToArray();
     93      int n = valuesArr.Length;
     94      if (n == 0) throw new InvalidOperationException("Enumeration contains no elements.");
     95      if (n == 1) return values.ElementAt(0);
    9696
    97       double[] sortedValues = values.ToArray();
    98       Array.Sort(sortedValues);
    99 
    100       int n = sortedValues.Length;
    101       if (p.IsAlmost(0.0)) return sortedValues[0];
    102       if (p.IsAlmost(1.0)) return sortedValues[n - 1];
     97      if (p.IsAlmost(0.0)) return valuesArr[0];
     98      if (p.IsAlmost(1.0)) return valuesArr[n - 1];
    10399
    104100      double t = p * (n - 1);
    105101      int index = (int)Math.Floor(t);
    106102      double percentage = t - index;
    107       return sortedValues[index] * (1 - percentage) + sortedValues[index + 1] * percentage;
     103      return valuesArr[index] * (1 - percentage) + valuesArr[index + 1] * percentage;
    108104    }
    109105
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.Designer.cs

    r5692 r5699  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic {
     22namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
    2323  partial class InteractiveSymbolicRegressionSolutionSimplifierView {
    2424    /// <summary>
     
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    48       this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    49       this.splitContainer = new System.Windows.Forms.SplitContainer();
    50       this.grpSimplify = new System.Windows.Forms.GroupBox();
    51       this.btnSimplify = new System.Windows.Forms.Button();
    52       this.grpViewHost = new System.Windows.Forms.GroupBox();
    53       this.splitContainer.Panel1.SuspendLayout();
    54       this.splitContainer.Panel2.SuspendLayout();
    55       this.splitContainer.SuspendLayout();
    56       this.grpSimplify.SuspendLayout();
    57       this.grpViewHost.SuspendLayout();
    5847      this.SuspendLayout();
    59       //
    60       // treeChart
    61       //
    62       this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    63                   | System.Windows.Forms.AnchorStyles.Left)
    64                   | System.Windows.Forms.AnchorStyles.Right)));
    65       this.treeChart.BackgroundColor = System.Drawing.Color.White;
    66       this.treeChart.LineColor = System.Drawing.Color.Black;
    67       this.treeChart.Location = new System.Drawing.Point(6, 16);
    68       this.treeChart.Name = "treeChart";
    69       this.treeChart.Size = new System.Drawing.Size(201, 297);
    70       this.treeChart.Spacing = 5;
    71       this.treeChart.TabIndex = 0;
    72       this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
    73       this.treeChart.Tree = null;
    74       this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
    75       //
    76       // viewHost
    77       //
    78       this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    79                   | System.Windows.Forms.AnchorStyles.Left)
    80                   | System.Windows.Forms.AnchorStyles.Right)));
    81       this.viewHost.Caption = "View";
    82       this.viewHost.Content = null;
    83       this.viewHost.Enabled = false;
    84       this.viewHost.Location = new System.Drawing.Point(6, 16);
    85       this.viewHost.Name = "viewHost";
    86       this.viewHost.ReadOnly = false;
    87       this.viewHost.Size = new System.Drawing.Size(335, 326);
    88       this.viewHost.TabIndex = 0;
    89       this.viewHost.ViewType = null;
    90       //
    91       // splitContainer
    92       //
    93       this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
    94       this.splitContainer.Location = new System.Drawing.Point(0, 0);
    95       this.splitContainer.Name = "splitContainer";
    96       //
    97       // splitContainer.Panel1
    98       //
    99       this.splitContainer.Panel1.Controls.Add(this.grpSimplify);
    100       //
    101       // splitContainer.Panel2
    102       //
    103       this.splitContainer.Panel2.Controls.Add(this.grpViewHost);
    104       this.splitContainer.Size = new System.Drawing.Size(564, 348);
    105       this.splitContainer.SplitterDistance = 213;
    106       this.splitContainer.TabIndex = 1;
    107       //
    108       // grpSimplify
    109       //
    110       this.grpSimplify.Controls.Add(this.btnSimplify);
    111       this.grpSimplify.Controls.Add(this.treeChart);
    112       this.grpSimplify.Dock = System.Windows.Forms.DockStyle.Fill;
    113       this.grpSimplify.Location = new System.Drawing.Point(0, 0);
    114       this.grpSimplify.Name = "grpSimplify";
    115       this.grpSimplify.Size = new System.Drawing.Size(213, 348);
    116       this.grpSimplify.TabIndex = 1;
    117       this.grpSimplify.TabStop = false;
    118       this.grpSimplify.Text = "Simplify";
    119       //
    120       // btnSimplify
    121       //
    122       this.btnSimplify.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    123                   | System.Windows.Forms.AnchorStyles.Right)));
    124       this.btnSimplify.Location = new System.Drawing.Point(6, 319);
    125       this.btnSimplify.Name = "btnSimplify";
    126       this.btnSimplify.Size = new System.Drawing.Size(201, 23);
    127       this.btnSimplify.TabIndex = 1;
    128       this.btnSimplify.Text = "Simplify";
    129       this.btnSimplify.UseVisualStyleBackColor = true;
    130       this.btnSimplify.Click += new System.EventHandler(this.btnSimplify_Click);
    131       //
    132       // grpViewHost
    133       //
    134       this.grpViewHost.Controls.Add(this.viewHost);
    135       this.grpViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    136       this.grpViewHost.Location = new System.Drawing.Point(0, 0);
    137       this.grpViewHost.Name = "grpViewHost";
    138       this.grpViewHost.Size = new System.Drawing.Size(347, 348);
    139       this.grpViewHost.TabIndex = 1;
    140       this.grpViewHost.TabStop = false;
    141       this.grpViewHost.Text = "Details";
    14248      //
    14349      // InteractiveSymbolicRegressionSolutionSimplifierView
     
    14551      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    14652      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    147       this.Controls.Add(this.splitContainer);
    14853      this.Name = "InteractiveSymbolicRegressionSolutionSimplifierView";
    14954      this.Size = new System.Drawing.Size(564, 348);
    150       this.splitContainer.Panel1.ResumeLayout(false);
    151       this.splitContainer.Panel2.ResumeLayout(false);
    152       this.splitContainer.ResumeLayout(false);
    153       this.grpSimplify.ResumeLayout(false);
    154       this.grpViewHost.ResumeLayout(false);
    15555      this.ResumeLayout(false);
    156 
    15756    }
    15857
    15958    #endregion
    160 
    161     private HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart;
    162     private System.Windows.Forms.SplitContainer splitContainer;
    163     private HeuristicLab.MainForm.WindowsForms.ViewHost viewHost;
    164     private System.Windows.Forms.GroupBox grpSimplify;
    165     private System.Windows.Forms.GroupBox grpViewHost;
    166     private System.Windows.Forms.Button btnSimplify;
    16759  }
    16860}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r5692 r5699  
    2626using System.Windows.Forms;
    2727using HeuristicLab.Common;
     28using HeuristicLab.MainForm.WindowsForms;
     29using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
    2830using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    31 using HeuristicLab.MainForm.WindowsForms;
    32 using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic;
    33 using HeuristicLab.Problems.DataAnalysis.Symbolic;
    34 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
    3531
    36 namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic {
    37   public partial class InteractiveSymbolicRegressionSolutionSimplifierView : AsynchronousContentView {
    38     private SymbolicExpressionTree simplifiedExpressionTree;
    39     private Dictionary<SymbolicExpressionTreeNode, ConstantTreeNode> replacementNodes;
    40     private Dictionary<SymbolicExpressionTreeNode, double> nodeImpacts;
     32namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
     33  public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView {
     34    private readonly ConstantTreeNode constantNode;
     35    private readonly SymbolicExpressionTree tempTree;
     36    public InteractiveSymbolicRegressionSolutionSimplifierView()
     37      : base() {
     38      InitializeComponent();
     39      this.Caption = "Interactive Regression Solution Simplifier";
    4140
    42     public InteractiveSymbolicRegressionSolutionSimplifierView() {
    43       InitializeComponent();
    44       this.replacementNodes = new Dictionary<SymbolicExpressionTreeNode, ConstantTreeNode>();
    45       this.nodeImpacts = new Dictionary<SymbolicExpressionTreeNode, double>();
    46       this.simplifiedExpressionTree = null;
    47       this.Caption = "Interactive Solution Simplifier";
     41      constantNode = ((ConstantTreeNode)new Constant().CreateTreeNode());
     42      ISymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
     43      ISymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
     44      root.AddSubTree(start);
     45      tempTree = new SymbolicExpressionTree(root);
    4846    }
    4947
    50     public new SymbolicRegressionSolution Content {
    51       get { return (SymbolicRegressionSolution)base.Content; }
     48    public new ISymbolicRegressionSolution Content {
     49      get { return (ISymbolicRegressionSolution)base.Content; }
    5250      set { base.Content = value; }
    5351    }
    5452
    55     protected override void RegisterContentEvents() {
    56       base.RegisterContentEvents();
    57       Content.ModelChanged += new EventHandler(Content_ModelChanged);
    58       Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
    59     }
    60     protected override void DeregisterContentEvents() {
    61       base.DeregisterContentEvents();
    62       Content.ModelChanged -= new EventHandler(Content_ModelChanged);
    63       Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
     53    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) {
     54      Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
     55      foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) {
     56        if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) {
     57          replacementValues[node] = CalculateReplacementValue(node, interpreter, dataset, rows);
     58        }
     59      }
     60      return replacementValues;
    6461    }
    6562
    66     private void Content_ModelChanged(object sender, EventArgs e) {
    67       this.CalculateReplacementNodesAndNodeImpacts();
    68     }
    69     private void Content_ProblemDataChanged(object sender, EventArgs e) {
    70       this.CalculateReplacementNodesAndNodeImpacts();
     63    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) {
     64      Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
     65      List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubTree(0).GetSubTree(0).IterateNodesPostfix().ToList();
     66      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows)
     67        .ToArray();
     68
     69      foreach (ISymbolicExpressionTreeNode node in nodes) {
     70        var parent = node.Parent;
     71        constantNode.Value = CalculateReplacementValue(node, interpreter, dataset, rows);
     72        ISymbolicExpressionTreeNode replacementNode = constantNode;
     73        SwitchNode(parent, node, replacementNode);
     74        var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).ToArray();
     75
     76        impactValues[node] = 1 - OnlinePearsonsRSquaredEvaluator.Calculate(originalOutput, newOutput);
     77        SwitchNode(parent, replacementNode, node);
     78      }
     79      return impactValues;
    7180    }
    7281
    73     protected override void OnContentChanged() {
    74       base.OnContentChanged();
    75       this.CalculateReplacementNodesAndNodeImpacts();
    76       this.viewHost.Content = this.Content;
     82    private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, Dataset dataset, IEnumerable<int> rows) {
     83      var start = tempTree.Root.GetSubTree(0);
     84      while (start.SubTrees.Count() > 0) start.RemoveSubTree(0);
     85      start.AddSubTree((ISymbolicExpressionTreeNode)node.Clone());
     86      return interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, rows).Median();
    7787    }
    7888
    79     private void CalculateReplacementNodesAndNodeImpacts() {
    80       this.replacementNodes.Clear();
    81       this.nodeImpacts.Clear();
    82       if (Content != null && Content.Model != null && Content.ProblemData != null) {
    83         SymbolicSimplifier simplifier = new SymbolicSimplifier();
    84         simplifiedExpressionTree = simplifier.Simplify(Content.Model.SymbolicExpressionTree);
    85         int samplesStart = Content.ProblemData.TrainingSamplesStart.Value;
    86         int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value;
    87         double originalTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate(
    88             Content.Model.Interpreter, simplifiedExpressionTree, Content.LowerEstimationLimit, Content.UpperEstimationLimit,
    89             Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value,
    90             Enumerable.Range(samplesStart, samplesEnd - samplesStart));
    9189
    92         this.CalculateReplacementNodes();
    93 
    94         this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root.SubTrees[0], originalTrainingMeanSquaredError);
    95         // automatically fold all branches with impact = 1
    96         List<SymbolicExpressionTreeNode> nodeList = simplifiedExpressionTree.Root.SubTrees[0].IterateNodesPrefix().ToList();
    97         foreach (var parent in nodeList) {
    98           for (int subTreeIndex = 0; subTreeIndex < parent.SubTrees.Count; subTreeIndex++) {
    99             var child = parent.SubTrees[subTreeIndex];
    100             if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(1.0)) {
    101               ReplaceNodeWithConstant(parent, subTreeIndex);
    102             }
    103           }
    104         }
    105         // show only interesting part of solution
    106         this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
    107         this.PaintNodeImpacts();
    108       }
    109     }
    110 
    111     private void CalculateReplacementNodes() {
    112       ISymbolicExpressionTreeInterpreter interpreter = Content.Model.Interpreter;
    113       IEnumerable<int> trainingSamples = Enumerable.Range(Content.ProblemData.TrainingSamplesStart.Value, Content.ProblemData.TrainingSamplesEnd.Value - Content.ProblemData.TrainingSamplesStart.Value);
    114       SymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
    115       SymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
    116       root.AddSubTree(start);
    117       SymbolicExpressionTree tree = new SymbolicExpressionTree(root);
    118       foreach (SymbolicExpressionTreeNode node in this.simplifiedExpressionTree.IterateNodesPrefix()) {
    119         if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) {
    120           while (start.SubTrees.Count > 0) start.RemoveSubTree(0);
    121           start.AddSubTree(node);
    122           double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, trainingSamples).Median();
    123           ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue);
    124           replacementNodes[node] = constantTreeNode;
    125         }
    126       }
    127     }
    128 
    129     private void CalculateNodeImpacts(SymbolicExpressionTree tree, SymbolicExpressionTreeNode currentTreeNode, double originalTrainingMeanSquaredError) {
    130       foreach (SymbolicExpressionTreeNode childNode in currentTreeNode.SubTrees.ToList()) {
    131         SwitchNode(currentTreeNode, childNode, replacementNodes[childNode]);
    132         int samplesStart = Content.ProblemData.TrainingSamplesStart.Value;
    133         int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value;
    134         double newTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate(
    135           Content.Model.Interpreter, tree,
    136           Content.LowerEstimationLimit, Content.UpperEstimationLimit,
    137           Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value,
    138           Enumerable.Range(samplesStart, samplesEnd - samplesStart));
    139         nodeImpacts[childNode] = newTrainingMeanSquaredError / originalTrainingMeanSquaredError;
    140         SwitchNode(currentTreeNode, replacementNodes[childNode], childNode);
    141         CalculateNodeImpacts(tree, childNode, originalTrainingMeanSquaredError);
    142       }
    143     }
    144 
    145     private void SwitchNode(SymbolicExpressionTreeNode root, SymbolicExpressionTreeNode oldBranch, SymbolicExpressionTreeNode newBranch) {
    146       for (int i = 0; i < root.SubTrees.Count; i++) {
    147         if (root.SubTrees[i] == oldBranch) {
     90    private void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
     91      for (int i = 0; i < root.SubTrees.Count(); i++) {
     92        if (root.GetSubTree(i) == oldBranch) {
    14893          root.RemoveSubTree(i);
    14994          root.InsertSubTree(i, newBranch);
     
    15297      }
    15398    }
    154 
    155     private ConstantTreeNode MakeConstantTreeNode(double value) {
    156       Constant constant = new Constant();
    157       constant.MinValue = value - 1;
    158       constant.MaxValue = value + 1;
    159       ConstantTreeNode constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
    160       constantTreeNode.Value = value;
    161       return constantTreeNode;
    162     }
    163 
    164     private void treeChart_SymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
    165       VisualSymbolicExpressionTreeNode visualTreeNode = (VisualSymbolicExpressionTreeNode)sender;
    166       foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    167         for (int i = 0; i < treeNode.SubTrees.Count; i++) {
    168           SymbolicExpressionTreeNode subTree = treeNode.SubTrees[i];
    169           if (subTree == visualTreeNode.SymbolicExpressionTreeNode) {
    170             ReplaceNodeWithConstant(treeNode, i);
    171           }
    172         }
    173       }
    174 
    175       // show only interesting part of solution
    176       this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
    177 
    178       SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone();
    179 
    180       this.Content.ModelChanged -= new EventHandler(Content_ModelChanged);
    181       this.Content.Model = new SymbolicRegressionModel(Content.Model.Interpreter, tree);
    182       this.Content.ModelChanged += new EventHandler(Content_ModelChanged);
    183 
    184       this.PaintNodeImpacts();
    185     }
    186 
    187     private void ReplaceNodeWithConstant(SymbolicExpressionTreeNode parent, int subTreeIndex) {
    188       SymbolicExpressionTreeNode subTree = parent.SubTrees[subTreeIndex];
    189       parent.RemoveSubTree(subTreeIndex);
    190       if (replacementNodes.ContainsKey(subTree))
    191         parent.InsertSubTree(subTreeIndex, replacementNodes[subTree]);
    192       else if (subTree is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)subTree))
    193         parent.InsertSubTree(subTreeIndex, replacementNodes.Where(v => v.Value == subTree).Single().Key);
    194       else if (!(subTree is ConstantTreeNode))
    195         throw new InvalidOperationException("Could not find replacement value.");
    196     }
    197 
    198     private void PaintNodeImpacts() {
    199       var impacts = nodeImpacts.Values;
    200       double max = impacts.Max();
    201       double min = impacts.Min();
    202       foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    203         if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
    204           double impact = this.nodeImpacts[treeNode];
    205           double replacementValue = this.replacementNodes[treeNode].Value;
    206           VisualSymbolicExpressionTreeNode visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    207 
    208           if (impact < 1.0) {
    209             visualTree.FillColor = Color.FromArgb((int)((1.0 - impact) * 255), Color.Red);
    210           } else {
    211             visualTree.FillColor = Color.FromArgb((int)((impact - 1.0) / max * 255), Color.Green);
    212           }
    213           visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact;
    214           visualTree.ToolTip += Environment.NewLine + "Replacement value: " + replacementValue;
    215         }
    216       }
    217       this.PaintCollapsedNodes();
    218       this.treeChart.Repaint();
    219     }
    220 
    221     private void PaintCollapsedNodes() {
    222       foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    223         if (treeNode is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)treeNode))
    224           this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange;
    225         else {
    226           VisualSymbolicExpressionTreeNode visNode = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    227           if (visNode != null)
    228             visNode.LineColor = Color.Black;
    229         }
    230       }
    231     }
    232 
    233     private void btnSimplify_Click(object sender, EventArgs e) {
    234       this.CalculateReplacementNodesAndNodeImpacts();
    235     }
    23699  }
    237100}
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.Designer.cs

    r5692 r5699  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic {
     22namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
    2323  partial class SymbolicRegressionSolutionView {
    2424    /// <summary>
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs

    r5692 r5699  
    2323using System.Windows.Forms;
    2424using HeuristicLab.MainForm;
    25 using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic;
     25using HeuristicLab.Problems.DataAnalysis.Views;
    2626
    27 namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic {
    28   [Content(typeof(SymbolicRegressionSolution))]
     27namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
     28  [Content(typeof(ISymbolicRegressionSolution))]
    2929  [View("Symbolic Regression Solution View")]
    3030  public partial class SymbolicRegressionSolutionView : DataAnalysisSolutionView {
     
    3333    }
    3434
    35     protected new SymbolicRegressionSolution Content {
    36       get { return (SymbolicRegressionSolution)base.Content; }
     35    protected new ISymbolicRegressionSolution Content {
     36      get { return (ISymbolicRegressionSolution)base.Content; }
    3737      set { base.Content = value; }
    3838    }
     
    4040    private void btn_SimplifyModel_Click(object sender, EventArgs e) {
    4141      InteractiveSymbolicRegressionSolutionSimplifierView view = new InteractiveSymbolicRegressionSolutionSimplifierView();
    42       view.Content = (SymbolicRegressionSolution)this.Content.Clone();
     42      view.Content = (ISymbolicRegressionSolution)this.Content.Clone();
    4343      view.Show();
    4444    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r5693 r5699  
    110110  </ItemGroup>
    111111  <ItemGroup>
     112    <Compile Include="InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs">
     113      <SubType>UserControl</SubType>
     114    </Compile>
     115    <Compile Include="InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs">
     116      <DependentUpon>InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs</DependentUpon>
     117    </Compile>
    112118    <Compile Include="SymbolicDataAnalysisModelView.cs">
    113119      <SubType>UserControl</SubType>
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs

    r5692 r5699  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic {
    23   partial class InteractiveSymbolicRegressionSolutionSimplifierView {
     22namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
     23  partial class InteractiveSymbolicDataAnalysisSolutionSimplifierView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r5692 r5699  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    3029using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    3130using HeuristicLab.MainForm.WindowsForms;
    32 using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic;
    3331using HeuristicLab.Problems.DataAnalysis.Symbolic;
    34 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
    3532
    36 namespace HeuristicLab.Problems.DataAnalysis.Views.Symbolic {
    37   public partial class InteractiveSymbolicRegressionSolutionSimplifierView : AsynchronousContentView {
    38     private SymbolicExpressionTree simplifiedExpressionTree;
    39     private Dictionary<SymbolicExpressionTreeNode, ConstantTreeNode> replacementNodes;
    40     private Dictionary<SymbolicExpressionTreeNode, double> nodeImpacts;
     33namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
     34  public abstract partial class InteractiveSymbolicDataAnalysisSolutionSimplifierView : AsynchronousContentView {
     35    private ISymbolicExpressionTree simplifiedExpressionTree;
     36    private Dictionary<ISymbolicExpressionTreeNode, ConstantTreeNode> replacementNodes;
     37    private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts;
    4138
    42     public InteractiveSymbolicRegressionSolutionSimplifierView() {
     39    public InteractiveSymbolicDataAnalysisSolutionSimplifierView() {
    4340      InitializeComponent();
    44       this.replacementNodes = new Dictionary<SymbolicExpressionTreeNode, ConstantTreeNode>();
    45       this.nodeImpacts = new Dictionary<SymbolicExpressionTreeNode, double>();
     41      this.replacementNodes = new Dictionary<ISymbolicExpressionTreeNode, ConstantTreeNode>();
     42      this.nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
    4643      this.simplifiedExpressionTree = null;
    4744      this.Caption = "Interactive Solution Simplifier";
    4845    }
    4946
    50     public new SymbolicRegressionSolution Content {
    51       get { return (SymbolicRegressionSolution)base.Content; }
     47    public new ISymbolicDataAnalysisSolution Content {
     48      get { return (ISymbolicDataAnalysisSolution)base.Content; }
    5249      set { base.Content = value; }
    5350    }
     
    6562
    6663    private void Content_ModelChanged(object sender, EventArgs e) {
     64      OnModelChanged();
     65    }
     66    private void Content_ProblemDataChanged(object sender, EventArgs e) {
     67      OnProblemDataChanged();
     68    }
     69
     70    protected virtual void OnModelChanged() {
    6771      this.CalculateReplacementNodesAndNodeImpacts();
    6872    }
    69     private void Content_ProblemDataChanged(object sender, EventArgs e) {
     73
     74    protected virtual void OnProblemDataChanged() {
    7075      this.CalculateReplacementNodesAndNodeImpacts();
    7176    }
     
    7883
    7984    private void CalculateReplacementNodesAndNodeImpacts() {
    80       this.replacementNodes.Clear();
    81       this.nodeImpacts.Clear();
     85      replacementNodes.Clear();
    8286      if (Content != null && Content.Model != null && Content.ProblemData != null) {
    83         SymbolicSimplifier simplifier = new SymbolicSimplifier();
     87        SymbolicDataAnalysisExpressionTreeSimplifier simplifier = new SymbolicDataAnalysisExpressionTreeSimplifier();
    8488        simplifiedExpressionTree = simplifier.Simplify(Content.Model.SymbolicExpressionTree);
    85         int samplesStart = Content.ProblemData.TrainingSamplesStart.Value;
    86         int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value;
    87         double originalTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate(
    88             Content.Model.Interpreter, simplifiedExpressionTree, Content.LowerEstimationLimit, Content.UpperEstimationLimit,
    89             Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value,
    90             Enumerable.Range(samplesStart, samplesEnd - samplesStart));
    9189
    92         this.CalculateReplacementNodes();
     90        var replacementValues = CalculateReplacementValues(Content.Model.Interpreter, simplifiedExpressionTree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndizes);
     91        foreach (var pair in replacementValues) {
     92          replacementNodes.Add(pair.Key, MakeConstantTreeNode(pair.Value));
     93        }
     94        nodeImpacts = CalculateImpactValues(Content.Model.Interpreter, simplifiedExpressionTree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndizes);
    9395
    94         this.CalculateNodeImpacts(simplifiedExpressionTree, simplifiedExpressionTree.Root.SubTrees[0], originalTrainingMeanSquaredError);
    9596        // automatically fold all branches with impact = 1
    96         List<SymbolicExpressionTreeNode> nodeList = simplifiedExpressionTree.Root.SubTrees[0].IterateNodesPrefix().ToList();
     97        List<ISymbolicExpressionTreeNode> nodeList = simplifiedExpressionTree.Root.GetSubTree(0).IterateNodesPrefix().ToList();
    9798        foreach (var parent in nodeList) {
    98           for (int subTreeIndex = 0; subTreeIndex < parent.SubTrees.Count; subTreeIndex++) {
    99             var child = parent.SubTrees[subTreeIndex];
     99          for (int subTreeIndex = 0; subTreeIndex < parent.SubTrees.Count(); subTreeIndex++) {
     100            var child = parent.GetSubTree(subTreeIndex);
    100101            if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(1.0)) {
    101102              ReplaceNodeWithConstant(parent, subTreeIndex);
     
    104105        }
    105106        // show only interesting part of solution
    106         this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
     107        this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.GetSubTree(0).GetSubTree(0));
    107108        this.PaintNodeImpacts();
    108109      }
    109110    }
    110111
    111     private void CalculateReplacementNodes() {
    112       ISymbolicExpressionTreeInterpreter interpreter = Content.Model.Interpreter;
    113       IEnumerable<int> trainingSamples = Enumerable.Range(Content.ProblemData.TrainingSamplesStart.Value, Content.ProblemData.TrainingSamplesEnd.Value - Content.ProblemData.TrainingSamplesStart.Value);
    114       SymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
    115       SymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
    116       root.AddSubTree(start);
    117       SymbolicExpressionTree tree = new SymbolicExpressionTree(root);
    118       foreach (SymbolicExpressionTreeNode node in this.simplifiedExpressionTree.IterateNodesPrefix()) {
    119         if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) {
    120           while (start.SubTrees.Count > 0) start.RemoveSubTree(0);
    121           start.AddSubTree(node);
    122           double constantTreeNodeValue = interpreter.GetSymbolicExpressionTreeValues(tree, Content.ProblemData.Dataset, trainingSamples).Median();
    123           ConstantTreeNode constantTreeNode = MakeConstantTreeNode(constantTreeNodeValue);
    124           replacementNodes[node] = constantTreeNode;
    125         }
    126       }
    127     }
    128 
    129     private void CalculateNodeImpacts(SymbolicExpressionTree tree, SymbolicExpressionTreeNode currentTreeNode, double originalTrainingMeanSquaredError) {
    130       foreach (SymbolicExpressionTreeNode childNode in currentTreeNode.SubTrees.ToList()) {
    131         SwitchNode(currentTreeNode, childNode, replacementNodes[childNode]);
    132         int samplesStart = Content.ProblemData.TrainingSamplesStart.Value;
    133         int samplesEnd = Content.ProblemData.TrainingSamplesEnd.Value;
    134         double newTrainingMeanSquaredError = SymbolicRegressionMeanSquaredErrorEvaluator.Calculate(
    135           Content.Model.Interpreter, tree,
    136           Content.LowerEstimationLimit, Content.UpperEstimationLimit,
    137           Content.ProblemData.Dataset, Content.ProblemData.TargetVariable.Value,
    138           Enumerable.Range(samplesStart, samplesEnd - samplesStart));
    139         nodeImpacts[childNode] = newTrainingMeanSquaredError / originalTrainingMeanSquaredError;
    140         SwitchNode(currentTreeNode, replacementNodes[childNode], childNode);
    141         CalculateNodeImpacts(tree, childNode, originalTrainingMeanSquaredError);
    142       }
    143     }
    144 
    145     private void SwitchNode(SymbolicExpressionTreeNode root, SymbolicExpressionTreeNode oldBranch, SymbolicExpressionTreeNode newBranch) {
    146       for (int i = 0; i < root.SubTrees.Count; i++) {
    147         if (root.SubTrees[i] == oldBranch) {
    148           root.RemoveSubTree(i);
    149           root.InsertSubTree(i, newBranch);
    150           return;
    151         }
    152       }
    153     }
     112    protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows);
     113    protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows);
    154114
    155115    private ConstantTreeNode MakeConstantTreeNode(double value) {
     
    165125      VisualSymbolicExpressionTreeNode visualTreeNode = (VisualSymbolicExpressionTreeNode)sender;
    166126      foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    167         for (int i = 0; i < treeNode.SubTrees.Count; i++) {
    168           SymbolicExpressionTreeNode subTree = treeNode.SubTrees[i];
     127        for (int i = 0; i < treeNode.SubTrees.Count(); i++) {
     128          ISymbolicExpressionTreeNode subTree = treeNode.GetSubTree(i);
    169129          if (subTree == visualTreeNode.SymbolicExpressionTreeNode) {
    170130            ReplaceNodeWithConstant(treeNode, i);
     
    174134
    175135      // show only interesting part of solution
    176       this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.SubTrees[0].SubTrees[0]);
     136      this.treeChart.Tree = new SymbolicExpressionTree(simplifiedExpressionTree.Root.GetSubTree(0).GetSubTree(0));
    177137
    178138      SymbolicExpressionTree tree = (SymbolicExpressionTree)simplifiedExpressionTree.Clone();
    179139
    180       this.Content.ModelChanged -= new EventHandler(Content_ModelChanged);
    181       this.Content.Model = new SymbolicRegressionModel(Content.Model.Interpreter, tree);
    182       this.Content.ModelChanged += new EventHandler(Content_ModelChanged);
     140      //this.Content.ModelChanged -= new EventHandler(Content_ModelChanged);
     141      //this.Content.Model = new SymbolicRegressionModel(Content.Model.Interpreter, tree);
     142      //this.Content.ModelChanged += new EventHandler(Content_ModelChanged);
    183143
    184144      this.PaintNodeImpacts();
    185145    }
    186146
    187     private void ReplaceNodeWithConstant(SymbolicExpressionTreeNode parent, int subTreeIndex) {
    188       SymbolicExpressionTreeNode subTree = parent.SubTrees[subTreeIndex];
     147    private void ReplaceNodeWithConstant(ISymbolicExpressionTreeNode parent, int subTreeIndex) {
     148      ISymbolicExpressionTreeNode subTree = parent.GetSubTree(subTreeIndex);
    189149      parent.RemoveSubTree(subTreeIndex);
    190150      if (replacementNodes.ContainsKey(subTree))
     
    200160      double max = impacts.Max();
    201161      double min = impacts.Min();
    202       foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
     162      foreach (ISymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    203163        if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
    204164          double impact = this.nodeImpacts[treeNode];
    205165          double replacementValue = this.replacementNodes[treeNode].Value;
    206166          VisualSymbolicExpressionTreeNode visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    207 
    208           if (impact < 1.0) {
    209             visualTree.FillColor = Color.FromArgb((int)((1.0 - impact) * 255), Color.Red);
    210           } else {
    211             visualTree.FillColor = Color.FromArgb((int)((impact - 1.0) / max * 255), Color.Green);
    212           }
     167         
     168          //if (impact < 1.0) {
     169          //  visualTree.FillColor = Color.FromArgb((int)((1.0 - impact) * 255), Color.Red);
     170          //} else {
     171          visualTree.FillColor = Color.FromArgb((int)((impact - 1.0) / max * 255), Color.Green);
     172          //}
    213173          visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact;
    214174          visualTree.ToolTip += Environment.NewLine + "Replacement value: " + replacementValue;
     
    220180
    221181    private void PaintCollapsedNodes() {
    222       foreach (SymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
     182      foreach (ISymbolicExpressionTreeNode treeNode in simplifiedExpressionTree.IterateNodesPostfix()) {
    223183        if (treeNode is ConstantTreeNode && replacementNodes.ContainsValue((ConstantTreeNode)treeNode))
    224184          this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange;
  • branches/DataAnalysis Refactoring/HeuristicLab/3.3/Files.txt

    r5693 r5699  
    6565HeuristicLab.Problems.DataAnalysis.Symbolic.Views\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.dll
    6666HeuristicLab.Problems.DataAnalysis.Symbolic.Classification\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.dll
     67HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.dll
    6768HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll
     69HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.dll
    6870HeuristicLab.Problems.DataAnalysis.Views\3.3:HeuristicLab.Problems.DataAnalysis.Views-3.3.dll
    6971HeuristicLab.Problems.DataAnalysis.Views\3.4:HeuristicLab.Problems.DataAnalysis.Views-3.4.dll
Note: See TracChangeset for help on using the changeset viewer.