Index: branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs
===================================================================
--- branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs	(revision 13485)
+++ branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs	(revision 13551)
@@ -30,5 +30,5 @@
 using HeuristicLab.MainForm;
 using HeuristicLab.Optimization;
-using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Optimization.Views;
 
 namespace HeuristicLab.OptimizationExpertSystem.Views {
@@ -47,4 +47,8 @@
     public ExpertSystemView() {
       InitializeComponent();
+      // brings progress panel to front (it is not visible by default, but obstructs other elements in designer)
+      this.Controls.SetChildIndex(this.progressPanel, 0);
+      algorithmStartButton.Text = string.Empty;
+      algorithmStartButton.Image = VSImageLibrary.Play;
       refreshMapButton.Text = string.Empty;
       refreshMapButton.Image = VSImageLibrary.Refresh;
@@ -60,5 +64,5 @@
 
     protected override void DeregisterContentEvents() {
-      Content.PropertyChanged -= Content_PropertyChanged;
+      Content.PropertyChanged -= ContentOnPropertyChanged;
       Content.SuggestedInstances.CollectionReset -= SuggestedInstancesOnChanged;
       Content.SuggestedInstances.ItemsAdded -= SuggestedInstancesOnChanged;
@@ -66,9 +70,10 @@
       Content.SuggestedInstances.ItemsRemoved -= SuggestedInstancesOnChanged;
       Content.SuggestedInstances.ItemsReplaced -= SuggestedInstancesOnChanged;
+      if (Content.Problem != null) Content.Problem.ProblemChanged -= ContentOnProblemChanged;
       base.DeregisterContentEvents();
     }
     protected override void RegisterContentEvents() {
       base.RegisterContentEvents();
-      Content.PropertyChanged += Content_PropertyChanged;
+      Content.PropertyChanged += ContentOnPropertyChanged;
       Content.SuggestedInstances.CollectionReset += SuggestedInstancesOnChanged;
       Content.SuggestedInstances.ItemsAdded += SuggestedInstancesOnChanged;
@@ -76,4 +81,5 @@
       Content.SuggestedInstances.ItemsRemoved += SuggestedInstancesOnChanged;
       Content.SuggestedInstances.ItemsReplaced += SuggestedInstancesOnChanged;
+      if (Content.Problem != null) Content.Problem.ProblemChanged += ContentOnProblemChanged;
     }
 
@@ -89,5 +95,5 @@
           algorithmViewHost.Content = null;
           runsView.Content = null;
-          algorithmInstancesViewHost.Content = null;
+          kbViewHost.Content = null;
           problemInstancesView.Content = null;
         } else {
@@ -95,5 +101,6 @@
           problemViewHost.Content = Content.Problem;
           runsView.Content = Content.Runs;
-          algorithmInstancesViewHost.Content = Content.AlgorithmInstances;
+          kbViewHost.ViewType = typeof(RunCollectionRLDView);
+          kbViewHost.Content = Content.KnowledgeBase;
           problemInstancesView.Content = Content.ProblemInstances;
         }
@@ -105,13 +112,13 @@
       base.SetEnabledStateOfControls();
       maxEvaluationsTextBox.Enabled = Content != null && !ReadOnly && !Locked;
-      newProblemButton.Enabled = Content != null && !ReadOnly && !Locked;
-      openProblemButton.Enabled = Content != null && !ReadOnly && !Locked;
-      problemViewHost.Enabled = Content != null && !ReadOnly && !Locked;
-      suggestedInstancesComboBox.Enabled = Content != null && !ReadOnly && !Locked;
+      problemViewHost.Enabled = Content != null && !ReadOnly && !Locked && !okbDownloadInProgress;
+      suggestedInstancesComboBox.Enabled = Content != null && !ReadOnly && !Locked && !okbDownloadInProgress;
+      algorithmStartButton.Enabled = Content != null && !ReadOnly && !Locked && suggestedInstancesComboBox.SelectedIndex >= 0;
       algorithmViewHost.Enabled = Content != null && !ReadOnly && !Locked;
       runsView.Enabled = Content != null;
-      algorithmInstancesViewHost.Enabled = Content != null && !okbDownloadInProgress;
+      kbViewHost.Enabled = Content != null && !okbDownloadInProgress;
+      problemInstancesView.Enabled = Content != null && !okbDownloadInProgress;
       refreshMapButton.Enabled = Content != null;
-      okbDownloadButton.Enabled = Content != null && Content.Problem != null && !ReadOnly && !Locked && !okbDownloadInProgress;
+      okbDownloadButton.Enabled = Content != null && Content.Problem != null && Content.Problem.ProblemId >= 0 && !ReadOnly && !Locked && !okbDownloadInProgress;
     }
 
@@ -134,7 +141,12 @@
     #region Event Handlers
     #region Content events
