Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Constant.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Constant.cs	(revision 145)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Constant.cs	(revision 146)
@@ -31,4 +31,6 @@
 namespace HeuristicLab.Functions {
   public class Constant : FunctionBase {
+    public static readonly string VALUE = "Value";
+
     public override string Description {
       get { return "Returns the value of local variable 'Value'."; }
@@ -44,6 +46,6 @@
     public Constant()
       : base() {
-      AddVariableInfo(new VariableInfo("Value", "The constant value", typeof(ConstrainedDoubleData), VariableKind.None));
-      GetVariableInfo("Value").Local = true;
+      AddVariableInfo(new VariableInfo(VALUE, "The constant value", typeof(ConstrainedDoubleData), VariableKind.None));
+      GetVariableInfo(VALUE).Local = true;
 
       ConstrainedDoubleData valueData = new ConstrainedDoubleData();
@@ -52,5 +54,5 @@
 
       // create the local variable
-      HeuristicLab.Core.Variable value = new HeuristicLab.Core.Variable("Value", valueData);
+      HeuristicLab.Core.Variable value = new HeuristicLab.Core.Variable(VALUE, valueData);
       AddVariable(value);
 
@@ -61,5 +63,5 @@
     public override object Clone(IDictionary<Guid, object> clonedObjects) {
       Constant clone = (Constant)base.Clone(clonedObjects);
-      clone.value = (ConstrainedDoubleData)clone.GetVariable("Value").Value;
+      clone.value = (ConstrainedDoubleData)clone.GetVariable(VALUE).Value;
       return clone;
     }
@@ -67,5 +69,5 @@
     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
       base.Populate(node, restoredObjects);
-      value = (ConstrainedDoubleData)GetVariable("Value").Value;
+      value = (ConstrainedDoubleData)GetVariable(VALUE).Value;
     }
 
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionView.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionView.cs	(revision 145)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/FunctionView.cs	(revision 146)
@@ -30,4 +30,5 @@
 using HeuristicLab.Core;
 using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Data;
 
 namespace HeuristicLab.Functions {
@@ -52,8 +53,8 @@
     protected override void UpdateControls() {
       functionTreeView.Nodes.Clear();
-      //functionTree.Accept(functionNameVisitor);
+      functionNameVisitor.Visit(functionTree);
       TreeNode rootNode = new TreeNode();
-      rootNode.Name = "TASK";// function.Name;
-      rootNode.Text = "TASK"; // functionNameVisitor.Name;
+      rootNode.Name = functionTree.Function.Name;
+      rootNode.Text = functionNameVisitor.Name;
       rootNode.Tag = functionTree;
       rootNode.ContextMenuStrip = treeNodeContextMenu;
@@ -68,7 +69,7 @@
     private void CreateTree(TreeNode rootNode, IFunctionTree functionTree) {
       TreeNode node = new TreeNode();
-      //functionTree.Accept(functionNameVisitor);
-      node.Name = "TASK"; // function.Name;
-      node.Text = "TASK"; // functionNameVisitor.Name;
+      functionNameVisitor.Visit(functionTree);
+      node.Name = functionTree.Function.Name;
+      node.Text = functionNameVisitor.Name;
       node.Tag = functionTree;
       node.ContextMenuStrip = treeNodeContextMenu;
@@ -121,6 +122,6 @@
       if(functionTreeView.SelectedNode != null && functionTreeView.SelectedNode.Tag != null) {
         TreeNode node = functionTreeView.SelectedNode;
-        // selectedFunctionTree.Accept(functionNameVisitor);
-        node.Text = "TASK"; // functionNameVisitor.Name;
+        functionNameVisitor.Visit(selectedBranch);
+        node.Text = functionNameVisitor.Name;
       }
     }
@@ -134,11 +135,12 @@
       if(node == null || node.Tag == null) return;
 
-      // ModelAnalyzerExportVisitor visitor = new ModelAnalyzerExportVisitor();
-      // ((IFunctionTree)node.Tag).Accept(visitor);
-      // Clipboard.SetText(visitor.ModelAnalyzerPrefix);
+      ModelAnalyzerExportVisitor visitor = new ModelAnalyzerExportVisitor();
+      visitor.Visit((IFunctionTree)node.Tag);
+      Clipboard.SetText(visitor.ModelAnalyzerPrefix);
     }
 
     private class FunctionNameVisitor : IFunctionVisitor {
       string name;
+      IFunctionTree currentBranch;
 
       public string Name {
@@ -146,6 +148,10 @@
       }
 
+      public void Visit(IFunctionTree tree) {
+        currentBranch = tree;
+        tree.Function.Accept(this);
+      }
+
       #region IFunctionVisitor Members
-
       public void Visit(IFunction function) {
         name = function.Name;
@@ -157,5 +163,5 @@
 
       public void Visit(Constant constant) {
-        name = constant.Value + "";
+        name = ((ConstrainedDoubleData)(currentBranch.GetLocalVariable(HeuristicLab.Functions.Constant.VALUE).Value)).Data + "";
       }
 
@@ -206,12 +212,15 @@
       public void Visit(Variable variable) {
         string timeOffset = "";
-        if(variable.SampleOffset < 0) {
-          timeOffset = "(t" + variable.SampleOffset + ")";
-        } else if(variable.SampleOffset > 0) {
-          timeOffset = "(t+" + variable.SampleOffset + ")";
+        int sampleOffset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.OFFSET).Value).Data;
+        int variableIndex = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.INDEX).Value).Data;
+        double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.WEIGHT).Value).Data;
+        if(sampleOffset < 0) {
+          timeOffset = "(t" + sampleOffset + ")";
+        } else if(sampleOffset > 0) {
+          timeOffset = "(t+" + sampleOffset + ")";
         } else {
           timeOffset = "";
         }
-        name = "Var" + variable.VariableIndex + timeOffset + " * " + variable.Weight;
+        name = "Var" + variableIndex + timeOffset + " * " + weight;
       }
 
@@ -251,123 +260,132 @@
     }
 
