Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Addition.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Addition.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Addition.cs	(revision 654)
@@ -47,8 +47,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/And.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/And.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/And.cs	(revision 654)
@@ -43,8 +43,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Average.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Average.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Average.cs	(revision 654)
@@ -41,8 +41,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Constant.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Constant.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Constant.cs	(revision 654)
@@ -90,8 +90,4 @@
       AddVariable(new HeuristicLab.Core.Variable(MANIPULATION, combinedOp));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Cosinus.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Cosinus.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Cosinus.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Differential.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Differential.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Differential.cs	(revision 654)
@@ -43,8 +43,4 @@
       : base() {
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Division.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Division.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Division.cs	(revision 654)
@@ -54,8 +54,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Equal.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Equal.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Equal.cs	(revision 654)
@@ -41,8 +41,4 @@
       AddConstraint(new SubOperatorTypeConstraint(1));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Exponential.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Exponential.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Exponential.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/GreaterThan.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/GreaterThan.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/GreaterThan.cs	(revision 654)
@@ -40,7 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(1));
     }
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/IfThenElse.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/IfThenElse.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/IfThenElse.cs	(revision 654)
@@ -43,8 +43,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/LessThan.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/LessThan.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/LessThan.cs	(revision 654)
@@ -41,8 +41,4 @@
       AddConstraint(new SubOperatorTypeConstraint(1));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Logarithm.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Logarithm.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Logarithm.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/ModelAnalyzerExporter.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/ModelAnalyzerExporter.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/ModelAnalyzerExporter.cs	(revision 654)
