Changeset 17501 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
- Timestamp:
- 04/09/20 13:10:50 (4 years ago)
- Location:
- branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views merged: 17377-17378,17380,17430
- Property svn:mergeinfo changed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r17207 r17501 166 166 private void Content_Changed(object sender, EventArgs e) { 167 167 UpdateView(); 168 SetEnabledStateOfControls(); 168 169 } 169 170 … … 193 194 194 195 progress.Start("Calculate Impact and Replacement Values ..."); 196 cancellationTokenSource = new CancellationTokenSource(); 195 197 progress.CanBeStopped = true; 196 cancellationTokenSource = new CancellationTokenSource();197 198 var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));199 200 198 try { 201 await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation 202 } catch (OperationCanceledException) { } 203 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 204 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { 205 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 206 } 207 208 foreach (var kvp in impactAndReplacementValues) { 209 nodeImpacts[kvp.Key] = kvp.Value.Item1; 210 } 211 212 var regressionProblemData = Content.ProblemData as IRegressionProblemData; 213 if (regressionProblemData != null) { 214 var interpreter = new IntervalInterpreter(); 215 var variableRanges = regressionProblemData.VariableRanges.GetIntervals(); 216 IDictionary<ISymbolicExpressionTreeNode, Interval> intervals; 217 interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals); 218 foreach (var kvp in intervals) { 219 nodeIntervals[kvp.Key] = kvp.Value; 220 } 221 } 222 223 224 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 var regressionProblemData = Content.ProblemData as IRegressionProblemData; 214 if (regressionProblemData != null) { 215 var interpreter = new IntervalInterpreter(); 216 var variableRanges = regressionProblemData.VariableRanges.GetIntervals(); 217 IDictionary<ISymbolicExpressionTreeNode, Interval> intervals; 218 interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals); 219 foreach (var kvp in intervals) { 220 nodeIntervals[kvp.Key] = kvp.Value; 221 } 222 } 223 } finally { 224 progress.Finish(); 225 } 226 225 227 progress.CanBeStopped = false; 226 228 PaintNodeImpacts(); … … 335 337 private async void btnOptimizeConstants_Click(object sender, EventArgs e) { 336 338 progress.Start("Optimizing Constants ..."); 337 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 338 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); 339 await Task.Delay(500); // wait for progressbar to finish animation 340 UpdateModel(newTree); // UpdateModel calls Progress.Finish (via Content_Changed) 339 cancellationTokenSource = new CancellationTokenSource(); 340 progress.CanBeStopped = true; 341 try { 342 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 343 344 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); 345 try { 346 await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation 347 } catch (OperationCanceledException) { } 348 UpdateModel(newTree); // triggers progress.Finish after calculating the node impacts when model is changed 349 } catch { 350 progress.Finish(); 351 } 341 352 } 342 353 }
Note: See TracChangeset
for help on using the changeset viewer.