Changeset 1091 for trunk/sources/HeuristicLab.ES/ESEditor.cs
- Timestamp:
- 01/08/09 10:19:30 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ES/ESEditor.cs
r896 r1091 52 52 public ESEditor() { 53 53 InitializeComponent(); 54 problemDimensionTextBox.Text = "1"; 54 55 } 55 56 /// <summary> … … 93 94 lambdaTextBox.Text = ES.Lambda.ToString(); 94 95 learningRateTextBox.Text = ES.LearningRate.ToString(); 96 generalLearningRateTextBox.Text = ES.GeneralLearningRate.ToString(); 95 97 } 96 98 … … 110 112 evaluationTextBox.Text = ES.Evaluator.GetType().Name; 111 113 recombinationTextBox.Text = ES.Recombinator.GetType().Name; 114 initialMutationStrengthVectorTextBox.Text = ArrayToString<double>(ES.ShakingFactors); 112 115 } 113 116 } … … 120 123 lambdaTextBox.DataBindings.Add("Text", ES, "Lambda"); 121 124 maximumGenerationsTextBox.DataBindings.Add("Text", ES, "MaximumGenerations"); 122 initialMutationStrengthTextBox.DataBindings.Add("Text", ES, "ShakingFactor"); 123 targetSuccessRateTextBox.DataBindings.Add("Text", ES, "SuccessProbability"); 125 generalLearningRateTextBox.DataBindings.Add("Text", ES, "GeneralLearningRate"); 124 126 learningRateTextBox.DataBindings.Add("Text", ES, "LearningRate"); 125 dampeningFactorTextBox.DataBindings.Add("Text", ES, "DampeningFactor");126 useSuccessRuleCheckBox.DataBindings.Add("Checked", ES, "UseSuccessRule");127 127 } 128 128 … … 229 229 #endregion 230 230 231 #region CheckBox Events232 private void useSuccessRuleCheckBox_CheckedChanged(object sender, EventArgs e) {233 targetSuccessRateTextBox.Enabled = useSuccessRuleCheckBox.Checked;234 learningRateTextBox.Enabled = useSuccessRuleCheckBox.Checked;235 dampeningFactorTextBox.Enabled = useSuccessRuleCheckBox.Checked;236 }237 #endregion238 239 231 #region RadioButton Events 240 232 private void plusRadioButton_CheckedChanged(object sender, EventArgs e) { … … 246 238 } 247 239 #endregion 240 241 private string ArrayToString<T>(T[] array) { 242 StringBuilder s = new StringBuilder(); 243 foreach (T element in array) 244 s.Append(element + "; "); 245 s.Remove(s.Length - 2, 2); 246 return s.ToString(); 247 } 248 249 private double[] StringToDoubleArray(string str) { 250 251 string[] s = str.Split(new char[] { ';' }); 252 double[] tmp = new double[s.Length]; 253 try { 254 for (int i = 0; i < s.Length; i++) { 255 tmp[i] = double.Parse(s[i]); 256 } 257 } catch (FormatException) { 258 return null; 259 } 260 return tmp; 261 } 262 263 private void initialMutationStrengthVectorTextBox_Validated(object sender, EventArgs e) { 264 double[] tmp = StringToDoubleArray(initialMutationStrengthVectorTextBox.Text); 265 if (tmp != null) ES.ShakingFactors = tmp; 266 else MessageBox.Show("Please use colons \";\" (without the quotes) to delimite the items like this: " + (1.2).ToString() + ";" + (1.1).ToString() + ";" + (3.453).ToString()); 267 int dim = int.Parse(problemDimensionTextBox.Text); 268 if (ES.ShakingFactors.Length != dim) { 269 problemDimensionTextBox.Text = ES.ShakingFactors.Length.ToString(); 270 } 271 Refresh(); 272 } 273 274 private void problemDimensionTextBox_Validated(object sender, EventArgs e) { 275 double[] tmp = StringToDoubleArray(initialMutationStrengthVectorTextBox.Text); 276 if (tmp != null) { 277 int dim = 0; 278 try { 279 dim = int.Parse(problemDimensionTextBox.Text); 280 if (dim < 1) throw new FormatException(); 281 } catch (FormatException) { 282 MessageBox.Show("Problem Dimension must contain an integer > 0"); 283 } 284 double[] shakingFactors = new double[dim]; 285 for (int i = 0; i < dim; i++) { 286 shakingFactors[i] = tmp[i % tmp.Length]; 287 } 288 ES.ShakingFactors = shakingFactors; 289 Refresh(); 290 } 291 } 248 292 } 249 293 }
Note: See TracChangeset
for help on using the changeset viewer.