Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18142


Ignore:
Timestamp:
12/16/21 11:22:29 (3 years ago)
Author:
chaider
Message:

#3140

  • Removed setter from INumericTreeNode
  • Fixed SymbolicExpressionImporter check for constants and number individually
  • Set exponent of power in DerivativeCalculator to number
  • Set number in TreeConstantNodeEditDialog and ExpressionTreeChart
  • Fixed setting of VariableRanges in DataAnalysisProblemData
Location:
branches/3140_NumberSymbol
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs

    r18115 r18142  
    104104        var symbol = dialog.SelectedSymbol;
    105105        var node = symbol.CreateTreeNode();
    106         if (node is INumericTreeNode numTreeNode) {
     106        if (node is NumberTreeNode numTreeNode) {
    107107          numTreeNode.Value = double.Parse(dialog.numberValueTextBox.Text);
    108108        } else if (node is VariableTreeNode) {
     
    132132      ISymbolicExpressionTreeNode newNode = null;
    133133      var result = DialogResult.Cancel;
    134       if (node is INumericTreeNode) {
     134      if (node is NumberTreeNode) {
    135135        using (var dialog = new NumberNodeEditDialog(node)) {
    136136          dialog.ShowDialog(this);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs

    r18115 r18142  
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    3030  public partial class NumberNodeEditDialog : Form {
    31     private INumericTreeNode numberTreeNode;
    32     public INumericTreeNode NewNode {
     31    private NumberTreeNode numberTreeNode;
     32    public NumberTreeNode NewNode {
    3333      get { return numberTreeNode; }
    3434      set {
    3535        if (InvokeRequired)
    36           Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (INumericTreeNode)x), value);
     36          Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (NumberTreeNode)x), value);
    3737        else
    3838          numberTreeNode = value;
     
    4343      InitializeComponent();
    4444      oldValueTextBox.TabStop = false; // cannot receive focus using tab key
    45       NewNode = (INumericTreeNode)node;
     45      NewNode = (NumberTreeNode)node;
    4646      InitializeFields();
    4747    }
     
    103103      // we impose an extra validation condition: that the new value is different from the original value
    104104      if (numberTreeNode.Value.Equals(value)) return;
    105 
    106105      numberTreeNode.Value = value;
    107106      DialogResult = DialogResult.OK;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs

    r18130 r18142  
    156156          var newPower = (ISymbolicExpressionTreeNode)branch.Clone();
    157157          var f = (ISymbolicExpressionTreeNode)newPower.GetSubtree(0).Clone();
    158           var newExponent = (INumericTreeNode)numberSy.CreateTreeNode();
    159           newExponent.Value = ((INumericTreeNode)newPower.GetSubtree(1)).Value - 1;
     158          var newExponent = (NumberTreeNode)numberSy.CreateTreeNode();
     159          newExponent.Value = ((NumberTreeNode)newPower.GetSubtree(1)).Value - 1;
    160160          return Product(Product(CreateNumber(exponent.Value), newPower), Derive(f, variableName));
    161161        } else throw new NotSupportedException("Cannot derive non-integer powers");
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs

    r18115 r18142  
    215215            variableTreeNode.Weight = variable.Weight;
    216216          } else if (node.Data is INumericTreeNode existingNumNode) {
    217             var newNumNode = (INumericTreeNode)treeNodes[i];
     217            var newNumNode = (NumberTreeNode)treeNodes[i];
    218218            newNumNode.Value = existingNumNode.Value;
    219219          }
     
    277277
    278278        var symbol = child.Data.Symbol;
    279         if (child.Data is INumericTreeNode firstNum) {
     279        if (child.Data is NumberTreeNode firstNum) {
    280280          // fold sibling number nodes into the first number
    281281          for (int k = j + 1; k < children.Length; ++k) {
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs

    r18123 r18142  
    162162        return tree;
    163163      } else if (tokens.Peek().Symbol == TokenSymbol.CONSTANT) {
    164         var t = (INumericTreeNode)number.CreateTreeNode();
    165         t.Value = tokens.Dequeue().DoubleValue;
    166         return t;
     164        var value = tokens.Dequeue().DoubleValue;
     165        var constant = new Constant() { Value = value };
     166        return constant.CreateTreeNode();
    167167      } else if (tokens.Peek().Symbol == TokenSymbol.LBRACKET) {
    168168        Expect(Token.LBRACKET, tokens);
    169169        Expect(Token.NUM, tokens);
    170         var t = (INumericTreeNode)number.CreateTreeNode();
     170        var t = (NumberTreeNode)number.CreateTreeNode();
    171171        if (tokens.Peek().Symbol == TokenSymbol.EQ) {
    172172          Expect(Token.EQ, tokens);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/INumericTreeNode.cs

    r18100 r18142  
    2626  [StorableType("194AFEE6-96E2-4F53-A5AD-D3CCFE928AE5")]
    2727  public interface INumericTreeNode : ISymbolicExpressionTreeNode {
    28     double Value { get; set; }
     28    double Value { get; }
    2929  }
    3030}
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/ConstantTreeNode.cs

    r18115 r18142  
    3030    public new Constant Symbol => (Constant) base.Symbol;
    3131
    32     public double Value {
    33       get => Symbol.Value;
    34       set => throw new System.NotSupportedException("Cannot change the value of a constant.");
    35     }
     32    public double Value => Symbol.Value;
    3633
    3734    [StorableConstructor]
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r18140 r18142  
    187187      Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly()));
    188188
     189      IntervalCollection varRanges = null;
    189190      if (variableRanges == null) {
    190         variableRanges = Dataset.GetVariableRanges();
     191        varRanges = Dataset.GetVariableRanges();
    191192      }else {
    192         foreach (var entry in variableRanges.GetVariableIntervals())
    193           VariableRanges.SetInterval(entry.Item1, entry.Item2);
    194       }
    195 
    196       Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));
     193        varRanges = (IntervalCollection) variableRanges.Clone();
     194      }
     195
     196      Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, varRanges));
    197197
    198198      TransformationsParameter.Hidden = true;
Note: See TracChangeset for help on using the changeset viewer.