Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs	(revision 2118)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherBase.cs	(revision 2119)
@@ -42,5 +42,7 @@
     private DataSet dataset;
     internal event EventHandler Changed;
-    public IEnumerable<string> AllowedTargetVariables {
+    private object locker = new object();
+
+    public IEnumerable<string> TargetVariables {
       get {
         if (dataset != null) {
@@ -50,5 +52,5 @@
     }
 
-    public IEnumerable<string> AllowedInputVariables {
+    public IEnumerable<string> InputVariables {
       get {
         if (dataset != null) {
@@ -58,6 +60,11 @@
     }
 
+    private List<int> allowedInputVariables;
+    private List<int> allowedTargetVariables;
+
     public DispatcherBase(IStore store) {
       this.store = store;
+      allowedInputVariables = new List<int>();
+      allowedTargetVariables = new List<int>();
     }
 
@@ -70,46 +77,18 @@
         OnChanged();
       }
-      int targetVariable = SelectTargetVariable(dataset.Problem.AllowedTargetVariables.ToArray());
-      IAlgorithm selectedAlgorithm = SelectAlgorithm(targetVariable, dataset.Problem.LearningTask);
-      string targetVariableName = dataset.Problem.GetVariableName(targetVariable);
+      if (allowedTargetVariables.Count > 0 && allowedInputVariables.Count > 0) {
+        int[] targetVariables, inputVariables;
+        lock (locker) {
+          targetVariables = allowedTargetVariables.ToArray();
+          inputVariables = allowedInputVariables.ToArray();
+        }
 
-      if (selectedAlgorithm != null) {
-        SetProblemParameters(selectedAlgorithm, dataset.Problem, targetVariable);
-      }
-      return selectedAlgorithm;
+        IAlgorithm selectedAlgorithm = SelectAndConfigureAlgorithm(targetVariables, inputVariables, dataset.Problem);
+        
+        return selectedAlgorithm;
+      } else return null;
     }
 
-    public abstract int SelectTargetVariable(int[] targetVariables);
-    public abstract IAlgorithm SelectAlgorithm(int targetVariable, LearningTask learningTask);
-
-    private void SetProblemParameters(IAlgorithm algo, Problem problem, int targetVariable) {
-      algo.Dataset = problem.Dataset;
-      algo.TargetVariable = targetVariable;
-      algo.ProblemInjector.GetVariable("TrainingSamplesStart").GetValue<IntData>().Data = problem.TrainingSamplesStart;
-      algo.ProblemInjector.GetVariable("TrainingSamplesEnd").GetValue<IntData>().Data = problem.TrainingSamplesEnd;
-      algo.ProblemInjector.GetVariable("ValidationSamplesStart").GetValue<IntData>().Data = problem.ValidationSamplesStart;
-      algo.ProblemInjector.GetVariable("ValidationSamplesEnd").GetValue<IntData>().Data = problem.ValidationSamplesEnd;
-      algo.ProblemInjector.GetVariable("TestSamplesStart").GetValue<IntData>().Data = problem.TestSamplesStart;
-      algo.ProblemInjector.GetVariable("TestSamplesEnd").GetValue<IntData>().Data = problem.TestSamplesEnd;
-      ItemList<IntData> allowedFeatures = algo.ProblemInjector.GetVariable("AllowedFeatures").GetValue<ItemList<IntData>>();
-      foreach (int allowedFeature in problem.AllowedInputVariables) allowedFeatures.Add(new IntData(allowedFeature));
-
-      if (problem.LearningTask == LearningTask.TimeSeries) {
-        algo.ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data = problem.AutoRegressive;
-        algo.ProblemInjector.GetVariable("MinTimeOffset").GetValue<IntData>().Data = problem.MinTimeOffset;
-        algo.ProblemInjector.GetVariable("MaxTimeOffset").GetValue<IntData>().Data = problem.MaxTimeOffset;
-      } else if (problem.LearningTask == LearningTask.Classification) {
-        ItemList<DoubleData> classValues = algo.ProblemInjector.GetVariable("TargetClassValues").GetValue<ItemList<DoubleData>>();
-        foreach (double classValue in GetDifferentClassValues(problem.Dataset, targetVariable)) classValues.Add(new DoubleData(classValue));
-      }
-    }
-
-    private IEnumerable<double> GetDifferentClassValues(HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable) {
-      return Enumerable.Range(0, dataset.Rows).Select(x => dataset.GetValue(x, targetVariable)).Distinct();
-    }
-
-    private void OnChanged() {
-      if (Changed != null) Changed(this, new EventArgs());
-    }
+    public abstract IAlgorithm SelectAndConfigureAlgorithm(int[] targetVariables, int[] inputVariables, Problem problem);
 
     #region IViewable Members
@@ -120,4 +99,28 @@
 
     #endregion
+
+    internal void EnableInputVariable(string name) {
+      lock (locker)
+        allowedInputVariables.Add(dataset.Problem.Dataset.GetVariableIndex(name));
+    }
+
+    internal void EnableTargetVariable(string name) {
+      lock (locker)
+        allowedTargetVariables.Add(dataset.Problem.Dataset.GetVariableIndex(name));
+    }
+
+    internal void DisableTargetVariable(string name) {
+      lock (locker)
+        allowedTargetVariables.Remove(dataset.Problem.Dataset.GetVariableIndex(name));
+    }
+
+    internal void DisableInputVariable(string name) {
+      lock (locker)
+        allowedInputVariables.Remove(dataset.Problem.Dataset.GetVariableIndex(name));
+    }
+
+    private void OnChanged() {
+      if (Changed != null) Changed(this, new EventArgs());
+    }
   }
 }
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.Designer.cs	(revision 2118)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.Designer.cs	(revision 2119)
@@ -37,4 +37,5 @@
       this.targetVariableList.Size = new System.Drawing.Size(171, 409);
       this.targetVariableList.TabIndex = 0;
+      this.targetVariableList.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.targetVariableList_ItemCheck);
       // 
       // inputVariableList
@@ -45,4 +46,5 @@
       this.inputVariableList.Size = new System.Drawing.Size(170, 409);
       this.inputVariableList.TabIndex = 1;
+      this.inputVariableList.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.inputVariableList_ItemCheck);
       // 
       // targetVariablesLabel
