Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs	(revision 1042)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs	(revision 1043)
@@ -45,5 +45,16 @@
     private Problem problem;
     public Problem Problem {
-      get { return problem; }
+      get {
+        // lazy loading of problem from DB
+        if (problem == null) {
+          IList<Statement> persistedData = Store.Select(new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, Ontology.AnyEntity));
+          if (persistedData.Count == 1) {
+            Literal persistedLiteral = (Literal)persistedData[0].Property;
+            this.problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value));
+          } else
+            this.problem = new Problem(); // no entry in the DB => create a new problem
+        }
+        return problem; 
+      }
     }
 
@@ -52,5 +63,4 @@
       guid = Guid.NewGuid();
       name = "Data set";
-      problem = new Problem();
     }
 
@@ -60,5 +70,5 @@
       guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length));
       IList<Statement> names = store.Select(new Statement(dataSetEntity, Ontology.PredicateName, Ontology.AnyEntity));
-      if(names.Count > 0) name = (string)((Literal)names[0].Property).Value;
+      if (names.Count > 0) name = (string)((Literal)names[0].Property).Value;
       else name = guid.ToString();
     }
@@ -67,5 +77,5 @@
       Entity myEntity = new Entity(Ontology.CedmaNameSpace + Guid);
       Store.Add(new Statement(myEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
-      Store.Add(new Statement(myEntity, Ontology.PredicateSerializedData, new Literal(PersistenceManager.SaveToGZip(problem))));
+      Store.Add(new Statement(myEntity, Ontology.PredicateSerializedData, new Literal(Convert.ToBase64String(PersistenceManager.SaveToGZip(problem)))));
       Store.Add(new Statement(myEntity, Ontology.PredicateName, new Literal(name)));
     }
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.cs	(revision 1042)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.cs	(revision 1043)
@@ -47,5 +47,6 @@
 
     void dataSetList_Changed(object sender, EventArgs e) {
-      UpdateControls();
+      if (InvokeRequired) Invoke((EventHandler)dataSetList_Changed, sender, e);
+      else UpdateControls();
     }
 
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Problem.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Problem.cs	(revision 1042)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Problem.cs	(revision 1043)
@@ -30,4 +30,12 @@
 
 namespace HeuristicLab.CEDMA.Core {
+
+  public enum LearningTask {
+    Classification,
+    Regression,
+    TimeSeries,
+    Clustering
+  }
+
   /// <summary>
   /// Problem describes the data mining task.
@@ -59,11 +67,10 @@
 
     private int validationSamplesStart;
-
     public int ValidationSamplesStart {
       get { return validationSamplesStart; }
       set { validationSamplesStart = value; }
     }
+
     private int validationSamplesEnd;
-
     public int ValidationSamplesEnd {
       get { return validationSamplesEnd; }
@@ -72,11 +79,10 @@
 
     private int testSamplesStart;
-
     public int TestSamplesStart {
       get { return testSamplesStart; }
       set { testSamplesStart = value; }
     }
+
     private int testSamplesEnd;
-
     public int TestSamplesEnd {
       get { return testSamplesEnd; }
@@ -95,5 +101,4 @@
 
     private bool autoRegressive;
-
     public bool AutoRegressive {
       get { return autoRegressive; }
@@ -101,9 +106,8 @@
     }
 
-    private bool timeSeries;
-
-    public bool TimeSeries {
-      get { return timeSeries; }
-      set { timeSeries = value; }
+    private LearningTask learningTask;
+    public LearningTask LearningTask {
+      get { return learningTask; }
+      set { learningTask = value; }
     }
 
@@ -118,4 +122,70 @@
       return new ProblemView(this);
     }
+
+    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
+      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
+      node.AppendChild(PersistenceManager.Persist("DataSet", dataset, document, persistedObjects));
+      XmlAttribute trainingSamplesStartAttr = document.CreateAttribute("TrainingSamplesStart");
+      trainingSamplesStartAttr.Value = TrainingSamplesStart.ToString();
+      XmlAttribute trainingSamplesEndAttr = document.CreateAttribute("TrainingSamplesEnd");
+      trainingSamplesEndAttr.Value = TrainingSamplesEnd.ToString();
+      XmlAttribute validationSamplesStartAttr = document.CreateAttribute("ValidationSamplesStart");
+      validationSamplesStartAttr.Value = ValidationSamplesStart.ToString();
+      XmlAttribute validationSamplesEndAttr = document.CreateAttribute("ValidationSamplesEnd");
+      validationSamplesEndAttr.Value = ValidationSamplesEnd.ToString();
+      XmlAttribute testSamplesStartAttr = document.CreateAttribute("TestSamplesStart");
+      testSamplesStartAttr.Value = TestSamplesStart.ToString();
+      XmlAttribute testSamplesEndAttr = document.CreateAttribute("TestSamplesEnd");
+      testSamplesEndAttr.Value = TestSamplesEnd.ToString();
+      XmlAttribute learningTaskAttr = document.CreateAttribute("LearningTask");
+      learningTaskAttr.Value = LearningTask.ToString();
+      XmlAttribute autoRegressiveAttr = document.CreateAttribute("AutoRegressive");
+      autoRegressiveAttr.Value = AutoRegressive.ToString();
+
+      node.Attributes.Append(trainingSamplesStartAttr);
+      node.Attributes.Append(trainingSamplesEndAttr);
+      node.Attributes.Append(validationSamplesStartAttr);
+      node.Attributes.Append(validationSamplesEndAttr);
+      node.Attributes.Append(testSamplesStartAttr);
+      node.Attributes.Append(testSamplesEndAttr);
+      node.Attributes.Append(learningTaskAttr);
+      node.Attributes.Append(autoRegressiveAttr);
+
+      XmlElement targetVariablesElement = document.CreateElement("AllowedTargetVariables");
+      targetVariablesElement.InnerText = SemiColonSeparatedList(AllowedTargetVariables);
+      XmlElement inputVariablesElement = document.CreateElement("AllowedInputVariables");
+      inputVariablesElement.InnerText = SemiColonSeparatedList(AllowedInputVariables);
+      node.AppendChild(targetVariablesElement);
+      node.AppendChild(inputVariablesElement);
+      return node;
+    }
+
+    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
+      base.Populate(node, restoredObjects);
+      dataset = (HeuristicLab.DataAnalysis.Dataset)PersistenceManager.Restore(node.SelectSingleNode("DataSet"), restoredObjects);
+      TrainingSamplesStart = int.Parse(node.Attributes["TrainingSamplesStart"].Value);
+      TrainingSamplesEnd = int.Parse(node.Attributes["TrainingSamplesEnd"].Value);
+      ValidationSamplesStart = int.Parse(node.Attributes["ValidationSamplesStart"].Value);
+      ValidationSamplesEnd = int.Parse(node.Attributes["ValidationSamplesEnd"].Value);
+      TestSamplesStart = int.Parse(node.Attributes["TestSamplesStart"].Value);
+      TestSamplesEnd = int.Parse(node.Attributes["TestSamplesEnd"].Value);
+      LearningTask = (LearningTask)Enum.Parse(typeof(LearningTask), node.Attributes["LearningTask"].Value);
+      AutoRegressive = bool.Parse(node.Attributes["AutoRegressive"].Value);
+      allowedTargetVariables.Clear();
+      foreach (string tok in node.SelectSingleNode("AllowedTargetVariables").InnerText.Split(new string[]{";"}, StringSplitOptions.RemoveEmptyEntries))
+        allowedTargetVariables.Add(int.Parse(tok));
+      allowedInputVariables.Clear();
+      foreach (string tok in node.SelectSingleNode("AllowedInputVariables").InnerText.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
+        allowedInputVariables.Add(int.Parse(tok));
+    }
+
+    private string SemiColonSeparatedList(List<int> xs) {
+      StringBuilder b = new StringBuilder();
+      foreach (int x in xs) {
+        b = b.Append(x).Append(";");
+      }
+      if (xs.Count > 0) b.Remove(b.Length - 1, 1); // remove last ';'
+      return b.ToString();
+    }
   }
 }
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs	(revision 1042)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs	(revision 1043)
@@ -62,4 +62,6 @@
       this.partitioningGroupBox = new System.Windows.Forms.GroupBox();
       this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
+      this.modelType = new System.Windows.Forms.ComboBox();
+      this.taskLabel = new System.Windows.Forms.Label();
       this.targetsGroupBox.SuspendLayout();
       this.inputsGroupBox.SuspendLayout();
@@ -168,5 +170,5 @@
       this.datasetView.Location = new System.Drawing.Point(3, 32);
       this.datasetView.Name = "datasetView";
-      this.datasetView.Size = new System.Drawing.Size(326, 230);
+      this.datasetView.Size = new System.Drawing.Size(326, 176);
       this.datasetView.TabIndex = 17;
       // 
@@ -200,5 +202,5 @@
       this.autoregressiveCheckBox.AutoSize = true;
       this.autoregressiveCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
-      this.autoregressiveCheckBox.Location = new System.Drawing.Point(3, 480);
+      this.autoregressiveCheckBox.Location = new System.Drawing.Point(215, 424);
       this.autoregressiveCheckBox.Name = "autoregressiveCheckBox";
       this.autoregressiveCheckBox.Size = new System.Drawing.Size(102, 17);
@@ -212,5 +214,5 @@
       this.targetsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
       this.targetsGroupBox.Controls.Add(this.targetsListBox);
-      this.targetsGroupBox.Location = new System.Drawing.Point(3, 374);
+      this.targetsGroupBox.Location = new System.Drawing.Point(3, 320);
       this.targetsGroupBox.Name = "targetsGroupBox";
       this.targetsGroupBox.Size = new System.Drawing.Size(167, 100);
@@ -223,5 +225,5 @@
       this.inputsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
       this.inputsGroupBox.Controls.Add(this.inputsListBox);
-      this.inputsGroupBox.Location = new System.Drawing.Point(176, 374);
+      this.inputsGroupBox.Location = new System.Drawing.Point(176, 320);
       this.inputsGroupBox.Name = "inputsGroupBox";
       this.inputsGroupBox.Size = new System.Drawing.Size(153, 100);
@@ -242,5 +244,5 @@
       this.partitioningGroupBox.Controls.Add(this.testSamplesStartTextBox);
       this.partitioningGroupBox.Controls.Add(this.testLabel);
-      this.partitioningGroupBox.Location = new System.Drawing.Point(3, 268);
+      this.partitioningGroupBox.Location = new System.Drawing.Point(3, 214);
       this.partitioningGroupBox.Name = "partitioningGroupBox";
       this.partitioningGroupBox.Size = new System.Drawing.Size(326, 100);
@@ -256,8 +258,30 @@
       this.openFileDialog.Title = "Import data set from file";
       // 
+      // modelType
+      // 
+      this.modelType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+      this.modelType.FormattingEnabled = true;
+      this.modelType.Location = new System.Drawing.Point(88, 422);
+      this.modelType.Name = "modelType";
+      this.modelType.Size = new System.Drawing.Size(121, 21);
+      this.modelType.TabIndex = 26;
+      this.modelType.SelectedValueChanged += new System.EventHandler(this.modelType_SelectedValueChanged);
+      // 
+      // taskLabel
+      // 
+      this.taskLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+      this.taskLabel.AutoSize = true;
+      this.taskLabel.Location = new System.Drawing.Point(8, 425);
+      this.taskLabel.Name = "taskLabel";
+      this.taskLabel.Size = new System.Drawing.Size(74, 13);
+      this.taskLabel.TabIndex = 27;
+      this.taskLabel.Text = "Learning task:";
+      // 
       // ProblemView
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.Controls.Add(this.taskLabel);
+      this.Controls.Add(this.modelType);
       this.Controls.Add(this.partitioningGroupBox);
       this.Controls.Add(this.inputsGroupBox);
@@ -267,5 +291,5 @@
       this.Controls.Add(this.importButton);
       this.Name = "ProblemView";
-      this.Size = new System.Drawing.Size(337, 500);
+      this.Size = new System.Drawing.Size(337, 446);
       this.targetsGroupBox.ResumeLayout(false);
       this.inputsGroupBox.ResumeLayout(false);
@@ -297,4 +321,6 @@
     private System.Windows.Forms.GroupBox partitioningGroupBox;
     private System.Windows.Forms.OpenFileDialog openFileDialog;
+    private System.Windows.Forms.ComboBox modelType;
+    private System.Windows.Forms.Label taskLabel;
   }
 }
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.cs	(revision 1042)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.cs	(revision 1043)
@@ -39,8 +39,13 @@
       this.problem = problem;
       InitializeComponent();
