Index: trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs	(revision 363)
+++ trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs	(revision 365)
@@ -96,4 +96,9 @@
             return currInstr.d_arg0;
           }
+        case EvaluatorSymbolTable.DIFFERENTIAL: {
+            int row = sampleIndex + currInstr.i_arg1;
+            if(row < 1 || row >= dataset.Rows) return double.NaN;
+            else return currInstr.d_arg0 * (dataset.GetValue(row, currInstr.i_arg0) - dataset.GetValue(row - 1, currInstr.i_arg0));
+          }
         case EvaluatorSymbolTable.MULTIPLICATION: {
             double result = EvaluateBakedCode();
Index: trunk/sources/HeuristicLab.Functions/Differential.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/Differential.cs	(revision 365)
+++ trunk/sources/HeuristicLab.Functions/Differential.cs	(revision 365)
@@ -0,0 +1,74 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 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.Text;
+using HeuristicLab.Core;
+using System.Diagnostics;
+using HeuristicLab.Data;
+using HeuristicLab.Constraints;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.Functions {
+  public sealed class Differential : FunctionBase {
+
+    public const string WEIGHT = "Weight";
+    public const string OFFSET = "SampleOffset";
+    public const string INDEX = "Variable";
+
+    public override string Description {
+      get {
+        return @"Differential returns the difference between the value of a variable at t and t-1. The weight is a coefficient that is multiplied to the the difference.";
+      }
+    }
+
+    public Differential()
+      : base() {
+      AddVariableInfo(new VariableInfo(INDEX, "Index of the variable in the dataset representing this feature", typeof(ConstrainedIntData), VariableKind.None));
+      GetVariableInfo(INDEX).Local = true;
+      AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(ConstrainedDoubleData), VariableKind.None));
+      GetVariableInfo(WEIGHT).Local = true;
+      AddVariableInfo(new VariableInfo(OFFSET, "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None));
+      GetVariableInfo(OFFSET).Local = true;
+
+      ConstrainedDoubleData weight = new ConstrainedDoubleData();
+      // initialize a totally arbitrary range for the weight = [-20.0, 20.0]
+      weight.AddConstraint(new DoubleBoundedConstraint(-20.0, 20.0));
+      AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight));
+
+      ConstrainedIntData variable = new ConstrainedIntData();
+      AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
+
+      ConstrainedIntData sampleOffset = new ConstrainedIntData();
+      // initialize a totally arbitrary default range for sampleoffset = [-10, 10]
+      sampleOffset.AddConstraint(new IntBoundedConstraint(0, 0));
+      AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset));
+
+      // variable can't have suboperators
+      AddConstraint(new NumberOfSubOperatorsConstraint(0, 0));
+    }
+
+    public override void Accept(IFunctionVisitor visitor) {
+      visitor.Visit(this);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Functions/FunctionView.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/FunctionView.cs	(revision 363)
+++ trunk/sources/HeuristicLab.Functions/FunctionView.cs	(revision 365)
@@ -168,4 +168,19 @@
       public void Visit(Cosinus cosinus) {
         name = "Sin";
+      }
+
+      public void Visit(Differential diff) {
+        string timeOffset = "";
+        int sampleOffset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.OFFSET).Value).Data;
+        int variableIndex = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.INDEX).Value).Data;
+        double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.WEIGHT).Value).Data;
+        if(sampleOffset < 0) {
+          timeOffset = "(t" + sampleOffset + ")";
+        } else if(sampleOffset > 0) {
+          timeOffset = "(t+" + sampleOffset + ")";
+        } else {
+          timeOffset = "";
+        }
+        name = "Diff" + variableIndex + timeOffset + " * " + weight;
       }
 
Index: trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj
===================================================================
--- trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj	(revision 363)
+++ trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj	(revision 365)
@@ -56,4 +56,5 @@
     <Compile Include="BakedTreeEvaluator.cs" />
     <Compile Include="Constant.cs" />
+    <Compile Include="Differential.cs" />
     <Compile Include="GreaterThan.cs" />
     <Compile Include="IfThenElse.cs">
Index: trunk/sources/HeuristicLab.Functions/IFunctionVisitor.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/IFunctionVisitor.cs	(revision 363)
+++ trunk/sources/HeuristicLab.Functions/IFunctionVisitor.cs	(revision 365)
@@ -33,4 +33,5 @@
     void Visit(Constant constant);
     void Visit(Cosinus cosinus);
+    void Visit(Differential differential);
     void Visit(Division division);
     void Visit(Equal equal);
Index: trunk/sources/HeuristicLab.Functions/ModelAnalyzerExporter.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/ModelAnalyzerExporter.cs	(revision 363)
+++ trunk/sources/HeuristicLab.Functions/ModelAnalyzerExporter.cs	(revision 365)
@@ -59,4 +59,12 @@
     public void Visit(Cosinus cosinus) {
       VisitFunction("Trigonometrics[1]", cosinus);
+    }
+
+    public void Visit(Differential differential) {
+      double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.WEIGHT).Value).Data;
+      double index = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.INDEX).Value).Data;
+      double offset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Differential.OFFSET).Value).Data;
+
+      prefix += currentIndend + "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
     }
 
Index: trunk/sources/HeuristicLab.Functions/SymbolTable.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/SymbolTable.cs	(revision 363)
+++ trunk/sources/HeuristicLab.Functions/SymbolTable.cs	(revision 365)
@@ -34,4 +34,5 @@
     public const int CONSTANT = 4;
     public const int COSINUS = 5;
+    public const int DIFFERENTIAL = 25;
     public const int DIVISION = 6;
     public const int EQU = 7;
@@ -82,4 +83,5 @@
       staticTypes[typeof(Variable)] = VARIABLE;
       staticTypes[typeof(Xor)] = XOR;
+      staticTypes[typeof(Differential)] = DIFFERENTIAL;
     }
 