@@ -73,5 +75,5 @@
       this.Controls.Add(this.targetVariableList);
       this.Name = "DispatcherView";
-      this.Size = new System.Drawing.Size(417, 427);
+      this.Size = new System.Drawing.Size(429, 482);
       this.ResumeLayout(false);
       this.PerformLayout();
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs	(revision 2118)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs	(revision 2119)
@@ -22,10 +22,26 @@
       base.UpdateControls();
 
-      foreach (string targetVar in dispatcher.AllowedTargetVariables) {
+      foreach (string targetVar in dispatcher.TargetVariables) {
         targetVariableList.Items.Add(targetVar);
       }
 
-      foreach (string inputVar in dispatcher.AllowedInputVariables) {
+      foreach (string inputVar in dispatcher.InputVariables) {
         inputVariableList.Items.Add(inputVar);
+      }
+    }
+
+    private void targetVariableList_ItemCheck(object sender, ItemCheckEventArgs e) {
+      if (e.NewValue == CheckState.Checked) {
+        dispatcher.EnableTargetVariable((string)targetVariableList.Items[e.Index]);
+      } else if (e.NewValue == CheckState.Unchecked) {
+        dispatcher.DisableTargetVariable((string)targetVariableList.Items[e.Index]);
+      }
+    }
+
+    private void inputVariableList_ItemCheck(object sender, ItemCheckEventArgs e) {
+      if (e.NewValue == CheckState.Checked) {
+        dispatcher.EnableInputVariable((string)inputVariableList.Items[e.Index]);
+      } else if (e.NewValue == CheckState.Unchecked) {
+        dispatcher.DisableInputVariable((string)inputVariableList.Items[e.Index]);
       }
     }
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerApplication.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerApplication.cs	(revision 2118)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/ServerApplication.cs	(revision 2119)
@@ -36,4 +36,5 @@
       serverControl.Dock = DockStyle.Fill;
       mainForm.Controls.Add(serverControl);
+      mainForm.Name = "CEDMA Server";
       Application.Run(mainForm);
     }
