- Timestamp:
- 08/08/09 11:20:02 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs
r2235 r2264 48 48 exported = Export(tree); 49 49 return true; 50 } catch(UnknownFunctionException) { 50 } 51 catch (UnknownFunctionException) { 51 52 exported = ""; 52 53 return false; … … 58 59 builder.Append("(" + ExportFunction(tree.Function, tree) + " "); 59 60 currentIndent += " "; 60 foreach (IFunctionTree subTree in tree.SubTrees) {61 foreach (IFunctionTree subTree in tree.SubTrees) { 61 62 builder.Append("\n"); 62 63 BuildExportString(subTree); 63 64 } 64 if(tree.SubTrees.Count > 0)builder.Append(")");65 builder.Append(")"); 65 66 currentIndent = currentIndent.Remove(0, 2); 66 67 } … … 69 70 // this is smelly, if there is a cleaner way to have a 'dynamic' visitor 70 71 // please let me know! (gkronber 14.10.2008) 71 if (function is Addition) return ((Addition)function).ExportToScheme();72 if (function is And) return ((And)function).ExportToScheme();73 if (function is Average) return ((Average)function).ExportToScheme();74 if (function is Constant) return ((Constant)function).ExportToScheme(tree);75 if (function is Cosinus) return ((Cosinus)function).ExportToScheme();76 if (function is Differential) return ((Differential)function).ExportToScheme(tree);77 if (function is Division) return ((Division)function).ExportToScheme();78 if (function is Equal) return ((Equal)function).ExportToScheme();79 if (function is Exponential) return ((Exponential)function).ExportToScheme();80 if (function is GreaterThan) return ((GreaterThan)function).ExportToScheme();81 if (function is IfThenElse) return ((IfThenElse)function).ExportToScheme();82 if (function is LessThan) return ((LessThan)function).ExportToScheme();83 if (function is Logarithm) return ((Logarithm)function).ExportToScheme();84 if (function is Multiplication) return ((Multiplication)function).ExportToScheme();85 if (function is Not) return ((Not)function).ExportToScheme();86 if (function is Or) return ((Or)function).ExportToScheme();87 if (function is Power) return ((Power)function).ExportToScheme();88 if (function is Signum) return ((Signum)function).ExportToScheme();89 if (function is Sinus) return ((Sinus)function).ExportToScheme();90 if (function is Sqrt) return ((Sqrt)function).ExportToScheme();91 if (function is Subtraction) return ((Subtraction)function).ExportToScheme();92 if (function is Tangens) return ((Tangens)function).ExportToScheme();93 if (function is Variable) return ((Variable)function).ExportToScheme(tree);94 if (function is Xor) return ((Xor)function).ExportToScheme();72 if (function is Addition) return ((Addition)function).ExportToScheme(); 73 if (function is And) return ((And)function).ExportToScheme(); 74 if (function is Average) return ((Average)function).ExportToScheme(); 75 if (function is Constant) return ((Constant)function).ExportToScheme(tree); 76 if (function is Cosinus) return ((Cosinus)function).ExportToScheme(); 77 if (function is Differential) return ((Differential)function).ExportToScheme(tree); 78 if (function is Division) return ((Division)function).ExportToScheme(); 79 if (function is Equal) return ((Equal)function).ExportToScheme(); 80 if (function is Exponential) return ((Exponential)function).ExportToScheme(); 81 if (function is GreaterThan) return ((GreaterThan)function).ExportToScheme(); 82 if (function is IfThenElse) return ((IfThenElse)function).ExportToScheme(); 83 if (function is LessThan) return ((LessThan)function).ExportToScheme(); 84 if (function is Logarithm) return ((Logarithm)function).ExportToScheme(); 85 if (function is Multiplication) return ((Multiplication)function).ExportToScheme(); 86 if (function is Not) return ((Not)function).ExportToScheme(); 87 if (function is Or) return ((Or)function).ExportToScheme(); 88 if (function is Power) return ((Power)function).ExportToScheme(); 89 if (function is Signum) return ((Signum)function).ExportToScheme(); 90 if (function is Sinus) return ((Sinus)function).ExportToScheme(); 91 if (function is Sqrt) return ((Sqrt)function).ExportToScheme(); 92 if (function is Subtraction) return ((Subtraction)function).ExportToScheme(); 93 if (function is Tangens) return ((Tangens)function).ExportToScheme(); 94 if (function is Variable) return ((Variable)function).ExportToScheme(tree); 95 if (function is Xor) return ((Xor)function).ExportToScheme(); 95 96 throw new UnknownFunctionException(function.Name); 96 97 } … … 109 110 return name; 110 111 } 111 112 //public string GetName(IFunctionTree tree) {113 // return SymbolicExpressionExporter.GetName(tree);114 //}115 112 } 116 113 … … 170 167 public static string ExportToScheme(this Variable variable, IFunctionTree tree) { 171 168 var varTree = (VariableFunctionTree)tree; 172 return " (variable " + varTree.Weight.ToString("r") + " " +173 varTree.VariableName + " " + varTree.SampleOffset + ")";169 return "variable " + varTree.Weight.ToString("r") + " " + 170 varTree.VariableName + " " + varTree.SampleOffset; 174 171 } 175 172 public static string ExportToScheme(this Differential differential, IFunctionTree tree) { 176 173 var varTree = (VariableFunctionTree)tree; 177 return " (differential " + varTree.Weight.ToString("r") + " " +178 varTree.VariableName + " " + varTree.SampleOffset + ")";174 return "differential " + varTree.Weight.ToString("r") + " " + 175 varTree.VariableName + " " + varTree.SampleOffset; 179 176 } 180 177
Note: See TracChangeset
for help on using the changeset viewer.