Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs	(revision 16386)
@@ -116,17 +116,5 @@
 
     public ModifiableDataset ToModifiable() {
-      var values = new List<IList>();
-      foreach (var v in variableNames) {
-        if (VariableHasType<double>(v)) {
-          values.Add(new List<double>((IList<double>)variableValues[v]));
-        } else if (VariableHasType<string>(v)) {
-          values.Add(new List<string>((IList<string>)variableValues[v]));
-        } else if (VariableHasType<DateTime>(v)) {
-          values.Add(new List<DateTime>((IList<DateTime>)variableValues[v]));
-        } else {
-          throw new ArgumentException("Unknown variable type.");
-        }
-      }
-      return new ModifiableDataset(variableNames, values);
+      return new ModifiableDataset(variableNames, variableNames.Select(v => variableValues[v]), true);
     }
 
@@ -141,5 +129,5 @@
     }
 
-    protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { }
+
 
     #region Backwards compatible code, remove with 3.5
@@ -179,4 +167,8 @@
       }
     }
+
+    public bool ContainsVariable(string variableName) {
+      return variableValues.ContainsKey(variableName);
+    }
     public IEnumerable<string> DoubleVariables {
       get { return variableValues.Where(p => p.Value is IList<double>).Select(p => p.Key); }
@@ -318,7 +310,8 @@
     #region IStringConvertibleMatrix Members
     [Storable]
-    protected int rows;
+    private int rows;
     public int Rows {
       get { return rows; }
+      protected set { rows = value; }
     }
     int IStringConvertibleMatrix.Rows {
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs	(revision 16386)
@@ -66,4 +66,32 @@
     public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
 
+    public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) {
+      return IsProblemDataCompatible(this, problemData, out errorMessage);
+    }
+
+    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
+      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
+      var classificationProblemData = problemData as IClassificationProblemData;
+      if (classificationProblemData == null)
+        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
+      return IsProblemDataCompatible(classificationProblemData, out errorMessage);
+    }
+
+    public static bool IsProblemDataCompatible(IClassificationModel model, IClassificationProblemData problemData, out string errorMessage) {
+      if (model == null) throw new ArgumentNullException("model", "The provided model is null.");
+      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
+      errorMessage = string.Empty;
+
+      if (model.TargetVariable != problemData.TargetVariable)
+        errorMessage = string.Format("The target variable of the model {0} does not match the target variable of the problemData {1}.", model.TargetVariable, problemData.TargetVariable);
+
+      var evaluationErrorMessage = string.Empty;
+      var datasetCompatible = model.IsDatasetCompatible(problemData.Dataset, out evaluationErrorMessage);
+      if (!datasetCompatible)
+        errorMessage += evaluationErrorMessage;
+
+      return string.IsNullOrEmpty(errorMessage);
+    }
+
     #region events
     public event EventHandler TargetVariableChanged;
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs	(revision 16386)
@@ -467,53 +467,4 @@
     }
     #endregion
-
-    protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
-      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
-      IClassificationProblemData classificationProblemData = problemData as IClassificationProblemData;
-      if (classificationProblemData == null)
-        throw new ArgumentException("The problem data is no classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      var returnValue = base.IsProblemDataCompatible(classificationProblemData, out errorMessage);
-      //check targetVariable
-      if (classificationProblemData.InputVariables.All(var => var.Value != TargetVariable)) {
-        errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)
-                       + Environment.NewLine + errorMessage;
-        return false;
-      }
-
-      var newClassValues = classificationProblemData.Dataset.GetDoubleValues(TargetVariable).Distinct().OrderBy(x => x);
-      if (!newClassValues.SequenceEqual(ClassValues)) {
-        errorMessage = errorMessage + string.Format("The class values differ in the provided classification problem data.");
-        returnValue = false;
-      }
-
-      var newPositivieClassName = classificationProblemData.PositiveClass;
-      if (newPositivieClassName != PositiveClass) {
-        errorMessage = errorMessage + string.Format("The positive class differs in the provided classification problem data.");
-        returnValue = false;
-      }
-
-      return returnValue;
-    }
-
-    public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
-      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
-      ClassificationProblemData classificationProblemData = problemData as ClassificationProblemData;
-      if (classificationProblemData == null)
-        throw new ArgumentException("The problem data is not a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      base.AdjustProblemDataProperties(problemData);
-      TargetVariable = classificationProblemData.TargetVariable;
-      for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)
-        ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
-
-      PositiveClass = classificationProblemData.PositiveClass;
-
-      for (int i = 0; i < Classes; i++) {
-        for (int j = 0; j < Classes; j++) {
-          ClassificationPenaltiesParameter.Value[i, j] = classificationProblemData.GetClassificationPenalty(ClassValuesCache[i], ClassValuesCache[j]);
-        }
-      }
-    }
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs	(revision 16386)
@@ -20,4 +20,5 @@
 #endregion
 
