Index: branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.Designer.cs
===================================================================
--- branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.Designer.cs	(revision 13812)
+++ branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.Designer.cs	(revision 13814)
@@ -35,5 +35,8 @@
       this.combinationGroupSizeNumericUpDown = new System.Windows.Forms.NumericUpDown();
       this.label1 = new System.Windows.Forms.Label();
-      this.warningLabel = new System.Windows.Forms.Label();
+      this.combinationsLabel = new System.Windows.Forms.Label();
+      this.combinationCountLabel = new System.Windows.Forms.Label();
+      this.progressBar = new System.Windows.Forms.ProgressBar();
+      this.worker = new System.ComponentModel.BackgroundWorker();
       ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
       ((System.ComponentModel.ISupportInitialize)(this.combinationGroupSizeNumericUpDown)).BeginInit();
@@ -44,5 +47,5 @@
       this.repetitionsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
-      this.repetitionsNumericUpDown.Location = new System.Drawing.Point(128, 12);
+      this.repetitionsNumericUpDown.Location = new System.Drawing.Point(81, 12);
       this.repetitionsNumericUpDown.Maximum = new decimal(new int[] {
             1000000,
@@ -56,5 +59,5 @@
             0});
       this.repetitionsNumericUpDown.Name = "repetitionsNumericUpDown";
-      this.repetitionsNumericUpDown.Size = new System.Drawing.Size(185, 20);
+      this.repetitionsNumericUpDown.Size = new System.Drawing.Size(240, 20);
       this.repetitionsNumericUpDown.TabIndex = 4;
       this.repetitionsNumericUpDown.ThousandsSeparator = true;
@@ -69,5 +72,5 @@
       // 
       this.repetitionsLabel.AutoSize = true;
-      this.repetitionsLabel.Location = new System.Drawing.Point(26, 14);
+      this.repetitionsLabel.Location = new System.Drawing.Point(12, 12);
       this.repetitionsLabel.Name = "repetitionsLabel";
       this.repetitionsLabel.Size = new System.Drawing.Size(63, 13);
@@ -79,5 +82,5 @@
       this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
       this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-      this.cancelButton.Location = new System.Drawing.Point(177, 130);
+      this.cancelButton.Location = new System.Drawing.Point(246, 66);
       this.cancelButton.Name = "cancelButton";
       this.cancelButton.Size = new System.Drawing.Size(75, 23);
@@ -85,10 +88,11 @@
       this.cancelButton.Text = "&Cancel";
       this.cancelButton.UseVisualStyleBackColor = true;
+      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
       // 
       // okButton
       // 
       this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-      this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-      this.okButton.Location = new System.Drawing.Point(80, 130);
+      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
+      this.okButton.Location = new System.Drawing.Point(165, 66);
       this.okButton.Name = "okButton";
       this.okButton.Size = new System.Drawing.Size(75, 23);
@@ -102,5 +106,5 @@
       this.combinationGroupSizeNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
-      this.combinationGroupSizeNumericUpDown.Location = new System.Drawing.Point(128, 38);
+      this.combinationGroupSizeNumericUpDown.Location = new System.Drawing.Point(81, 38);
       this.combinationGroupSizeNumericUpDown.Maximum = new decimal(new int[] {
             1000000,
@@ -114,5 +118,5 @@
             0});
       this.combinationGroupSizeNumericUpDown.Name = "combinationGroupSizeNumericUpDown";
-      this.combinationGroupSizeNumericUpDown.Size = new System.Drawing.Size(185, 20);
+      this.combinationGroupSizeNumericUpDown.Size = new System.Drawing.Size(240, 20);
       this.combinationGroupSizeNumericUpDown.TabIndex = 4;
       this.combinationGroupSizeNumericUpDown.ThousandsSeparator = true;
@@ -129,5 +133,5 @@
       // 
       this.label1.AutoSize = true;