-    //private class ModelAnalyzerExportVisitor : IFunctionVisitor {
-    //  private string prefix;
-    //  private string currentIndend = "";
-    //  public string ModelAnalyzerPrefix {
-    //    get { return prefix; }
-    //  }
-    //  public void Reset() {
-    //    prefix = "";
-    //  }
-
-    //  private void VisitFunction(string name, IFunction f) {
-    //    prefix += currentIndend + "[F]"+name+"(\n";
-    //    currentIndend += "  ";
-    //    foreach(IFunction subFunction in f.SubTrees) {
-    //      subFunction.Accept(this);
-    //      prefix += ";\n";
-    //    }
-    //    prefix = prefix.TrimEnd(';','\n');
-    //    prefix += ")";
-    //    currentIndend = currentIndend.Remove(0, 2);
-    //  }
-
-    //  #region IFunctionVisitor Members
-
-    //  public void Visit(IFunction function) {
-    //    prefix += function.Name;
-    //  }
-
-    //  public void Visit(Addition addition) {
-    //    VisitFunction("Addition[0]", addition);
-    //  }
-
-    //  public void Visit(Constant constant) {
-    //    prefix += currentIndend + "[T]Constant(" + constant.Value.Data.ToString() + ";0;0)";
-    //  }
-
-    //  public void Visit(Cosinus cosinus) {
-    //    VisitFunction("Trigonometrics[1]", cosinus);
-    //  }
-
-    //  public void Visit(Division division) {
-    //    VisitFunction("Division[0]", division);
-    //  }
-
-    //  public void Visit(Exponential exponential) {
-    //    VisitFunction("Exponential[0]", exponential);
-    //  }
-
-    //  public void Visit(Logarithm logarithm) {
-    //    VisitFunction("Logarithm[0]", logarithm);
-    //  }
-
-    //  public void Visit(Multiplication multiplication) {
-    //    VisitFunction("Multiplication[0]", multiplication);
-    //  }
-
-    //  public void Visit(Power power) {
-    //    VisitFunction("Power[0]", power);
-    //  }
-
-    //  public void Visit(Signum signum) {
-    //    VisitFunction("Signum[0]", signum);
-    //  }
-
-    //  public void Visit(Sinus sinus) {
-    //    VisitFunction("Trigonometrics[0]", sinus);
-    //  }
-
-    //  public void Visit(Sqrt sqrt) {
-    //    VisitFunction("Sqrt[0]", sqrt);
-    //  }
-
-    //  public void Visit(Substraction substraction) {
-    //    VisitFunction("Substraction[0]", substraction);
-    //  }
-
-    //  public void Visit(Tangens tangens) {
-    //    VisitFunction("Trigonometrics[2]", tangens);
-    //  }
-
-    //  public void Visit(HeuristicLab.Functions.Variable variable) {
-    //    prefix += currentIndend + "[T]Variable(" + variable.Weight + ";" + variable.VariableIndex + ";" + -variable.SampleOffset + ")";
-    //  }
-
-    //  public void Visit(And and) {
-    //    VisitFunction("Logical[0]", and);
-    //  }
-
-    //  public void Visit(Average average) {
-    //    VisitFunction("N/A (average)", average);
-    //  }
-
-    //  public void Visit(IfThenElse ifThenElse) {
-    //    VisitFunction("Conditional[0]", ifThenElse);
-    //  }
-
-    //  public void Visit(Not not) {
-    //    VisitFunction("Logical[2]", not);
-    //  }
-
-    //  public void Visit(Or or) {
-    //    VisitFunction("Logical[1]", or);
-    //  }
-
-    //  public void Visit(Xor xor) {
-    //    VisitFunction("N/A (xor)", xor);
-    //  }
-
-    //  public void Visit(Equal equal) {
-    //    VisitFunction("Boolean[2]", equal);
-    //  }
-
-    //  public void Visit(LessThan lessThan) {
-    //    VisitFunction("Boolean[0]", lessThan);
-    //  }
-
-    //  #endregion
-    //}
-
+    private class ModelAnalyzerExportVisitor : IFunctionVisitor {
+      private string prefix;
+      private string currentIndend = "";
+      private IFunctionTree currentBranch;
+      public string ModelAnalyzerPrefix {
+        get { return prefix; }
+      }
+      public void Reset() {
+        prefix = "";
+      }
+
+      private void VisitFunction(string name, IFunction f) {
+        prefix += currentIndend + "[F]" + name + "(\n";
+      }
+
+      #region IFunctionVisitor Members
+
+      public void Visit(IFunction function) {
+        prefix += function.Name;
+      }
+
+      public void Visit(Addition addition) {
+        VisitFunction("Addition[0]", addition);
+      }
+
+      public void Visit(Constant constant) {
+        double value = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Constant.VALUE).Value).Data;
+        prefix += currentIndend + "[T]Constant(" + value + ";0;0)";
+      }
+
+      public void Visit(Cosinus cosinus) {
+        VisitFunction("Trigonometrics[1]", cosinus);
+      }
+
+      public void Visit(Division division) {
+        VisitFunction("Division[0]", division);
+      }
+
+      public void Visit(Exponential exponential) {
+        VisitFunction("Exponential[0]", exponential);
+      }
+
+      public void Visit(Logarithm logarithm) {
+        VisitFunction("Logarithm[0]", logarithm);
+      }
+
+      public void Visit(Multiplication multiplication) {
+        VisitFunction("Multiplication[0]", multiplication);
+      }
+
+      public void Visit(Power power) {
+        VisitFunction("Power[0]", power);
+      }
+
+      public void Visit(Signum signum) {
+        VisitFunction("Signum[0]", signum);
+      }
+
+      public void Visit(Sinus sinus) {
+        VisitFunction("Trigonometrics[0]", sinus);
+      }
+
+      public void Visit(Sqrt sqrt) {
+        VisitFunction("Sqrt[0]", sqrt);
+      }
+
+      public void Visit(Substraction substraction) {
+        VisitFunction("Substraction[0]", substraction);
+      }
+
+      public void Visit(Tangens tangens) {
+        VisitFunction("Trigonometrics[2]", tangens);
+      }
+
+      public void Visit(HeuristicLab.Functions.Variable variable) {
+        double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.WEIGHT).Value).Data;
+        double index = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.INDEX).Value).Data;
+        double offset = ((ConstrainedIntData)currentBranch.GetLocalVariable(HeuristicLab.Functions.Variable.OFFSET).Value).Data;
+
+        prefix += currentIndend + "[T]Variable(" + weight + ";" + index + ";" + -offset + ")";
+      }
+
+      public void Visit(And and) {
+        VisitFunction("Logical[0]", and);
+      }
+
+      public void Visit(Average average) {
+        VisitFunction("N/A (average)", average);
+      }
+
+      public void Visit(IfThenElse ifThenElse) {
+        VisitFunction("Conditional[0]", ifThenElse);
+      }
+
+      public void Visit(Not not) {
+        VisitFunction("Logical[2]", not);
+      }
+
+      public void Visit(Or or) {
+        VisitFunction("Logical[1]", or);
+      }
+
+      public void Visit(Xor xor) {
+        VisitFunction("N/A (xor)", xor);
+      }
+
+      public void Visit(Equal equal) {
+        VisitFunction("Boolean[2]", equal);
+      }
+
+      public void Visit(LessThan lessThan) {
+        VisitFunction("Boolean[0]", lessThan);
+      }
+      #endregion
+
+      public void Visit(IFunctionTree functionTree) {
+        currentBranch = functionTree;
+        functionTree.Function.Accept(this);
+        currentIndend += "  ";
+        foreach(IFunctionTree subTree in functionTree.SubTrees) {
+          Visit(subTree);
+          prefix += ";\n";
+        }
+        prefix = prefix.TrimEnd(';', '\n');
+        prefix += ")";
+        currentIndend = currentIndend.Remove(0, 2);
+      }
+    }
   }
 }