+using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -44,5 +45,11 @@
     public new IClassificationProblemData ProblemData {
       get { return (IClassificationProblemData)base.ProblemData; }
-      set { base.ProblemData = value; }
+      set {
+        if (value == null) throw new ArgumentNullException("The problemData must not be null.");
+        string errorMessage = string.Empty;
+        if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage);
+
+        base.ProblemData = value;
+      }
     }
 
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/ConstantModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/ConstantModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/ConstantModel.cs	(revision 16386)
@@ -83,4 +83,22 @@
     }
 
+    public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) {
+      return ClassificationModel.IsProblemDataCompatible(this, problemData, out errorMessage);
+    }
+
+    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
+      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
+
+      var regressionProblemData = problemData as IRegressionProblemData;
+      if (regressionProblemData != null)
+        return IsProblemDataCompatible(regressionProblemData, out errorMessage);
+
+      var classificationProblemData = problemData as IClassificationProblemData;
+      if (classificationProblemData != null)
+        return IsProblemDataCompatible(classificationProblemData, out errorMessage);
+
+      throw new ArgumentException("The problem data is not a regression nor a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
+    }
+
     #region IStringConvertibleValue
     public bool ReadOnly { get; private set; }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisModel.cs	(revision 16386)
@@ -20,4 +20,5 @@
 #endregion
 
+using System;
 using System.Collections.Generic;
 using HeuristicLab.Common;
@@ -38,4 +39,28 @@
 
     public abstract IEnumerable<string> VariablesUsedForPrediction { get; }
+
+    public virtual bool IsDatasetCompatible(IDataset dataset, out string errorMessage) {
+      if (dataset == null) throw new ArgumentNullException("dataset", "The provided dataset is null.");
+      return IsDatasetCompatible(this, dataset, out errorMessage);
+    }
+
+    public abstract bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage);
+
+    public static bool IsDatasetCompatible(IDataAnalysisModel model, IDataset dataset, out string errorMessage) {
+      if(model == null) throw new ArgumentNullException("model", "The provided model is null.");
+      if (dataset == null) throw new ArgumentNullException("dataset", "The provided dataset is null.");
+      errorMessage = string.Empty;
+
+      foreach (var variable in model.VariablesUsedForPrediction) {
+        if (!dataset.ContainsVariable(variable)) {
+          if (string.IsNullOrEmpty(errorMessage)) {
+            errorMessage = "The following variables must be present in the dataset for model evaluation:";
+          }
+          errorMessage += System.Environment.NewLine + " " + variable;
+        }
+      }
+
+      return string.IsNullOrEmpty(errorMessage);
+    }
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs	(revision 16386)
@@ -163,5 +163,5 @@
 
       var variables = dataset.VariableNames.Where(variable => dataset.VariableHasType<double>(variable) || dataset.VariableHasType<string>(variable));
-      var inputVariables = new CheckedItemList<StringValue>(variables.Select(x => new StringValue(x)));
+      var inputVariables = new CheckedItemList<StringValue>(variables.Select(x => new StringValue(x).AsReadOnly()));
       foreach (StringValue x in inputVariables)
         inputVariables.SetItemCheckedState(x, allowedInputVariables.Contains(x.Value));