+      foreach (LearningTask l in Enum.GetValues(typeof(LearningTask))) {
+        modelType.Items.Add(l);
+      }
+      UpdateControls();
     }
 
     protected override void UpdateControls() {
       base.UpdateControls();
+      datasetView.Dataset = problem.DataSet;
       trainingSamplesStartTextBox.Text = problem.TrainingSamplesStart.ToString();
       trainingSamplesEndTextBox.Text = problem.TrainingSamplesEnd.ToString();
@@ -49,4 +54,11 @@
       testSamplesStartTextBox.Text = problem.TestSamplesStart.ToString();
       testSamplesEndTextBox.Text = problem.TestSamplesEnd.ToString();
+      autoregressiveCheckBox.Checked = problem.AutoRegressive;
+      for (int i = 0; i < modelType.Items.Count; i++) {
+        if ((LearningTask)modelType.Items[i] == problem.LearningTask) {
+          modelType.SelectedIndex = i;
+          break;
+        }
+      }
       targetsListBox.Items.Clear();
       inputsListBox.Items.Clear();
@@ -105,26 +117,4 @@
       }
 
-    }
-    private void ShowWarningMessageBox(Exception ex) {
-      MessageBox.Show(ex.Message,
-                      "Warning - " + ex.GetType().Name,
-                      MessageBoxButtons.OK,
-                      MessageBoxIcon.Warning);
-    }
-    private void ShowErrorMessageBox(Exception ex) {
-      MessageBox.Show(BuildErrorMessage(ex),
-                      "Error - " + ex.GetType().Name,
-                      MessageBoxButtons.OK,
-                      MessageBoxIcon.Error);
-    }
-    private string BuildErrorMessage(Exception ex) {
-      StringBuilder sb = new StringBuilder();
-      sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
-
-      while (ex.InnerException != null) {
-        ex = ex.InnerException;
-        sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
-      }
-      return sb.ToString();
     }
 
@@ -204,4 +194,32 @@
       return y0 > x1;
     }
+    private void ShowWarningMessageBox(Exception ex) {
+      MessageBox.Show(ex.Message,
+                      "Warning - " + ex.GetType().Name,
+                      MessageBoxButtons.OK,
+                      MessageBoxIcon.Warning);
+    }
+    private void ShowErrorMessageBox(Exception ex) {
+      MessageBox.Show(BuildErrorMessage(ex),
+                      "Error - " + ex.GetType().Name,
+                      MessageBoxButtons.OK,
+                      MessageBoxIcon.Error);
+    }
+    private string BuildErrorMessage(Exception ex) {
+      StringBuilder sb = new StringBuilder();
+      sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
+
+      while (ex.InnerException != null) {
+        ex = ex.InnerException;
+        sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
+      }
+      return sb.ToString();
+    }
+
+    private void modelType_SelectedValueChanged(object sender, EventArgs e) {
+      if ((LearningTask)modelType.SelectedItem == LearningTask.TimeSeries) autoregressiveCheckBox.Enabled = true;
+      else autoregressiveCheckBox.Enabled = false;
+      problem.LearningTask = (LearningTask)modelType.SelectedItem;
+    }
   }
 }
