Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/21/11 11:11:38 (13 years ago)
Author:
epitzer
Message:

Correct locking construct for external evaluation on multiple clients and simplify string formatting (#1526)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation.GP/3.4/ExternalEvaluationSymbolicExpressionTreeStringFormatter.cs

    r5809 r6460  
    2828using HeuristicLab.Problems.DataAnalysis.Symbolic;
    2929using System;
     30using System.Globalization;
    3031
    3132namespace HeuristicLab.Problems.ExternalEvaluation.GP {
     
    5758      StringBuilder strBuilder = new StringBuilder();
    5859      if (Indent) strBuilder.Append(' ', indentLength);
    59       strBuilder.Append("(");
    60       // internal nodes or leaf nodes?
    61       if (node.Subtrees.Count() > 0) {
    62         // symbol on same line as '('
     60      if (node.Subtrees.Count() > 0) { // internal node
     61        strBuilder.Append("(");
    6362        if (node.Symbol is Addition) {
    6463          strBuilder.AppendLine("+");
     
    9897        // each subtree expression on a new line
    9998        // and closing ')' also on new line
    100 
    10199        foreach (var subtree in node.Subtrees) {
    102100          strBuilder.AppendLine(FormatRecursively(subtree, indentLength + 2));
     
    107105        if (node is VariableTreeNode) {
    108106          var varNode = node as VariableTreeNode;
    109           // symbol in the same line with as '(' and ')'
    110           strBuilder.Append(";" + varNode.VariableName + ";" + varNode.Weight.ToString("E4"));
    111           strBuilder.Append(")");
     107          strBuilder.AppendFormat("(* {0} {1})", varNode.VariableName, varNode.Weight.ToString("g17", CultureInfo.InvariantCulture));
    112108        } else if (node is ConstantTreeNode) {
    113109          var constNode = node as ConstantTreeNode;
    114           // symbol in the same line with as '(' and ')'
    115           strBuilder.Append(";" + constNode.Value.ToString("E4"));
    116           strBuilder.Append(")");
     110          strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture));
    117111        } else {
    118112          throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " not supported for external evaluation.");
Note: See TracChangeset for help on using the changeset viewer.