@@ -207,39 +207,4 @@
       if (listeners != null) listeners(this, EventArgs.Empty);
     }
-
-    protected virtual bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
-      errorMessage = string.Empty;
-      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
-
-      //check allowed input variables
-      StringBuilder message = new StringBuilder();
-      var variables = new HashSet<string>(problemData.InputVariables.Select(x => x.Value));
-      foreach (var item in AllowedInputVariables) {
-        if (!variables.Contains(item))
-          message.AppendLine("Input variable '" + item + "' is not present in the new problem data.");
-      }
-
-      if (message.Length != 0) {
-        errorMessage = message.ToString();
-        return false;
-      }
-      return true;
-
-    }
-
-    public virtual void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
-      DataAnalysisProblemData data = problemData as DataAnalysisProblemData;
-      if (data == null) throw new ArgumentException("The problem data is not a data analysis problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      string errorMessage;
-      if (!data.IsProblemDataCompatible(this, out errorMessage)) {
-        throw new InvalidOperationException(errorMessage);
-      }
-
-      foreach (var inputVariable in InputVariables) {
-        var variable = data.InputVariables.FirstOrDefault(i => i.Value == inputVariable.Value);
-        InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable));
-      }
-    }
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs	(revision 16386)
@@ -58,12 +58,13 @@
       get { return (IDataAnalysisProblemData)this[ProblemDataResultName].Value; }
       set {
-        if (this[ProblemDataResultName].Value != value) {
-          if (value != null) {
-            ProblemData.Changed -= new EventHandler(ProblemData_Changed);
-            this[ProblemDataResultName].Value = value;
-            ProblemData.Changed += new EventHandler(ProblemData_Changed);
-            OnProblemDataChanged();
-          }
-        }
+        if (value == null) throw new ArgumentNullException("The problemData must not be null.");
+        if (this[ProblemDataResultName].Value == value) return;
+        string errorMessage = string.Empty;
+        if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage);
+
+        ProblemData.Changed -= new EventHandler(ProblemData_Changed);
+        this[ProblemDataResultName].Value = value;
+        ProblemData.Changed += new EventHandler(ProblemData_Changed);
+        OnProblemDataChanged();
       }
     }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionModel.cs	(revision 16386)
@@ -67,4 +67,32 @@
     public abstract IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData);
 
+    public virtual bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) {
+      return IsProblemDataCompatible(this, problemData, out errorMessage);
+    }
+
+    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
+      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
+      var regressionProblemData = problemData as IRegressionProblemData;
+      if (regressionProblemData == null)
+        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
+      return IsProblemDataCompatible(regressionProblemData, out errorMessage);
+    }
+
+    public static bool IsProblemDataCompatible(IRegressionModel model, IRegressionProblemData problemData, out string errorMessage) {
+      if (model == null) throw new ArgumentNullException("model", "The provided model is null.");
+      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
+      errorMessage = string.Empty;
+
+      if (model.TargetVariable != problemData.TargetVariable)
+        errorMessage = string.Format("The target variable of the model {0} does not match the target variable of the problemData {1}.", model.TargetVariable, problemData.TargetVariable);
+
+      var evaluationErrorMessage = string.Empty;
+      var datasetCompatible = model.IsDatasetCompatible(problemData.Dataset, out evaluationErrorMessage);
+      if (!datasetCompatible)
+        errorMessage += evaluationErrorMessage;
+
+      return string.IsNullOrEmpty(errorMessage);
+    }
+
     #region events
     public event EventHandler TargetVariableChanged;
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs	(revision 16386)
@@ -161,23 +161,4 @@
       OnChanged();
     }
