Changeset 17928 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Timestamp:
- 04/06/21 13:13:32 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs
r17180 r17928 57 57 this.grpViewHost = new System.Windows.Forms.GroupBox(); 58 58 this.treeChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart(); 59 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 59 60 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 60 61 this.splitContainer.Panel1.SuspendLayout(); … … 148 149 this.btnSimplify.Text = "Simplify"; 149 150 this.btnSimplify.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; 151 this.toolTip.SetToolTip(this.btnSimplify, "Simplifies the model structure based on mathematical simplification rules."); 150 152 this.btnSimplify.UseVisualStyleBackColor = true; 151 153 this.btnSimplify.Click += new System.EventHandler(this.btnSimplify_Click); … … 162 164 this.btnOptimizeConstants.Text = "Optimize"; 163 165 this.btnOptimizeConstants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; 166 this.toolTip.SetToolTip(this.btnOptimizeConstants, "Optimizes the numerical constants of the model. \r\nIf the algorithm converges, opt" + 167 "imization is stopped."); 164 168 this.btnOptimizeConstants.UseVisualStyleBackColor = true; 165 169 this.btnOptimizeConstants.Click += new System.EventHandler(this.btnOptimizeConstants_Click); … … 226 230 protected System.Windows.Forms.Button btnOptimizeConstants; 227 231 private System.Windows.Forms.Label treeStatusValue; 232 private System.Windows.Forms.ToolTip toolTip; 228 233 } 229 234 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r17180 r17928 35 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 36 36 public abstract partial class InteractiveSymbolicDataAnalysisSolutionSimplifierView : AsynchronousContentView { 37 private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes; 38 private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes; 39 private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts; 37 private readonly Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(); 38 private readonly Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(); 39 private readonly Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>(); 40 private readonly Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>(); 40 41 41 42 private readonly ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator; … … 49 50 protected InteractiveSymbolicDataAnalysisSolutionSimplifierView(ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator) { 50 51 InitializeComponent(); 51 foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();52 changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();53 nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();54 52 this.Caption = "Interactive Solution Simplifier"; 55 53 this.impactCalculator = impactCalculator; … … 168 166 private void Content_Changed(object sender, EventArgs e) { 169 167 UpdateView(); 168 SetEnabledStateOfControls(); 170 169 } 171 170 172 171 protected override void OnContentChanged() { 173 172 base.OnContentChanged(); 174 foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(); 173 foldedNodes.Clear(); 174 changedNodes.Clear(); 175 nodeIntervals.Clear(); 176 nodeImpacts.Clear(); 175 177 UpdateView(); 176 178 viewHost.Content = this.Content; … … 192 194 193 195 progress.Start("Calculate Impact and Replacement Values ..."); 196 cancellationTokenSource = new CancellationTokenSource(); 194 197 progress.CanBeStopped = true; 195 cancellationTokenSource = new CancellationTokenSource();196 var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));197 198 try { 198 await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation 199 } catch (OperationCanceledException) { } 200 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 201 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { 202 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 203 } 204 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 205 progress.Finish(); 199 var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree)); 200 try { 201 await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation 202 } catch (OperationCanceledException) { } 203 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] = MakeConstantTreeNode(pair.Value); 207 } 208 209 foreach (var pair in impactAndReplacementValues) { 210 nodeImpacts[pair.Key] = pair.Value.Item1; 211 } 212 213 if (IntervalInterpreter.IsCompatible(tree)) { 214 var regressionProblemData = Content.ProblemData as IRegressionProblemData; 215 if (regressionProblemData != null) { 216 var interpreter = new IntervalInterpreter(); 217 var variableRanges = regressionProblemData.VariableRanges.GetReadonlyDictionary(); 218 IDictionary<ISymbolicExpressionTreeNode, Interval> intervals; 219 interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals); 220 foreach (var kvp in intervals) { 221 nodeIntervals[kvp.Key] = kvp.Value; 222 } 223 } 224 } 225 } finally { 226 progress.Finish(); 227 } 228 206 229 progress.CanBeStopped = false; 207 230 PaintNodeImpacts(); … … 296 319 } 297 320 } 298 if (visualTree != null) 321 if (visualTree != null) { 322 if (nodeIntervals.ContainsKey(treeNode)) 323 visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{nodeIntervals[treeNode].LowerBound:G5} ... {nodeIntervals[treeNode].UpperBound:G5}]"); 299 324 if (changedNodes.ContainsKey(treeNode)) { 300 325 visualTree.LineColor = Color.DodgerBlue; … … 302 327 visualTree.LineColor = Color.DarkOrange; 303 328 } 329 } 304 330 } 305 331 treeChart.RepaintNodes(); … … 313 339 private async void btnOptimizeConstants_Click(object sender, EventArgs e) { 314 340 progress.Start("Optimizing Constants ..."); 315 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 316 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); 317 await Task.Delay(500); // wait for progressbar to finish animation 318 UpdateModel(newTree); // UpdateModel calls Progress.Finish (via Content_Changed) 341 cancellationTokenSource = new CancellationTokenSource(); 342 progress.CanBeStopped = true; 343 try { 344 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 345 346 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); 347 try { 348 await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation 349 } catch (OperationCanceledException) { } 350 UpdateModel(newTree); // triggers progress.Finish after calculating the node impacts when model is changed 351 } catch { 352 progress.Finish(); 353 } 319 354 } 320 355 }
Note: See TracChangeset
for help on using the changeset viewer.