Changeset 18086 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs
- Timestamp:
- 11/19/21 16:07:45 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs
r17586 r18086 453 453 } 454 454 455 private asyncTask<DoubleLimit> UpdateAllSeriesDataAsync(CancellationToken cancellationToken) {455 private Task<DoubleLimit> UpdateAllSeriesDataAsync(CancellationToken cancellationToken) { 456 456 var updateTasks = solutions.Select(solution => UpdateSeriesDataAsync(solution, cancellationToken)); 457 457 458 double min = double.MaxValue, max = double.MinValue; 459 foreach (var update in updateTasks) { 460 var limit = await update; 461 if (limit.Lower < min) min = limit.Lower; 462 if (limit.Upper > max) max = limit.Upper; 463 } 464 465 return new DoubleLimit(min, max); 458 return Task.Run(() => { 459 double min = double.MaxValue, max = double.MinValue; 460 foreach (var update in updateTasks) { 461 var limit = update.Result; 462 if (limit.Lower < min) min = limit.Lower; 463 if (limit.Upper > max) max = limit.Upper; 464 } 465 466 return new DoubleLimit(min, max); 467 }, cancellationToken); 466 468 } 467 469 … … 530 532 531 533 public async Task AddSolutionAsync(IRegressionSolution solution) { 534 if (solutions.Contains(solution)) 535 return; 532 536 if (!SolutionsCompatible(solutions.Concat(new[] { solution }))) 533 537 throw new ArgumentException("The solution is not compatible with the problem data."); 534 if (solutions.Contains(solution))535 return;536 538 537 539 solutions.Add(solution); … … 568 570 var refSolution = solutions.First(); 569 571 var refSolVars = refSolution.ProblemData.Dataset.VariableNames; 572 var refFactorVars = refSolution.ProblemData.Dataset.StringVariables; 573 var distinctVals = refFactorVars.ToDictionary(fv => fv, fv => refSolution.ProblemData.Dataset.GetStringValues(fv).Distinct().ToArray()); 574 570 575 foreach (var solution in solutions.Skip(1)) { 571 var variables1 = solution.ProblemData.Dataset.VariableNames;572 if (!variables1. All(refSolVars.Contains))576 var variables1 = new HashSet<string>(solution.ProblemData.Dataset.VariableNames); 577 if (!variables1.IsSubsetOf(refSolVars)) 573 578 return false; 574 579 575 foreach (var factorVar in variables1.Where(solution.ProblemData.Dataset.VariableHasType<string>)) { 576 var distinctVals = refSolution.ProblemData.Dataset.GetStringValues(factorVar).Distinct(); 577 if (solution.ProblemData.Dataset.GetStringValues(factorVar).Any(val => !distinctVals.Contains(val))) return false; 580 foreach (var factorVar in solution.ProblemData.Dataset.StringVariables) { 581 var refValues = distinctVals[factorVar]; 582 var values = new HashSet<string>(solution.ProblemData.Dataset.GetStringValues(factorVar)); 583 584 if (!values.IsSubsetOf(refValues)) 585 return false; 578 586 } 579 587 } … … 646 654 647 655 private void sharedFixedVariables_Reset(object sender, EventArgs e) { 656 RecalculateInternalDataset(); 648 657 var newValue = sharedFixedVariables.GetDoubleValue(FreeVariable, 0); 649 658 VerticalLineAnnotation.X = newValue; 650 UpdateCursor(); // triggers update of InternalDataset659 UpdateCursor(); 651 660 } 652 661
Note: See TracChangeset
for help on using the changeset viewer.