-
-    protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
-      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
-      IRegressionProblemData regressionProblemData = problemData as IRegressionProblemData;
-      if (regressionProblemData == null)
-        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      var returnValue = base.IsProblemDataCompatible(problemData, out errorMessage);
-      return returnValue;
-    }
-
-    public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
-      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
-      RegressionProblemData regressionProblemData = problemData as RegressionProblemData;
-      if (regressionProblemData == null)
-        throw new ArgumentException("The problem data is not a regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      base.AdjustProblemDataProperties(problemData);
-    }
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs	(revision 16386)
@@ -70,5 +70,11 @@
     public new IRegressionProblemData ProblemData {
       get { return (IRegressionProblemData)base.ProblemData; }
-      set { base.ProblemData = value; }
+      set {
+        if (value == null) throw new ArgumentNullException("The problemData must not be null.");
+        string errorMessage = string.Empty;
+        if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage);
+
+        base.ProblemData = value;
+      }
     }
 
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs	(revision 16386)
@@ -1620,36 +1620,4 @@
       OnChanged();
     }
-
-    protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
-      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
-      ITimeSeriesPrognosisProblemData timeseriesProblemData = problemData as ITimeSeriesPrognosisProblemData;
-      if (timeseriesProblemData == null)
-        throw new ArgumentException("The problem data is not a time-series problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      var returnValue = base.IsProblemDataCompatible(problemData, out errorMessage);
-      //check targetVariable
-      if (problemData.InputVariables.All(var => var.Value != TargetVariable)) {
-        errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)
-                       + Environment.NewLine + errorMessage;
-        return false;
-      }
-      return returnValue;
-    }
-
-    public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
-      TimeSeriesPrognosisProblemData timeSeriesProblemData = problemData as TimeSeriesPrognosisProblemData;
-      if (timeSeriesProblemData == null)
-        throw new ArgumentException("The problem data is not a timeseries problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
-
-      var trainingDataStart = TrainingIndices.First();
-
-      base.AdjustProblemDataProperties(problemData);
-
-      TestPartition.Start = trainingDataStart;
-
-      TrainingHorizon = timeSeriesProblemData.TrainingHorizon;
-      TestHorizon = timeSeriesProblemData.TestHorizon;
-    }
-
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationModel.cs	(revision 16386)
@@ -31,4 +31,5 @@
     IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows);
     IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
+    bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage);
     string TargetVariable { get; set; }
     event EventHandler TargetVariableChanged;
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs	(revision 16386)
@@ -30,4 +30,6 @@
   public interface IDataAnalysisModel : INamedItem {
     IEnumerable<string> VariablesUsedForPrediction { get; }
+    bool IsDatasetCompatible(IDataset dataset, out string errorMessage);
+    bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage);
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs	(revision 16386)
@@ -49,6 +49,4 @@
 
     event EventHandler Changed;
-
-    void AdjustProblemDataProperties(IDataAnalysisProblemData problemData);
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataset.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataset.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataset.cs	(revision 16386)
@@ -33,4 +33,5 @@
     IEnumerable<string> DateTimeVariables { get; }
 
+    bool ContainsVariable(string variablename);
     bool VariableHasType<T>(string variableName);
 
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionModel.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionModel.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionModel.cs	(revision 16386)
@@ -31,4 +31,5 @@
     IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows);
     IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData);
+    bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage);
     string TargetVariable { get; set; }
     event EventHandler TargetVariableChanged;
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs	(revision 15962)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs	(revision 16386)
@@ -47,6 +47,37 @@
     public ModifiableDataset() { }
 
-    public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues) :
-      base(variableNames, variableValues, cloneValues: false) { }
+    public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues, bool cloneValues = false) :
+      base(variableNames, variableValues, cloneValues) { }
+
+    public Dataset ToDataset() {
+      return new Dataset(variableNames, variableNames.Select(v => variableValues[v]));
+    }
+
+
+    public IEnumerable<object> GetRow(int row) {
+      if (row < 0 || row >= Rows)
+        throw new ArgumentException(string.Format("Invalid row {0} specified. The dataset contains {1} row(s).", row, Rows));
+
+      return variableValues.Select(x => x.Value[row]);
+    }
+
+    public void AddRow(IEnumerable<object> values) {
+      var list = values.ToList();
+      if (list.Count != variableNames.Count)
+        throw new ArgumentException("The number of values must be equal to the number of variable names.");
+      // check if all the values are of the correct type
+      for (int i = 0; i < list.Count; ++i) {
+        if (list[i].GetType() != GetVariableType(variableNames[i])) {
+          throw new ArgumentException("The type of the provided value does not match the variable type.");
+        }
+      }
+      // add values
+      for (int i = 0; i < list.Count; ++i) {
+        variableValues[variableNames[i]].Add(list[i]);
+      }
+      Rows++;
+      OnRowsChanged();
+      OnReset();
+    }
 
     public void ReplaceRow(int row, IEnumerable<object> values) {
@@ -64,4 +95,42 @@
         variableValues[variableNames[i]][row] = list[i];
       }
