Index: /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs	(revision 17605)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs	(revision 17606)
@@ -26,8 +26,11 @@
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 
+using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
+
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
   public class SymbolicExpressionImporter {
     private const string VARSTART = "VAR";
     private const string LAGGEDVARSTART = "LAGVARIABLE";
+    private const string VECVARSTART = "VEC";
     private const string INTEGRALSTART = "INTEG";
     private const string DEFUNSTART = "DEFUN";
@@ -70,5 +73,5 @@
         {"EXPINT", new ExponentialIntegralEi()},
         {"AQ", new AnalyticQuotient() },
-        {"MEAN", new Average()},
+        //{"MEAN", new Average()},
         {"IF", new IfThenElse()},
         {">", new GreaterThan()},
@@ -82,10 +85,16 @@
         {"MAIN", new StartSymbol()},
         {"FACTOR", new FactorVariable() },
-        {"BINFACTOR", new BinaryFactorVariable()}
+        {"BINFACTOR", new BinaryFactorVariable()},
+        {"SUM", new Sum() },
+        {"MEAN", new Mean()},
+        {"LENGTH", new Length()},
+        {"STDEV", new StandardDeviation()},
+        {"VAR", new Variance()}
       };
 
     Constant constant = new Constant();
-    Variable variable = new Variable();
+    Variable variable = new Variable() { VariableDataType = typeof(double) };
     LaggedVariable laggedVariable = new LaggedVariable();
+    Variable vectorVariable = new Variable() { VariableDataType = typeof(DoubleVector) };
     Defun defun = new Defun();
     TimeLag timeLag = new TimeLag();
@@ -129,4 +138,6 @@
         } else if (tokens.Peek().StringValue.StartsWith(LAGGEDVARSTART)) {
           tree = ParseLaggedVariable(tokens);
+        } else if (tokens.Peek().StringValue.StartsWith(VECVARSTART)) {
+          tree = ParseVectorVariable(tokens);
         } else if (tokens.Peek().StringValue.StartsWith(TIMELAGSTART)) {
           tree = ParseTimeLag(tokens);
@@ -216,4 +227,13 @@
     }
 
+    private ISymbolicExpressionTreeNode ParseVectorVariable(Queue<Token> tokens) {
+      Token varTok = tokens.Dequeue();
+      Debug.Assert(varTok.StringValue == "VECTORVARIABLE");
+      VariableTreeNode t = (VariableTreeNode)vectorVariable.CreateTreeNode();
+      t.Weight = tokens.Dequeue().DoubleValue;
+      t.VariableName = tokens.Dequeue().StringValue;
+      return t;
+    }
+
     private ISymbolicExpressionTreeNode ParseFactor(Queue<Token> tokens) {
       Token tok = tokens.Dequeue();
Index: /branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs	(revision 17605)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs	(revision 17606)
@@ -193,7 +193,7 @@
 
       AssertEqualAfterSimplification("(+ 3.0 (binfactor a val 4.0 ))", "(+ (binfactor a val 4.0 ) 3.0))"); // not allowed
-      AssertEqualAfterSimplification("(- 3.0 (binfactor a val 4.0 ))", "(+ (binfactor a val -4.0 ) 3.0)"); 
+      AssertEqualAfterSimplification("(- 3.0 (binfactor a val 4.0 ))", "(+ (binfactor a val -4.0 ) 3.0)");
       AssertEqualAfterSimplification("(+ (binfactor a val 4.0 ) 3.0)", "(+ (binfactor a val 4.0 ) 3.0)");  // not allowed
-      AssertEqualAfterSimplification("(- (binfactor a val 4.0 ) 3.0)", "(+ (binfactor a val 4.0 ) -3.0)"); 
+      AssertEqualAfterSimplification("(- (binfactor a val 4.0 ) 3.0)", "(+ (binfactor a val 4.0 ) -3.0)");
       AssertEqualAfterSimplification("(* 2.0 (binfactor a val 4.0))", "(binfactor a val 8.0 )");
       AssertEqualAfterSimplification("(* (binfactor a val 4.0) 2.0)", "(binfactor a val 8.0 )");
@@ -202,7 +202,7 @@
 
       // exp( binfactor w val=a) = if(val=a) exp(w) else exp(0) = binfactor( (exp(w) - 1) val a) + 1
-      AssertEqualAfterSimplification("(exp (binfactor a val 3.0))", 
+      AssertEqualAfterSimplification("(exp (binfactor a val 3.0))",
         string.Format(CultureInfo.InvariantCulture, "(+ (binfactor a val {0}) 1.0)", Math.Exp(3.0) - 1)
-        ); 
+        );
       AssertEqualAfterSimplification("(sqrt (binfactor a val 16.0))", "(binfactor a val 4.0))"); // sqrt(0) = 0
       AssertEqualAfterSimplification("(sqr (binfactor a val 3.0))", "(binfactor a val 9.0))"); // 0*0 = 0
@@ -212,5 +212,5 @@
       AssertEqualAfterSimplification("(sin (binfactor a val 2.0) )",
         string.Format(CultureInfo.InvariantCulture, "(binfactor a val {0}))", Math.Sin(2.0))); // sin(0) = 0
-      AssertEqualAfterSimplification("(cos (binfactor a val 2.0) )", 
+      AssertEqualAfterSimplification("(cos (binfactor a val 2.0) )",
         string.Format(CultureInfo.InvariantCulture, "(+ (binfactor a val {0}) 1.0)", Math.Cos(2.0) - 1)); // cos(0) = 1
       AssertEqualAfterSimplification("(tan (binfactor a val 2.0) )",
@@ -269,4 +269,16 @@
 
       #endregion
+
+      #region vectors
+      AssertEqualAfterVectorSimplification(
+        "(sum (vectorvariable 2.0 a))",
+        "(* (sum (vectorvariable 1.0 a)) 2.0)");
+      AssertEqualAfterVectorSimplification(
+        "(sum (* 2.0 (vectorvariable 1.0 a)))",
+        "(* (sum (vectorvariable 1.0 a)) 2.0)");
+      AssertEqualAfterVectorSimplification(
+        "(sum (+ 2.0 (vectorvariable 1.0 a)))",
+        "(+ (* (length (vectorvariable 1.0 a)) 2.0)(sum (vectorvariable 1.0 a)) )");
+      #endregion
     }
 
@@ -278,5 +290,13 @@
       var expectedTree = importer.Import(expected);
       Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));
-
+    }
+
+    private void AssertEqualAfterVectorSimplification(string original, string expected) {
+      var formatter = new SymbolicExpressionTreeStringFormatter();
+      var importer = new SymbolicExpressionImporter();
+      var simplifier = new VectorTreeSimplifier(new SymbolicDataAnalysisExpressionTreeVectorInterpreter());
+      var actualTree = simplifier.Simplify(importer.Import(original));
+      var expectedTree = importer.Import(expected);
+      Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));
     }
   }
Index: /branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj
===================================================================
--- /branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 17605)
+++ /branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 17606)
@@ -598,5 +598,4 @@
     <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\OnlineCalculatorPerformanceTest.cs" />
     <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\StatisticCalculatorsTest.cs" />
-    <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\ConstantOptimizationWithVectorsTest.cs" />
     <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\DeriveTest.cs" />
     <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\InfixExpressionParserTest.cs" />
