- Timestamp:
- 12/15/21 11:50:57 (3 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol (added) merged: 18091,18093,18100,18112-18121,18123-18131
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
/branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views (added) merged: 18100,18114-18115,18125
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r18052 r18132 129 129 </Compile> 130 130 <Compile Include="Plugin.cs" /> 131 <Compile Include="Symbols\ConstantView.cs"> 132 <SubType>UserControl</SubType> 133 </Compile> 134 <Compile Include="Symbols\ConstantView.Designer.cs"> 135 <DependentUpon>ConstantView.cs</DependentUpon> 136 </Compile> 137 <Compile Include="Symbols\NumberView.cs"> 138 <SubType>UserControl</SubType> 139 </Compile> 140 <Compile Include="Symbols\NumberView.Designer.cs"> 141 <DependentUpon>NumberView.cs</DependentUpon> 142 </Compile> 131 143 <Compile Include="TextualSymbolicDataAnalysisModelView.cs"> 132 144 <SubType>UserControl</SubType> … … 146 158 <Compile Include="GraphicalSymbolicDataAnalysisModelView.designer.cs"> 147 159 <DependentUpon>GraphicalSymbolicDataAnalysisModelView.cs</DependentUpon> 148 </Compile>149 <Compile Include="Symbols\ConstantView.cs">150 <SubType>UserControl</SubType>151 </Compile>152 <Compile Include="Symbols\ConstantView.Designer.cs">153 <DependentUpon>ConstantView.cs</DependentUpon>154 160 </Compile> 155 161 <Compile Include="Symbols\LaggedVariableView.cs"> -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs
r17430 r18132 54 54 this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); 55 55 this.btnSimplify = new System.Windows.Forms.Button(); 56 this.btnOptimize Constants = new System.Windows.Forms.Button();56 this.btnOptimizeParameters = new System.Windows.Forms.Button(); 57 57 this.grpViewHost = new System.Windows.Forms.GroupBox(); 58 58 this.treeChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart(); … … 132 132 | System.Windows.Forms.AnchorStyles.Right))); 133 133 this.flowLayoutPanel.Controls.Add(this.btnSimplify); 134 this.flowLayoutPanel.Controls.Add(this.btnOptimize Constants);134 this.flowLayoutPanel.Controls.Add(this.btnOptimizeParameters); 135 135 this.flowLayoutPanel.Location = new System.Drawing.Point(6, 370); 136 136 this.flowLayoutPanel.Name = "flowLayoutPanel"; … … 153 153 this.btnSimplify.Click += new System.EventHandler(this.btnSimplify_Click); 154 154 // 155 // btnOptimize Constants156 // 157 this.btnOptimize Constants.AutoSize = true;158 this.btnOptimize Constants.Enabled = false;159 this.btnOptimize Constants.Image = HeuristicLab.Common.Resources.VSImageLibrary.Performance;160 this.btnOptimize Constants.Location = new System.Drawing.Point(89, 3);161 this.btnOptimize Constants.Name = "btnOptimizeConstants";162 this.btnOptimize Constants.Size = new System.Drawing.Size(80, 24);163 this.btnOptimize Constants.TabIndex = 2;164 this.btnOptimize Constants.Text = "Optimize";165 this.btnOptimize Constants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;166 this.toolTip.SetToolTip(this.btnOptimize Constants, "Optimizes the numerical constants of the model. \r\nIf the algorithm converges, opt" +155 // btnOptimizeParameters 156 // 157 this.btnOptimizeParameters.AutoSize = true; 158 this.btnOptimizeParameters.Enabled = false; 159 this.btnOptimizeParameters.Image = HeuristicLab.Common.Resources.VSImageLibrary.Performance; 160 this.btnOptimizeParameters.Location = new System.Drawing.Point(89, 3); 161 this.btnOptimizeParameters.Name = "btnOptimizeParameters"; 162 this.btnOptimizeParameters.Size = new System.Drawing.Size(80, 24); 163 this.btnOptimizeParameters.TabIndex = 2; 164 this.btnOptimizeParameters.Text = "Optimize"; 165 this.btnOptimizeParameters.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; 166 this.toolTip.SetToolTip(this.btnOptimizeParameters, "Optimizes the parameters of the model. \r\nIf the algorithm converges, opt" + 167 167 "imization is stopped."); 168 this.btnOptimize Constants.UseVisualStyleBackColor = true;169 this.btnOptimize Constants.Click += new System.EventHandler(this.btnOptimizeConstants_Click);168 this.btnOptimizeParameters.UseVisualStyleBackColor = true; 169 this.btnOptimizeParameters.Click += new System.EventHandler(this.btnOptimizeParameters_Click); 170 170 // 171 171 // grpViewHost … … 228 228 private System.Windows.Forms.Button btnSimplify; 229 229 private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel; 230 protected System.Windows.Forms.Button btnOptimize Constants;230 protected System.Windows.Forms.Button btnOptimizeParameters; 231 231 private System.Windows.Forms.Label treeStatusValue; 232 232 private System.Windows.Forms.ToolTip toolTip; -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r17579 r18132 109 109 110 110 // the optimizer always assumes 2 children for multiplication and addition nodes 111 // thus, we enforce that the tree stays valid so that the constantoptimization won't throw an exception111 // thus, we enforce that the tree stays valid so that the parameter optimization won't throw an exception 112 112 // by returning 2 as the minimum allowed arity for addition and multiplication symbols 113 113 private readonly Func<ISymbol, int> GetMinArity = symbol => { … … 130 130 131 131 if (valid) { 132 btnOptimize Constants.Enabled = true;132 btnOptimizeParameters.Enabled = true; 133 133 btnSimplify.Enabled = true; 134 134 treeStatusValue.Visible = false; 135 135 } else { 136 btnOptimize Constants.Enabled = false;136 btnOptimizeParameters.Enabled = false; 137 137 btnSimplify.Enabled = false; 138 138 treeStatusValue.Visible = true; … … 193 193 treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); 194 194 195 progress.Start("Calculate Impact and Replacement Values ...");195 progress.Start("Calculate impact and replacement values ..."); 196 196 cancellationTokenSource = new CancellationTokenSource(); 197 197 progress.CanBeStopped = true; … … 203 203 204 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] = Make ConstantTreeNode(pair.Value);205 foreach (var pair in replacementValues.Where(pair => !(pair.Key is INumericTreeNode))) { 206 foldedNodes[pair.Key] = MakeNumberTreeNode(pair.Value); 207 207 } 208 208 … … 235 235 foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 236 236 if (progress.ProgressState == ProgressState.StopRequested) continue; 237 double impactValue, replacementValue, newQualityForImpactsCalculation;238 impactCalculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, out impactValue, out replacementValue, out newQualityForImpactsCalculation);237 impactCalculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, 238 out double impactValue, out double replacementValue, out _); 239 239 double newProgressValue = progress.ProgressValue + 1.0 / (tree.Length - 2); 240 240 progress.ProgressValue = Math.Min(newProgressValue, 1); … … 246 246 protected abstract void UpdateModel(ISymbolicExpressionTree tree); 247 247 248 protected virtual ISymbolicExpressionTree Optimize Constants(ISymbolicExpressionTree tree, IProgress progress) {248 protected virtual ISymbolicExpressionTree OptimizeParameters(ISymbolicExpressionTree tree, IProgress progress) { 249 249 return tree; 250 250 } 251 251 252 private static ConstantTreeNode MakeConstantTreeNode(double value) {253 var constant = new Constant{ MinValue = value - 1, MaxValue = value + 1 };254 var constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();255 constantTreeNode.Value = value;256 return constantTreeNode;252 private static NumberTreeNode MakeNumberTreeNode(double value) { 253 var num = new Number { MinValue = value - 1, MaxValue = value + 1 }; 254 var numTreeNode = (NumberTreeNode)num.CreateTreeNode(); 255 numTreeNode.Value = value; 256 return numTreeNode; 257 257 } 258 258 … … 297 297 VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode); 298 298 299 if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {299 if (!(treeNode is INumericTreeNode) && nodeImpacts.ContainsKey(treeNode)) { 300 300 visualTree.ToolTip = visualTree.Content.ToString(); 301 301 double impact = nodeImpacts[treeNode]; … … 314 314 } 315 315 visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact; 316 var constantReplacementNode = foldedNodes[treeNode] as ConstantTreeNode; 317 if (constantReplacementNode != null) { 318 visualTree.ToolTip += Environment.NewLine + "Replacement value: " + constantReplacementNode.Value; 316 if (foldedNodes[treeNode] is INumericTreeNode numReplacementNode) { 317 visualTree.ToolTip += Environment.NewLine + "Replacement value: " + numReplacementNode.Value; 319 318 } 320 319 } 321 320 if (visualTree != null) { 322 321 if (nodeIntervals.ContainsKey(treeNode)) 323 visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{nodeIntervals[treeNode].LowerBound:G5} ... {nodeIntervals[treeNode].UpperBound:G5}]");322 visualTree.ToolTip += string.Format($"{Environment.NewLine}Intervals: [{nodeIntervals[treeNode].LowerBound:G5} ... {nodeIntervals[treeNode].UpperBound:G5}]"); 324 323 if (changedNodes.ContainsKey(treeNode)) { 325 324 visualTree.LineColor = Color.DodgerBlue; 326 } else if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {325 } else if (treeNode is INumericTreeNode && foldedNodes.ContainsKey(treeNode)) { 327 326 visualTree.LineColor = Color.DarkOrange; 328 327 } … … 337 336 } 338 337 339 private async void btnOptimize Constants_Click(object sender, EventArgs e) {340 progress.Start("Optimizing Constants ...");338 private async void btnOptimizeParameters_Click(object sender, EventArgs e) { 339 progress.Start("Optimizing parameters ..."); 341 340 cancellationTokenSource = new CancellationTokenSource(); 342 341 progress.CanBeStopped = true; … … 344 343 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 345 344 346 var newTree = await Task.Run(() => Optimize Constants(tree, progress));345 var newTree = await Task.Run(() => OptimizeParameters(tree, progress)); 347 346 try { 348 347 await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs
r17180 r18132 64 64 this.insertNodeToolStripMenuItem.Name = "insertNodeToolStripMenuItem"; 65 65 this.insertNodeToolStripMenuItem.Size = new System.Drawing.Size(165, 22); 66 this.insertNodeToolStripMenuItem.Text = "Insert Node";66 this.insertNodeToolStripMenuItem.Text = "Insert node"; 67 67 this.insertNodeToolStripMenuItem.Click += new System.EventHandler(this.insertNodeToolStripMenuItem_Click); 68 68 // … … 71 71 this.changeNodeToolStripMenuItem.Name = "changeNodeToolStripMenuItem"; 72 72 this.changeNodeToolStripMenuItem.Size = new System.Drawing.Size(165, 22); 73 this.changeNodeToolStripMenuItem.Text = "Change Node";73 this.changeNodeToolStripMenuItem.Text = "Change node"; 74 74 this.changeNodeToolStripMenuItem.Click += new System.EventHandler(this.changeNodeToolStripMenuItem_Click); 75 75 // … … 78 78 this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; 79 79 this.cutToolStripMenuItem.Size = new System.Drawing.Size(165, 22); 80 this.cutToolStripMenuItem.Text = "Cut Subtree";80 this.cutToolStripMenuItem.Text = "Cut subtree"; 81 81 this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); 82 82 // … … 109 109 this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; 110 110 this.pasteToolStripMenuItem.Size = new System.Drawing.Size(165, 22); 111 this.pasteToolStripMenuItem.Text = "Paste Subtree";111 this.pasteToolStripMenuItem.Text = "Paste subtree"; 112 112 this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Clicked); 113 113 // … … 121 121 this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; 122 122 this.copyToolStripMenuItem.Size = new System.Drawing.Size(165, 22); 123 this.copyToolStripMenuItem.Text = "Copy Subtree";123 this.copyToolStripMenuItem.Text = "Copy subtree"; 124 124 this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); 125 125 // -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
r17180 r18132 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 30 internal delegate void 31 ModifyTree(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode node, ISymbolicExpressionTreeNode oldChild, ISymbolicExpressionTreeNode newChild,bool removeSubtree = true);30 internal delegate void ModifyTree(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode node, ISymbolicExpressionTreeNode oldChild, ISymbolicExpressionTreeNode newChild, 31 bool removeSubtree = true); 32 32 33 33 internal sealed partial class InteractiveSymbolicExpressionTreeChart : SymbolicExpressionTreeChart { … … 82 82 83 83 protected override void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 84 currSelected = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender; ;84 currSelected = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender; 85 85 base.OnSymbolicExpressionTreeNodeClicked(sender, e); 86 86 } … … 104 104 var symbol = dialog.SelectedSymbol; 105 105 var node = symbol.CreateTreeNode(); 106 if (node is ConstantTreeNode) { 107 var constant = node as ConstantTreeNode; 108 constant.Value = double.Parse(dialog.constantValueTextBox.Text); 106 if (node is INumericTreeNode numTreeNode) { 107 numTreeNode.Value = double.Parse(dialog.numberValueTextBox.Text); 109 108 } else if (node is VariableTreeNode) { 110 109 var variable = node as VariableTreeNode; … … 133 132 ISymbolicExpressionTreeNode newNode = null; 134 133 var result = DialogResult.Cancel; 135 if (node is ConstantTreeNode) {136 using (var dialog = new ConstantNodeEditDialog(node)) {134 if (node is INumericTreeNode) { 135 using (var dialog = new NumberNodeEditDialog(node)) { 137 136 dialog.ShowDialog(this); 138 137 newNode = dialog.NewNode; … … 200 199 // check if the copied/cut node (stored in the tempNode) can be inserted as a child of the current selected node 201 200 var node = currSelected.Content; 202 if (node is ConstantTreeNode || node is VariableTreeNode) return;201 if (node is INumericTreeNode || node is VariableTreeNode) return; 203 202 // check if the currently selected node can accept the copied node as a child 204 203 // no need to check the grammar, an arity check will do just fine here -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/ConstantView.Designer.cs
r17180 r18132 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.weightNuLabel = new System.Windows.Forms.Label(); 48 this.minValueTextBox = new System.Windows.Forms.TextBox(); 49 this.initializationGroupBox = new System.Windows.Forms.GroupBox(); 50 this.weightSigmaLabel = new System.Windows.Forms.Label(); 51 this.maxValueTextBox = new System.Windows.Forms.TextBox(); 52 this.mutationGroupBox = new System.Windows.Forms.GroupBox(); 53 this.multiplicativeChangeLabel = new System.Windows.Forms.Label(); 54 this.multiplicativeChangeSigmaTextBox = new System.Windows.Forms.TextBox(); 55 this.additiveChangeLabel = new System.Windows.Forms.Label(); 56 this.additiveChangeSigmaTextBox = new System.Windows.Forms.TextBox(); 47 this.valueLabel = new System.Windows.Forms.Label(); 48 this.valueTextBox = new System.Windows.Forms.TextBox(); 57 49 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 58 this.initializationGroupBox.SuspendLayout();59 this.mutationGroupBox.SuspendLayout();60 50 this.SuspendLayout(); 61 51 // … … 68 58 this.errorProvider.SetIconAlignment(this.initialFrequencyTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 69 59 this.initialFrequencyTextBox.Size = new System.Drawing.Size(280, 20); 60 // 61 // minimumArityLabel 62 // 63 this.toolTip.SetToolTip(this.minimumArityLabel, "The minimum arity of the symbol"); 64 // 65 // maximumArityLabel 66 // 67 this.toolTip.SetToolTip(this.maximumArityLabel, "The maximum arity of the symbol"); 70 68 // 71 69 // minimumArityTextBox … … 89 87 this.infoLabel.Location = new System.Drawing.Point(379, 3); 90 88 // 91 // weightNuLabel89 // valueLabel 92 90 // 93 this. weightNuLabel.AutoSize = true;94 this. weightNuLabel.Location = new System.Drawing.Point(6, 22);95 this. weightNuLabel.Name = "weightNuLabel";96 this. weightNuLabel.Size = new System.Drawing.Size(56, 13);97 this. weightNuLabel.TabIndex = 0;98 this. weightNuLabel.Text = "Min value:";99 this.toolTip.SetToolTip(this. weightNuLabel, "The minimal value to use for random initialization of constants.");91 this.valueLabel.AutoSize = true; 92 this.valueLabel.Location = new System.Drawing.Point(3, 130); 93 this.valueLabel.Name = "valueLabel"; 94 this.valueLabel.Size = new System.Drawing.Size(37, 13); 95 this.valueLabel.TabIndex = 0; 96 this.valueLabel.Text = "Value:"; 97 this.toolTip.SetToolTip(this.valueLabel, "The value of the constant."); 100 98 // 101 // minValueTextBox99 // valueTextBox 102 100 // 103 this. minValueTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)101 this.valueTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 104 102 | System.Windows.Forms.AnchorStyles.Right))); 105 this.errorProvider.SetIconAlignment(this.minValueTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 106 this.minValueTextBox.Location = new System.Drawing.Point(92, 19); 107 this.minValueTextBox.Name = "minValueTextBox"; 108 this.minValueTextBox.Size = new System.Drawing.Size(300, 20); 109 this.minValueTextBox.TabIndex = 1; 110 this.toolTip.SetToolTip(this.minValueTextBox, "The minimal value to use for random initialization of constants."); 111 this.minValueTextBox.TextChanged += new System.EventHandler(this.minValueTextBox_TextChanged); 112 // 113 // initializationGroupBox 114 // 115 this.initializationGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 116 | System.Windows.Forms.AnchorStyles.Right))); 117 this.initializationGroupBox.Controls.Add(this.weightSigmaLabel); 118 this.initializationGroupBox.Controls.Add(this.maxValueTextBox); 119 this.initializationGroupBox.Controls.Add(this.weightNuLabel); 120 this.initializationGroupBox.Controls.Add(this.minValueTextBox); 121 this.initializationGroupBox.Location = new System.Drawing.Point(0, 127); 122 this.initializationGroupBox.Name = "initializationGroupBox"; 123 this.initializationGroupBox.Size = new System.Drawing.Size(398, 73); 124 this.initializationGroupBox.TabIndex = 5; 125 this.initializationGroupBox.TabStop = false; 126 this.initializationGroupBox.Text = "Initialization"; 127 // 128 // weightSigmaLabel 129 // 130 this.weightSigmaLabel.AutoSize = true; 131 this.weightSigmaLabel.Location = new System.Drawing.Point(6, 48); 132 this.weightSigmaLabel.Name = "weightSigmaLabel"; 133 this.weightSigmaLabel.Size = new System.Drawing.Size(59, 13); 134 this.weightSigmaLabel.TabIndex = 2; 135 this.weightSigmaLabel.Text = "Max value:"; 136 this.toolTip.SetToolTip(this.weightSigmaLabel, "The maximal value to use for random initialization of constants."); 137 // 138 // maxValueTextBox 139 // 140 this.maxValueTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 141 | System.Windows.Forms.AnchorStyles.Right))); 142 this.errorProvider.SetIconAlignment(this.maxValueTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 143 this.maxValueTextBox.Location = new System.Drawing.Point(92, 45); 144 this.maxValueTextBox.Name = "maxValueTextBox"; 145 this.maxValueTextBox.Size = new System.Drawing.Size(300, 20); 146 this.maxValueTextBox.TabIndex = 3; 147 this.toolTip.SetToolTip(this.maxValueTextBox, "The maximal value to use for random initialization of constants."); 148 this.maxValueTextBox.TextChanged += new System.EventHandler(this.maxValueTextBox_TextChanged); 149 // 150 // mutationGroupBox 151 // 152 this.mutationGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 153 | System.Windows.Forms.AnchorStyles.Right))); 154 this.mutationGroupBox.Controls.Add(this.multiplicativeChangeLabel); 155 this.mutationGroupBox.Controls.Add(this.multiplicativeChangeSigmaTextBox); 156 this.mutationGroupBox.Controls.Add(this.additiveChangeLabel); 157 this.mutationGroupBox.Controls.Add(this.additiveChangeSigmaTextBox); 158 this.mutationGroupBox.Location = new System.Drawing.Point(0, 206); 159 this.mutationGroupBox.Name = "mutationGroupBox"; 160 this.mutationGroupBox.Size = new System.Drawing.Size(398, 73); 161 this.mutationGroupBox.TabIndex = 6; 162 this.mutationGroupBox.TabStop = false; 163 this.mutationGroupBox.Text = "Mutation"; 164 // 165 // multiplicativeChangeLabel 166 // 167 this.multiplicativeChangeLabel.AutoSize = true; 168 this.multiplicativeChangeLabel.Location = new System.Drawing.Point(6, 48); 169 this.multiplicativeChangeLabel.Name = "multiplicativeChangeLabel"; 170 this.multiplicativeChangeLabel.Size = new System.Drawing.Size(146, 13); 171 this.multiplicativeChangeLabel.TabIndex = 2; 172 this.multiplicativeChangeLabel.Text = "Multiplicative change (sigma):"; 173 this.toolTip.SetToolTip(this.multiplicativeChangeLabel, "The sigma (std. dev.) parameter for the normal distribution to use to sample the " + 174 "multiplicative change."); 175 // 176 // multiplicativeChangeSigmaTextBox 177 // 178 this.multiplicativeChangeSigmaTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 179 | System.Windows.Forms.AnchorStyles.Right))); 180 this.errorProvider.SetIconAlignment(this.multiplicativeChangeSigmaTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 181 this.multiplicativeChangeSigmaTextBox.Location = new System.Drawing.Point(168, 45); 182 this.multiplicativeChangeSigmaTextBox.Name = "multiplicativeChangeSigmaTextBox"; 183 this.multiplicativeChangeSigmaTextBox.Size = new System.Drawing.Size(224, 20); 184 this.multiplicativeChangeSigmaTextBox.TabIndex = 3; 185 this.toolTip.SetToolTip(this.multiplicativeChangeSigmaTextBox, "The sigma (std. dev.) parameter for the normal distribution to use to sample a mu" + 186 "ltiplicative change."); 187 this.multiplicativeChangeSigmaTextBox.TextChanged += new System.EventHandler(this.multiplicativeChangeSigmaTextBox_TextChanged); 188 // 189 // additiveChangeLabel 190 // 191 this.additiveChangeLabel.AutoSize = true; 192 this.additiveChangeLabel.Location = new System.Drawing.Point(6, 22); 193 this.additiveChangeLabel.Name = "additiveChangeLabel"; 194 this.additiveChangeLabel.Size = new System.Drawing.Size(123, 13); 195 this.additiveChangeLabel.TabIndex = 0; 196 this.additiveChangeLabel.Text = "Additive change (sigma):"; 197 this.toolTip.SetToolTip(this.additiveChangeLabel, "The sigma (std. dev.) parameter for the normal distribution to sample the additiv" + 198 "e change."); 199 // 200 // additiveChangeSigmaTextBox 201 // 202 this.additiveChangeSigmaTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 203 | System.Windows.Forms.AnchorStyles.Right))); 204 this.errorProvider.SetIconAlignment(this.additiveChangeSigmaTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 205 this.additiveChangeSigmaTextBox.Location = new System.Drawing.Point(168, 19); 206 this.additiveChangeSigmaTextBox.Name = "additiveChangeSigmaTextBox"; 207 this.additiveChangeSigmaTextBox.Size = new System.Drawing.Size(224, 20); 208 this.additiveChangeSigmaTextBox.TabIndex = 1; 209 this.toolTip.SetToolTip(this.additiveChangeSigmaTextBox, "The sigma (std. dev.) parameter for the normal distribution to use to sample an a" + 210 "dditive change."); 211 this.additiveChangeSigmaTextBox.TextChanged += new System.EventHandler(this.additiveChangeSigmaTextBox_TextChanged); 103 this.errorProvider.SetIconAlignment(this.valueTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 104 this.valueTextBox.Location = new System.Drawing.Point(93, 127); 105 this.valueTextBox.Name = "valueTextBox"; 106 this.valueTextBox.Size = new System.Drawing.Size(280, 20); 107 this.valueTextBox.TabIndex = 1; 108 this.toolTip.SetToolTip(this.valueTextBox, "The value of the constant."); 109 this.valueTextBox.TextChanged += new System.EventHandler(this.valueTextBox_TextChanged); 212 110 // 213 111 // ConstantView 214 112 // 215 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);216 113 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 217 this.Controls.Add(this. mutationGroupBox);218 this.Controls.Add(this. initializationGroupBox);114 this.Controls.Add(this.valueLabel); 115 this.Controls.Add(this.valueTextBox); 219 116 this.Name = "ConstantView"; 220 this.Size = new System.Drawing.Size(398, 284); 117 this.Size = new System.Drawing.Size(398, 168); 118 this.Controls.SetChildIndex(this.valueTextBox, 0); 119 this.Controls.SetChildIndex(this.valueLabel, 0); 120 this.Controls.SetChildIndex(this.enabledCheckBox, 0); 121 this.Controls.SetChildIndex(this.initialFrequencyLabel, 0); 122 this.Controls.SetChildIndex(this.initialFrequencyTextBox, 0); 221 123 this.Controls.SetChildIndex(this.maximumArityLabel, 0); 222 124 this.Controls.SetChildIndex(this.maximumArityTextBox, 0); … … 224 126 this.Controls.SetChildIndex(this.minimumArityTextBox, 0); 225 127 this.Controls.SetChildIndex(this.infoLabel, 0); 226 this.Controls.SetChildIndex(this.initializationGroupBox, 0);227 this.Controls.SetChildIndex(this.initialFrequencyTextBox, 0);228 this.Controls.SetChildIndex(this.initialFrequencyLabel, 0);229 128 this.Controls.SetChildIndex(this.nameLabel, 0); 230 129 this.Controls.SetChildIndex(this.nameTextBox, 0); 231 this.Controls.SetChildIndex(this.mutationGroupBox, 0);232 130 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 233 this.initializationGroupBox.ResumeLayout(false);234 this.initializationGroupBox.PerformLayout();235 this.mutationGroupBox.ResumeLayout(false);236 this.mutationGroupBox.PerformLayout();237 131 this.ResumeLayout(false); 238 132 this.PerformLayout(); … … 242 136 #endregion 243 137 244 private System.Windows.Forms.Label weightNuLabel; 245 private System.Windows.Forms.TextBox minValueTextBox; 246 protected System.Windows.Forms.GroupBox initializationGroupBox; 247 private System.Windows.Forms.Label weightSigmaLabel; 248 private System.Windows.Forms.TextBox maxValueTextBox; 249 protected System.Windows.Forms.GroupBox mutationGroupBox; 250 private System.Windows.Forms.Label multiplicativeChangeLabel; 251 private System.Windows.Forms.TextBox multiplicativeChangeSigmaTextBox; 252 private System.Windows.Forms.Label additiveChangeLabel; 253 private System.Windows.Forms.TextBox additiveChangeSigmaTextBox; 254 138 private System.Windows.Forms.Label valueLabel; 139 private System.Windows.Forms.TextBox valueTextBox; 255 140 } 256 141 } -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/ConstantView.cs
r17180 r18132 43 43 Content.Changed += new EventHandler(Content_Changed); 44 44 } 45 45 46 46 protected override void DeregisterContentEvents() { 47 47 base.DeregisterContentEvents(); … … 56 56 protected override void SetEnabledStateOfControls() { 57 57 base.SetEnabledStateOfControls(); 58 minValueTextBox.Enabled = Content != null; 59 minValueTextBox.ReadOnly = ReadOnly; 60 maxValueTextBox.Enabled = Content != null; 61 maxValueTextBox.ReadOnly = ReadOnly; 62 additiveChangeSigmaTextBox.Enabled = Content != null; 63 additiveChangeSigmaTextBox.ReadOnly = ReadOnly; 64 multiplicativeChangeSigmaTextBox.Enabled = Content != null; 65 multiplicativeChangeSigmaTextBox.ReadOnly = ReadOnly; 58 valueTextBox.Enabled = Content != null; 59 valueTextBox.ReadOnly = ReadOnly; 66 60 } 67 61 … … 73 67 74 68 #region control event handlers 75 private void minValueTextBox_TextChanged(object sender, EventArgs e) {76 double min;77 if (double.TryParse( minValueTextBox.Text, out min)) {78 Content. MinValue = min;79 errorProvider.SetError( minValueTextBox, string.Empty);69 private void valueTextBox_TextChanged(object sender, EventArgs e) { 70 double val; 71 if (double.TryParse(valueTextBox.Text, out val)) { 72 Content.Value = val; 73 errorProvider.SetError(valueTextBox, string.Empty); 80 74 } else { 81 errorProvider.SetError(minValueTextBox, "Invalid value"); 82 } 83 } 84 private void maxValueTextBox_TextChanged(object sender, EventArgs e) { 85 double max; 86 if (double.TryParse(maxValueTextBox.Text, out max)) { 87 Content.MaxValue = max; 88 errorProvider.SetError(maxValueTextBox, string.Empty); 89 } else { 90 errorProvider.SetError(maxValueTextBox, "Invalid value"); 91 } 92 } 93 94 private void additiveChangeSigmaTextBox_TextChanged(object sender, EventArgs e) { 95 double sigma; 96 if (double.TryParse(additiveChangeSigmaTextBox.Text, out sigma) && sigma >= 0.0) { 97 Content.ManipulatorSigma = sigma; 98 errorProvider.SetError(additiveChangeSigmaTextBox, string.Empty); 99 } else { 100 errorProvider.SetError(additiveChangeSigmaTextBox, "Invalid value"); 101 } 102 } 103 104 private void multiplicativeChangeSigmaTextBox_TextChanged(object sender, EventArgs e) { 105 double sigma; 106 if (double.TryParse(multiplicativeChangeSigmaTextBox.Text, out sigma) && sigma >= 0.0) { 107 Content.MultiplicativeManipulatorSigma = sigma; 108 errorProvider.SetError(multiplicativeChangeSigmaTextBox, string.Empty); 109 } else { 110 errorProvider.SetError(multiplicativeChangeSigmaTextBox, "Invalid value"); 75 errorProvider.SetError(valueTextBox, "Invalid value"); 111 76 } 112 77 } … … 116 81 private void UpdateControl() { 117 82 if (Content == null) { 118 minValueTextBox.Text = string.Empty; 119 maxValueTextBox.Text = string.Empty; 120 minValueTextBox.Text = string.Empty; 121 multiplicativeChangeSigmaTextBox.Text = string.Empty; 122 additiveChangeSigmaTextBox.Text = string.Empty; 83 valueTextBox.Text = string.Empty; 123 84 } else { 124 minValueTextBox.Text = Content.MinValue.ToString(); 125 maxValueTextBox.Text = Content.MaxValue.ToString(); 126 additiveChangeSigmaTextBox.Text = Content.ManipulatorSigma.ToString(); 127 multiplicativeChangeSigmaTextBox.Text = Content.MultiplicativeManipulatorSigma.ToString(); 85 valueTextBox.Text = Content.Value.ToString("g17"); 128 86 } 129 87 SetEnabledStateOfControls(); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.Designer.cs
r17180 r18132 21 21 22 22 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 23 partial class ConstantNodeEditDialog {23 partial class NumberNodeEditDialog { 24 24 /// <summary> 25 25 /// Required designer variable. … … 121 121 this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); 122 122 // 123 // ConstantNodeEditDialog123 // NumberNodeEditDialog 124 124 // 125 125 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); … … 138 138 this.MaximizeBox = false; 139 139 this.MinimizeBox = false; 140 this.Name = " ConstantNodeEditDialog";140 this.Name = "NumberNodeEditDialog"; 141 141 this.ShowIcon = false; 142 142 this.ShowInTaskbar = false; 143 143 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 144 this.Text = "Edit constantvalue";145 this.KeyDown += new System.Windows.Forms.KeyEventHandler(this. ConstantNodeEditDialog_KeyDown);144 this.Text = "Edit number value"; 145 this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.NumberNodeEditDialog_KeyDown); 146 146 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 147 147 this.ResumeLayout(false); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs
r17180 r18132 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 30 public partial class ConstantNodeEditDialog : Form {31 private ConstantTreeNode constantTreeNode;32 public ConstantTreeNode NewNode {33 get { return constantTreeNode; }30 public partial class NumberNodeEditDialog : Form { 31 private INumericTreeNode numberTreeNode; 32 public INumericTreeNode NewNode { 33 get { return numberTreeNode; } 34 34 set { 35 35 if (InvokeRequired) 36 Invoke(new Action<SymbolicExpressionTreeNode>(x => constantTreeNode = (ConstantTreeNode)x), value);36 Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (INumericTreeNode)x), value); 37 37 else 38 constantTreeNode = value;38 numberTreeNode = value; 39 39 } 40 40 } 41 41 42 public ConstantNodeEditDialog(ISymbolicExpressionTreeNode node) {42 public NumberNodeEditDialog(ISymbolicExpressionTreeNode node) { 43 43 InitializeComponent(); 44 44 oldValueTextBox.TabStop = false; // cannot receive focus using tab key 45 NewNode = ( ConstantTreeNode)node;45 NewNode = (INumericTreeNode)node; 46 46 InitializeFields(); 47 47 } … … 49 49 private void InitializeFields() { 50 50 if (NewNode == null) 51 throw new ArgumentException("Node is not a constant.");51 throw new ArgumentException("Node is not a number."); 52 52 else { 53 this.Text = "Edit constant";54 newValueTextBox.Text = oldValueTextBox.Text = Math.Round( constantTreeNode.Value, 4).ToString();53 this.Text = "Edit number"; 54 newValueTextBox.Text = oldValueTextBox.Text = Math.Round(numberTreeNode.Value, 4).ToString(); 55 55 } 56 56 } … … 71 71 72 72 private static bool ValidateNewValue(string value, out string errorMessage) { 73 double val; 74 bool valid = double.TryParse(value, out val); 73 bool valid = double.TryParse(value, out _); 75 74 errorMessage = string.Empty; 76 75 if (!valid) { … … 87 86 // proxy handler passing key strokes to the parent control 88 87 private void childControl_KeyDown(object sender, KeyEventArgs e) { 89 ConstantNodeEditDialog_KeyDown(sender, e);88 NumberNodeEditDialog_KeyDown(sender, e); 90 89 } 91 90 92 private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {91 private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) { 93 92 if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) { 94 93 if (!ValidateChildren()) return; … … 100 99 public event EventHandler DialogValidated; 101 100 private void OnDialogValidated(object sender, EventArgs e) { 102 if ( constantTreeNode == null) return;101 if (numberTreeNode == null) return; 103 102 var value = double.Parse(newValueTextBox.Text); 104 103 // we impose an extra validation condition: that the new value is different from the original value 105 if ( constantTreeNode.Value.Equals(value)) return;104 if (numberTreeNode.Value.Equals(value)) return; 106 105 107 constantTreeNode.Value = value;106 numberTreeNode.Value = value; 108 107 DialogResult = DialogResult.OK; 109 108 var dialogValidated = DialogValidated; -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs
r17180 r18132 52 52 this.variableNamesCombo = new System.Windows.Forms.ComboBox(); 53 53 this.variableWeightTextBox = new System.Windows.Forms.TextBox(); 54 this. constantValueTextBox = new System.Windows.Forms.TextBox();55 this. constantValueLabel = new System.Windows.Forms.Label();54 this.numberValueTextBox = new System.Windows.Forms.TextBox(); 55 this.numberValueLabel = new System.Windows.Forms.Label(); 56 56 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 57 57 this.okButton = new System.Windows.Forms.Button(); … … 121 121 this.variableWeightTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.variableWeightTextBox_Validating); 122 122 // 123 // constantValueTextBox124 // 125 this. constantValueTextBox.Location = new System.Drawing.Point(101, 37);126 this. constantValueTextBox.Name = "constantValueTextBox";127 this. constantValueTextBox.Size = new System.Drawing.Size(127, 20);128 this. constantValueTextBox.TabIndex = 7;129 this. constantValueTextBox.Text = "0.0";130 this. constantValueTextBox.Visible = false;131 this. constantValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.constantValueTextBox_Validating);132 // 133 // constantValueLabel134 // 135 this. constantValueLabel.AutoSize = true;136 this. constantValueLabel.Location = new System.Drawing.Point(19, 40);137 this. constantValueLabel.Name = "constantValueLabel";138 this. constantValueLabel.Size = new System.Drawing.Size(34, 13);139 this. constantValueLabel.TabIndex = 8;140 this. constantValueLabel.Text = "Value";141 this. constantValueLabel.Visible = false;123 // numberValueTextBox 124 // 125 this.numberValueTextBox.Location = new System.Drawing.Point(101, 37); 126 this.numberValueTextBox.Name = "numberValueTextBox"; 127 this.numberValueTextBox.Size = new System.Drawing.Size(127, 20); 128 this.numberValueTextBox.TabIndex = 7; 129 this.numberValueTextBox.Text = "0.0"; 130 this.numberValueTextBox.Visible = false; 131 this.numberValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberValueTextBox_Validating); 132 // 133 // numberValueLabel 134 // 135 this.numberValueLabel.AutoSize = true; 136 this.numberValueLabel.Location = new System.Drawing.Point(19, 40); 137 this.numberValueLabel.Name = "numberValueLabel"; 138 this.numberValueLabel.Size = new System.Drawing.Size(34, 13); 139 this.numberValueLabel.TabIndex = 8; 140 this.numberValueLabel.Text = "Value"; 141 this.numberValueLabel.Visible = false; 142 142 // 143 143 // errorProvider … … 187 187 this.Controls.Add(this.cancelButton); 188 188 this.Controls.Add(this.okButton); 189 this.Controls.Add(this. constantValueLabel);190 this.Controls.Add(this. constantValueTextBox);189 this.Controls.Add(this.numberValueLabel); 190 this.Controls.Add(this.numberValueTextBox); 191 191 this.Controls.Add(this.variableWeightTextBox); 192 192 this.Controls.Add(this.variableNamesCombo); … … 211 211 private System.Windows.Forms.Label variableWeightLabel; 212 212 private System.Windows.Forms.Label variableNameLabel; 213 private System.Windows.Forms.Label constantValueLabel;213 private System.Windows.Forms.Label numberValueLabel; 214 214 private System.Windows.Forms.ErrorProvider errorProvider; 215 internal System.Windows.Forms.TextBox constantValueTextBox;215 internal System.Windows.Forms.TextBox numberValueTextBox; 216 216 internal System.Windows.Forms.TextBox variableWeightTextBox; 217 217 internal System.Windows.Forms.ComboBox variableNamesCombo; -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs
r17180 r18132 57 57 var combo = (ComboBox)sender; 58 58 var symbol = combo.Items[combo.SelectedIndex]; 59 if (symbol is Constant) {60 // add controls to the dialog for changing the constantvalue59 if (symbol is Number) { 60 // add controls to the dialog for changing the number value 61 61 variableNameLabel.Visible = false; 62 62 variableNamesCombo.Visible = false; 63 63 variableWeightLabel.Visible = false; 64 64 variableWeightTextBox.Visible = false; 65 constantValueLabel.Visible = true;66 constantValueTextBox.Visible = true;65 numberValueLabel.Visible = true; 66 numberValueTextBox.Visible = true; 67 67 } else if (symbol is VariableBase) { 68 68 var variableSymbol = (VariableBase)symbol; … … 80 80 variableWeightLabel.Visible = true; 81 81 variableWeightTextBox.Visible = true; 82 constantValueLabel.Visible = false;83 constantValueTextBox.Visible = false;82 numberValueLabel.Visible = false; 83 numberValueTextBox.Visible = false; 84 84 // add controls to the dialog for changing the variable name or weight 85 85 } else { … … 88 88 variableWeightLabel.Visible = false; 89 89 variableWeightTextBox.Visible = false; 90 constantValueLabel.Visible = false;91 constantValueTextBox.Visible = false;90 numberValueLabel.Visible = false; 91 numberValueTextBox.Visible = false; 92 92 } 93 93 } … … 102 102 } 103 103 104 private void constantValueTextBox_Validating(object sender, CancelEventArgs e) {104 private void numberValueTextBox_Validating(object sender, CancelEventArgs e) { 105 105 string errorMessage; 106 if (ValidateDoubleValue( constantValueTextBox.Text, out errorMessage)) return;106 if (ValidateDoubleValue(numberValueTextBox.Text, out errorMessage)) return; 107 107 e.Cancel = true; 108 errorProvider.SetError( constantValueTextBox, errorMessage);109 constantValueTextBox.SelectAll();108 errorProvider.SetError(numberValueTextBox, errorMessage); 109 numberValueTextBox.SelectAll(); 110 110 } 111 111 -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.cs
r17180 r18132 60 60 private void InitializeFields() { 61 61 if (NewNode == null) 62 throw new ArgumentException("Node is not a constant.");62 throw new ArgumentException("Node is not a variable node."); 63 63 else { 64 64 this.Text = "Edit variable";
Note: See TracChangeset
for help on using the changeset viewer.