+      OnReset();
+    }
+
+    // slow, avoid using this
+    public void RemoveRow(int row) {
+      foreach (var list in variableValues.Values)
+        list.RemoveAt(row);
+      Rows--;
+      OnRowsChanged();
+      OnReset();
+    }
+
+    // adds a new variable to the dataset
+    public void AddVariable(string variableName, IList values) {
+      InsertVariable(variableName, Columns, values);
+    }
+
+    public void InsertVariable(string variableName, int position, IList values) {
+      if (variableValues.ContainsKey(variableName))
+        throw new ArgumentException(string.Format("Variable {0} is already present in the dataset.", variableName));
+
+      if (position < 0 || position > Columns)
+        throw new ArgumentException(string.Format("Incorrect position {0} specified. The position must be between 0 and {1}.", position, Columns));
+
+      if (values == null)
+        throw new ArgumentNullException("values", "Values must not be null. At least an empty list of values has to be provided.");
+
+      if (values.Count != Rows)
+        throw new ArgumentException(string.Format("{0} values are provided, but {1} rows are present in the dataset.", values.Count, Rows));
+
+      if (!IsAllowedType(values))
+        throw new ArgumentException(string.Format("Unsupported type {0} for variable {1}.", GetElementType(values), variableName));
+
+      variableNames.Insert(position, variableName);
+      variableValues[variableName] = values;
+
+      OnColumnsChanged();
+      OnColumnNamesChanged();
       OnReset();
     }
@@ -77,41 +146,4 @@
     }
 
-    public void AddRow(IEnumerable<object> values) {
-      var list = values.ToList();
-      if (list.Count != variableNames.Count)
-        throw new ArgumentException("The number of values must be equal to the number of variable names.");
-      // check if all the values are of the correct type
-      for (int i = 0; i < list.Count; ++i) {
-        if (list[i].GetType() != GetVariableType(variableNames[i])) {
-          throw new ArgumentException("The type of the provided value does not match the variable type.");
-        }
-      }
-      // add values
-      for (int i = 0; i < list.Count; ++i) {
-        variableValues[variableNames[i]].Add(list[i]);
-      }
-      rows++;
-      OnRowsChanged();
-      OnReset();
-    }
-
-    // adds a new variable to the dataset
-    public void AddVariable(string variableName, IList values) {
-      if (variableValues.ContainsKey(variableName))
-        throw new ArgumentException(string.Format("Variable {0} is already present in the dataset.", variableName));
-
-      if (values == null || values.Count == 0)
-        throw new ArgumentException("Cannot add variable with no values.");
-
-      if (!IsAllowedType(values))
-        throw new ArgumentException(string.Format("Unsupported type {0} for variable {1}.", GetElementType(values), variableName));
-
-      variableValues[variableName] = values;
-      variableNames.Add(variableName);
-
-      OnColumnsChanged();
-      OnColumnNamesChanged();
-      OnReset();
-    }
 
     public void RemoveVariable(string variableName) {
@@ -125,12 +157,13 @@
     }
 
-    // slow, avoid using this
-    public void RemoveRow(int row) {
-      foreach (var list in variableValues.Values)
-        list.RemoveAt(row);
-      rows--;
+    public void ClearValues() {
+      foreach (var list in variableValues.Values) {
+        list.Clear();
+      }
+      Rows = 0;
       OnRowsChanged();
       OnReset();
     }
+
 
     public void SetVariableValue(object value, string variableName, int row) {