Index: /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Variable.cs
===================================================================
--- /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Variable.cs	(revision 145)
+++ /branches/FunctionsAndStructIdRefactoring/HeuristicLab.Functions/Variable.cs	(revision 146)
@@ -32,4 +32,8 @@
   public class Variable : FunctionBase {
 
+    public static readonly string WEIGHT = "Weight";
+    public static readonly string OFFSET = "SampleOffset";
+    public static readonly string INDEX = "Variable";
+
     private ConstrainedIntData variable;
     private ConstrainedDoubleData weight;
@@ -56,23 +60,23 @@
     public Variable()
       : base() {
-      AddVariableInfo(new VariableInfo("Variable", "Index of the variable in the dataset representing this feature", typeof(ConstrainedIntData), VariableKind.None));
-      GetVariableInfo("Variable").Local = true;
-      AddVariableInfo(new VariableInfo("Weight", "Weight is multiplied to the feature value", typeof(ConstrainedDoubleData), VariableKind.None));
-      GetVariableInfo("Weight").Local = true;
-      AddVariableInfo(new VariableInfo("SampleOffset", "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None));
-      GetVariableInfo("SampleOffset").Local = true;
+      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;
 
       variable = new ConstrainedIntData();
-      AddVariable(new HeuristicLab.Core.Variable("Variable", variable));
+      AddVariable(new HeuristicLab.Core.Variable(INDEX, variable));
 
       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));
+      AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight));
 
       sampleOffset = new ConstrainedIntData();
       // initialize a totally arbitrary default range for sampleoffset = [-10, 10]
       sampleOffset.AddConstraint(new IntBoundedConstraint(0, 0));