-      this.label1.Location = new System.Drawing.Point(26, 40);
+      this.label1.Location = new System.Drawing.Point(12, 40);
       this.label1.Name = "label1";
       this.label1.Size = new System.Drawing.Size(60, 13);
@@ -135,12 +139,37 @@
       this.label1.Text = "&Group size:";
       // 
-      // warningLabel
-      // 
-      this.warningLabel.ForeColor = System.Drawing.Color.Red;
-      this.warningLabel.Location = new System.Drawing.Point(26, 67);
-      this.warningLabel.Name = "warningLabel";
-      this.warningLabel.Size = new System.Drawing.Size(287, 50);
-      this.warningLabel.TabIndex = 5;
-      this.warningLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+      // combinationsLabel
+      // 
+      this.combinationsLabel.AutoSize = true;
+      this.combinationsLabel.Location = new System.Drawing.Point(12, 71);
+      this.combinationsLabel.Name = "combinationsLabel";
+      this.combinationsLabel.Size = new System.Drawing.Size(73, 13);
+      this.combinationsLabel.TabIndex = 11;
+      this.combinationsLabel.Text = "Combinations:";
+      // 
+      // combinationCountLabel
+      // 
+      this.combinationCountLabel.AutoSize = true;
+      this.combinationCountLabel.Location = new System.Drawing.Point(91, 71);
+      this.combinationCountLabel.Name = "combinationCountLabel";
+      this.combinationCountLabel.Size = new System.Drawing.Size(0, 13);
+      this.combinationCountLabel.TabIndex = 12;
+      // 
+      // progressBar
+      // 
+      this.progressBar.Location = new System.Drawing.Point(15, 66);
+      this.progressBar.Name = "progressBar";
+      this.progressBar.Size = new System.Drawing.Size(144, 23);
+      this.progressBar.Step = 1;
+      this.progressBar.TabIndex = 13;
+      this.progressBar.Visible = false;
+      // 
+      // worker
+      // 
+      this.worker.WorkerReportsProgress = true;
+      this.worker.WorkerSupportsCancellation = true;
+      this.worker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.worker_DoWork);
+      this.worker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.worker_ProgressChanged);
+      this.worker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.worker_RunWorkerCompleted);
       // 
       // CreateTargetVariationExperimentDialog
@@ -150,8 +179,10 @@
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.CancelButton = this.cancelButton;
-      this.ClientSize = new System.Drawing.Size(349, 165);
+      this.ClientSize = new System.Drawing.Size(333, 101);
+      this.Controls.Add(this.progressBar);
+      this.Controls.Add(this.combinationCountLabel);
+      this.Controls.Add(this.combinationsLabel);
       this.Controls.Add(this.okButton);
       this.Controls.Add(this.cancelButton);
-      this.Controls.Add(this.warningLabel);
       this.Controls.Add(this.label1);
       this.Controls.Add(this.repetitionsLabel);
@@ -159,5 +190,7 @@
       this.Controls.Add(this.repetitionsNumericUpDown);
       this.Name = "CreateTargetVariationExperimentDialog";
+      this.ShowIcon = false;
       this.Text = "Create Target Variation Experiment";
+      this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CreateTargetVariationExperimentDialog_FormClosing);
       ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
       ((System.ComponentModel.ISupportInitialize)(this.combinationGroupSizeNumericUpDown)).EndInit();
@@ -175,5 +208,8 @@
     private System.Windows.Forms.NumericUpDown combinationGroupSizeNumericUpDown;
     private System.Windows.Forms.Label label1;
-    private System.Windows.Forms.Label warningLabel;
+    private System.Windows.Forms.Label combinationsLabel;
+    private System.Windows.Forms.Label combinationCountLabel;
+    private System.Windows.Forms.ProgressBar progressBar;
+    private System.ComponentModel.BackgroundWorker worker;
   }
 }
