Changeset 8535 for branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.cs
- Timestamp:
- 08/29/12 09:22:21 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.cs
r8524 r8535 36 36 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views { 37 37 public partial class CreateExperimentDialogV2 : Form { 38 private readonly IAlgorithm algorithm; 38 39 private readonly Progress progress; 39 private readonly IAlgorithm algorithm;40 40 private ParameterConfigurationTree parameterConfigurationTree; 41 41 private bool createBatchRun; 42 42 private int repetitions; 43 43 private IEngine engine; 44 private Task generation;44 private Task experimentGenerator; 45 45 private CancellationTokenSource cts; 46 46 private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstanceProviders; … … 93 93 parameterConfigurationTreeView.Content = parameterConfigurationTree = new ParameterConfigurationTree(algorithm, algorithm.Problem); 94 94 parameterConfigurationTree.ExperimentGenerationProgressChanged += (o, args) => progress.ProgressValue = parameterConfigurationTree.ExperimentGenerationProgress; 95 parameterConfigurationTree.CombinationsCountChanged += (o, args) => UpdateCombinationsCount(); 95 96 new ProgressView(parameterConfigurationTreeView, progress) { CancelTimeoutMs = 10000 }; 96 97 } else { … … 101 102 102 103 private void CreateExperimentDialogV2_FormClosing(object sender, FormClosingEventArgs e) { 103 if ( generation!= null) e.Cancel = true;104 if (experimentGenerator != null) e.Cancel = true; 104 105 } 105 106 … … 160 161 } 161 162 } 162 } 163 } 164 165 private void calculateCombinationsButton_Click(object sender, EventArgs e) { 166 long parameterConfigurationsCnt = parameterConfigurationTree.GetCombinationCount(0); 167 int problemInstanceCnt = 1 + selectedProblemInstanceProviders.Values.Sum(x => x.Count); 168 combinationsTextBox.Text = (parameterConfigurationsCnt * problemInstanceCnt).ToString(); 163 UpdateCombinationsCount(); 164 } 169 165 } 170 166 171 167 private void okButton_Click(object sender, System.EventArgs e) { 172 168 configurationTabControl.SelectedTab = parameterConfigurationTabPage; 173 generation= Task.Factory.StartNew(() => {169 experimentGenerator = Task.Factory.StartNew(() => { 174 170 StartProgressView(); 175 171 var engineAlgorithm = algorithm as EngineAlgorithm; … … 181 177 finally { FinishProgressView(); } 182 178 }, cts.Token); 183 generation.ContinueWith(t => {184 generation= null;179 experimentGenerator.ContinueWith(t => { 180 experimentGenerator = null; 185 181 CloseDialog(); 186 182 }, TaskContinuationOptions.OnlyOnRanToCompletion); 187 generation.ContinueWith(t => {188 generation= null;183 experimentGenerator.ContinueWith(t => { 184 experimentGenerator = null; 189 185 if (t.IsCanceled) cts = new CancellationTokenSource(); 190 186 if (t.IsFaulted) { … … 201 197 repetitionsNumericUpDown.Enabled = state; 202 198 engineComboBox.Enabled = state; 203 calculateCombinationsButton.Enabled = state;204 199 okButton.Enabled = state; 205 200 cancelButton.Enabled = state; … … 222 217 } 223 218 219 private void UpdateCombinationsCount() { 220 var combinationsCount = parameterConfigurationTree.CombinationsCount; 221 var instanceCount = 1 + selectedProblemInstanceProviders.Values.Sum(x => x.Count); 222 combinationsCountLabel.Text = (combinationsCount * instanceCount).ToString(); 223 } 224 224 225 private void StartProgressView() { 225 226 if (InvokeRequired) {
Note: See TracChangeset
for help on using the changeset viewer.