-    private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
+    private void ContentOnProblemChanged(object sender, EventArgs eventArgs) {
+      UpdateSuggestedInstancesCombobox();
+      SetEnabledStateOfControls();
+    }
+
+    private void ContentOnPropertyChanged(object sender, PropertyChangedEventArgs e) {
       if (InvokeRequired) {
-        Invoke((Action<object, PropertyChangedEventArgs>)Content_PropertyChanged, sender, e);
+        Invoke((Action<object, PropertyChangedEventArgs>)ContentOnPropertyChanged, sender, e);
         return;
       }
@@ -142,7 +154,10 @@
       try {
         switch (e.PropertyName) {
-          case "AlgorithmInstances": algorithmInstancesViewHost.Content = Content.AlgorithmInstances; break;
+          case "KnowledgeBase": kbViewHost.Content = Content.KnowledgeBase; break;
           case "MaximumEvaluations": maxEvaluationsTextBox.Text = Content.MaximumEvaluations.ToString(); break;
-          case "Problem": problemViewHost.Content = Content.Problem; break;
+          case "Problem":
+            problemViewHost.Content = Content.Problem;
+            Content.Problem.ProblemChanged += ContentOnProblemChanged;
+            break;
           case "ProblemInstances": problemInstancesView.Content = Content.ProblemInstances; break;
         }
@@ -172,77 +187,4 @@
         errorProvider.SetError(maxEvaluationsTextBox, null);
       }
-    }
-
-    private void newProblemButton_Click(object sender, EventArgs e) {
-      if (problemTypeSelectorDialog == null) {
-        problemTypeSelectorDialog = new TypeSelectorDialog { Caption = "Select Problem" };
-        problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
-        problemTypeSelectorDialog.TypeSelector.Configure(typeof(ISingleObjectiveHeuristicOptimizationProblem)
-          , showNotInstantiableTypes: false, showGenericTypes: false);
-      }
-      if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
-        try {
-          Content.Problem = (ISingleObjectiveHeuristicOptimizationProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
-        } catch (Exception ex) {
-          ErrorHandling.ShowErrorDialog(this, ex);
-        }
-      }
-    }
-
-    private void openProblemButton_Click(object sender, EventArgs e) {
-      openFileDialog.Title = "Open Problem";
-      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
-        newProblemButton.Enabled = openProblemButton.Enabled = false;
-        problemViewHost.Enabled = false;
-
-        ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
-          try {
-            if (error != null) throw error;
-            var problem = content as ISingleObjectiveHeuristicOptimizationProblem;
-            if (problem == null) {
-              var algorithm = content as IAlgorithm;
-              if (algorithm == null || !(algorithm.Problem is ISingleObjectiveHeuristicOptimizationProblem))
-                MessageBox.Show(this, "The selected file is not a problem, nor an algorithm with a problem.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
-              else Content.Problem = (ISingleObjectiveHeuristicOptimizationProblem)algorithm.Problem;
-            } else
-              Content.Problem = problem;
-          } catch (Exception ex) {
-            ErrorHandling.ShowErrorDialog(this, ex);
-          } finally {
-            Invoke(new Action(delegate() {
-              problemViewHost.Enabled = true;
-              newProblemButton.Enabled = openProblemButton.Enabled = true;
-            }));
-          }
-        });
-      }
-    }
-
-    private void problemTabPage_DragEnterOver(object sender, DragEventArgs e) {
-      e.Effect = DragDropEffects.None;
-      var prob = e.Data.GetData(Constants.DragDropDataFormat) as ISingleObjectiveHeuristicOptimizationProblem;
-      if (!ReadOnly && prob != null) {
-        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
-        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
-        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
-        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
-        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
-      }
-    }
-
-    private void problemTabPage_DragDrop(object sender, DragEventArgs e) {
-      if (e.Effect != DragDropEffects.None) {
-        var prob = e.Data.GetData(Constants.DragDropDataFormat) as ISingleObjectiveHeuristicOptimizationProblem;
-        if (e.Effect.HasFlag(DragDropEffects.Copy)) prob = (ISingleObjectiveHeuristicOptimizationProblem)prob.Clone();
-        Content.Problem = prob;
-      }
-    }
-
-    private void suggestedInstancesComboBox_SelectedIndexChanged(object sender, EventArgs e) {
-      if (SuppressEvents) return;
-      if (InvokeRequired) { Invoke((Action<object, EventArgs>)suggestedInstancesComboBox_SelectedIndexChanged, sender, e); return; }
-      if (suggestedInstancesComboBox.SelectedIndex >= 0)
-        algorithmViewHost.Content = (IAlgorithm)suggestedInstancesComboBox.SelectedItem;
-      else algorithmViewHost.Content = null;
     }
     #endregion
@@ -290,4 +232,8 @@
 
     private void okbDownloadButton_Click(object sender, EventArgs e) {
+      if (Content.Problem.ProblemId < 0) {
+        MessageBox.Show("Please select a problem instance first.");
+        return;
+      }
       var progress = new Progress();
       progress.ProgressStateChanged += OkbDownloadProgressOnStateChanged;
@@ -307,4 +253,12 @@
       }
     }
+
+    private void algorithmStartButton_Click(object sender, EventArgs e) {
+      var selectedInstance = (IAlgorithm)suggestedInstancesComboBox.SelectedItem;
+      var clone = (IAlgorithm)selectedInstance.Clone();
+      clone.Prepare(true);
+      clone.Start();
+      algorithmViewHost.Content = clone.Results;
+    }
   }
 }