Index: /trunk/sources/HeuristicLab.CEDMA.Server/3.3/SimpleDispatcher.cs
===================================================================
--- /trunk/sources/HeuristicLab.CEDMA.Server/3.3/SimpleDispatcher.cs	(revision 2118)
+++ /trunk/sources/HeuristicLab.CEDMA.Server/3.3/SimpleDispatcher.cs	(revision 2119)
@@ -39,7 +39,13 @@
 namespace HeuristicLab.CEDMA.Server {
   public class SimpleDispatcher : DispatcherBase {
+    private class AlgorithmConfiguration {
+      public string name;
+      public int targetVariable;
+      public List<int> inputVariables;
+    }
+
     private Random random;
     private IStore store;
-    private Dictionary<int, List<string>> finishedAndDispatchedRuns;
+    private Dictionary<int, List<AlgorithmConfiguration>> finishedAndDispatchedRuns;
 
     public SimpleDispatcher(IStore store)
@@ -47,39 +53,44 @@
       this.store = store;
       random = new Random();
-      finishedAndDispatchedRuns = new Dictionary<int, List<string>>();
+      finishedAndDispatchedRuns = new Dictionary<int, List<AlgorithmConfiguration>>();
       PopulateFinishedRuns();
     }
 
-    public override IAlgorithm SelectAlgorithm(int targetVariable, LearningTask learningTask) {
+    public override IAlgorithm SelectAndConfigureAlgorithm(int[] targetVariables, int[] inputVariables, Problem problem) {
+      int targetVariable = SelectTargetVariable(targetVariables);
+
       DiscoveryService ds = new DiscoveryService();
       IAlgorithm[] algos = ds.GetInstances<IAlgorithm>();
       IAlgorithm selectedAlgorithm = null;
-      switch (learningTask) {
+      switch (problem.LearningTask) {
         case LearningTask.Regression: {
             var regressionAlgos = algos.Where(a => (a as IClassificationAlgorithm) == null && (a as ITimeSeriesAlgorithm) == null);
-            selectedAlgorithm = ChooseDeterministic(targetVariable, regressionAlgos) ?? ChooseStochastic(regressionAlgos);
+            selectedAlgorithm = ChooseDeterministic(targetVariable, inputVariables, regressionAlgos) ?? ChooseStochastic(regressionAlgos);
             break;
           }
         case LearningTask.Classification: {
             var classificationAlgos = algos.Where(a => (a as IClassificationAlgorithm) != null);
-            selectedAlgorithm = ChooseDeterministic(targetVariable, classificationAlgos) ?? ChooseStochastic(classificationAlgos);
+            selectedAlgorithm = ChooseDeterministic(targetVariable, inputVariables, classificationAlgos) ?? ChooseStochastic(classificationAlgos);
             break;
           }
         case LearningTask.TimeSeries: {
             var timeSeriesAlgos = algos.Where(a => (a as ITimeSeriesAlgorithm) != null);
-            selectedAlgorithm = ChooseDeterministic(targetVariable, timeSeriesAlgos) ?? ChooseStochastic(timeSeriesAlgos);
+            selectedAlgorithm = ChooseDeterministic(targetVariable, inputVariables, timeSeriesAlgos) ?? ChooseStochastic(timeSeriesAlgos);
             break;
           }
       }
+
+      SetProblemParameters(selectedAlgorithm, problem, targetVariable, inputVariables);
+
       if (selectedAlgorithm != null) {
-        AddDispatchedRun(targetVariable, selectedAlgorithm.Name);
+        AddDispatchedRun(targetVariable, inputVariables, selectedAlgorithm.Name);
       }
       return selectedAlgorithm;
     }
 
-    private IAlgorithm ChooseDeterministic(int targetVariable, IEnumerable<IAlgorithm> algos) {
+    private IAlgorithm ChooseDeterministic(int targetVariable, int[] inputVariables, IEnumerable<IAlgorithm> algos) {
       var deterministicAlgos = algos
         .Where(a => (a as IStochasticAlgorithm) == null)
-        .Where(a => AlgorithmFinishedOrDispatched(targetVariable, a.Name) == false);
+        .Where(a => AlgorithmFinishedOrDispatched(targetVariable, inputVariables, a.Name) == false);
 
       if (deterministicAlgos.Count() == 0) return null;
@@ -93,9 +104,10 @@
     }
 
-    public override int SelectTargetVariable(int[] targetVariables) {
+    public int SelectTargetVariable(int[] targetVariables) {
       return targetVariables[random.Next(targetVariables.Length)];
     }
 
     private void PopulateFinishedRuns() {
+      Dictionary<Entity, Entity> processedModels = new Dictionary<Entity, Entity>();
       var datasetBindings = store
         .Query(
@@ -112,28 +124,81 @@
           "?Model <" + Ontology.Name + "> ?AlgoName .",
           0, 1000)
-          .Select(x => new Resource[] { (Literal)x.Get("TargetVariable"), (Literal)x.Get("AlgoName") });
+          .Select(x => new Resource[] { (Literal)x.Get("TargetVariable"), (Literal)x.Get("AlgoName"), (Entity)x.Get("Model") });
 
         foreach (Resource[] row in result) {
-          string targetVariable = (string)((Literal)row[0]).Value;
-          string algoName = (string)((Literal)row[1]).Value;
-
-          int targetVariableIndex = ds.Problem.Dataset.GetVariableIndex(targetVariable);
-          if (!AlgorithmFinishedOrDispatched(targetVariableIndex, algoName))
-            AddDispatchedRun(targetVariableIndex, algoName);
+          Entity model = ((Entity)row[2]);
+          if (!processedModels.ContainsKey(model)) {
+            processedModels.Add(model, model);
+
+            string targetVariable = (string)((Literal)row[0]).Value;
+            string algoName = (string)((Literal)row[1]).Value;
+            int targetVariableIndex = ds.Problem.Dataset.GetVariableIndex(targetVariable);
+
+            var inputVariableLiterals = store
+              .Query(
+                "<" + model.Uri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + Environment.NewLine +
+                "?InputVariable <" + Ontology.Name + "> ?Name .",
+                0, 1000)
+              .Select(x => (Literal)x.Get("Name"))
+              .Select(l => (string)l.Value)
+              .Distinct();
+
+            List<int> inputVariables = new List<int>();
+            foreach (string variableName in inputVariableLiterals) {
+              int variableIndex = ds.Problem.Dataset.GetVariableIndex(variableName);
+              inputVariables.Add(variableIndex);
+            }
+            if (!AlgorithmFinishedOrDispatched(targetVariableIndex, inputVariables.ToArray(), algoName)) {
+              AddDispatchedRun(targetVariableIndex, inputVariables.ToArray(), algoName);
+            }
+          }
         }
       }
     }
 
-    private void AddDispatchedRun(int targetVariable, string algoName) {
+    private void SetProblemParameters(IAlgorithm algo, Problem problem, int targetVariable, int[] inputVariables) {
+      algo.Dataset = problem.Dataset;
+      algo.TargetVariable = targetVariable;
+      algo.ProblemInjector.GetVariable("TrainingSamplesStart").GetValue<IntData>().Data = problem.TrainingSamplesStart;
+      algo.ProblemInjector.GetVariable("TrainingSamplesEnd").GetValue<IntData>().Data = problem.TrainingSamplesEnd;
+      algo.ProblemInjector.GetVariable("ValidationSamplesStart").GetValue<IntData>().Data = problem.ValidationSamplesStart;
+      algo.ProblemInjector.GetVariable("ValidationSamplesEnd").GetValue<IntData>().Data = problem.ValidationSamplesEnd;
+      algo.ProblemInjector.GetVariable("TestSamplesStart").GetValue<IntData>().Data = problem.TestSamplesStart;
+      algo.ProblemInjector.GetVariable("TestSamplesEnd").GetValue<IntData>().Data = problem.TestSamplesEnd;
+      ItemList<IntData> allowedFeatures = algo.ProblemInjector.GetVariable("AllowedFeatures").GetValue<ItemList<IntData>>();
+      foreach (int inputVariable in inputVariables) allowedFeatures.Add(new IntData(inputVariable));
+
+      if (problem.LearningTask == LearningTask.TimeSeries) {
+        algo.ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data = problem.AutoRegressive;
+        algo.ProblemInjector.GetVariable("MinTimeOffset").GetValue<IntData>().Data = problem.MinTimeOffset;
+        algo.ProblemInjector.GetVariable("MaxTimeOffset").GetValue<IntData>().Data = problem.MaxTimeOffset;
+      } else if (problem.LearningTask == LearningTask.Classification) {
+        ItemList<DoubleData> classValues = algo.ProblemInjector.GetVariable("TargetClassValues").GetValue<ItemList<DoubleData>>();
+        foreach (double classValue in GetDifferentClassValues(problem.Dataset, targetVariable)) classValues.Add(new DoubleData(classValue));
+      }
+    }
+
+    private IEnumerable<double> GetDifferentClassValues(HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable) {
+      return Enumerable.Range(0, dataset.Rows).Select(x => dataset.GetValue(x, targetVariable)).Distinct();
+    }
+
+    private void AddDispatchedRun(int targetVariable, int[] inputVariables, string algoName) {
       if (!finishedAndDispatchedRuns.ContainsKey(targetVariable)) {
-        finishedAndDispatchedRuns[targetVariable] = new List<string>();
-      }
-      finishedAndDispatchedRuns[targetVariable].Add(algoName);
-    }
-
-    private bool AlgorithmFinishedOrDispatched(int targetVariable, string algoName) {
+        finishedAndDispatchedRuns[targetVariable] = new List<AlgorithmConfiguration>();
+      }
+      AlgorithmConfiguration conf = new AlgorithmConfiguration();
+      conf.name = algoName;
+      conf.inputVariables = new List<int>(inputVariables);
+      conf.targetVariable = targetVariable;
+      finishedAndDispatchedRuns[targetVariable].Add(conf);
+    }
+
+    private bool AlgorithmFinishedOrDispatched(int targetVariable, int[] inputVariables, string algoName) {
       return
         finishedAndDispatchedRuns.ContainsKey(targetVariable) &&
-        finishedAndDispatchedRuns[targetVariable].Contains(algoName);
+        finishedAndDispatchedRuns[targetVariable].Any(x => targetVariable == x.targetVariable &&
+                                                           algoName == x.name &&
+                                                           inputVariables.Count() == x.inputVariables.Count() &&
+                                                           inputVariables.All(v => x.inputVariables.Contains(v)));
     }
   }
