Changeset 18100


Ignore:
Timestamp:
12/01/21 13:40:55 (7 months 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
Files:
2 added
37 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/GBM/GradientBoostingRegressionAlgorithm.cs

    r17180 r18100  
    417417      var addNode = new Addition().CreateTreeNode();
    418418      var mulNode = new Multiplication().CreateTreeNode();
    419       var scaleNode = (ConstantTreeNode)new Constant().CreateTreeNode(); // all models are scaled using the same nu
     419      var scaleNode = (NumberTreeNode)new Number().CreateTreeNode(); // all models are scaled using the same nu
    420420      scaleNode.Value = nu;
    421421
  • branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/RegressionTreeModel.cs

    r17180 r18100  
    230230      var startSy = new StartSymbol();
    231231      var varCondSy = new VariableCondition() { IgnoreSlope = true };
    232       var constSy = new Constant();
     232      var numSy = new Number();
    233233
    234234      var startNode = startSy.CreateTreeNode();
    235       startNode.AddSubtree(CreateSymbolicRegressionTreeRecursive(tree, 0, varCondSy, constSy));
     235      startNode.AddSubtree(CreateSymbolicRegressionTreeRecursive(tree, 0, varCondSy, numSy));
    236236      var rootNode = rootSy.CreateTreeNode();
    237237      rootNode.AddSubtree(startNode);
     
    239239    }
    240240
    241     private ISymbolicExpressionTreeNode CreateSymbolicRegressionTreeRecursive(TreeNode[] treeNodes, int nodeIdx, VariableCondition varCondSy, Constant constSy) {
     241    private ISymbolicExpressionTreeNode CreateSymbolicRegressionTreeRecursive(TreeNode[] treeNodes, int nodeIdx, VariableCondition varCondSy, Number constSy) {
    242242      var curNode = treeNodes[nodeIdx];
    243243      if (curNode.VarName == TreeNode.NO_VARIABLE) {
    244         var node = (ConstantTreeNode)constSy.CreateTreeNode();
     244        var node = (NumberTreeNode)constSy.CreateTreeNode();
    245245        node.Value = curNode.Val;
    246246        return node;
  • branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression/NonlinearRegression.cs

    r17180 r18100  
    123123      : base() {
    124124      Problem = new RegressionProblem();
    125       Parameters.Add(new FixedValueParameter<StringValue>(ModelStructureParameterName, "The function for which the parameters must be fit (only numeric constants are tuned).", new StringValue("1.0 * x*x + 0.0")));
     125      Parameters.Add(new FixedValueParameter<StringValue>(ModelStructureParameterName, "The function for which the parameters must be fit (only numeric constants are tuned).", new StringValue("<num> * x*x + 0.0")));
    126126      Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "The maximum number of iterations for constants optimization.", new IntValue(200)));
    127127      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of independent random restarts (>0)", new IntValue(10)));
     
    267267      // initialize constants randomly
    268268      if (rand != null) {
    269         foreach (var node in tree.IterateNodesPrefix().OfType<ConstantTreeNode>()) {
     269        foreach (var node in tree.IterateNodesPrefix().OfType<NumberTreeNode>()) {
    270270          double f = Math.Exp(NormalDistributedRandom.NextDouble(rand, 0, 1));
    271271          double s = rand.NextDouble() < 0.5 ? -1 : 1;
  • branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs

    r17931 r18100  
    220220      }
    221221
    222       var constSy = new Constant();
     222      var numSy = new Number();
    223223      var varCondSy = new VariableCondition() { IgnoreSlope = true };
    224224
    225       var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, constSy, varCondSy);
     225      var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, numSy, varCondSy);
    226226
    227227      var startNode = new StartSymbol().CreateTreeNode();
     
    232232    }
    233233
    234     private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Constant constSy, VariableCondition varCondSy) {
     234    private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Number numSy, VariableCondition varCondSy) {
    235235
    236236      // alglib source for evaluation of one tree (dfprocessinternal)
     
    262262
    263263      if ((double)(trees[k]) == (double)(-1)) {
    264         var constNode = (ConstantTreeNode)constSy.CreateTreeNode();
    265         constNode.Value = trees[k + 1];
    266         return constNode;
     264        var numNode = (NumberTreeNode)numSy.CreateTreeNode();
     265        numNode.Value = trees[k + 1];
     266        return numNode;
    267267      } else {
    268268        var condNode = (VariableConditionTreeNode)varCondSy.CreateTreeNode();
     
    271271        condNode.Slope = double.PositiveInfinity;
    272272
    273         var left = CreateRegressionTreeRec(trees, offset, k + 3, constSy, varCondSy);
    274         var right = CreateRegressionTreeRec(trees, offset, offset + (int)Math.Round(trees[k + 2]), constSy, varCondSy);
     273        var left = CreateRegressionTreeRec(trees, offset, k + 3, numSy, varCondSy);
     274        var right = CreateRegressionTreeRec(trees, offset, offset + (int)Math.Round(trees[k + 2]), numSy, varCondSy);
    275275
    276276        condNode.AddSubtree(left); // not 100% correct because interpreter uses: if(x <= thres) left() else right() and RF uses if(x < thres) left() else right() (see above)
  • branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModelAlglib_3_7.cs

    r17931 r18100  
    220220      }
    221221
    222       var constSy = new Constant();
     222      var numSy = new Number();
    223223      var varCondSy = new VariableCondition() { IgnoreSlope = true };
    224224
    225       var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, constSy, varCondSy);
     225      var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, numSy, varCondSy);
    226226
    227227      var startNode = new StartSymbol().CreateTreeNode();
     
    232232    }
    233233
    234     private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Constant constSy, VariableCondition varCondSy) {
     234    private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Number constSy, VariableCondition varCondSy) {
    235235
    236236      // alglib source for evaluation of one tree (dfprocessinternal)
     
    262262
    263263      if ((double)(trees[k]) == (double)(-1)) {
    264         var constNode = (ConstantTreeNode)constSy.CreateTreeNode();
    265         constNode.Value = trees[k + 1];
    266         return constNode;
     264        var numNode = (NumberTreeNode)constSy.CreateTreeNode();
     265        numNode.Value = trees[k + 1];
     266        return numNode;
    267267      } else {
    268268        var condNode = (VariableConditionTreeNode)varCondSy.CreateTreeNode();
  • branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModelFull.cs

    r17931 r18100  
    199199      }
    200200
    201       var constSy = new Constant();
     201      var numSy = new Number();
    202202      var varCondSy = new VariableCondition() { IgnoreSlope = true };
    203203
    204       var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, constSy, varCondSy);
     204      var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, numSy, varCondSy);
    205205
    206206      var startNode = new StartSymbol().CreateTreeNode();
     
    211211    }
    212212
    213     private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Constant constSy, VariableCondition varCondSy) {
     213    private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Number constSy, VariableCondition varCondSy) {
    214214
    215215      // alglib source for evaluation of one tree (dfprocessinternal)
     
    241241
    242242      if ((double)(trees[k]) == (double)(-1)) {
    243         var constNode = (ConstantTreeNode)constSy.CreateTreeNode();
    244         constNode.Value = trees[k + 1];
    245         return constNode;
     243        var numNode = (NumberTreeNode)constSy.CreateTreeNode();
     244        numNode.Value = trees[k + 1];
     245        return numNode;
    246246      } else {
    247247        var condNode = (VariableConditionTreeNode)varCondSy.CreateTreeNode();
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningOperator.cs

    r17180 r18100  
    101101      for (int i = 0; i < nodes.Count; ++i) {
    102102        var node = nodes[i];
    103         if (node is ConstantTreeNode) continue;
     103        if (node is NumberTreeNode) continue;
    104104
    105105        double impactValue, replacementValue, newQualityForImpactsCalculation;
     
    109109        if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
    110110
    111         var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
    112         constantNode.Value = replacementValue;
     111        var numberNode = (NumberTreeNode)node.Grammar.GetSymbol("Number").CreateTreeNode();
     112        numberNode.Value = replacementValue;
    113113
    114         ReplaceWithConstant(node, constantNode);
     114        ReplaceWithConstant(node, numberNode);
    115115        i += node.GetLength() - 1; // skip subtrees under the node that was folded
    116116
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionResponseFunctionView.cs

    r18093 r18100  
    120120
    121121    private void ChangeVariableValue(string variableName, double value) {
    122       foreach (var constNode in variableNodes[variableName].Cast<NumTreeNode>())
    123         constNode.Value = value;
     122      foreach (var numNode in variableNodes[variableName].Cast<NumberTreeNode>())
     123        numNode.Value = value;
    124124
    125125      UpdateResponseSeries();
     
    210210
    211211          int childIndex = varNode.Parent.IndexOfSubtree(varNode);
    212           var replacementNode = MakeConstantTreeNode(medianValues[varNode.VariableName]);
     212          var replacementNode = MakeNumberTreeNode(medianValues[varNode.VariableName]);
    213213          var parent = varNode.Parent;
    214214          parent.RemoveSubtree(childIndex);
     
    223223    }
    224224
    225     private ISymbolicExpressionTreeNode MakeProduct(NumTreeNode c, double weight) {
     225    private ISymbolicExpressionTreeNode MakeProduct(NumberTreeNode c, double weight) {
    226226      var mul = new Multiplication();
    227227      var prod = mul.CreateTreeNode();
    228       prod.AddSubtree(MakeConstantTreeNode(weight));
     228      prod.AddSubtree(MakeNumberTreeNode(weight));
    229229      prod.AddSubtree(c);
    230230      return prod;
    231231    }
    232232
    233     private NumTreeNode MakeConstantTreeNode(double value) {
    234       Num num = new Num();
    235       num.MinValue = value - 1;
    236       num.MaxValue = value + 1;
    237       NumTreeNode numTreeNode = (NumTreeNode)num.CreateTreeNode();
    238       numTreeNode.Value = value;
    239       return numTreeNode;
     233    private NumberTreeNode MakeNumberTreeNode(double value) {
     234      Number number = new Number();
     235      number.MinValue = value - 1;
     236      number.MaxValue = value + 1;
     237      NumberTreeNode numberTreeNode = (NumberTreeNode)number.CreateTreeNode();
     238      numberTreeNode.Value = value;
     239      return numberTreeNode;
    240240    }
    241241  }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs

    r17958 r18100  
    123123          if (errorState == OnlineCalculatorError.None) {
    124124            //Set alpha and beta to the scaling nodes from ia grammar
    125             var offsetParameter = offset.GetSubtree(1) as ConstantTreeNode;
     125            var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
    126126            offsetParameter.Value = alpha;
    127             var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;
     127            var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
    128128            scalingParameter.Value = beta;
    129129          }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs

    r18093 r18100  
    155155          if (errorState == OnlineCalculatorError.None) {
    156156            //Set alpha and beta to the scaling nodes from ia grammar
    157             var offsetParameter = offset.GetSubtree(1) as NumTreeNode;
     157            var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
    158158            offsetParameter.Value = alpha;
    159             var scalingParameter = scaling.GetSubtree(1) as NumTreeNode;
     159            var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
    160160            scalingParameter.Value = beta;
    161161          }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs

    r18093 r18100  
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    34   [Item("Num Optimization Evaluator", "Calculates Pearson R² of a symbolic regression solution and optimizes the constant used.")]
     34  [Item("Constant Optimization Evaluator", "Calculates Pearson R² of a symbolic regression solution and optimizes the constant used.")]
    3535  [StorableType("24B68851-036D-4446-BD6F-3823E9028FF4")]
    3636  public class SymbolicRegressionConstantOptimizationEvaluator : SymbolicRegressionSingleObjectiveEvaluator {
     
    307307      int i = 0;
    308308      foreach (var node in tree.Root.IterateNodesPrefix().OfType<SymbolicExpressionTreeTerminalNode>()) {
    309         NumTreeNode numTreeNode = node as NumTreeNode;
     309        NumberTreeNode numberTreeNode = node as NumberTreeNode;
    310310        VariableTreeNodeBase variableTreeNodeBase = node as VariableTreeNodeBase;
    311311        FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode;
    312         if (numTreeNode != null) {
    313           if (numTreeNode.Parent.Symbol is Power
    314               && numTreeNode.Parent.GetSubtree(1) == numTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter)
    315           numTreeNode.Value = constants[i++];
     312        if (numberTreeNode != null) {
     313          if (numberTreeNode.Parent.Symbol is Power
     314              && numberTreeNode.Parent.GetSubtree(1) == numberTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter)
     315          numberTreeNode.Value = constants[i++];
    316316        } else if (updateVariableWeights && variableTreeNodeBase != null)
    317317          variableTreeNodeBase.Weight = constants[i++];
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs

    r17180 r18100  
    9191      for (int i = 0; i < nodes.Count; ++i) {
    9292        var node = nodes[i];
    93         if (node is ConstantTreeNode) continue;
     93        if (node is NumberTreeNode) continue;
    9494
    9595        double impactValue, replacementValue;
     
    100100        if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
    101101
    102         var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
     102        var constantNode = (NumberTreeNode)node.Grammar.GetSymbol("Number").CreateTreeNode();
    103103        constantNode.Value = replacementValue;
    104104
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r17579 r18100  
    203203
    204204        var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
    205         foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
     205        foreach (var pair in replacementValues.Where(pair => !(pair.Key is NumberTreeNode))) {
    206206          foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    207207        }
     
    250250    }
    251251
    252     private static ConstantTreeNode MakeConstantTreeNode(double value) {
    253       var constant = new Constant { MinValue = value - 1, MaxValue = value + 1 };
    254       var constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
     252    private static NumberTreeNode MakeConstantTreeNode(double value) {
     253      var constant = new Number { MinValue = value - 1, MaxValue = value + 1 };
     254      var constantTreeNode = (NumberTreeNode)constant.CreateTreeNode();
    255255      constantTreeNode.Value = value;
    256256      return constantTreeNode;
     
    297297        VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    298298
    299         if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
     299        if (!(treeNode is NumberTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
    300300          visualTree.ToolTip = visualTree.Content.ToString();
    301301          double impact = nodeImpacts[treeNode];
     
    314314          }
    315315          visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact;
    316           var constantReplacementNode = foldedNodes[treeNode] as ConstantTreeNode;
     316          var constantReplacementNode = foldedNodes[treeNode] as NumberTreeNode;
    317317          if (constantReplacementNode != null) {
    318318            visualTree.ToolTip += Environment.NewLine + "Replacement value: " + constantReplacementNode.Value;
     
    324324          if (changedNodes.ContainsKey(treeNode)) {
    325325            visualTree.LineColor = Color.DodgerBlue;
    326           } else if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {
     326          } else if (treeNode is NumberTreeNode && foldedNodes.ContainsKey(treeNode)) {
    327327            visualTree.LineColor = Color.DarkOrange;
    328328          }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs

    r17180 r18100  
    104104        var symbol = dialog.SelectedSymbol;
    105105        var node = symbol.CreateTreeNode();
    106         if (node is ConstantTreeNode) {
    107           var constant = node as ConstantTreeNode;
    108           constant.Value = double.Parse(dialog.constantValueTextBox.Text);
     106        if (node is NumberTreeNode) {
     107          var number = node as NumberTreeNode;
     108          number.Value = double.Parse(dialog.numberValueTextBox.Text);
    109109        } else if (node is VariableTreeNode) {
    110110          var variable = node as VariableTreeNode;
     
    133133      ISymbolicExpressionTreeNode newNode = null;
    134134      var result = DialogResult.Cancel;
    135       if (node is ConstantTreeNode) {
    136         using (var dialog = new ConstantNodeEditDialog(node)) {
     135      if (node is NumberTreeNode) {
     136        using (var dialog = new NumberNodeEditDialog(node)) {
    137137          dialog.ShowDialog(this);
    138138          newNode = dialog.NewNode;
     
    200200      // check if the copied/cut node (stored in the tempNode) can be inserted as a child of the current selected node
    201201      var node = currSelected.Content;
    202       if (node is ConstantTreeNode || node is VariableTreeNode) return;
     202      if (node is NumberTreeNode || node is VariableTreeNode) return;
    203203      // check if the currently selected node can accept the copied node as a child
    204204      // no need to check the grammar, an arity check will do just fine here
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/ConstantView.cs

    r17180 r18100  
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    29   [View("Constant View")]
    30   [Content(typeof(Constant), true)]
     29  [View("Number View")]
     30  [Content(typeof(Number), true)]
    3131  public partial class ConstantView : SymbolView {
    32     public new Constant Content {
    33       get { return (Constant)base.Content; }
     32    public new Number Content {
     33      get { return (Number)base.Content; }
    3434      set { base.Content = value; }
    3535    }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.Designer.cs

    r17180 r18100  
    2121
    2222namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    23   partial class ConstantNodeEditDialog {
     23  partial class NumberNodeEditDialog {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    121121      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
    122122      //
    123       // ConstantNodeEditDialog
     123      // NumberNodeEditDialog
    124124      //
    125125      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     
    138138      this.MaximizeBox = false;
    139139      this.MinimizeBox = false;
    140       this.Name = "ConstantNodeEditDialog";
     140      this.Name = "NumberNodeEditDialog";
    141141      this.ShowIcon = false;
    142142      this.ShowInTaskbar = false;
    143143      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    144144      this.Text = "Edit constant value";
    145       this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ConstantNodeEditDialog_KeyDown);
     145      this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.NumberNodeEditDialog_KeyDown);
    146146      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    147147      this.ResumeLayout(false);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs

    r17180 r18100  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    30   public partial class ConstantNodeEditDialog : Form {
    31     private ConstantTreeNode constantTreeNode;
    32     public ConstantTreeNode NewNode {
    33       get { return constantTreeNode; }
     30  public partial class NumberNodeEditDialog : Form {
     31    private NumberTreeNode numberTreeNode;
     32    public NumberTreeNode NewNode {
     33      get { return numberTreeNode; }
    3434      set {
    3535        if (InvokeRequired)
    36           Invoke(new Action<SymbolicExpressionTreeNode>(x => constantTreeNode = (ConstantTreeNode)x), value);
     36          Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (NumberTreeNode)x), value);
    3737        else
    38           constantTreeNode = value;
     38          numberTreeNode = value;
    3939      }
    4040    }
    4141
    42     public ConstantNodeEditDialog(ISymbolicExpressionTreeNode node) {
     42    public NumberNodeEditDialog(ISymbolicExpressionTreeNode node) {
    4343      InitializeComponent();
    4444      oldValueTextBox.TabStop = false; // cannot receive focus using tab key
    45       NewNode = (ConstantTreeNode)node;
     45      NewNode = (NumberTreeNode)node;
    4646      InitializeFields();
    4747    }
     
    4949    private void InitializeFields() {
    5050      if (NewNode == null)
    51         throw new ArgumentException("Node is not a constant.");
     51        throw new ArgumentException("Node is not a number.");
    5252      else {
    5353        this.Text = "Edit constant";
    54         newValueTextBox.Text = oldValueTextBox.Text = Math.Round(constantTreeNode.Value, 4).ToString();
     54        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(numberTreeNode.Value, 4).ToString();
    5555      }
    5656    }
     
    8787    // proxy handler passing key strokes to the parent control
    8888    private void childControl_KeyDown(object sender, KeyEventArgs e) {
    89       ConstantNodeEditDialog_KeyDown(sender, e);
     89      NumberNodeEditDialog_KeyDown(sender, e);
    9090    }
    9191
    92     private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
     92    private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
    9393      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
    9494        if (!ValidateChildren()) return;
     
    100100    public event EventHandler DialogValidated;
    101101    private void OnDialogValidated(object sender, EventArgs e) {
    102       if (constantTreeNode == null) return;
     102      if (numberTreeNode == null) return;
    103103      var value = double.Parse(newValueTextBox.Text);
    104104      // we impose an extra validation condition: that the new value is different from the original value
    105       if (constantTreeNode.Value.Equals(value)) return;
     105      if (numberTreeNode.Value.Equals(value)) return;
    106106
    107       constantTreeNode.Value = value;
     107      numberTreeNode.Value = value;
    108108      DialogResult = DialogResult.OK;
    109109      var dialogValidated = DialogValidated;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs

    r17180 r18100  
    5252      this.variableNamesCombo = new System.Windows.Forms.ComboBox();
    5353      this.variableWeightTextBox = new System.Windows.Forms.TextBox();
    54       this.constantValueTextBox = new System.Windows.Forms.TextBox();
    55       this.constantValueLabel = new System.Windows.Forms.Label();
     54      this.numberValueTextBox = new System.Windows.Forms.TextBox();
     55      this.numberValueLabel = new System.Windows.Forms.Label();
    5656      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    5757      this.okButton = new System.Windows.Forms.Button();
     
    121121      this.variableWeightTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.variableWeightTextBox_Validating);
    122122      //
    123       // constantValueTextBox
    124       //
    125       this.constantValueTextBox.Location = new System.Drawing.Point(101, 37);
    126       this.constantValueTextBox.Name = "constantValueTextBox";
    127       this.constantValueTextBox.Size = new System.Drawing.Size(127, 20);
    128       this.constantValueTextBox.TabIndex = 7;
    129       this.constantValueTextBox.Text = "0.0";
    130       this.constantValueTextBox.Visible = false;
    131       this.constantValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.constantValueTextBox_Validating);
    132       //
    133       // constantValueLabel
    134       //
    135       this.constantValueLabel.AutoSize = true;
    136       this.constantValueLabel.Location = new System.Drawing.Point(19, 40);
    137       this.constantValueLabel.Name = "constantValueLabel";
    138       this.constantValueLabel.Size = new System.Drawing.Size(34, 13);
    139       this.constantValueLabel.TabIndex = 8;
    140       this.constantValueLabel.Text = "Value";
    141       this.constantValueLabel.Visible = false;
     123      // numberValueTextBox
     124      //
     125      this.numberValueTextBox.Location = new System.Drawing.Point(101, 37);
     126      this.numberValueTextBox.Name = "numberValueTextBox";
     127      this.numberValueTextBox.Size = new System.Drawing.Size(127, 20);
     128      this.numberValueTextBox.TabIndex = 7;
     129      this.numberValueTextBox.Text = "0.0";
     130      this.numberValueTextBox.Visible = false;
     131      this.numberValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberValueTextBox_Validating);
     132      //
     133      // numberValueLabel
     134      //
     135      this.numberValueLabel.AutoSize = true;
     136      this.numberValueLabel.Location = new System.Drawing.Point(19, 40);
     137      this.numberValueLabel.Name = "numberValueLabel";
     138      this.numberValueLabel.Size = new System.Drawing.Size(34, 13);
     139      this.numberValueLabel.TabIndex = 8;
     140      this.numberValueLabel.Text = "Value";
     141      this.numberValueLabel.Visible = false;
    142142      //
    143143      // errorProvider
     
    187187      this.Controls.Add(this.cancelButton);
    188188      this.Controls.Add(this.okButton);
    189       this.Controls.Add(this.constantValueLabel);
    190       this.Controls.Add(this.constantValueTextBox);
     189      this.Controls.Add(this.numberValueLabel);
     190      this.Controls.Add(this.numberValueTextBox);
    191191      this.Controls.Add(this.variableWeightTextBox);
    192192      this.Controls.Add(this.variableNamesCombo);
     
    211211    private System.Windows.Forms.Label variableWeightLabel;
    212212    private System.Windows.Forms.Label variableNameLabel;
    213     private System.Windows.Forms.Label constantValueLabel;
     213    private System.Windows.Forms.Label numberValueLabel;
    214214    private System.Windows.Forms.ErrorProvider errorProvider;
    215     internal System.Windows.Forms.TextBox constantValueTextBox;
     215    internal System.Windows.Forms.TextBox numberValueTextBox;
    216216    internal System.Windows.Forms.TextBox variableWeightTextBox;
    217217    internal System.Windows.Forms.ComboBox variableNamesCombo;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs

    r17180 r18100  
    5757      var combo = (ComboBox)sender;
    5858      var symbol = combo.Items[combo.SelectedIndex];
    59       if (symbol is Constant) {
     59      if (symbol is Number) {
    6060        // add controls to the dialog for changing the constant value
    6161        variableNameLabel.Visible = false;
     
    6363        variableWeightLabel.Visible = false;
    6464        variableWeightTextBox.Visible = false;
    65         constantValueLabel.Visible = true;
    66         constantValueTextBox.Visible = true;
     65        numberValueLabel.Visible = true;
     66        numberValueTextBox.Visible = true;
    6767      } else if (symbol is VariableBase) {
    6868        var variableSymbol = (VariableBase)symbol;
     
    8080        variableWeightLabel.Visible = true;
    8181        variableWeightTextBox.Visible = true;
    82         constantValueLabel.Visible = false;
    83         constantValueTextBox.Visible = false;
     82        numberValueLabel.Visible = false;
     83        numberValueTextBox.Visible = false;
    8484        // add controls to the dialog for changing the variable name or weight
    8585      } else {
     
    8888        variableWeightLabel.Visible = false;
    8989        variableWeightTextBox.Visible = false;
    90         constantValueLabel.Visible = false;
    91         constantValueTextBox.Visible = false;
     90        numberValueLabel.Visible = false;
     91        numberValueTextBox.Visible = false;
    9292      }
    9393    }
     
    102102    }
    103103
    104     private void constantValueTextBox_Validating(object sender, CancelEventArgs e) {
     104    private void numberValueTextBox_Validating(object sender, CancelEventArgs e) {
    105105      string errorMessage;
    106       if (ValidateDoubleValue(constantValueTextBox.Text, out errorMessage)) return;
     106      if (ValidateDoubleValue(numberValueTextBox.Text, out errorMessage)) return;
    107107      e.Cancel = true;
    108       errorProvider.SetError(constantValueTextBox, errorMessage);
    109       constantValueTextBox.SelectAll();
     108      errorProvider.SetError(numberValueTextBox, errorMessage);
     109      numberValueTextBox.SelectAll();
    110110    }
    111111
  • 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.