Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/CsvFileParser.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/CsvFileParser.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/CsvFileParser.cs	(revision 3373)
@@ -0,0 +1,317 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using HeuristicLab.Data;
+using System.Text;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  public class CsvFileParser {
+    private const string VARIABLENAMES = "VARIABLENAMES";
+    private Tokenizer tokenizer;
+    private List<string> variableNames;
+    private List<List<double>> rowValues;
+
+    private int rows;
+    public int Rows {
+      get { return rows; }
+      set { rows = value; }
+    }
+
+    private int columns;
+    public int Columns {
+      get { return columns; }
+      set { columns = value; }
+    }
+
+    private double[,] values;
+    public double[,] Values {
+      get {
+        return values;
+      }
+    }
+
+    public IEnumerable<string> VariableNames {
+      get {
+        if (variableNames.Count > 0) return variableNames;
+        else {
+          string[] names = new string[columns];
+          for (int i = 0; i < names.Length; i++) {
+            names[i] = "X" + i.ToString("000");
+          }
+          return names;
+        }
+      }
+    }
+
+    public CsvFileParser() {
+      rowValues = new List<List<double>>();
+      variableNames = new List<string>();
+    }
+
+    private void Reset() {
+      variableNames.Clear();
+      rowValues.Clear();
+    }
+
+    public void Parse(string fileName) {
+      TryParse(fileName);
+      // translate the list of samples into a DoubleMatrixData item
+      rows = rowValues.Count;
+      columns = rowValues[0].Count;
+      values = new double[rows, columns];
+
+      int rowIndex = 0;
+      int columnIndex = 0;
+      foreach (List<double> row in rowValues) {
+        columnIndex = 0;
+        foreach (double element in row) {
+          values[rowIndex, columnIndex++] = element;
+        }
+        rowIndex++;
+      }
+    }
+
+    private void TryParse(string fileName) {
+      Exception lastEx = null;
+      NumberFormatInfo[] possibleFormats = new NumberFormatInfo[] { NumberFormatInfo.InvariantInfo };
+      foreach (NumberFormatInfo numberFormat in possibleFormats) {
+        using (StreamReader reader = new StreamReader(fileName)) {
+          tokenizer = new Tokenizer(reader, numberFormat);
+          try {
+            // parse the file
+            Parse();
+            return; // parsed without errors -> return;
+          }
+          catch (DataFormatException ex) {
+            lastEx = ex;
+          }
+        }
+      }
+      // all number formats threw an exception -> rethrow the last exception
+      throw lastEx;
+    }
+
+    #region tokenizer
+    internal enum TokenTypeEnum {
+      NewLine, Separator, String, Double
+    }
+
+    internal class Token {
+      public TokenTypeEnum type;
+      public string stringValue;
+      public double doubleValue;
+
+      public Token(TokenTypeEnum type, string value) {
+        this.type = type;
+        stringValue = value;
+        doubleValue = 0.0;
+      }
+
+      public override string ToString() {
+        return stringValue;
+      }
+    }
+
+
+    internal class Tokenizer {
+      private StreamReader reader;
+      private List<Token> tokens;
+      private NumberFormatInfo numberFormatInfo;
+
+      private int currentLineNumber = 0;
+      public int CurrentLineNumber {
+        get { return currentLineNumber; }
+        private set { currentLineNumber = value; }
+      }
+      private string currentLine;
+      public string CurrentLine {
+        get { return currentLine; }
+        private set { currentLine = value; }
+      }
+
+      private Token newlineToken;
+      public Token NewlineToken {
+        get { return newlineToken; }
+        private set { newlineToken = value; }
+      }
+      private Token separatorToken;
+      public Token SeparatorToken {
+        get { return separatorToken; }
+        private set { separatorToken = value; }
+      }
+
+      public Tokenizer(StreamReader reader, NumberFormatInfo numberFormatInfo, char separator) {
+        this.reader = reader;
+        this.numberFormatInfo = numberFormatInfo;
+        separatorToken = new Token(TokenTypeEnum.Separator, separator.ToString());
+        newlineToken = new Token(TokenTypeEnum.NewLine, Environment.NewLine);
+        tokens = new List<Token>();
+        ReadNextTokens();
+      }
+      public Tokenizer(StreamReader reader, NumberFormatInfo numberFormatInfo)
+        : this(reader, numberFormatInfo, ';') {
+      }
+
+      private void ReadNextTokens() {
+        if (!reader.EndOfStream) {
+          CurrentLine = reader.ReadLine();
+          var newTokens = from str in Split(CurrentLine)
+                          let trimmedStr = str.Trim()
+                          where !string.IsNullOrEmpty(trimmedStr)
+                          select MakeToken(trimmedStr.Trim());
+
+          tokens.AddRange(newTokens);
+          tokens.Add(NewlineToken);
+          CurrentLineNumber++;
+        }
+      }
+
+      private IEnumerable<string> Split(string line) {
+        StringBuilder subStr = new StringBuilder();
+        foreach (char c in line) {
+          if (c == ';') {
+            yield return subStr.ToString();
+            subStr = new StringBuilder();
+            yield return c.ToString();
+          } else {
+            subStr.Append(c);
+          }
+        }
+        yield return subStr.ToString();
+      }
+
+      private Token MakeToken(string strToken) {
+        Token token = new Token(TokenTypeEnum.String, strToken);
+        if (strToken.Equals(SeparatorToken.stringValue)) {
+          return SeparatorToken;
+        } else if (double.TryParse(strToken, NumberStyles.Float, numberFormatInfo, out token.doubleValue)) {
+          token.type = TokenTypeEnum.Double;
+          return token;
+        }
+
+        // couldn't parse the token as an int or float number so return a string token
+        return token;
+      }
+
+      public Token Peek() {
+        return tokens[0];
+      }
+
+      public Token Next() {
+        Token next = tokens[0];
+        tokens.RemoveAt(0);
+        if (tokens.Count == 0) {
+          ReadNextTokens();
+        }
+        return next;
+      }
+
+      public bool HasNext() {
+        return tokens.Count > 0 || !reader.EndOfStream;
+      }
+    }
+    #endregion
+
+    #region parsing
+    private void Parse() {
+      ParseVariableNames();
+      if (!tokenizer.HasNext()) Error("Couldn't parse data values. Probably because of incorrect number format (the parser expects english number format with a '.' as decimal separator).", "", tokenizer.CurrentLineNumber);
+      ParseValues();
+      if (rowValues.Count == 0) Error("Couldn't parse data values. Probably because of incorrect number format (the parser expects english number format with a '.' as decimal separator).", "", tokenizer.CurrentLineNumber);
+    }
+
+    private void ParseValues() {
+      while (tokenizer.HasNext()) {
+        List<double> row = new List<double>();
+        row.Add(NextValue(tokenizer));
+        while (tokenizer.HasNext() && tokenizer.Peek() == tokenizer.SeparatorToken) {
+          Expect(tokenizer.SeparatorToken);
+          row.Add(NextValue(tokenizer));
+        }
+        Expect(tokenizer.NewlineToken);
+        // all rows have to have the same number of values            
+        // the first row defines how many samples are needed
+        if (rowValues.Count > 0 && rowValues[0].Count != row.Count) {
+          Error("The first row of the dataset has " + rowValues[0].Count + " columns." +
+            "\nLine " + tokenizer.CurrentLineNumber + " has " + row.Count + " columns.", "", tokenizer.CurrentLineNumber);
+        }
+        // add the current row to the collection of rows and start a new row
+        rowValues.Add(row);
+        row = new List<double>();
+      }
+    }
+
+    private double NextValue(Tokenizer tokenizer) {
+      if (tokenizer.Peek() == tokenizer.SeparatorToken || tokenizer.Peek() == tokenizer.NewlineToken) return double.NaN;
+      Token current = tokenizer.Next();
+      if (current.type == TokenTypeEnum.Separator || current.type == TokenTypeEnum.String) {
+        return double.NaN;
+      } else if (current.type == TokenTypeEnum.Double) {
+        // just take the value
+        return current.doubleValue;
+      }
+      // found an unexpected token => throw error 
+      Error("Unexpected token.", current.stringValue, tokenizer.CurrentLineNumber);
+      // this line is never executed because Error() throws an exception
+      throw new InvalidOperationException();
+    }
+
+    private void ParseVariableNames() {
+      // if the first line doesn't start with a double value then we assume that the
+      // first line contains variable names
+      if (tokenizer.HasNext() && tokenizer.Peek().type != TokenTypeEnum.Double) {
+
+        List<Token> tokens = new List<Token>();
+        Token valueToken;
+        valueToken = tokenizer.Next();
+        tokens.Add(valueToken);
+        while (tokenizer.HasNext() && tokenizer.Peek() == tokenizer.SeparatorToken) {
+          Expect(tokenizer.SeparatorToken);
+          valueToken = tokenizer.Next();
+          if (valueToken != tokenizer.NewlineToken) {
+            tokens.Add(valueToken);
+          }
+        }
+        if (valueToken != tokenizer.NewlineToken) {
+          Expect(tokenizer.NewlineToken);
+        }
+        variableNames = tokens.Select(x => x.stringValue.Trim()).ToList();
+      }
+    }
+
+    private void Expect(Token expectedToken) {
+      Token actualToken = tokenizer.Next();
+      if (actualToken != expectedToken) {
+        Error("Expected: " + expectedToken, actualToken.stringValue, tokenizer.CurrentLineNumber);
+      }
+    }
+
+    private void Error(string message, string token, int lineNumber) {
+      throw new DataFormatException("Error while parsing.\n" + message, token, lineNumber);
+    }
+    #endregion
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs	(revision 3373)
@@ -0,0 +1,63 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Problems.DataAnalysis;
+using System.Drawing;
+using System.IO;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  [Item("DataAnalysisProblem", "Represents a data analysis problem.")]
+  [Creatable("Problems")]
+  [StorableClass]
+  public class DataAnalysisProblem : ParameterizedNamedItem {
+    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
+    public override Image ItemImage {
+      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
+    }
+
+    #region Parameter Properties
+    public ValueParameter<DataAnalysisProblemData> DataAnalysisProblemDataParameter {
+      get { return (ValueParameter<DataAnalysisProblemData>)Parameters[DataAnalysisProblemDataParameterName]; }
+    }
+    #endregion
+    #region properties
+    public DataAnalysisProblemData DataAnalysisProblemData {
+      get { return DataAnalysisProblemDataParameter.Value; }
+      set { DataAnalysisProblemDataParameter.Value = value; }
+    }
+    #endregion
+
+    public DataAnalysisProblem()
+      : base() {
+      Parameters.Add(new ValueParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem.", new DataAnalysisProblemData()));
+    }
+
+    [StorableConstructor]
+    private DataAnalysisProblem(bool deserializing) : base() { }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs	(revision 3373)
@@ -0,0 +1,154 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Problems.DataAnalysis;
+using System.Drawing;
+using System.IO;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  [Item("DataAnalysisProblemData", "Represents an item containing all data defining a data analysis problem.")]
+  [StorableClass]
+  public class DataAnalysisProblemData : NamedItem {
+    #region properties
+    private Dataset dataset;
+    [Storable]
+    public Dataset Dataset {
+      get { return dataset; }
+      set {
+        if (dataset != value) {
+          if (value == null) throw new ArgumentNullException();
+          else {
+            dataset = value;
+            OnDatasetChanged(EventArgs.Empty);
+          }
+        }
+      }
+    }
+    private StringValue targetVariable;
+    [Storable]
+    public StringValue TargetVariable {
+      get { return targetVariable; }
+      set { targetVariable = value; }
+    }
+    private ItemList<StringValue> inputVariables;
+    [Storable]
+    public ItemList<StringValue> InputVariables {
+      get { return inputVariables; }
+      set {
+        if (inputVariables != value) {
+          if (value == null) throw new ArgumentNullException();
+          else {
+            inputVariables = value;
+            OnInputVariablesChanged(EventArgs.Empty);
+          }
+        }
+      }
+    }
+    private IntValue trainingSamplesStart;
+    [Storable]
+    public IntValue TrainingSamplesStart {
+      get { return trainingSamplesStart; }
+      set { trainingSamplesStart = value; }
+    }
+    private IntValue trainingSamplesEnd;
+    [Storable]
+    public IntValue TrainingSamplesEnd {
+      get { return trainingSamplesEnd; }
+      set { trainingSamplesEnd = value; }
+    }
+    private IntValue validationSamplesStart;
+    [Storable]
+    public IntValue ValidationSamplesStart {
+      get { return validationSamplesStart; }
+      set { validationSamplesStart = value; }
+    }
+    private IntValue validationSamplesEnd;
+    [Storable]
+    public IntValue ValidationSamplesEnd {
+      get { return validationSamplesEnd; }
+      set { validationSamplesEnd = value; }
+    }
+    private IntValue testSamplesStart;
+    [Storable]
+    public IntValue TestSamplesStart {
+      get { return testSamplesStart; }
+      set { testSamplesStart = value; }
+    }
+    private IntValue testSamplesEnd;
+    [Storable]
+    public IntValue TestSamplesEnd {
+      get { return testSamplesEnd; }
+      set { testSamplesEnd = value; }
+    }
+    #endregion
+
+    public DataAnalysisProblemData()
+      : base() {
+      dataset = new Dataset();
+      targetVariable = new StringValue();
+      inputVariables = new ItemList<StringValue>();
+      trainingSamplesStart = new IntValue();
+      trainingSamplesEnd = new IntValue();
+      validationSamplesStart = new IntValue();
+      validationSamplesEnd = new IntValue();
+      testSamplesStart = new IntValue();
+      testSamplesEnd = new IntValue();
+    }
+
+    [StorableConstructor]
+    private DataAnalysisProblemData(bool deserializing) : base() { }
+
+    #region events
+    public event EventHandler InputVariablesChanged;
+    protected virtual void OnInputVariablesChanged(EventArgs e) {
+      var listeners = InputVariablesChanged;
+      if (listeners != null) listeners(this, e);
+    }
+
+    public event EventHandler DatasetChanged;
+    protected virtual void OnDatasetChanged(EventArgs e) {
+      EventHandler handler = DatasetChanged;
+      if (handler != null) handler(this, e);
+    }
+    #endregion
+
+    public virtual void ImportFromFile(string fileName) {
+      var csvFileParser = new CsvFileParser();
+      csvFileParser.Parse(fileName);
+      Name = "Data imported from " + Path.GetFileName(fileName);
+      Dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
+      Dataset.Name = Path.GetFileName(fileName);
+      TargetVariable = new StringValue(Dataset.VariableNames.First());
+      InputVariables = new ItemList<StringValue>(Dataset.VariableNames.Skip(1).Select(s => new StringValue(s)));
+      TrainingSamplesStart = new IntValue(0);
+      TrainingSamplesEnd = new IntValue(csvFileParser.Rows);
+      TestSamplesStart = new IntValue(0);
+      TestSamplesEnd = new IntValue(csvFileParser.Rows);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataFormatException.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataFormatException.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataFormatException.cs	(revision 3373)
@@ -0,0 +1,43 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  public class DataFormatException : Exception {
+    private int line;
+    public int Line {
+      get { return line; }
+    }
+    private string token;
+    public string Token {
+      get { return token; }
+    }
+    public DataFormatException(string message, string token, int line)
+      : base(message + "\nToken: " + token + " (line: " + line + ")") {
+      this.token = token;
+      this.line = line;
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj	(revision 3334)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj	(revision 3373)
@@ -70,4 +70,5 @@
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
     </Reference>
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml.Linq">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -83,4 +84,8 @@
     <None Include="HeuristicLabProblemsDataAnalysisPlugin.cs.frame" />
     <None Include="Properties\AssemblyInfo.frame" />
+    <Compile Include="CsvFileParser.cs" />
+    <Compile Include="DataAnalysisProblem.cs" />
+    <Compile Include="DataAnalysisProblemData.cs" />
+    <Compile Include="DataFormatException.cs" />
     <Compile Include="Dataset.cs" />
     <Compile Include="Evaluators\SimpleEvaluator.cs" />
@@ -89,4 +94,10 @@
     <Compile Include="MatrixExtensions.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Symbolic\ArithmeticExpressionGrammar.cs" />
+    <Compile Include="Symbolic\SimpleArithmeticExpressionEvaluator.cs" />
+    <Compile Include="Symbolic\Symbols\Constant.cs" />
+    <Compile Include="Symbolic\Symbols\ConstantTreeNode.cs" />
+    <Compile Include="Symbolic\Symbols\Variable.cs" />
+    <Compile Include="Symbolic\Symbols\VariableTreeNode.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -94,4 +105,8 @@
       <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
       <Name>HeuristicLab.Collections-3.3</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.2\HeuristicLab.Common.Resources-3.2.csproj">
+      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
+      <Name>HeuristicLab.Common.Resources-3.2</Name>
     </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Common\3.2\HeuristicLab.Common-3.2.csproj">
@@ -127,4 +142,8 @@
       <Name>HeuristicLab.PluginInfrastructure</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
+      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
+      <Name>HeuristicLab.Random-3.3</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ArithmeticExpressionGrammar.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ArithmeticExpressionGrammar.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ArithmeticExpressionGrammar.cs	(revision 3373)
@@ -0,0 +1,90 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols;
+using HeuristicLab.Data;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
+  [StorableClass]
+  [Item("ArithmeticExpressionGrammar", "Represents a grammar for functional expressions using only arithmetic operations.")]
+  public class ArithmeticExpressionGrammar : DefaultSymbolicExpressionGrammar {
+    [Storable]
+    private List<string> variableNames = new List<string>();
+    public IEnumerable<string> VariableNames {
+      get { return variableNames; }
+      set {
+        variableNames = new List<string>(value);
+        variableSymbol.VariableNames = variableNames;
+      }
+    }
+
+    [Storable]
+    private HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable variableSymbol;
+
+    public ArithmeticExpressionGrammar()
+      : base() {
+      Initialize();
+    }
+
+    private void Initialize() {
+      var add = new Addition();
+      var sub = new Subtraction();
+      var mul = new Multiplication();
+      var div = new Division();
+      var constant = new Constant();
+      variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable();
+
+      var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, variableSymbol };
+      var functionSymbols = new List<Symbol>() { add, sub, mul, div };
+
+      foreach (var symb in allSymbols)
+        AddSymbol(symb);
+
+      foreach (var funSymb in functionSymbols) {
+        SetMinSubtreeCount(funSymb, 1);
+        SetMaxSubtreeCount(funSymb, 3);
+      }
+      SetMinSubtreeCount(constant, 0);
+      SetMaxSubtreeCount(constant, 0);
+      SetMinSubtreeCount(variableSymbol, 0);
+      SetMaxSubtreeCount(variableSymbol, 0);
+
+      // allow each symbol as child of the start symbol
+      foreach (var symb in allSymbols) {
+        SetAllowedChild(StartSymbol, symb, 0);
+      }
+
+      // allow each symbol as child of every other symbol (except for terminals that have maxSubtreeCount == 0)
+      foreach (var parent in allSymbols) {
+        for (int i = 0; i < GetMaxSubtreeCount(parent); i++)
+          foreach (var child in allSymbols) {
+            SetAllowedChild(parent, child, i);
+          }
+      }
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ISymbolicRegressionEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ISymbolicRegressionEvaluator.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/ISymbolicRegressionEvaluator.cs	(revision 3373)
@@ -0,0 +1,42 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Drawing;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
+  public interface ISymbolicRegressionEvaluator : ISingleObjectiveEvaluator {
+    ILookupParameter<SymbolicExpressionTree> FunctionTreeParameter { get; }
+    ILookupParameter<RegressionProblemData> RegressionProblemDataParameter { get; }
+    ILookupParameter<DoubleValue> NumberOfEvaluatedNodesParameter { get; }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionEvaluator.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionEvaluator.cs	(revision 3373)
@@ -0,0 +1,97 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using HeuristicLab.Common;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using System.Collections.Generic;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
+  [StorableClass]
+  [Item("SimpleArithmeticExpressionEvaluator", "Default evaluator for arithmetic symbolic expression trees.")]
+  public class SimpleArithmeticExpressionEvaluator {
+    private Dataset dataset;
+    private int row;
+    private Instruction[] code;
+    private int pc;
+    public IEnumerable<double> EstimatedValues(SymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) {
+      this.dataset = dataset;
+      var compiler = new SymbolicExpressionTreeCompiler();
+      code = compiler.Compile(tree);
+      foreach (var row in rows) {
+        this.row = row;
+        pc = 0;
+        var estimatedValue = Evaluate();
+        if (double.IsNaN(estimatedValue) || double.IsInfinity(estimatedValue)) yield return 0.0;
+        else yield return estimatedValue;
+      }
+    }
+
+    public double Evaluate() {
+      var currentInstr = code[pc++];
+      switch (currentInstr.symbol) {
+        case CodeSymbol.Add: {
+            double s = 0.0;
+            for (int i = 0; i < currentInstr.nArguments; i++) {
+              s += Evaluate();
+            }
+            return s;
+          }
+        case CodeSymbol.Sub: {
+            double s = Evaluate();
+            for (int i = 1; i < currentInstr.nArguments; i++) {
+              s -= Evaluate();
+            }
+            return s;
+          }
+        case CodeSymbol.Mul: {
+            double p = Evaluate();
+            for (int i = 1; i < currentInstr.nArguments; i++) {
+              p *= Evaluate();
+            }
+            return p;
+          }
+        case CodeSymbol.Div: {
+            double p = Evaluate();
+            for (int i = 1; i < currentInstr.nArguments; i++) {
+              p /= Evaluate();
+            }
+            return p;
+          }
+        case CodeSymbol.Dynamic: {
+            var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
+            if (variableTreeNode != null) {
+              return dataset[row, dataset.GetVariableIndex(variableTreeNode.VariableName)] * variableTreeNode.Weight;
+            }
+            var constTreeNode = currentInstr.dynamicNode as ConstantTreeNode;
+            if (constTreeNode != null) {
+              return constTreeNode.Value;
+            } else throw new NotSupportedException();
+          }
+        default: throw new NotSupportedException();
+      }
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Constant.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Constant.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Constant.cs	(revision 3373)
@@ -0,0 +1,52 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Core;
+using HeuristicLab.Operators;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Parameters;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
+  [StorableClass]
+  [Item("Constant", "Represents a constant value.")]
+  public sealed class Constant : Symbol {
+    #region Propeties
+    private double minValue;
+    public double MinValue {
+      get { return minValue; }
+      set { minValue = value; }
+    }
+    private double maxValue;
+    public double MaxValue {
+      get { return maxValue; }
+      set { maxValue = value; }
+    }
+    #endregion
+    public Constant()
+      : base() {
+    }
+
+    public override SymbolicExpressionTreeNode CreateTreeNode() {
+      return new ConstantTreeNode(this);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/ConstantTreeNode.cs	(revision 3373)
@@ -0,0 +1,65 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System;
+using System.Collections.Generic;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Random;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
+  [StorableClass]
+  public sealed class ConstantTreeNode : SymbolicExpressionTreeTerminalNode {
+    public new Constant Symbol {
+      get { return (Constant)base.Symbol; }
+    }
+    public override bool HasLocalParameters {
+      get {
+        return true;
+      }
+    }
+
+    private double constantValue;
+    [Storable]
+    public double Value {
+      get { return constantValue; }
+      set { constantValue = value; }
+    }
+    // copy constructor
+    private ConstantTreeNode(ConstantTreeNode original)
+      : base(original) {
+      constantValue = original.constantValue;
+    }
+
+    public ConstantTreeNode(Constant constantSymbol) : base(constantSymbol) { }
+
+    public override void ResetLocalParameters(IRandom random) {
+      base.ResetLocalParameters(random);
+      var range = Symbol.MaxValue - Symbol.MaxValue;
+      Value = random.NextDouble() * range - Symbol.MinValue;
+    }
+
+    public override object Clone() {
+      return new ConstantTreeNode(this);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs	(revision 3373)
@@ -0,0 +1,73 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Core;
+using HeuristicLab.Operators;
+using HeuristicLab.Random;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Parameters;
+using System.Collections.Generic;
+using System;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
+  [StorableClass]
+  [Item("Variable", "Represents a variable value.")]
+  public sealed class Variable : Symbol {
+    #region Properties
+    private double weightNu;
+    [Storable]
+    public double WeightNu {
+      get { return weightNu; }
+      set { weightNu = value; }
+    }
+    private double weightSigma;
+    [Storable]
+    public double WeightSigma {
+      get { return weightSigma; }
+      set {
+        if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
+        weightSigma = value;
+      }
+    }
+    private List<string> variableNames;
+    [Storable]
+    public ICollection<string> VariableNames {
+      get { return variableNames; }
+      set {
+        if (value == null) throw new ArgumentNullException();
+        variableNames.Clear();
+        variableNames.AddRange(value);
+      }
+    }
+    #endregion
+    public Variable()
+      : base() {
+      weightNu = 1.0;
+      weightSigma = 1.0;
+      variableNames = new List<string>();
+    }
+
+    public override SymbolicExpressionTreeNode CreateTreeNode() {
+      return new VariableTreeNode(this);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs	(revision 3373)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableTreeNode.cs	(revision 3373)
@@ -0,0 +1,70 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System;
+using System.Collections.Generic;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Random;
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
+  [StorableClass]
+  public sealed class VariableTreeNode : SymbolicExpressionTreeTerminalNode {
+    public new Variable Symbol {
+      get { return (Variable)base.Symbol; }
+    }
+    private double weight;
+    [Storable]
+    public double Weight {
+      get { return weight; }
+      set { weight = value; }
+    }
+    private string variableName;
+    [Storable]
+    public string VariableName {
+      get { return variableName; }
+      set { variableName = value; }
+    }
+
+    // copy constructor
+    private VariableTreeNode(VariableTreeNode original)
+      : base(original) {
+      weight = original.weight;
+      variableName = original.variableName;
+    }
+
+    public VariableTreeNode(Variable variableSymbol) : base(variableSymbol) { }
+
+    public override void ResetLocalParameters(IRandom random) {
+      base.ResetLocalParameters(random);
+      var normalDistributedRNG = new NormalDistributedRandom(random, Symbol.WeightNu, Symbol.WeightSigma);
+      weight = normalDistributedRNG.NextDouble();
+      var variableList = new List<string>(Symbol.VariableNames);
+      int variableIndex = random.Next(0, variableList.Count);
+      variableName = variableList[variableIndex];
+    }
+
+    public override object Clone() {
+      return new VariableTreeNode(this);
+    }
+  }
+}
