Index: /trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs
===================================================================
--- /trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs	(revision 2541)
+++ /trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs	(revision 2542)
@@ -57,5 +57,18 @@
       int minTimeOffset = minTimeOffsetData == null ? 0 : minTimeOffsetData.Data;
 
-      List<int> allowedColumns = CalculateAllowedColumns(dataset, targetVariableIndex, start, end);
+      IFunctionTree tree = CreateModel(dataset, targetVariable, dataset.VariableNames, start, end, minTimeOffset, maxTimeOffset);
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), new GeneticProgrammingModel(tree)));
+      return null;
+    }
+
+    public static IFunctionTree CreateModel(Dataset dataset, string targetVariable, IEnumerable<string> inputVariables, int start, int end) {
+      return CreateModel(dataset, targetVariable, inputVariables, start, end, 0, 0);
+    }
+
+    public static IFunctionTree CreateModel(Dataset dataset, string targetVariable, IEnumerable<string> inputVariables,
+        int start, int end,
+        int minTimeOffset, int maxTimeOffset) {
+      int targetVariableIndex = dataset.GetVariableIndex(targetVariable);
+      List<int> allowedColumns = CalculateAllowedColumns(dataset, targetVariableIndex, inputVariables.Select(x => dataset.GetVariableIndex(x)), start, end);
       List<int> allowedRows = CalculateAllowedRows(dataset, targetVariableIndex, allowedColumns, start, end, minTimeOffset, maxTimeOffset);
 
@@ -63,11 +76,8 @@
       double[] targetVector = PrepareTargetVector(dataset, targetVariableIndex, allowedRows);
       double[] coefficients = CalculateCoefficients(inputMatrix, targetVector);
-      IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList(), minTimeOffset, maxTimeOffset);
-
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), new GeneticProgrammingModel(tree)));
-      return null;
+      return CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList(), minTimeOffset, maxTimeOffset);
     }
 
-    private IFunctionTree CreateModel(double[] coefficients, List<string> allowedVariables, int minTimeOffset, int maxTimeOffset) {
+    private static IFunctionTree CreateModel(double[] coefficients, List<string> allowedVariables, int minTimeOffset, int maxTimeOffset) {
       IFunctionTree root = new Addition().GetTreeNode();
 
@@ -90,5 +100,5 @@
     }
 
-    private double[] CalculateCoefficients(double[,] inputMatrix, double[] targetVector) {
+    private static double[] CalculateCoefficients(double[,] inputMatrix, double[] targetVector) {
       int retVal = 0;
       alglib.linreg.linearmodel lm = new alglib.linreg.linearmodel();
@@ -115,5 +125,5 @@
 
     //returns list of valid row indexes (rows without NaN values)
-    private List<int> CalculateAllowedRows(Dataset dataset, int targetVariable, IList<int> allowedColumns, int start, int end, int minTimeOffset, int maxTimeOffset) {
+    private static List<int> CalculateAllowedRows(Dataset dataset, int targetVariable, IList<int> allowedColumns, int start, int end, int minTimeOffset, int maxTimeOffset) {
       List<int> allowedRows = new List<int>();
       bool add;
@@ -140,11 +150,11 @@
 
     //returns list of valid column indexes (columns which contain max. 10% NaN (or infinity) and contain at least two different values)
-    private List<int> CalculateAllowedColumns(Dataset dataset, int targetVariable, int start, int end) {
+    private static List<int> CalculateAllowedColumns(Dataset dataset, int targetVariable, IEnumerable<int> inputVariables, int start, int end) {
       List<int> allowedColumns = new List<int>();
       double n = end - start;
-      for (int i = 0; i < dataset.Columns; i++) {
-        double nanRatio = dataset.CountMissingValues(i, start, end) / n;
-        if (i != targetVariable && nanRatio < 0.1 && dataset.GetRange(i, start, end) > 0.0) {
-          allowedColumns.Add(i);
+      foreach (int inputVariable in inputVariables) {// = 0; i < dataset.Columns; i++) {
+        double nanRatio = dataset.CountMissingValues(inputVariable, start, end) / n;
+        if (inputVariable != targetVariable && nanRatio < 0.1 && dataset.GetRange(inputVariable, start, end) > 0.0) {
+          allowedColumns.Add(inputVariable);
         }
       }
@@ -152,5 +162,5 @@
     }
 
-    private double[,] PrepareInputMatrix(Dataset dataset, List<int> allowedColumns, List<int> allowedRows, int minTimeOffset, int maxTimeOffset) {
+    private static double[,] PrepareInputMatrix(Dataset dataset, List<int> allowedColumns, List<int> allowedRows, int minTimeOffset, int maxTimeOffset) {
       int rowCount = allowedRows.Count;
       int timeOffsetRange = (maxTimeOffset - minTimeOffset + 1);
@@ -167,5 +177,5 @@
     }
 
-    private double[] PrepareTargetVector(Dataset dataset, int targetVariable, List<int> allowedRows) {
+    private static double[] PrepareTargetVector(Dataset dataset, int targetVariable, List<int> allowedRows) {
       int rowCount = allowedRows.Count;
       double[] targetVector = new double[rowCount];
