Changeset 18067
- Timestamp:
- 10/14/21 17:59:53 (3 years ago)
- Location:
- branches/3136_Structural_GP
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs
r18066 r18067 82 82 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(GrammarParameterName, grammar)); 83 83 84 structureTemplate.Template = "f(x)*f(y)+5";84 //structureTemplate.Template = "f(x)*f(y)+5"; 85 85 } 86 86 -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.Designer.cs
r18063 r18067 1 1 2 using System.Drawing; 3 2 4 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 3 5 partial class StructureTemplateView { … … 25 27 /// </summary> 26 28 private void InitializeComponent() { 29 this.components = new System.ComponentModel.Container(); 27 30 this.expressionInput = new System.Windows.Forms.TextBox(); 28 31 this.parseButton = new System.Windows.Forms.Button(); … … 30 33 this.symRegTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView(); 31 34 this.templateStructureGroupBox = new System.Windows.Forms.GroupBox(); 35 this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart(); 32 36 this.splitContainer = new System.Windows.Forms.SplitContainer(); 33 this. subFunctionListView = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.SubFunctionListView();37 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 34 38 this.templateStructureGroupBox.SuspendLayout(); 35 39 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); … … 71 75 // 72 76 this.symRegTreeChart.AllowDrop = true; 73 this.symRegTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 74 | System.Windows.Forms.AnchorStyles.Left) 77 this.symRegTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 75 78 | System.Windows.Forms.AnchorStyles.Right))); 76 79 this.symRegTreeChart.Caption = "Graphical SymbolicExpressionTree View"; … … 79 82 this.symRegTreeChart.Name = "symRegTreeChart"; 80 83 this.symRegTreeChart.ReadOnly = false; 81 this.symRegTreeChart.Size = new System.Drawing.Size(288, 320);84 this.symRegTreeChart.Size = new System.Drawing.Size(288, 153); 82 85 this.symRegTreeChart.TabIndex = 6; 83 86 // 84 87 // templateStructureGroupBox 85 88 // 89 this.templateStructureGroupBox.Controls.Add(this.treeChart); 86 90 this.templateStructureGroupBox.Controls.Add(this.symRegTreeChart); 87 91 this.templateStructureGroupBox.Controls.Add(this.parseButton); … … 95 99 this.templateStructureGroupBox.TabStop = false; 96 100 this.templateStructureGroupBox.Text = "Template Structure"; 101 // 102 // treeChart 103 // 104 this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 105 | System.Windows.Forms.AnchorStyles.Right))); 106 this.treeChart.BackgroundColor = System.Drawing.Color.White; 107 this.treeChart.LineColor = System.Drawing.Color.Black; 108 this.treeChart.Location = new System.Drawing.Point(6, 233); 109 this.treeChart.MinimumHorizontalDistance = 30; 110 this.treeChart.MinimumHorizontalPadding = 20; 111 this.treeChart.MinimumVerticalDistance = 30; 112 this.treeChart.MinimumVerticalPadding = 20; 113 this.treeChart.Name = "treeChart"; 114 this.treeChart.PreferredNodeHeight = 46; 115 this.treeChart.PreferredNodeWidth = 70; 116 this.treeChart.Size = new System.Drawing.Size(288, 150); 117 this.treeChart.SuspendRepaint = false; 118 this.treeChart.TabIndex = 7; 119 this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F); 120 this.treeChart.Tree = null; 97 121 // 98 122 // splitContainer … … 110 134 // splitContainer.Panel2 111 135 // 112 this.splitContainer.Panel2.Controls.Add(this. subFunctionListView);136 this.splitContainer.Panel2.Controls.Add(this.viewHost); 113 137 this.splitContainer.Panel2MinSize = 5; 114 138 this.splitContainer.Size = new System.Drawing.Size(600, 400); … … 116 140 this.splitContainer.TabIndex = 10; 117 141 // 118 // subFunctionListView142 // viewHost 119 143 // 120 this.subFunctionListView.Caption = "View"; 121 this.subFunctionListView.Content = null; 122 this.subFunctionListView.Dock = System.Windows.Forms.DockStyle.Fill; 123 this.subFunctionListView.Location = new System.Drawing.Point(0, 0); 124 this.subFunctionListView.Name = "subFunctionListView"; 125 this.subFunctionListView.ReadOnly = false; 126 this.subFunctionListView.Size = new System.Drawing.Size(296, 400); 127 this.subFunctionListView.TabIndex = 7; 144 this.viewHost.Caption = "View"; 145 this.viewHost.Content = null; 146 this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill; 147 this.viewHost.Enabled = false; 148 this.viewHost.Location = new System.Drawing.Point(0, 0); 149 this.viewHost.Name = "viewHost"; 150 this.viewHost.ReadOnly = false; 151 this.viewHost.Size = new System.Drawing.Size(296, 400); 152 this.viewHost.TabIndex = 8; 153 this.viewHost.ViewsLabelVisible = true; 154 this.viewHost.ViewType = null; 128 155 // 129 156 // StructureTemplateView … … 149 176 private System.Windows.Forms.Label errorLabel; 150 177 private Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView symRegTreeChart; 151 private SubFunctionListView subFunctionListView;152 178 private System.Windows.Forms.GroupBox templateStructureGroupBox; 153 179 private System.Windows.Forms.SplitContainer splitContainer; 180 private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart; 181 private MainForm.WindowsForms.ViewHost viewHost; 154 182 } 155 183 } -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs
r18065 r18067 8 8 using HeuristicLab.Data; 9 9 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 10 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 10 11 using HeuristicLab.MainForm; 11 12 using HeuristicLab.MainForm.WindowsForms; … … 24 25 InitializeComponent(); 25 26 errorLabel.Text = ""; 27 treeChart.SymbolicExpressionTreeNodeClicked += TreeChart_SymbolicExpressionTreeNodeClicked; 28 } 29 30 private void TreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 31 var visualTreeNode = sender as VisualTreeNode<ISymbolicExpressionTreeNode>; 32 if(visualTreeNode != null) { 33 var subFunctionTreeNode = visualTreeNode.Content as SubFunctionTreeNode; 34 viewHost.Content = subFunctionTreeNode?.SubFunction; 35 } 26 36 } 27 37 … … 32 42 expressionInput.Text = Content.Template; 33 43 symRegTreeChart.Content = Content.Tree; 34 subFunctionListView.Content = new ItemList<SubFunction>(Content.SubFunctions.Values).AsReadOnly(); 35 44 45 treeChart.Tree = Content.Tree; 46 36 47 errorLabel.Text = ""; 37 48 … … 43 54 Content.Template = expressionInput.Text; 44 55 symRegTreeChart.Content = Content.Tree; 45 46 var subFunctionList = new ItemList<SubFunction>(); 47 foreach (var func in Content.SubFunctions.Values) 48 subFunctionList.Add(func); 49 subFunctionListView.Content = subFunctionList.AsReadOnly(); 56 treeChart.Tree = Content.Tree; 50 57 51 58 errorLabel.Text = "Template structure successfully parsed."; -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs
r18065 r18067 81 81 internal static readonly BidirectionalLookup<string, ISymbol> 82 82 knownSymbols = new BidirectionalLookup<string, ISymbol>(StringComparer.InvariantCulture, new SymbolComparer()); 83 internal static readonly SubFunctionSymbol subFunctionSymbol = new SubFunctionSymbol(); 83 84 84 85 private Constant constant = new Constant(); … … 137 138 { "XOR", new Xor()}, 138 139 { "DIFF", new Derivative()}, 139 { "LAG", new LaggedVariable() } ,140 { "F", new SubFunctionSymbol() } 140 { "LAG", new LaggedVariable() }/*, 141 { "F", new SubFunctionSymbol() }*/ 141 142 }; 142 143 … … 341 342 342 343 private ISymbol GetSymbol(string tok) { 343 var symb = knownSymbols.GetByFirst(tok).FirstOrDefault(); 344 if (symb == null) throw new ArgumentException(string.Format("Unknown token {0} found.", tok)); 345 return symb; 344 if(knownSymbols.ContainsFirst(tok)) 345 return knownSymbols.GetByFirst(tok).FirstOrDefault(); 346 else 347 return subFunctionSymbol; 346 348 } 347 349 … … 453 455 laggedVarNode.Lag = (int)Math.Round(sign * lagToken.doubleVal); 454 456 laggedVarNode.Weight = 1.0; 455 } else if (funcNode.Symbol is SubFunctionSymbol) { 457 } else if (funcNode.Symbol is SubFunctionSymbol) { // SubFunction 456 458 var subFunction = funcNode as SubFunctionTreeNode; 459 subFunction.Name = next.strVal; 457 460 // input arguments 458 461 var args = ParseArgList(tokens); 459 IList<string> functionArguments = new List<string>();462 IList<string> arguments = new List<string>(); 460 463 foreach (var arg in args) 461 464 if(arg is VariableTreeNode varTreeNode) 462 functionArguments.Add(varTreeNode.VariableName);463 subFunction. FunctionArguments = functionArguments;465 arguments.Add(varTreeNode.VariableName); 466 subFunction.Arguments = arguments; 464 467 } else { 465 468 // functions -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs
r18066 r18067 62 62 if (node is SubFunctionTreeNode subFunctionTreeNode) { 63 63 var subFunction = new SubFunction() { 64 Name = $"f{count++}({string.Join(",", subFunctionTreeNode. FunctionArguments)})",65 FunctionArguments = subFunctionTreeNode. FunctionArguments64 Name = $"f{count++}({string.Join(",", subFunctionTreeNode.Arguments)})", 65 FunctionArguments = subFunctionTreeNode.Arguments 66 66 }; 67 67 subFunctionTreeNode.SubFunction = subFunction; -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs
r18065 r18067 44 44 } 45 45 46 public IEnumerable<string> FunctionArguments { 46 public IEnumerable<string> FunctionArguments { // TODO: gehört weg 47 47 get => FunctionArgumentsParameter.Value.Select(x => x.Value); 48 48 set { -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/SubFunctionTreeNode.cs
r18066 r18067 10 10 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 11 11 [StorableType("05130B5F-0125-4367-A4E9-C42D1085024E")] 12 public class SubFunctionTreeNode : SymbolicExpressionTreeNode { 12 public class SubFunctionTreeNode : SymbolicExpressionTreeNode { //TODO: as TerminalNode? -> but has children in a fully builded tree 13 13 14 14 #region Properties 15 15 public new SubFunctionSymbol Symbol => (SubFunctionSymbol)base.Symbol; 16 16 17 public IEnumerable<string> FunctionArguments { get; set; } = Enumerable.Empty<string>();17 public IEnumerable<string> Arguments { get; set; } = Enumerable.Empty<string>(); 18 18 19 19 public SubFunction SubFunction { get; set; } 20 21 public string Name { get; set; } 20 22 #endregion 21 23 … … 34 36 public override IDeepCloneable Clone(Cloner cloner) => new SubFunctionTreeNode(this, cloner); 35 37 #endregion 38 39 public override string ToString() { 40 if (string.IsNullOrEmpty(Name)) 41 return base.ToString(); 42 return Name; 43 } 44 36 45 } 37 46 }
Note: See TracChangeset
for help on using the changeset viewer.