private static void AssertSettingExists(string settingId, string expectedValue, AnalysisConfig actual) { Assert.IsNotNull(actual.AdditionalSettings, "Not expecting the additional settings to be null"); AnalysisSetting actualSetting = actual.AdditionalSettings.FirstOrDefault(s => string.Equals(settingId, s.Id, StringComparison.InvariantCultureIgnoreCase)); Assert.IsNotNull(actualSetting, "Expected setting not found: {0}", settingId); Assert.AreEqual(expectedValue, actualSetting.Value, "Setting does not have the expected value. SettingId: {0}", settingId); }
private void tabControl_SelectedPageChanged(object sender, TabPageChangedEventArgs e) { try { AnalysisSetting.RefreshValues(AlgorithmSetting); var xtraTabControl = sender as XtraTabControl; if (e.Page.Name == xtraTabControl.TabPages[1].Name) { DisplaySetting(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void sbAnalysis_Click(object sender, EventArgs e) { try { if (AnalysisSetting.List.Count == 0) { MessageBox.Show("Выберите пожалуйста методы для сравнения!"); return; } AnalysisSetting.RefreshValues(AlgorithmSetting); GenAnalysis = new GenAnalysis(meOutputAnalysis, AnalysisSetting); GenAnalysis.Start(); DisplayChartAnalysis(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Загрузка значений конфигураций генетического алгоритма /// </summary> private void LoadConfig() { try { AlgorithmSetting = new AlgorithmSetting(); //Загрузка конфигураций методик генетического алгоритма LoadSelectTarget(); LoadSelectParent(); LoadSelectCross(); LoadSelectMutate(); LoadSelectSelection(); //Загрузка значений списка целевых функций cmboCalcFunction.Properties.Items.AddRange(funcList); cmboCalcFunction.EditValue = cmboCalcFunction.Properties.Items[0]; //Выставление параметров функции FunctionStep = Convert.ToDouble(seFunctionStep.EditValue); AlgorithmSetting.FunctionStartValue = Convert.ToInt32(seFunctionStartValue.EditValue); AlgorithmSetting.FunctionFinishValue = Convert.ToInt32(seFunctionFinishValue.EditValue); AlgorithmSetting.Accuracy = Convert.ToInt32(seAccuracy.EditValue); //Выставление настроек ГА AlgorithmSetting.GenerationSize = Convert.ToInt32(seGenerationSize.EditValue); AlgorithmSetting.PopulationSize = Convert.ToInt32(sePopulationSize.EditValue); AlgorithmSetting.SelectionTreshold = Convert.ToDouble(seSelectionTreshold.EditValue); AlgorithmSetting.MutationProbability = Convert.ToDouble(seMutationProbability.EditValue); AlgorithmSetting.MutationGeneProbability = Convert.ToDouble(seMutationGeneProbability.EditValue); AlgorithmSetting.DevidePointCount = Convert.ToInt32(seDevidePointCount.EditValue); AlgorithmSetting.MutateGeneCount = Convert.ToInt32(seMutateGeneCount.EditValue); AlgorithmSetting.GroupSize = Convert.ToInt32(seGroupSize.EditValue); AlgorithmSetting.IsDuplicate = Convert.ToBoolean(ceIsDuplicate.EditValue); AlgorithmSetting.IsDisplaySelectionResult = Convert.ToBoolean(ceIsDisplaySelectionResult.EditValue); AlgorithmSetting.IsDisplayMutateResult = Convert.ToBoolean(ceIsDisplayMutateResult.EditValue); AlgorithmSetting.IsDisplayCrossResult = Convert.ToBoolean(ceIsDisplayCrossResult.EditValue); // Блокирование контролов в зависимости от настроек ГА seDevidePointCount.Enabled = AlgorithmSetting.SelectCross == SelectCross.CrossingoverNPoint ? true : false; seMutateGeneCount.Enabled = AlgorithmSetting.SelectMutate == SelectMutate.MutateNPoint ? true : false; seMutationGeneProbability.Enabled = AlgorithmSetting.SelectMutate == SelectMutate.DensityMutate ? true : false; seSelectionTreshold.Enabled = AlgorithmSetting.SelectSelection == SelectSelection.TruncationSelection ? true : false; seGroupSize.Enabled = AlgorithmSetting.SelectSelection == SelectSelection.ClassicTournament || AlgorithmSetting.SelectSelection == SelectSelection.EqualProbabilityTournament || AlgorithmSetting.SelectSelection == SelectSelection.RouletteTournament ? true : false; ceIsDuplicate.Enabled = AlgorithmSetting.SelectSelection == SelectSelection.EqualProbabilityTournament || AlgorithmSetting.SelectSelection == SelectSelection.RouletteSelection || AlgorithmSetting.SelectSelection == SelectSelection.RouletteTournament ? true : false; ceIsDisplaySelectionResult.Enabled = AlgorithmSetting.SelectSelection == SelectSelection.RouletteSelection || AlgorithmSetting.SelectSelection == SelectSelection.ClassicTournament || AlgorithmSetting.SelectSelection == SelectSelection.EqualProbabilityTournament || AlgorithmSetting.SelectSelection == SelectSelection.RouletteTournament ? true : false; sbStart.Enabled = false; ChangeRangeTrack(AlgorithmSetting.GenerationSize); // Блокировка вкладки "Анализ" tabControl.TabPages[1].PageEnabled = false; AnalysisSetting = new AnalysisSetting(AlgorithmSetting) { RunAmount = Convert.ToInt32(seRunAmount.EditValue) }; LoadSelectMethod(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }