Index: /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs
===================================================================
--- /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs	(revision 7973)
+++ /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs	(revision 7974)
@@ -36,5 +36,5 @@
 namespace HeuristicLab.Optimizer {
   public partial class CreateExperimentDialog : Form {
-    private enum DialogMode { Normal = 1, DiscoveringInstances = 2, CreatingExperiment = 3 };
+    private enum DialogMode { Normal = 1, DiscoveringInstances = 2, CreatingExperiment = 3, PreparingExperiment = 4 };
 
     private IOptimizer optimizer;
@@ -59,5 +59,5 @@
     private Dictionary<IValueParameter, Tuple<double, double, double>> doubleParameters;
     private HashSet<IValueParameter> boolParameters;
-    private Dictionary<IValueParameter, HashSet<INamedItem>> multipleChoiceParameters;
+    private Dictionary<IValueParameter, HashSet<IItem>> multipleChoiceParameters;
 
     private StringBuilder failedInstances;
@@ -80,5 +80,5 @@
       doubleParameters = new Dictionary<IValueParameter, Tuple<double, double, double>>();
       boolParameters = new HashSet<IValueParameter>();
-      multipleChoiceParameters = new Dictionary<IValueParameter, HashSet<INamedItem>>();
+      multipleChoiceParameters = new Dictionary<IValueParameter, HashSet<IItem>>();
     }
 
@@ -119,5 +119,5 @@
       if (isConstrainedValueParameter) {
         if (e.Item.Checked) {
-          multipleChoiceParameters.Add(parameter, new HashSet<INamedItem>());
+          multipleChoiceParameters.Add(parameter, new HashSet<IItem>());
         } else {
           multipleChoiceParameters.Remove(parameter);
@@ -184,5 +184,5 @@
           choicesListView.Items.Add(new ListViewItem(choice.ToString()) {
             Tag = choice,
-            Checked = multipleChoiceParameters[parameter].Contains((INamedItem)choice)
+            Checked = multipleChoiceParameters[parameter].Contains(choice)
           });
         }
@@ -223,6 +223,6 @@
       var parameter = (IValueParameter)choicesListView.Tag;
       if (e.Item.Checked) {
-        multipleChoiceParameters[parameter].Add((INamedItem)e.Item.Tag);
-      } else multipleChoiceParameters[parameter].Remove((INamedItem)e.Item.Tag);
+        multipleChoiceParameters[parameter].Add((IItem)e.Item.Tag);
+      } else multipleChoiceParameters[parameter].Remove((IItem)e.Item.Tag);
 
       UpdateVariationsLabel();
@@ -475,13 +475,15 @@
       createBatchRunCheckBox.Enabled = mode == DialogMode.Normal;
       repetitionsNumericUpDown.Enabled = mode == DialogMode.Normal;
+      parametersSplitContainer.Enabled = mode == DialogMode.Normal || mode == DialogMode.DiscoveringInstances;
       selectAllCheckBox.Enabled = mode == DialogMode.Normal;
       selectNoneCheckBox.Enabled = mode == DialogMode.Normal;
       instancesTreeView.Enabled = mode == DialogMode.Normal;
-      instancesTreeView.Visible = mode == DialogMode.Normal || mode == DialogMode.CreatingExperiment;
+      instancesTreeView.Visible = mode == DialogMode.Normal || mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
       okButton.Enabled = mode == DialogMode.Normal;
-      okButton.Visible = mode != DialogMode.CreatingExperiment;
+      okButton.Visible = mode != DialogMode.CreatingExperiment && mode != DialogMode.PreparingExperiment;
+      cancelButton.Enabled = mode != DialogMode.PreparingExperiment;
       instanceDiscoveryProgressLabel.Visible = mode == DialogMode.DiscoveringInstances;
       instanceDiscoveryProgressBar.Visible = mode == DialogMode.DiscoveringInstances;
-      experimentCreationProgressBar.Visible = mode == DialogMode.CreatingExperiment;
+      experimentCreationProgressBar.Visible = mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
     }
 
@@ -600,7 +602,7 @@
     }
 
-    private IEnumerable<Dictionary<IValueParameter, INamedItem>> GetMultipleChoiceConfigurations() {
-      var configuration = new Dictionary<IValueParameter, INamedItem>();
-      var enumerators = new Dictionary<IValueParameter, IEnumerator<INamedItem>>();
+    private IEnumerable<Dictionary<IValueParameter, IItem>> GetMultipleChoiceConfigurations() {
+      var configuration = new Dictionary<IValueParameter, IItem>();
+      var enumerators = new Dictionary<IValueParameter, IEnumerator<IItem>>();
       bool finished;
       do {
@@ -620,4 +622,5 @@
           if (!enumerators[p].MoveNext()) {
             enumerators[p] = multipleChoiceParameters[p].GetEnumerator();
+            enumerators[p].MoveNext();
           } else {
             finished = false;
@@ -688,12 +691,10 @@
       var localExperiment = new Experiment();
 
+      int counter = 0, totalVariations = GetNumberOfVariations();
       if (instances.Count == 0) {
-        var variations = experimentCreationBackgroundWorker_CalculateParameterVariations(optimizer);
-        foreach (var v in variations)
-          AddOptimizer(v, localExperiment);
+        AddParameterVariations(localExperiment, ref counter, totalVariations);
         experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
 
       } else {
-        int counter = 0, totalVariations = GetNumberOfVariations();
         foreach (var provider in instances.Keys) {
           foreach (var descriptor in instances[provider]) {
@@ -714,16 +715,26 @@
             }
             if (!failed) {
-              var variations = experimentCreationBackgroundWorker_CalculateParameterVariations(algorithm);
-              foreach (var v in variations) {
-                AddOptimizer(v, localExperiment);
-                counter++;
-                experimentCreationBackgroundWorker.ReportProgress((int)Math.Round(100.0 * counter / totalVariations), descriptor.Name);
-              }
-            } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round(100.0 * counter / totalVariations), "Loading failed (" + descriptor.Name + ")");
-          }
-        }
-      }
-      if (localExperiment != null) localExperiment.Prepare(true);
+              AddParameterVariations(localExperiment, ref counter, totalVariations);
+            } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
+          }
+        }
+      }
+      if (localExperiment != null) {
+        // this step can take some time
+        SetMode(DialogMode.PreparingExperiment);
+        experimentCreationBackgroundWorker.ReportProgress(-1);
+        localExperiment.Prepare(true);
+        experimentCreationBackgroundWorker.ReportProgress(100);
+      }
       Experiment = localExperiment;
+    }
+
+    private void AddParameterVariations(Experiment localExperiment, ref int counter, int totalVariations) {
+      var variations = experimentCreationBackgroundWorker_CalculateParameterVariations(optimizer);
+      foreach (var v in variations) {
+        AddOptimizer(v, localExperiment);
+        counter++;
+        experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), string.Empty);
+      }
     }
 
@@ -794,7 +805,9 @@
             var originalEnumerator = ((IEnumerable<object>)((dynamic)m.Key).ValidValues).GetEnumerator();
             while (variantEnumerator.MoveNext() && originalEnumerator.MoveNext()) {
-              if (m.Value == (INamedItem)originalEnumerator.Current) {
+              if (m.Value == (IItem)originalEnumerator.Current) {
                 variantParam.Value = (dynamic)variantEnumerator.Current;
-                variant.Name += m.Key.Name + "=" + m.Value.Name + ", ";
+                if (m.Value is INamedItem)
+                  variant.Name += m.Key.Name + "=" + ((INamedItem)m.Value).Name + ", ";
+                else variant.Name += m.Key.Name + "=" + m.Value.ToString() + ", ";
                 break;
               }
@@ -816,5 +829,10 @@
 
     private void experimentCreationBackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
-      experimentCreationProgressBar.Value = e.ProgressPercentage;
+      if (e.ProgressPercentage >= 0 && e.ProgressPercentage <= 100) {
+        experimentCreationProgressBar.Style = ProgressBarStyle.Continuous;
+        experimentCreationProgressBar.Value = e.ProgressPercentage;
+      } else {
+        experimentCreationProgressBar.Style = ProgressBarStyle.Marquee;
+      }
       Application.DoEvents();
     }
