Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/12 09:22:21 (12 years ago)
Author:
jkarder
Message:

#1853:

  • enhanced combinations count calculation
  • restructured code
  • minor code improvements
  • added license information
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.cs

    r8524 r8535  
    3636namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    3737  public partial class CreateExperimentDialogV2 : Form {
     38    private readonly IAlgorithm algorithm;
    3839    private readonly Progress progress;
    39     private readonly IAlgorithm algorithm;
    4040    private ParameterConfigurationTree parameterConfigurationTree;
    4141    private bool createBatchRun;
    4242    private int repetitions;
    4343    private IEngine engine;
    44     private Task generation;
     44    private Task experimentGenerator;
    4545    private CancellationTokenSource cts;
    4646    private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstanceProviders;
     
    9393        parameterConfigurationTreeView.Content = parameterConfigurationTree = new ParameterConfigurationTree(algorithm, algorithm.Problem);
    9494        parameterConfigurationTree.ExperimentGenerationProgressChanged += (o, args) => progress.ProgressValue = parameterConfigurationTree.ExperimentGenerationProgress;
     95        parameterConfigurationTree.CombinationsCountChanged += (o, args) => UpdateCombinationsCount();
    9596        new ProgressView(parameterConfigurationTreeView, progress) { CancelTimeoutMs = 10000 };
    9697      } else {
     
    101102
    102103    private void CreateExperimentDialogV2_FormClosing(object sender, FormClosingEventArgs e) {
    103       if (generation != null) e.Cancel = true;
     104      if (experimentGenerator != null) e.Cancel = true;
    104105    }
    105106
     
    160161          }
    161162        }
    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      }
    169165    }
    170166
    171167    private void okButton_Click(object sender, System.EventArgs e) {
    172168      configurationTabControl.SelectedTab = parameterConfigurationTabPage;
    173       generation = Task.Factory.StartNew(() => {
     169      experimentGenerator = Task.Factory.StartNew(() => {
    174170        StartProgressView();
    175171        var engineAlgorithm = algorithm as EngineAlgorithm;
     
    181177        finally { FinishProgressView(); }
    182178      }, cts.Token);
    183       generation.ContinueWith(t => {
    184         generation = null;
     179      experimentGenerator.ContinueWith(t => {
     180        experimentGenerator = null;
    185181        CloseDialog();
    186182      }, TaskContinuationOptions.OnlyOnRanToCompletion);
    187       generation.ContinueWith(t => {
    188         generation = null;
     183      experimentGenerator.ContinueWith(t => {
     184        experimentGenerator = null;
    189185        if (t.IsCanceled) cts = new CancellationTokenSource();
    190186        if (t.IsFaulted) {
     
    201197      repetitionsNumericUpDown.Enabled = state;
    202198      engineComboBox.Enabled = state;
    203       calculateCombinationsButton.Enabled = state;
    204199      okButton.Enabled = state;
    205200      cancelButton.Enabled = state;
     
    222217    }
    223218
     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
    224225    private void StartProgressView() {
    225226      if (InvokeRequired) {
Note: See TracChangeset for help on using the changeset viewer.