Changeset 2264


Ignore:
Timestamp:
08/08/09 11:20:02 (12 years ago)
Author:
gkronber
Message:

Fixed export of GP trees to s-exp in the trunk. #715

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolicExpressionExporter.cs

    r2235 r2264  
    4848        exported = Export(tree);
    4949        return true;
    50       } catch(UnknownFunctionException) {
     50      }
     51      catch (UnknownFunctionException) {
    5152        exported = "";
    5253        return false;
     
    5859      builder.Append("(" + ExportFunction(tree.Function, tree) + " ");
    5960      currentIndent += "  ";
    60       foreach(IFunctionTree subTree in tree.SubTrees) {
     61      foreach (IFunctionTree subTree in tree.SubTrees) {
    6162        builder.Append("\n");
    6263        BuildExportString(subTree);
    6364      }
    64       if(tree.SubTrees.Count > 0) builder.Append(")");
     65      builder.Append(")");
    6566      currentIndent = currentIndent.Remove(0, 2);
    6667    }
     
    6970      // this is smelly, if there is a cleaner way to have a 'dynamic' visitor
    7071      // 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();
    9596      throw new UnknownFunctionException(function.Name);
    9697    }
     
    109110      return name;
    110111    }
    111 
    112     //public string GetName(IFunctionTree tree) {
    113     //  return SymbolicExpressionExporter.GetName(tree);
    114     //}
    115112  }
    116113
     
    170167    public static string ExportToScheme(this Variable variable, IFunctionTree tree) {
    171168      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;
    174171    }
    175172    public static string ExportToScheme(this Differential differential, IFunctionTree tree) {
    176173      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;
    179176    }
    180177
Note: See TracChangeset for help on using the changeset viewer.