Index: branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.cs
===================================================================
--- branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.cs	(revision 13812)
+++ branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.cs	(revision 13814)
@@ -22,4 +22,5 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Windows.Forms;
@@ -32,18 +33,15 @@
   public partial class CreateTargetVariationExperimentDialog : Form {
     public Experiment Experiment { get; private set; }
-    private int repetitions;
-    private int combinationGroupSize;
 
     public CreateTargetVariationExperimentDialog() : this(null) { }
     public CreateTargetVariationExperimentDialog(IAlgorithm alg) {
       InitializeComponent();
-      repetitions = (int)repetitionsNumericUpDown.Value;
-      combinationGroupSize = (int)combinationGroupSizeNumericUpDown.Value;
 
       var problem = alg.Problem as IDataAnalysisProblem;
-      var inputCount = problem.ProblemData.AllowedInputVariables.Count();
-      if (combinationGroupSize > inputCount)
-        combinationGroupSize = inputCount;
-      warningLabel.Text = string.Format("Warning: this will create {0} combinations.", EnumerableExtensions.BinomialCoefficient(inputCount, combinationGroupSize));
+      var inputCount = problem.ProblemData.AllowedInputVariables.Count() - 1; // -1 because one will be the target
+      if (combinationGroupSizeNumericUpDown.Value > inputCount)
+        combinationGroupSizeNumericUpDown.Value = inputCount;
+      var combinationGroupSize = (int)combinationGroupSizeNumericUpDown.Value;
+      combinationCountLabel.Text = ((inputCount + 1) * EnumerableExtensions.BinomialCoefficient(inputCount, combinationGroupSize)).ToString();
 
       Experiment = null;
@@ -51,7 +49,5 @@
     }
 
-    public Experiment CreateVariableCombinations(IAlgorithm algorithm) {
-      var experiment = new Experiment("Target Variation Experiment");
-
+    public static IEnumerable<IOptimizer> CreateVariableCombinations(IAlgorithm algorithm, int combinationGroupSize, int repetitions) {
       if (algorithm == null)
         throw new ArgumentNullException("The algorithm parameter must be a valid IAlgorithm instance.");
@@ -61,11 +57,7 @@
 
       var variables = problemData.AllowedInputVariables.ToList();
-
-      for (int i = 0; i < variables.Count; i++) {
-        var target = variables[i];
+      int count = 1;
+      foreach (var target in variables) {
         var inputs = variables.Where(x => x != target).ToList();
-        if (combinationGroupSize > inputs.Count)
-          combinationGroupSize = inputs.Count;
-
         var combinations = inputs.Combinations(combinationGroupSize);
 
@@ -81,13 +73,11 @@
           SetTargetName(problemData, target);
 
-          var batchrun = new BatchRun(string.Format("Batchrun {0}", i + 1)) {
+          var batchRun = new BatchRun(string.Format("Batchrun {0}", count++)) {
             Repetitions = repetitions,
             Optimizer = alg
           };
-
-          experiment.Optimizers.Add(batchrun);
+          yield return batchRun;
         }
       }
-      return experiment;
     }
 
@@ -117,11 +107,16 @@
 
     #region events
-    private void okButton_Click(object sender, EventArgs e) {
-      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
-      if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IAlgorithm) && !activeView.Locked) {
-        Experiment = CreateVariableCombinations((IAlgorithm)activeView.Content);
-        DialogResult = DialogResult.OK;
-        Close();
-      }
+    private void CreateTargetVariationExperimentDialog_FormClosing(object sender, FormClosingEventArgs e) {
+      if (worker.IsBusy) {
+        if (DialogResult != DialogResult.OK) {
+          if (worker.IsBusy) worker.CancelAsync();
+        }
+        e.Cancel = true;
+      }
+    }
+
+    private void repetitionsNumericUpDown_Validated(object sender, EventArgs e) {
+      if (repetitionsNumericUpDown.Text == string.Empty)
+        repetitionsNumericUpDown.Text = repetitionsNumericUpDown.Value.ToString();
     }
 
@@ -132,13 +127,7 @@
       var problem = algorithm.Problem as IDataAnalysisProblem;
       if (problem == null) return;
-      var inputCount = problem.ProblemData.AllowedInputVariables.Count();
+      var inputCount = problem.ProblemData.AllowedInputVariables.Count() - 1;
       if (combinationGroupSizeNumericUpDown.Value > inputCount)
         combinationGroupSizeNumericUpDown.Value = inputCount;
-    }
-
-    private void repetitionsNumericUpDown_Validated(object sender, EventArgs e) {
-      if (repetitionsNumericUpDown.Text == string.Empty)
-        repetitionsNumericUpDown.Text = repetitionsNumericUpDown.Value.ToString();
-      repetitions = (int)repetitionsNumericUpDown.Value;
     }
 
@@ -146,11 +135,66 @@
       if (combinationGroupSizeNumericUpDown.Text == string.Empty)
         combinationGroupSizeNumericUpDown.Text = combinationGroupSizeNumericUpDown.Value.ToString();
-      combinationGroupSize = (int)combinationGroupSizeNumericUpDown.Value;
+
       IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
       if (activeView == null) return;
       var algorithm = (IAlgorithm)activeView.Content;
       var problem = (IDataAnalysisProblem)algorithm.Problem;
-      var inputCount = problem.ProblemData.AllowedInputVariables.Count();
-      warningLabel.Text = string.Format("Warning: this will create {0} combinations.", EnumerableExtensions.BinomialCoefficient(inputCount, combinationGroupSize));
+      var inputCount = problem.ProblemData.AllowedInputVariables.Count() - 1;
+      if (combinationGroupSizeNumericUpDown.Value > inputCount)
+        combinationGroupSizeNumericUpDown.Value = inputCount;
+      combinationCountLabel.Text = ((inputCount + 1) * EnumerableExtensions.BinomialCoefficient(inputCount, (int)combinationGroupSizeNumericUpDown.Value)).ToString();
+    }
+
+    private void worker_DoWork(object sender, DoWorkEventArgs e) {
+      IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
+      var algorithm = (IAlgorithm)activeView.Content;
+      var problem = (IDataAnalysisProblem)algorithm.Problem;
+      var experiment = new Experiment("Target Variation Experiment");
+      var repetitions = (int)repetitionsNumericUpDown.Value;
+      var inputCount = problem.ProblemData.AllowedInputVariables.Count() - 1;
+      var combinationGroupSize = (int)combinationGroupSizeNumericUpDown.Value;
+      var totalNumberOfCombinations = (inputCount + 1) * EnumerableExtensions.BinomialCoefficient(inputCount, combinationGroupSize);
+      int progress = 0;
+      foreach (var optimizer in CreateVariableCombinations(algorithm, combinationGroupSize, repetitions)) {
+        experiment.Optimizers.Add(optimizer);
+        progress++;
+        worker.ReportProgress((int)Math.Round(100d * progress / totalNumberOfCombinations));
+      }
+      Experiment = experiment;
+    }
+
+    private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
+      if (InvokeRequired) {
+        Invoke((Action<int>)UpdateProgress, e.ProgressPercentage);
+      } else {
+        UpdateProgress(e.ProgressPercentage);
+      }
+    }
+
+    private void UpdateProgress(int percentage) {
+      progressBar.Value = percentage;
+    }
+
+    private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
+      if (e.Cancelled || e.Error != null)
+        return;
+      DialogResult = DialogResult.OK;
+      Close();
+    }
+
+    private void okButton_Click(object sender, EventArgs args) {
+      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
+      if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IAlgorithm) && !activeView.Locked) {
+        okButton.Enabled = false;
+        combinationsLabel.Visible = false;
+        combinationCountLabel.Visible = false;
+        progressBar.Visible = true;
+        worker.RunWorkerAsync();
+      }
+    }
+
+    private void cancelButton_Click(object sender, EventArgs e) {
+      if (worker.IsBusy)
+        worker.CancelAsync();
     }
     #endregion