-      AddVariable(new HeuristicLab.Core.Variable("SampleOffset", sampleOffset));
+      AddVariable(new HeuristicLab.Core.Variable(OFFSET, sampleOffset));
 
       // samplefeature can't have suboperators
@@ -82,7 +86,7 @@
     public override object Clone(IDictionary<Guid, object> clonedObjects) {
       HeuristicLab.Functions.Variable clone = (HeuristicLab.Functions.Variable)base.Clone(clonedObjects);
-      clone.variable = (ConstrainedIntData)clone.GetVariable("Variable").Value;
-      clone.weight = (ConstrainedDoubleData)clone.GetVariable("Weight").Value;
-      clone.sampleOffset = (ConstrainedIntData)clone.GetVariable("SampleOffset").Value;
+      clone.variable = (ConstrainedIntData)clone.GetVariable(INDEX).Value;
+      clone.weight = (ConstrainedDoubleData)clone.GetVariable(WEIGHT).Value;
+      clone.sampleOffset = (ConstrainedIntData)clone.GetVariable(OFFSET).Value;
       return clone;
     }
@@ -90,7 +94,7 @@
     public override void Populate(System.Xml.XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
       base.Populate(node, restoredObjects);
-      variable = (ConstrainedIntData)GetVariable("Variable").Value;
-      weight = (ConstrainedDoubleData)GetVariable("Weight").Value;
-      sampleOffset = (ConstrainedIntData)GetVariable("SampleOffset").Value;
+      variable = (ConstrainedIntData)GetVariable(INDEX).Value;
+      weight = (ConstrainedDoubleData)GetVariable(WEIGHT).Value;
+      sampleOffset = (ConstrainedIntData)GetVariable(OFFSET).Value;
     }
 
