Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/24/21 13:40:39 (3 years ago)
Author:
chaider
Message:

#3041

  • Renaming Constant Symbol to Num, behaves like before
  • Adding new Symbol RealConstant (Constant), this symbol behaves now like a real constant, won't be changed by parameter optimization or manipulators
  • Refactored classes part1
Location:
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs

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

    r17817 r18093  
    145145
    146146    private AutoDiff.Term ConvertToAutoDiff(ISymbolicExpressionTreeNode node) {
    147       if (node.Symbol is Constant) {
    148         initialConstants.Add(((ConstantTreeNode)node).Value);
     147      if (node.Symbol is Num) {
     148        initialConstants.Add(((NumTreeNode)node).Value);
     149        var var = new AutoDiff.Variable();
     150        variables.Add(var);
     151        return var;
     152      }
     153
     154      if (node.Symbol is RealConstant) {
     155        initialConstants.Add(((RealConstantTreeNode)node).Value);
    149156        var var = new AutoDiff.Variable();
    150157        variables.Add(var);
     
    260267      }
    261268      if (node.Symbol is Power) {
    262         var powerNode = node.GetSubtree(1) as ConstantTreeNode;
     269        var powerNode = node.GetSubtree(1) as NumTreeNode;
    263270        if (powerNode == null)
    264271          throw new NotSupportedException("Only integer powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol.");
     
    330337          !(n.Symbol is FactorVariable) &&
    331338          !(n.Symbol is LaggedVariable) &&
    332           !(n.Symbol is Constant) &&
     339          !(n.Symbol is Num) &&
     340          !(n.Symbol is RealConstant) &&
    333341          !(n.Symbol is Addition) &&
    334342          !(n.Symbol is Subtraction) &&
Note: See TracChangeset for help on using the changeset viewer.