Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/01/21 13:40:55 (3 years ago)
Author:
chaider
Message:

#3140

  • some more refactoring
  • added possibility to set value of num nodes in infix parser
  • changed displaying style of number
Location:
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs

    r17180 r18100  
    8888      StringBuilder builder = new StringBuilder();
    8989      var varTreeNode = tree as VariableTreeNode;
     90      var numTreeNode = tree as NumberTreeNode;
    9091      var constTreeNode = tree as ConstantTreeNode;
    9192      var factorVarTreeNode = tree as FactorVariableTreeNode;
     
    9798      } else if (binFactorVarTreeNode != null) {
    9899        builder.Append("(factor " + binFactorVarTreeNode.VariableName + "=" + binFactorVarTreeNode.VariableValue);
    99       } else if (constTreeNode != null) {
     100      } else if (numTreeNode != null || constTreeNode != null) {
    100101        builder.Append("(const");
    101102      } else {
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs

    r18093 r18100  
    5858
    5959      if (@const!=0.0) {
    60         NumTreeNode cNode = (NumTreeNode)new Num().CreateTreeNode();
     60        NumberTreeNode cNode = (NumberTreeNode)new Number().CreateTreeNode();
    6161        cNode.Value = @const;
    6262        add.AddSubtree(cNode);
     
    9999
    100100      if (!@const.IsAlmost(0.0)) {
    101         NumTreeNode cNode = (NumTreeNode)new Num().CreateTreeNode();
     101        NumberTreeNode cNode = (NumberTreeNode)new Number().CreateTreeNode();
    102102        cNode.Value = @const;
    103103        addition.AddSubtree(cNode);
     
    130130
    131131      if (!@const.IsAlmost(0.0)) {
    132         NumTreeNode cNode = (NumTreeNode)new Num().CreateTreeNode();
     132        NumberTreeNode cNode = (NumberTreeNode)new Number().CreateTreeNode();
    133133        cNode.Value = @const;
    134134        addition.AddSubtree(cNode);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs

    r18093 r18100  
    145145
    146146    private AutoDiff.Term ConvertToAutoDiff(ISymbolicExpressionTreeNode node) {
    147       if (node.Symbol is Num) {
    148         initialConstants.Add(((NumTreeNode)node).Value);
     147      if (node.Symbol is Number) {
     148        initialConstants.Add(((NumberTreeNode)node).Value);
    149149        var var = new AutoDiff.Variable();
    150150        variables.Add(var);
     
    152152      }
    153153
    154       if (node.Symbol is RealConstant) {
    155         initialConstants.Add(((RealConstantTreeNode)node).Value);
     154      if (node.Symbol is Constant) {
     155        initialConstants.Add(((ConstantTreeNode)node).Value);
    156156        var var = new AutoDiff.Variable();
    157157        variables.Add(var);
     
    267267      }
    268268      if (node.Symbol is Power) {
    269         var powerNode = node.GetSubtree(1) as NumTreeNode;
     269        var powerNode = node.GetSubtree(1) as NumberTreeNode;
    270270        if (powerNode == null)
    271271          throw new NotSupportedException("Only integer powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol.");
     
    337337          !(n.Symbol is FactorVariable) &&
    338338          !(n.Symbol is LaggedVariable) &&
    339           !(n.Symbol is Num) &&
    340           !(n.Symbol is RealConstant) &&
     339          !(n.Symbol is Number) &&
     340          !(n.Symbol is Constant) &&
    341341          !(n.Symbol is Addition) &&
    342342          !(n.Symbol is Subtraction) &&
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs

    r17811 r18100  
    5454
    5555          var power = node.GetSubtree(1);
    56           if(power is ConstantTreeNode constNode && Math.Truncate(constNode.Value) == constNode.Value) {
     56          if(power is NumberTreeNode constNode && Math.Truncate(constNode.Value) == constNode.Value) {
    5757            strBuilder.Append(" ").Append(token).Append(" ").Append(constNode.Value.ToString(formatString, numberFormat));
    5858          } else {
     
    141141
    142142          if (!factorNode.Weight.IsAlmost(1.0)) strBuilder.Append(")");
    143         } else if (node.Symbol is Constant) {
    144           var constNode = node as ConstantTreeNode;
     143        } else if (node.Symbol is Number) {
     144          var constNode = node as NumberTreeNode;
    145145          if (constants == null && constNode.Value < 0) {
    146146            strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat))
     
    204204    /// </summary>
    205205    /// <param name="symbolicExpressionTree">The tree representation of the expression.</param>
    206     /// <param name="numberFormat">Number format that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param>
     206    /// <param name="numberFormat">Constant format that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param>
    207207    /// <param name="formatString">The format string for numeric parameters (e.g. \"G4\" to limit to 4 digits, default is \"G\")</param>
    208208    /// <returns>Infix expression</returns>
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs

    r17648 r18100  
    162162          var varNode = node as VariableTreeNode;
    163163          strBuilder.AppendFormat("{0} * {1}", VariableName2Identifier(varNode.VariableName), varNode.Weight.ToString("g17", CultureInfo.InvariantCulture));
    164         } else if (node is ConstantTreeNode) {
    165           var constNode = node as ConstantTreeNode;
    166           strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture));
     164        } else if (node is INumericTreeNode numNode) {
     165          strBuilder.Append(numNode.Value.ToString("g17", CultureInfo.InvariantCulture));
    167166        } else if (node.Symbol is FactorVariable) {
    168167          var factorNode = node as FactorVariableTreeNode;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs

    r17180 r18100  
    134134        }
    135135        stringBuilder.Append("))");
    136       } else if (symbol is Constant) {
    137         ConstantTreeNode constantTreeNode = node as ConstantTreeNode;
    138         stringBuilder.Append(constantTreeNode.Value.ToString(CultureInfo.InvariantCulture));
     136      } else if (symbol is INumericSymbol numNode) {
     137        var numTreeNode = node as INumericTreeNode;
     138        stringBuilder.Append(numTreeNode.Value.ToString(CultureInfo.InvariantCulture));
    139139      } else if (symbol is Cosine) {
    140140        stringBuilder.Append("COS(");
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r17826 r18100  
    189189      } else if (node.Symbol is IfThenElse) {
    190190        strBuilder.Append(@" \operatorname{if}  \left( ");
    191       } else if (node.Symbol is Constant) {
    192         var constName = "c_{" + constIndex + "}";
     191      } else if (node.Symbol is INumericSymbol numNode) {
     192        var numName = "c_{" + constIndex + "}";
    193193        constIndex++;
    194         var constNode = node as ConstantTreeNode;
    195         if (constNode.Value.IsAlmost(1.0)) {
     194        var numericNode = node as INumericTreeNode;
     195        if (numericNode.Value.IsAlmost(1.0)) {
    196196          strBuilder.Append("1 ");
    197197        } else {
    198           strBuilder.Append(constName);
    199           constants.Add(new KeyValuePair<string, double>(constName, constNode.Value));
    200         }
    201 
     198          strBuilder.Append(numName);
     199          constants.Add(new KeyValuePair<string, double>(numName, numericNode.Value));
     200        }
    202201      } else if (node.Symbol is FactorVariable) {
    203202        var factorNode = node as FactorVariableTreeNode;
     
    471470      } else if (node.Symbol is IfThenElse) {
    472471        strBuilder.Append(@" \right) ");
     472      } else if (node.Symbol is Number) {
    473473      } else if (node.Symbol is Constant) {
    474       } else if (node.Symbol is LaggedVariable) {
     474      }else if (node.Symbol is LaggedVariable) {
    475475      } else if (node.Symbol is Variable) {
    476476      } else if (node.Symbol is FactorVariable) {
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs

    r17180 r18100  
    151151        }
    152152        stringBuilder.Append(")");
    153       } else if (symbol is Constant) {
    154         ConstantTreeNode constantTreeNode = node as ConstantTreeNode;
    155         stringBuilder.Append(constantTreeNode.Value.ToString(CultureInfo.InvariantCulture));
     153      } else if (symbol is INumericSymbol) {
     154        var numberTreeNode = node as INumericTreeNode;
     155        stringBuilder.Append(numberTreeNode?.Value.ToString(CultureInfo.InvariantCulture));
    156156      } else if (symbol is Cosine) {
    157157        stringBuilder.Append("cos(");
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs

    r17180 r18100  
    130130          var varNode = node as VariableTreeNode;
    131131          strBuilder.AppendFormat("Times[{0}, {1}]", varNode.VariableName, varNode.Weight.ToString("G17", CultureInfo.InvariantCulture));
    132         } else if (node.Symbol is Constant) {
    133           var constNode = node as ConstantTreeNode;
    134           strBuilder.Append(constNode.Value.ToString("G17", CultureInfo.InvariantCulture));
     132        } else if (node.Symbol is INumericSymbol) {
     133          var numNode = node as INumericTreeNode;
     134          strBuilder.Append(numNode?.Value.ToString("G17", CultureInfo.InvariantCulture));
    135135        } else if (node.Symbol is FactorVariable) {
    136136          var factorNode = node as FactorVariableTreeNode;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionPythonFormatter.cs

    r17929 r18100  
    202202      else if (node is VariableTreeNode)
    203203        FormatVariableTreeNode(node, strBuilder);
    204       else if (node is ConstantTreeNode)
    205         FormatConstantTreeNode(node, strBuilder);
     204      else if (node is INumericTreeNode)
     205        FormatNumericTreeNode(node, strBuilder);
    206206      else
    207207        throw new NotSupportedException("Formatting of symbol: " + symbol + " not supported for Python symbolic expression tree formatter.");
     
    227227    }
    228228
    229     private static void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    230       var constNode = node as ConstantTreeNode;
    231       strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture));
     229    private static void FormatNumericTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     230      var symbol = node.Symbol;
     231      double value = 0.0;
     232      if (symbol is INumericSymbol) {
     233        var numNode = node as INumericTreeNode;
     234        value = numNode.Value;
     235      } else {
     236        throw new NotSupportedException("Formatting of symbol: " + symbol + " not supported for Python symbolic expression tree formatter.");
     237      }
     238       
     239
     240      strBuilder.Append(value.ToString("g17", CultureInfo.InvariantCulture));
    232241    }
    233242
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs

    r17180 r18100  
    8383        }
    8484        stringBuilder.Append(")");
    85       } else if (symbol is Constant) {
    86         ConstantTreeNode constantTreeNode = node as ConstantTreeNode;
    87         stringBuilder.Append(constantTreeNode.Value.ToString(CultureInfo.InvariantCulture));
    88       } else if (symbol is Cosine) {
     85      } else if (symbol is INumericSymbol) {
     86        var numberTreeNode = node as INumericTreeNode;
     87        stringBuilder.Append(numberTreeNode?.Value.ToString(CultureInfo.InvariantCulture));
     88      }else if (symbol is Cosine) {
    8989        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    9090        stringBuilder.Append(" cos");
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/TSQLExpressionFormatter.cs

    r17180 r18100  
    164164          var varNode = node as VariableTreeNode;
    165165          strBuilder.AppendFormat("{0} * {1}", VariableName2Identifier(varNode.VariableName), varNode.Weight.ToString("g17", CultureInfo.InvariantCulture));
    166         } else if (node is ConstantTreeNode) {
    167           var constNode = node as ConstantTreeNode;
    168           strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture));
    169         } else if (node.Symbol is FactorVariable) {
     166        } else if (node is INumericTreeNode numNode) {
     167          strBuilder.Append(numNode.Value.ToString("g17", CultureInfo.InvariantCulture));
     168        }else if (node.Symbol is FactorVariable) {
    170169          var factorNode = node as FactorVariableTreeNode;
    171170          FormatFactor(level, factorNode, strBuilder);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/ArithmeticExpressionGrammar.cs

    r18093 r18100  
    4949      var mul = new Multiplication();
    5050      var div = new Division();
    51       var constant = new Num();
    52       constant.MinValue = -20;
    53       constant.MaxValue = 20;
    54       var number = new RealConstant();
     51      var number = new Number();
    5552      number.MinValue = -20;
    5653      number.MaxValue = 20;
     54      var constant = new Constant();
    5755      var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable();
    5856      var binFactorVariableSymbol = new BinaryFactorVariable();
    5957      var factorVariableSymbol = new FactorVariable();
    6058
    61       var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, number, variableSymbol, binFactorVariableSymbol, factorVariableSymbol };
     59      var allSymbols = new List<Symbol>() { add, sub, mul, div, number, constant, variableSymbol, binFactorVariableSymbol, factorVariableSymbol };
    6260      var functionSymbols = new List<Symbol>() { add, sub, mul, div };
    6361
     
    6866        SetSubtreeCount(funSymb, 1, 3);
    6967      }
     68      SetSubtreeCount(number, 0, 0);
    7069      SetSubtreeCount(constant, 0, 0);
    71       SetSubtreeCount(number, 0, 0);
    7270      SetSubtreeCount(variableSymbol, 0, 0);
    7371      SetSubtreeCount(binFactorVariableSymbol, 0, 0);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs

    r18093 r18100  
    118118      variableCondition.InitialFrequency = 0.0;
    119119
    120       var constant = new Num();
    121       constant.MinValue = -20;
    122       constant.MaxValue = 20;
     120      var number = new Number();
     121      number.MinValue = -20;
     122      number.MaxValue = 20;
    123123      var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable();
    124124      var binFactorVariable = new BinaryFactorVariable();
     
    130130      autoregressiveVariable.Enabled = false;
    131131
    132       var number = new RealConstant();
    133       number.MinValue = -20;
    134       number.MaxValue = 20;
     132      var constant = new Constant();
    135133
    136134      var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp, tanh,
    137135        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
    138         @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, number, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition };
     136        @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, number, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition };
    139137      var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, tanh, not, timeLag, integral, derivative,
    140138        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
     
    143141      var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, aq, variableCondition };
    144142      var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or, xor };
    145       var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, constant, number, laggedVariable, autoregressiveVariable };
     143      var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, number, constant, laggedVariable, autoregressiveVariable };
    146144
    147145      foreach (var symb in allSymbols)
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/LinearScalingGrammar.cs

    r18093 r18100  
    6666      var abs = new Absolute();
    6767      var aq = new AnalyticQuotient();
    68       var constant = new Num();
    69       constant.MinValue = -20;
    70       constant.MaxValue = 20;
    71       var number = new RealConstant();
     68      var number = new Number();
    7269      number.MinValue = -20;
    7370      number.MaxValue = 20;
     71      var constant = new Constant();
    7472      var variableSymbol = new Variable();
    7573
     
    8179      //all other symbols
    8280      var allSymbols = new List<Symbol> {
    83         add, sub, mul, div, constant, number, variableSymbol, sin, cos, tan, log, square, sqrt, cube, cbrt, exp,
     81        add, sub, mul, div, number, constant, variableSymbol, sin, cos, tan, log, square, sqrt, cube, cbrt, exp,
    8482        tanh, aq, abs
    8583      };
     
    8987      var realValueSymbols = new List<Symbol> {
    9088         add, sub, mul, div, sin, cos, tan, tanh, exp, log, aq, abs, square, cube, sqrt, cbrt,
    91          variableSymbol, constant, number
     89         variableSymbol, number, constant
    9290        };
    9391
     
    116114      //Define childs for offset
    117115      AddAllowedChildSymbol(offset, scaling, 0);
    118       AddAllowedChildSymbol(offset, constant, 1);
     116      AddAllowedChildSymbol(offset, number, 1);
    119117
    120118      //Define childs for scaling
    121119      foreach (var symb in allSymbols) AddAllowedChildSymbol(scaling, symb, 0);
    122       AddAllowedChildSymbol(scaling, constant, 1);
     120      AddAllowedChildSymbol(scaling, number, 1);
    123121
    124122      //Define childs for realvalue symbols
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r18093 r18100  
    105105      var derivative = new Derivative();
    106106
    107       var constant = new Num();
    108       constant.MinValue = -20;
    109       constant.MaxValue = 20;
    110       var number = new RealConstant();
     107      var number = new Number();
    111108      number.MinValue = -20;
    112109      number.MaxValue = 20;
     110      var constant = new Constant();
    113111      var variableSymbol = new Variable();
    114112      var binFactorVariable = new BinaryFactorVariable();
     
    124122      var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi,
    125123        fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient});
    126       var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, number, variableSymbol, binFactorVariable, factorVariable });
     124      var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { number, constant, variableSymbol, binFactorVariable, factorVariable });
    127125      var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols });
    128126
     
    196194      AddAllowedChildSymbol(powerSymbols, laggedVariable, 0);
    197195      AddAllowedChildSymbol(powerSymbols, autoregressiveVariable, 0);
    198       AddAllowedChildSymbol(powerSymbols, constant, 1);
     196      AddAllowedChildSymbol(powerSymbols, number, 1);
    199197
    200198      AddAllowedChildSymbol(square, realValuedSymbols, 0);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r18093 r18100  
    174174    <Compile Include="Interfaces\IBoundsEstimator.cs" />
    175175    <Compile Include="Interfaces\IModelBacktransformator.cs" />
     176    <Compile Include="Interfaces\INumericSymbol.cs" />
     177    <Compile Include="Interfaces\INumericTreeNode.cs" />
    176178    <Compile Include="Interfaces\IVariableTreeNode.cs" />
    177179    <Compile Include="Interfaces\IVariableSymbol.cs" />
     
    238240    <Compile Include="Symbols\AutoregressiveVariable.cs" />
    239241    <Compile Include="Symbols\Average.cs" />
    240     <Compile Include="Symbols\Num.cs" />
    241     <Compile Include="Symbols\NumTreeNode.cs" />
     242    <Compile Include="Symbols\Number.cs" />
     243    <Compile Include="Symbols\NumberTreeNode.cs" />
    242244    <Compile Include="Symbols\AiryA.cs" />
    243245    <Compile Include="Symbols\AiryB.cs" />
     
    251253    <Compile Include="Symbols\CubeRoot.cs" />
    252254    <Compile Include="Symbols\HyperbolicTangent.cs" />
    253     <Compile Include="Symbols\RealConstant.cs" />
    254     <Compile Include="Symbols\RealConstantTreeNode.cs" />
     255    <Compile Include="Symbols\Constant.cs" />
     256    <Compile Include="Symbols\ConstantTreeNode.cs" />
    255257    <Compile Include="Symbols\VariableBase.cs" />
    256258    <Compile Include="Symbols\VariableTreeNodeBase.cs" />
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs

    r18093 r18100  
    8282      knownSymbols = new BidirectionalLookup<string, ISymbol>(StringComparer.InvariantCulture, new SymbolComparer());
    8383
    84     private Num num = new Num();
    85     private RealConstant realConstant = new RealConstant();
     84    private Number number = new Number();
     85    private Constant constant = new Constant();
    8686    private Variable variable = new Variable();
    8787    private BinaryFactorVariable binaryFactorVar = new BinaryFactorVariable();
     
    181181            && str[pos] != ']'
    182182            && str[pos] != '}'
    183             && str[pos] != ',') {
     183            && str[pos] != ','
     184            && str[pos] != '>') {
    184185            sb.Append(str[pos]);
    185186            pos++;
     
    333334          foreach (var negTerm in negTerms) sumNeg.AddSubtree(negTerm);
    334335
    335           var constNode = (NumTreeNode)num.CreateTreeNode();
     336          var constNode = (NumberTreeNode)number.CreateTreeNode();
    336337          constNode.Value = -1.0;
    337338          var prod = GetSymbol("*").CreateTreeNode();
     
    532533        }
    533534      } else if (next.TokenType == TokenType.LeftAngleBracket) {
     535        Token numberTok = null;
    534536        var leftAngleBracket = tokens.Dequeue();
    535537        if (leftAngleBracket.TokenType != TokenType.LeftAngleBracket)
     
    539541        if (idTok.TokenType != TokenType.Identifier || idTok.strVal.ToLower() != "num")
    540542          throw new ArgumentException("string 'num' expected");
     543
     544        if (tokens.Peek().TokenType == TokenType.Eq) {
     545          var equalTok = tokens.Dequeue();
     546          if (tokens.Peek().TokenType != TokenType.Number)
     547            throw new ArgumentException("No value for number specified.");
     548
     549          numberTok = tokens.Dequeue();
     550        }
     551
    541552        var rightAngleBracket = tokens.Dequeue();
    542553        if (rightAngleBracket.TokenType != TokenType.RightAngleBracket)
    543554          throw new ArgumentException("closing bracket > expected");
    544         var numNode = (NumTreeNode)num.CreateTreeNode();
     555        var numNode = (NumberTreeNode)number.CreateTreeNode();
     556        if (numberTok != null) numNode.Value = numberTok.doubleVal;
    545557        return numNode;
    546558      } else if (next.TokenType == TokenType.Number) {
    547559        var numTok = tokens.Dequeue();
    548         var constNode = (RealConstantTreeNode)realConstant.CreateTreeNode();
     560        var constNode = (ConstantTreeNode)constant.CreateTreeNode();
    549561        constNode.Value = numTok.doubleVal;
    550562        return constNode;
Note: See TracChangeset for help on using the changeset viewer.