@@ -27,142 +27,194 @@
 
 namespace HeuristicLab.GP.StructureIdentification {
-  public class ModelAnalyzerExporter : IFunctionVisitor {
-    private string prefix;
-    private string currentIndent = "";
-    private IFunctionTree currentBranch;
-    public string ModelAnalyzerPrefix {
-      get { return prefix; }
-    }
-    public void Reset() {
-      prefix = "";
-    }
-
-    private void VisitFunction(string name, IFunction f) {
-      prefix += currentIndent + "[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(Constant.VALUE).Value).Data;
-      prefix += currentIndent + "[T]Constant(" + value.ToString("r") + ";0;0)";
-    }
-
-    public void Visit(Cosinus cosinus) {
-      VisitFunction("Trigonometrics[1]", cosinus);
-    }
-
-    public void Visit(Differential differential) {
-      double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(Differential.WEIGHT).Value).Data;
-      double index = ((ConstrainedIntData)currentBranch.GetLocalVariable(Differential.INDEX).Value).Data;
-      double offset = ((ConstrainedIntData)currentBranch.GetLocalVariable(Differential.OFFSET).Value).Data;
-
-      prefix += currentIndent + "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
-    }
-
-    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(Subtraction substraction) {
-      VisitFunction("Subtraction[0]", substraction);
-    }
-
-    public void Visit(Tangens tangens) {
-      VisitFunction("Trigonometrics[2]", tangens);
-    }
-
-    public void Visit(Variable variable) {
-      double weight = ((ConstrainedDoubleData)currentBranch.GetLocalVariable(Variable.WEIGHT).Value).Data;
-      double index = ((ConstrainedIntData)currentBranch.GetLocalVariable(Variable.INDEX).Value).Data;
-      double offset = ((ConstrainedIntData)currentBranch.GetLocalVariable(Variable.OFFSET).Value).Data;
-
-      prefix += currentIndent + "[T]Variable(" + weight.ToString("r") + ";" + 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);
-    }
-
-    public void Visit(GreaterThan greaterThan) {
-      VisitFunction("Boolean[4]", greaterThan);
-    }
+  public class ModelAnalyzerExporter : IFunctionTreeExporter, IFunctionTreeNameGenerator {
+    #region IFunctionTreeExporter Members
+
+    public string Name {
+      get {
+        return "HL2 ModelAnalyzer Exporter";
+      }
+    }
+
+    public bool TryExport(IFunctionTree tree, out string exported) {
+      try {
+        exported = Export(tree);
+        return true;
+      } catch(UnknownFunctionException) {
+        exported = "";
+        return false;
+      }
+    }
+
+    public string Export(IFunctionTree tree) {
+      string result = ExportFunction(tree.Function, tree);
+      result += "(\n";
+      foreach(IFunctionTree subTree in tree.SubTrees) {
+        result += Export(subTree);
+        result += ";\n";
+      }
+      result = result.TrimEnd(';', '\n');
+      if(tree.SubTrees.Count > 0) result += ")";
+      return result;
+    }
+
     #endregion
 
-    public void Visit(IFunctionTree functionTree) {
-      currentBranch = functionTree;
-      functionTree.Function.Accept(this);
-      currentIndent += "  ";
-      foreach(IFunctionTree subTree in functionTree.SubTrees) {
-        Visit(subTree);
-        prefix += ";\n";
-      }
-      prefix = prefix.TrimEnd(';', '\n');
-      if(functionTree.SubTrees.Count>0) prefix += ")";
-      currentIndent = currentIndent.Remove(0, 2);
+    private string ExportFunction(IFunction function, IFunctionTree tree) {
+      // this is smelly, if there is a cleaner way to have a 'dynamic' visitor 
+      // please let me know! (gkronber 14.10.2008)
+      if(function is Addition) return ((Addition)function).ExportToHL2(tree);
+      if(function is And) return ((And)function).ExportToHL2(tree);
+      if(function is Average) return ((Average)function).ExportToHL2(tree);
+      if(function is Constant) return ((Constant)function).ExportToHL2(tree);
+      if(function is Cosinus) return ((Cosinus)function).ExportToHL2(tree);
+      if(function is Differential) return ((Differential)function).ExportToHL2(tree);
+      if(function is Division) return ((Division)function).ExportToHL2(tree);
+      if(function is Equal) return ((Equal)function).ExportToHL2(tree);
+      if(function is Exponential) return ((Exponential)function).ExportToHL2(tree);
+      if(function is GreaterThan) return ((GreaterThan)function).ExportToHL2(tree);
+      if(function is IfThenElse) return ((IfThenElse)function).ExportToHL2(tree);
+      if(function is LessThan) return ((LessThan)function).ExportToHL2(tree);
+      if(function is Logarithm) return ((Logarithm)function).ExportToHL2(tree);
+      if(function is Multiplication) return ((Multiplication)function).ExportToHL2(tree);
+      if(function is Not) return ((Not)function).ExportToHL2(tree);
+      if(function is Or) return ((Or)function).ExportToHL2(tree);
+      if(function is Power) return ((Power)function).ExportToHL2(tree);
+      if(function is Signum) return ((Signum)function).ExportToHL2(tree);
+      if(function is Sinus) return ((Sinus)function).ExportToHL2(tree);
+      if(function is Sqrt) return ((Sqrt)function).ExportToHL2(tree);
+      if(function is Subtraction) return ((Subtraction)function).ExportToHL2(tree);
+      if(function is Tangens) return ((Tangens)function).ExportToHL2(tree);
+      if(function is Variable) return ((Variable)function).ExportToHL2(tree);
+      if(function is Xor) return ((Xor)function).ExportToHL2(tree);
+      throw new UnknownFunctionException(function.Name);
+    }
+
+    #region IFunctionTreeNameGenerator Members
+
+    string IFunctionTreeNameGenerator.Name {
+      get { return "HL2 Representation"; }
+    }
+
+    public string GetName(IFunctionTree tree) {
+      string name = "";
+      try {
+        name = ExportFunction(tree.Function, tree);
+      } catch(UnknownFunctionException) {
+        name = "N/A";
+      }
+      return name;
+    }
+
+    #endregion
+  }
+
+  internal static class HL2ExporterExtensions {
+    private static string GetHL2FunctionName(string name) {
+      return "[F]" + name ;
+    }
+
+    public static string ExportToHL2(this Addition addition, IFunctionTree tree) {
+      return GetHL2FunctionName("Addition[0]");
+    }
+
+    public static string ExportToHL2(this Constant constant, IFunctionTree tree) {
+      double value = ((ConstrainedDoubleData)tree.GetLocalVariable(Constant.VALUE).Value).Data;
+      return "[T]Constant(" + value.ToString("r") + ";0;0)";
+    }
+
+    public static string ExportToHL2(this Cosinus cosinus, IFunctionTree tree) {
+      return GetHL2FunctionName("Trigonometrics[1]");
+    }
+
+    public static string ExportToHL2(this Differential differential, IFunctionTree tree) {
+      double weight = ((ConstrainedDoubleData)tree.GetLocalVariable(Differential.WEIGHT).Value).Data;
+      double index = ((ConstrainedIntData)tree.GetLocalVariable(Differential.INDEX).Value).Data;
+      double offset = ((ConstrainedIntData)tree.GetLocalVariable(Differential.OFFSET).Value).Data;
+
+      return "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
+    }
+
+    public static string ExportToHL2(this Division division, IFunctionTree tree) {
+      return GetHL2FunctionName("Division[0]");
+    }
+
+    public static string ExportToHL2(this Exponential exponential, IFunctionTree tree) {
+      return GetHL2FunctionName("Exponential[0]");
+    }
+
+    public static string ExportToHL2(this Logarithm logarithm, IFunctionTree tree) {
+      return GetHL2FunctionName("Logarithm[0]");
+    }
+
+    public static string ExportToHL2(this Multiplication multiplication, IFunctionTree tree) {
+      return GetHL2FunctionName("Multiplication[0]");
+    }
+
+    public static string ExportToHL2(this Power power, IFunctionTree tree) {
+      return GetHL2FunctionName("Power[0]");
+    }
+
+    public static string ExportToHL2(this Signum signum, IFunctionTree tree) {
+      return GetHL2FunctionName("Signum[0]");
+    }
+
+    public static string ExportToHL2(this Sinus sinus, IFunctionTree tree) {
+      return GetHL2FunctionName("Trigonometrics[0]");
+    }
+
+    public static string ExportToHL2(this Sqrt sqrt, IFunctionTree tree) {
+      return GetHL2FunctionName("Sqrt[0]");
+    }
+
+    public static string ExportToHL2(this Subtraction substraction, IFunctionTree tree) {
+      return GetHL2FunctionName("Subtraction[0]");
+    }
+
+    public static string ExportToHL2(this Tangens tangens, IFunctionTree tree) {
+      return GetHL2FunctionName("Trigonometrics[2]");
+    }
+
+    public static string ExportToHL2(this Variable variable, IFunctionTree tree) {
+      double weight = ((ConstrainedDoubleData)tree.GetLocalVariable(Variable.WEIGHT).Value).Data;
+      double index = ((ConstrainedIntData)tree.GetLocalVariable(Variable.INDEX).Value).Data;
+      double offset = ((ConstrainedIntData)tree.GetLocalVariable(Variable.OFFSET).Value).Data;
+
+      return "[T]Variable(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
+    }
+
+    public static string ExportToHL2(this And and, IFunctionTree tree) {
+      return GetHL2FunctionName("Logical[0]");
+    }
+
+    public static string ExportToHL2(this Average average, IFunctionTree tree) {
+      return GetHL2FunctionName("Average[0]");
+    }
+
+    public static string ExportToHL2(this IfThenElse ifThenElse, IFunctionTree tree) {
+      return GetHL2FunctionName("Conditional[0]");
+    }
+
+    public static string ExportToHL2(this Not not, IFunctionTree tree) {
+      return GetHL2FunctionName("Logical[2]");
+    }
+
+    public static string ExportToHL2(this Or or, IFunctionTree tree) {
+      return GetHL2FunctionName("Logical[1]");
+    }
+
+    public static string ExportToHL2(this Xor xor, IFunctionTree tree) {
+      return GetHL2FunctionName("Logical[3]");
+    }
+
+    public static string ExportToHL2(this Equal equal, IFunctionTree tree) {
+      return GetHL2FunctionName("Boolean[2]");
+    }
+
+    public static string ExportToHL2(this LessThan lessThan, IFunctionTree tree) {
+      return GetHL2FunctionName("Boolean[0]");
+    }
+
+    public static string ExportToHL2(this GreaterThan greaterThan, IFunctionTree tree) {
+      return GetHL2FunctionName("Boolean[4]");
     }
   }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Multiplication.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Multiplication.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Multiplication.cs	(revision 654)
@@ -48,8 +48,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Not.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Not.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Not.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Or.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Or.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Or.cs	(revision 654)
@@ -43,8 +43,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Power.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Power.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Power.cs	(revision 654)
@@ -41,8 +41,4 @@
       AddConstraint(new SubOperatorTypeConstraint(1));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Signum.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Signum.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Signum.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Sinus.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Sinus.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Sinus.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Sqrt.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Sqrt.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Sqrt.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Subtraction.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Subtraction.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Subtraction.cs	(revision 654)
@@ -48,8 +48,4 @@
       AddConstraint(new SubOperatorTypeConstraint(2));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/SymbolicExpressionExporter.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/SymbolicExpressionExporter.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/SymbolicExpressionExporter.cs	(revision 654)
@@ -27,141 +27,192 @@
 
 namespace HeuristicLab.GP.StructureIdentification {
-  public class SymbolicExpressionExporter : IFunctionVisitor {
-    private IFunctionTree currentBranch;
+  public class SymbolicExpressionExporter : IFunctionTreeExporter, IFunctionTreeNameGenerator {
     private StringBuilder builder;
     private string currentIndent;
-    public SymbolicExpressionExporter() {
-      Reset();
-    }
-
-    public void Reset() {
+
+    #region IFunctionTreeExporter Members
+
+    public string Name {
+      get { return "Symbolic Expression Exporter"; }
+    }
+
+
+    public string Export(IFunctionTree tree) {
+      builder = new StringBuilder();
       currentIndent = "";
-      builder = new StringBuilder();
-    }
-
-    public string GetStringRepresentation() {
+      BuildExportString(tree);
       return builder.ToString();
     }
 
-    private void VisitFunction(string name, IFunction f) {
+    public bool TryExport(IFunctionTree tree, out string exported) {
+      try {
+        exported = Export(tree);
+        return true;
+      } catch(UnknownFunctionException) {
+        exported = "";
+        return false;
+      }
+    }
+
+    private void BuildExportString(IFunctionTree tree) {
       builder.Append(currentIndent);
-      builder.Append("(" + name + " ");
-    }
-
-    #region IFunctionVisitor Members
-
-    public void Visit(IFunction function) {
-      builder.Append(function.Name);
-    }
-
-    public void Visit(Addition addition) {
-      VisitFunction("+", addition);
-    }
-
-    public void Visit(Constant constant) {
-      builder.Append(currentIndent+currentBranch.GetLocalVariable(Constant.VALUE).Value);
-    }
-
-    public void Visit(Cosinus cosinus) {
-      VisitFunction("cos", cosinus);
-    }
-
-    public void Visit(Division division) {
-      VisitFunction("/", division);
-    }
-
-    public void Visit(Exponential exponential) {
-      VisitFunction("exp", exponential);
-    }
-
-    public void Visit(Logarithm logarithm) {
-      VisitFunction("log", logarithm);
-    }
-
-    public void Visit(Multiplication multiplication) {
-      VisitFunction("*", multiplication);
-    }
-
-    public void Visit(Power power) {
-      VisitFunction("expt", power);
-    }
-
-    public void Visit(Signum signum) {
-      VisitFunction("sign", signum);
-    }
-
-    public void Visit(Sinus sinus) {
-      VisitFunction("sin", sinus);
-    }
-
-    public void Visit(Sqrt sqrt) {
-      VisitFunction("sqrt", sqrt);
-    }
-
-    public void Visit(Subtraction subtraction) {
-      VisitFunction("-", subtraction);
-    }
-
-    public void Visit(Tangens tangens) {
-      VisitFunction("tan", tangens);
-    }
-
-    public void Visit(Variable variable) {
-      builder.Append(currentIndent + "(variable " + currentBranch.GetLocalVariable(Variable.WEIGHT).Value + " " +
-        currentBranch.GetLocalVariable(Variable.INDEX).Value + " " + currentBranch.GetLocalVariable(Variable.OFFSET).Value + ")");
-    }
-    public void Visit(Differential differential) {
-      builder.Append(currentIndent+"(differential " + currentBranch.GetLocalVariable(Differential.WEIGHT).Value + " "+
-        currentBranch.GetLocalVariable(Differential.INDEX).Value+ " " + currentBranch.GetLocalVariable(Differential.OFFSET).Value+")");
-    }
-
-    public void Visit(And and) {
-      VisitFunction("and", and);
-    }
-
-    public void Visit(Average average) {
-      VisitFunction("mean", average);
-    }
-
-    public void Visit(IfThenElse ifThenElse) {
-      VisitFunction("if", ifThenElse);
-    }
-
-    public void Visit(Not not) {
-      VisitFunction("not", not);
-    }
-
-    public void Visit(Or or) {
-      VisitFunction("or", or);
-    }
-
-    public void Visit(Xor xor) {
-      VisitFunction("xor", xor);
-    }
-
-    public void Visit(Equal equal) {
-      VisitFunction("equ", equal);
-    }
-
-    public void Visit(LessThan lessThan) {
-      VisitFunction("<", lessThan);
-    }
-
-    public void Visit(GreaterThan greaterThan) {
-      VisitFunction(">", greaterThan);
-    }
+      builder.Append("(" + ExportFunction(tree.Function, tree) + " ");
+      currentIndent += "  ";
+      foreach(IFunctionTree subTree in tree.SubTrees) {
+        builder.Append("\n");
+        BuildExportString(subTree);
+      }
+      if(tree.SubTrees.Count > 0) builder.Append(")");
+      currentIndent = currentIndent.Remove(0, 2);
+    }
+
+    private string ExportFunction(IFunction function, IFunctionTree tree) {
+      // this is smelly, if there is a cleaner way to have a 'dynamic' visitor 
+      // please let me know! (gkronber 14.10.2008)
+      if(function is Addition) return ((Addition)function).ExportToScheme();
+      if(function is And) return ((And)function).ExportToScheme();
+      if(function is Average) return ((Average)function).ExportToScheme();
+      if(function is Constant) return ((Constant)function).ExportToScheme(tree);
+      if(function is Cosinus) return ((Cosinus)function).ExportToScheme();
+      if(function is Differential) return ((Differential)function).ExportToScheme(tree);
+      if(function is Division) return ((Division)function).ExportToScheme();
+      if(function is Equal) return ((Equal)function).ExportToScheme();
+      if(function is Exponential) return ((Exponential)function).ExportToScheme();
+      if(function is GreaterThan) return ((GreaterThan)function).ExportToScheme();
+      if(function is IfThenElse) return ((IfThenElse)function).ExportToScheme();
+      if(function is LessThan) return ((LessThan)function).ExportToScheme();
+      if(function is Logarithm) return ((Logarithm)function).ExportToScheme();
+      if(function is Multiplication) return ((Multiplication)function).ExportToScheme();
+      if(function is Not) return ((Not)function).ExportToScheme();
+      if(function is Or) return ((Or)function).ExportToScheme();
+      if(function is Power) return ((Power)function).ExportToScheme();
+      if(function is Signum) return ((Signum)function).ExportToScheme();
+      if(function is Sinus) return ((Sinus)function).ExportToScheme();
+      if(function is Sqrt) return ((Sqrt)function).ExportToScheme();
+      if(function is Subtraction) return ((Subtraction)function).ExportToScheme();
+      if(function is Tangens) return ((Tangens)function).ExportToScheme();
+      if(function is Variable) return ((Variable)function).ExportToScheme(tree);
+      if(function is Xor) return ((Xor)function).ExportToScheme();
+      throw new UnknownFunctionException(function.Name);
+    }
+
+
     #endregion
 
-    public void Visit(IFunctionTree functionTree) {
-      currentBranch = functionTree;
-      functionTree.Function.Accept(this);
-      currentIndent += "  ";
-
-      foreach(IFunctionTree subTree in functionTree.SubTrees) {
-        builder.Append("\n");
-        Visit(subTree);
+    #region IFunctionTreeNameGenerator Members
+
+    string IFunctionTreeNameGenerator.Name {
+      get { return "Symbolic Expression"; }
+    }
+
+    public string GetName(IFunctionTree tree) {
+      string name = "";
+      try {
+        name = ExportFunction(tree.Function, tree);
+      } catch(UnknownFunctionException) {
+        name = "N/A";
       }
-      if(functionTree.SubTrees.Count > 0) builder.Append(")");
-      currentIndent = currentIndent.Remove(0, 2);
+      return name;
+    }
+
+    #endregion
+  }
+
+  internal static class SchemeExporterExtensions {
+    public static string ExportToScheme(this Addition addition) {
+      return "+";
+    }
+
+    public static string ExportToScheme(this Constant constant, IFunctionTree tree) {
+      return tree.GetLocalVariable(Constant.VALUE).Value.ToString();
+    }
+
+    public static string ExportToScheme(this Cosinus cosinus) {
+      return "cos";
+    }
+
+    public static string ExportToScheme(this Division division) {
+      return "/";
+    }
+
+    public static string ExportToScheme(this Exponential exponential) {
+      return "exp";
+    }
+
+    public static string ExportToScheme(this Logarithm logarithm) {
+      return "log";
+    }
+
+    public static string ExportToScheme(this Multiplication multiplication) {
+      return "*";
+    }
+
+    public static string ExportToScheme(this Power power) {
+      return "expt";
+    }
+
+    public static string ExportToScheme(this Signum signum) {
+      return "sign";
+    }
+
+    public static string ExportToScheme(this Sinus sinus) {
+      return "sin";
+    }
+
+    public static string ExportToScheme(this Sqrt sqrt) {
+      return "sqrt";
+    }
+
+    public static string ExportToScheme(this Subtraction subtraction) {
+      return "-";
+    }
+
+    public static string ExportToScheme(this Tangens tangens) {
+      return "tan";
+    }
+
+    public static string ExportToScheme(this Variable variable, IFunctionTree tree) {
+      return "(variable " + tree.GetLocalVariable(Variable.WEIGHT).Value + " " +
+        tree.GetLocalVariable(Variable.INDEX).Value + " " + tree.GetLocalVariable(Variable.OFFSET).Value + ")";
+    }
+    public static string ExportToScheme(this Differential differential, IFunctionTree tree) {
+      return "(differential " + tree.GetLocalVariable(Differential.WEIGHT).Value + " " +
+        tree.GetLocalVariable(Differential.INDEX).Value + " " + tree.GetLocalVariable(Differential.OFFSET).Value + ")";
+    }
+
+    public static string ExportToScheme(this And and) {
+      return "and";
+    }
+
+    public static string ExportToScheme(this Average average) {
+      return "mean";
+    }
+
+    public static string ExportToScheme(this IfThenElse ifThenElse) {
+      return "if";
+    }
+
+    public static string ExportToScheme(this Not not) {
+      return "not";
+    }
+
+    public static string ExportToScheme(this Or or) {
+      return "or";
+    }
+
+    public static string ExportToScheme(this Xor xor) {
+      return "xor";
+    }
+
+    public static string ExportToScheme(this Equal equal) {
+      return "equ";
+    }
+
+    public static string ExportToScheme(this LessThan lessThan) {
+      return "<";
+    }
+
+    public static string ExportToScheme(this GreaterThan greaterThan) {
+      return ">";
     }
   }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Tangens.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Tangens.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Tangens.cs	(revision 654)
@@ -40,8 +40,4 @@
       AddConstraint(new SubOperatorTypeConstraint(0));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Variable.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Variable.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Variable.cs	(revision 654)
@@ -207,8 +207,4 @@
       SetupManipulation();
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
Index: branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Xor.cs
===================================================================
--- branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Xor.cs	(revision 651)
+++ branches/GpPluginsRefactoringBranch/HeuristicLab.GP.StructureIdentification/Xor.cs	(revision 654)
@@ -41,8 +41,4 @@
       AddConstraint(new SubOperatorTypeConstraint(1));
     }
-
-    public override void Accept(IFunctionVisitor visitor) {
-      visitor.Visit(this);
-    }
   }
 }
