private void Run_Click(object sender, RoutedEventArgs e) { try { ExceptionLabel.Foreground = Brushes.DarkRed; if (AccuracyComboBox.SelectedItem == null) { throw new Exception(Properties.Resources.ExceptionLabelAccuracyNOTChosen); } var random = new Random(); var solver = new ClassLibrary.Logic.Solver(); var accuracy = double.Parse(AccuracyComboBox.Text); var parametersForDefined = FileProcessing.ReadSolutionForPersistenceTest(_filename); if (parametersForDefined == null) { throw new Exception(Properties.Resources.ExceptionLabelIncorrectFileFormat); } (double, double)cParameters = PercentFinder.GetCsRange(parametersForDefined); (double, double)abParameters = PercentFinder.GetABRange(parametersForDefined); (double, double)lParameters = PercentFinder.GetLRange(parametersForDefined); DistributionParametersService distributionParameters = new DistributionParametersService(); var distributionParametersIds = distributionParameters.GetAppropriateIds( cParameters, abParameters, lParameters); if (distributionParametersIds.Count < 5) { throw new Exception(Properties.Resources.ExceptionLabelNOTEnoughData); } PercentageService percentageService = new PercentageService(); var percentages = percentageService.GetAppropriate(parametersForDefined.A.Length, distributionParametersIds, parametersForDefined.Alpha.Length); if (percentages.Count < 5) { throw new Exception(Properties.Resources.ExceptionLabelNOTEnoughDataForParameters); } var valueFromDB = percentages.Average(); //var percent = PercentFinder.FindPercentOfChange(parametersForDefined, solver, random); parametersForDefined.Clear(); var percent = PercentFinder.SearchMeanPercent(PercentFinder.FindPercentOfChange, parametersForDefined, accuracy, solver, random); ExceptionLabel.Content = ""; var window = new Result(valueFromDB, percent, percentages); window.Show(); } catch (Exception ex) { ExceptionLabel.Content = ex.Message; } }
private void FindPercentButton_Click(object sender, RoutedEventArgs e) { try { var accuracy = double.Parse(AccuracyComboBox.Text); var random = new Random(); var solver = new ClassLibrary.Logic.Solver(); //var parametersForDefined = FileProcessing.ReadSolutionForPersistenceTest(_filename); (double, double)cParameters = PercentFinder.GetCsRange(_data.ParametersForDefined); (double, double)abParameters = PercentFinder.GetABRange(_data.ParametersForDefined); (double, double)lParameters = PercentFinder.GetLRange(_data.ParametersForDefined); DistributionParametersService distributionParameters = new DistributionParametersService(); var distributionParametersIds = distributionParameters.GetAppropriateIds( cParameters, abParameters, lParameters); if (distributionParametersIds.Count < 5) { throw new Exception(Properties.Resources.ExceptionLabelNOTEnoughData); } PercentageService percentageService = new PercentageService(); var percentages = percentageService.GetAppropriate(_data.ParametersForDefined.A.Length, distributionParametersIds, _data.R); if (percentages.Count < 5) { throw new Exception(Properties.Resources.ExceptionLabelNOTEnoughDataForParameters); } var valueFromDB = percentages.Average(); //var percent = PercentFinder.FindPercentOfChange(parametersForDefined, solver, random); _data.ParametersForDefined.Clear(); var percent = PercentFinder.SearchMeanPercent(PercentFinder.FindPercentOfChange, _data.ParametersForDefined, accuracy, solver, random); var window = new Result(valueFromDB, percent, percentages); window.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }